Redesign shell: topbar + sidebar navigation, ui.js, new test list markup

- base.html: new topbar/sidebar/main layout, accessible mobile menu,
  dismissible message banners, toast container, page_head block
- ui.js: current-page nav highlight, mobile menu close, copy toast
- index/testsummary: one card per section with column headers,
  labelled flags instead of coloured asterisks, empty state
- pagebrowser: nav landmark + aria labels
All Django logic, URLs, IDs and JS hooks are unchanged.
This commit is contained in:
claude committed 2026-10-08 22:37:46 +02:00
1 parent 7bbcff231d
commit cb3d99fa45
6 files changed
+390 -154

No files matched your search

+136
View File
@@ -0,0 +1,136 @@
/* ==========================================================================
OpenBench - small UI helpers (progressive enhancement only).
Nothing here changes what the site does: it highlights the current page in
the navigation, closes the mobile menu, shows a toast after copying text and
lets message banners be dismissed.
========================================================================== */
(function () {
'use strict';
function ready(fn) {
if (document.readyState !== 'loading')
fn();
else
document.addEventListener('DOMContentLoaded', fn);
}
function normalise(path) {
path = path.replace(/\/+$/, '');
return path === '' ? '/' : path;
}
/* ---------- Navigation: mark the link for the current page ---------- */
function highlightNavigation() {
var here = normalise(window.location.pathname);
// The front page is served from both / and /index
if (here === '/')
here = '/index';
var best = null;
var bestLength = -1;
document.querySelectorAll('#sidebar a[href^="/"]').forEach(function (link) {
var target = normalise(new URL(link.getAttribute('href'), window.location.origin).pathname);
var matches = here === target || here.indexOf(target + '/') === 0;
if (matches && target.length > bestLength) {
best = link;
bestLength = target.length;
}
});
if (best) {
best.classList.add('active');
best.setAttribute('aria-current', 'page');
}
}
/* ---------- Mobile navigation ---------- */
function setSidebar(open) {
document.body.classList.toggle('sidebar-open', open);
var toggle = document.getElementById('sidebar-toggle');
if (toggle)
toggle.setAttribute('aria-expanded', String(open));
}
function initSidebar() {
var backdrop = document.getElementById('sidebar-backdrop');
if (backdrop)
backdrop.addEventListener('click', function () { setSidebar(false); });
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape')
setSidebar(false);
});
document.querySelectorAll('#sidebar a').forEach(function (link) {
link.addEventListener('click', function () { setSidebar(false); });
});
}
/* ---------- Toast ---------- */
var toastTimer = null;
function toast(message) {
var element = document.getElementById('toast');
if (!element)
return;
element.textContent = message;
element.classList.add('show');
window.clearTimeout(toastTimer);
toastTimer = window.setTimeout(function () {
element.classList.remove('show');
}, 1800);
}
// Give copy_text() (see copy_text.js) some visible feedback
function wrapCopyText() {
if (typeof window.copy_text !== 'function' || window.copy_text.wrapped)
return;
var original = window.copy_text;
window.copy_text = function () {
var result = original.apply(this, arguments);
toast('Copied to clipboard');
return result;
};
window.copy_text.wrapped = true;
}
/* ---------- Dismissible banners ---------- */
function initBanners() {
document.addEventListener('click', function (event) {
var button = event.target.closest('.banner-close');
if (!button)
return;
var banner = button.closest('.banner');
if (banner)
banner.remove();
});
}
ready(function () {
highlightNavigation();
initSidebar();
initBanners();
wrapCopyText();
});
})();
+5 -5
View File
@@ -1,7 +1,7 @@
<div class="mt-3" id="pagebrowse">
<nav class="mt-3" id="pagebrowser" aria-label="Pagination">
{% if paging.prev != paging.next %}
<div class="pagination">
<a class="page previous" href="/{{ paging.url }}/{{ paging.prev }}">
<a class="page previous" href="/{{ paging.url }}/{{ paging.prev }}" aria-label="Previous page">
<i class="fa-solid fa-arrow-left"></i>
</a>
<div class="pages">
@@ -9,15 +9,15 @@
{% if page == "..." %}
<span class="page ellipsis"><i class="fa-solid fa-fw fa-1x fa-ellipsis"></i></span>
{% elif page == paging.page %}
<a class="page current" href="/{{ paging.url }}/{{ page }}">{{ page }}</a>
<a class="page current" href="/{{ paging.url }}/{{ page }}" aria-current="page">{{ page }}</a>
{% else %}
<a class="page" href="/{{ paging.url }}/{{ page }}">{{ page }}</a>
{% endif %}
{% endfor %}
</div>
<a class="page next" href="/{{ paging.url }}/{{ paging.next }}">
<a class="page next" href="/{{ paging.url }}/{{ paging.next }}" aria-label="Next page">
<i class="fa-solid fa-arrow-right"></i>
</a>
</div>
{% endif %}
</div>
</nav>
+10
View File
@@ -0,0 +1,10 @@
<thead>
<tr class="table-header">
<th>Author</th>
<th>Engine</th>
<th>Test</th>
<th class="textcenter">Diff</th>
<th>Time Control</th>
<th>Result</th>
</tr>
</thead>
+10 -10
View File
@@ -1,15 +1,15 @@
{% load mytags %}
<td><a href="/user/{{test.author}}">{{test.author|capfirst|slice:":6"}}</a></td>
<td>{{test.dev_engine}}</td>
<td>
<td class="col-author"><a href="/user/{{test.author}}">{{test.author|capfirst|slice:":6"}}</a></td>
<td class="col-engine">{{test.dev_engine}}</td>
<td class="col-test">
<a href="{{test|workload_url}}">{{test|prettyDevName}}</a>
{% if test.error %} <span style="color: red; cursor: pointer" title="Crash or illegal move">*</span> {% endif %}
{% if test|test_is_fischer %} <span style="color: green; cursor: pointer" title="Fischer random chess">*</span> {% endif %}
{% if test.error %}<span class="flag flag-error" title="Crash or illegal move">crash</span>{% endif %}
{% if test|test_is_fischer %}<span class="flag flag-frc" title="Fischer random chess">frc</span>{% endif %}
</td>
<td class="textcenter"><a href="{{test|gitDiffLink}}">diff</a></td>
<td>
<td class="col-diff textcenter"><a href="{{test|gitDiffLink}}">diff</a></td>
<td class="col-tc">
{{test.dev_time_control}}
{% if test|test_is_time_odds %} <span style="color: yellow; cursor: pointer" title="Time odds">*</span> {% endif %}
{% if test|test_is_smp_odds %} <span style="color: orange; cursor: pointer" title="Thread odds">*</span> {% endif %}
{% if test|test_is_time_odds %}<span class="flag flag-time" title="Time odds">time odds</span>{% endif %}
{% if test|test_is_smp_odds %}<span class="flag flag-smp" title="Thread odds">thread odds</span>{% endif %}
</td>
<td class='statblock statblock-{{test|testResultColour}}'><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td>
<td class='statblock statblock-{{test|testResultColour}} col-result'><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td>
+139 -85
View File
@@ -5,6 +5,7 @@
{% load static %}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#0B0E14">
<meta name="color-scheme" content="dark">
@@ -17,7 +18,8 @@
<link href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css' rel='stylesheet'>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
<title>RektBench</title>
@@ -25,6 +27,8 @@
{% block scripts %}
{% endblock %}
<script src="{% static 'ui.js' %}?{{ static_version }}" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
@@ -61,109 +65,159 @@
}, false);
function toggle_sidebar() {
document.body.classList.toggle('sidebar-open')
var open = document.body.classList.toggle('sidebar-open');
var toggle = document.getElementById('sidebar-toggle');
if (toggle)
toggle.setAttribute('aria-expanded', String(open));
}
</script>
</head>
<body>
<div id="sidebar">
<a class="skip-link" href="#content">Skip to content</a>
<ul>
<li class="header">Admin</li>
<header id="topbar">
<button id="sidebar-toggle" type="button" onclick="toggle_sidebar()"
aria-label="Toggle navigation" aria-controls="sidebar" aria-expanded="false">
<i class="fa-solid fa-bars fa-fw"></i>
</button>
<a class="brand" href="/">
<img class="brand-logo" src="{% static 'logo.svg' %}?{{ static_version }}" alt="" width="26" height="26">
<span class="brand-name">RektBench</span>
<span class="brand-sub">Testing Framework</span>
</a>
<div class="topbar-spacer"></div>
<nav class="topbar-actions" aria-label="Quick actions">
<a class="topbar-btn" href="/search" title="Search tests">
<i class="fa-solid fa-magnifying-glass fa-fw"></i><span>Search</span>
</a>
<a class="topbar-btn topbar-btn-primary" href="/newTest" title="Create a new test">
<i class="fa-solid fa-plus fa-fw"></i><span>Create Test</span>
</a>
{% if user.is_authenticated %}
<li><a href="/logout/"><i class="fa-solid fa-right-from-bracket fa-fw"></i> Logout</a></li>
<li><a href="/profile/"><i class="fa-solid fa-user fa-fw"></i> Profile</a></li>
<a class="topbar-btn" href="/profile/" title="Profile">
<i class="fa-solid fa-user fa-fw"></i><span>{{ user.username|capfirst }}</span>
</a>
{% else %}
<li><a href="/login"><i class="fa-solid fa-right-to-bracket fa-fw"></i> Login</a></li>
<li><a href="/register"><i class="fa-solid fa-registered fa-fw"></i> Register</a></li>
<a class="topbar-btn" href="/login" title="Login">
<i class="fa-solid fa-right-to-bracket fa-fw"></i><span>Login</span>
</a>
{% endif %}
</ul>
</nav>
<hr>
</header>
<ul>
<li class="header">Tests</li>
<li><a href="/index"><i class="fa-solid fa-house fa-fw"></i> Index</a></li>
<li><a href="/greens"><i class="fa-solid fa-heart fa-fw"></i> Greens</a></li>
<li><a href="/search"><i class="fa-solid fa-magnifying-glass fa-fw"></i> Search</a></li>
</ul>
<div id="layout">
<hr>
<nav id="sidebar" aria-label="Main navigation">
<ul>
<li class="header">Actions</li>
<li><a href="/newTest"><i class="fa-solid fa-plus fa-fw"></i> Create Test</a></li>
<li><a href="/newTune"><i class="fa-solid fa-vial fa-fw"></i> Create Tune</a></li>
<li><a href="/newDatagen"><i class="fa-solid fa-database fa-fw"></i> Create Datagen</a></li>
<li><a href="/newNetwork"><i class="fa-solid fa-upload fa-fw"></i> Upload Net</a></li>
</ul>
<hr>
<ul>
<li class="header">Info</li>
<li><a href="/users"><i class="fa-solid fa-users fa-fw"></i> Users</a></li>
<li><a href="/events"><i class="fa-solid fa-circle-exclamation fa-fw"></i> Events</a></li>
<li><a href="/errors"><i class="fa-solid fa-exclamation-triangle fa-fw"></i> Errors</a></li>
<li><a href="/machines"><i class="fa-solid fa-microchip fa-fw"></i> Machines</a></li>
<li><a href="/networks"><i class="fa-solid fa-circle-nodes fa-fw"></i> Networks</a></li>
</ul>
<hr>
<ul>
<li class="header">Support</li>
<li><a href="{{config.client_repo_url}}"><i class="fa-brands fa-github fa-fw"></i> OpenBench</a></li>
<li><a href="https://discord.gg/9MVg7fBTpM"><i class="fa-brands fa-discord fa-fw"></i> Discord</a></li>
</ul>
<hr>
<ul>
<li class="header">Engines</li>
{% for engine, data in config.engines.items %}
<li><a href="{{data.source}}">{{engine}}</a></li>
{% endfor %}
</ul>
<hr>
</div>
<div id="content-parent">
<div id="content" class="pb-5">
<div id="content-header">
<button id="sidebar-toggle" onclick="toggle_sidebar()">
<i class="fa-solid fa-bars fa-fw"></i>
</button>
<h2>
<a class="site-title" href="/">RektBench&nbsp;Testing&nbsp;Framework</a>
</h2>
<div class="nav-section">
<div class="nav-title">Account</div>
<ul>
{% if user.is_authenticated %}
<li><a href="/profile/"><i class="fa-solid fa-user fa-fw"></i> Profile</a></li>
<li><a href="/logout/"><i class="fa-solid fa-right-from-bracket fa-fw"></i> Logout</a></li>
{% else %}
<li><a href="/login"><i class="fa-solid fa-right-to-bracket fa-fw"></i> Login</a></li>
<li><a href="/register"><i class="fa-solid fa-registered fa-fw"></i> Register</a></li>
{% endif %}
</ul>
</div>
{% if request.session.error_message %}
<div class="error-message">
<pre>{{request.session.error_message}}</pre>
</div>
{% endif %}
<div class="nav-section">
<div class="nav-title">Tests</div>
<ul>
<li><a href="/index"><i class="fa-solid fa-house fa-fw"></i> Index</a></li>
<li><a href="/greens"><i class="fa-solid fa-heart fa-fw"></i> Greens</a></li>
<li><a href="/search"><i class="fa-solid fa-magnifying-glass fa-fw"></i> Search</a></li>
</ul>
</div>
{% if request.session.warning_message %}
<div class="warning-message">
<pre>{{request.session.warning_message}}</pre>
</div>
{% endif %}
<div class="nav-section">
<div class="nav-title">Actions</div>
<ul>
<li><a href="/newTest"><i class="fa-solid fa-plus fa-fw"></i> Create Test</a></li>
<li><a href="/newTune"><i class="fa-solid fa-vial fa-fw"></i> Create Tune</a></li>
<li><a href="/newDatagen"><i class="fa-solid fa-database fa-fw"></i> Create Datagen</a></li>
<li><a href="/newNetwork"><i class="fa-solid fa-upload fa-fw"></i> Upload Net</a></li>
</ul>
</div>
{% if request.session.status_message %}
<div class="status-message">
<pre>{{request.session.status_message}}</pre>
</div>
{% endif %}
<div class="nav-section">
<div class="nav-title">Info</div>
<ul>
<li><a href="/users"><i class="fa-solid fa-users fa-fw"></i> Users</a></li>
<li><a href="/events"><i class="fa-solid fa-circle-exclamation fa-fw"></i> Events</a></li>
<li><a href="/errors"><i class="fa-solid fa-triangle-exclamation fa-fw"></i> Errors</a></li>
<li><a href="/machines"><i class="fa-solid fa-microchip fa-fw"></i> Machines</a></li>
<li><a href="/networks"><i class="fa-solid fa-circle-nodes fa-fw"></i> Networks</a></li>
</ul>
</div>
<div class="nav-section">
<div class="nav-title">Support</div>
<ul>
<li><a href="{{config.client_repo_url}}"><i class="fa-brands fa-github fa-fw"></i> OpenBench</a></li>
<li><a href="https://discord.gg/9MVg7fBTpM"><i class="fa-brands fa-discord fa-fw"></i> Discord</a></li>
</ul>
</div>
<div class="nav-section">
<div class="nav-title">Engines</div>
<ul>
{% for engine, data in config.engines.items %}
<li><a href="{{data.source}}"><i class="fa-solid fa-chess-knight fa-fw"></i> {{engine}}</a></li>
{% endfor %}
</ul>
</div>
</nav>
<div id="sidebar-backdrop"></div>
<main id="content-parent">
<div id="content">
{% if request.session.error_message %}
<div class="banner error-message" role="alert">
<i class="fa-solid fa-circle-exclamation banner-icon"></i>
<pre>{{request.session.error_message}}</pre>
<button class="banner-close" type="button" aria-label="Dismiss"><i class="fa-solid fa-xmark"></i></button>
</div>
{% endif %}
{% if request.session.warning_message %}
<div class="banner warning-message" role="alert">
<i class="fa-solid fa-triangle-exclamation banner-icon"></i>
<pre>{{request.session.warning_message}}</pre>
<button class="banner-close" type="button" aria-label="Dismiss"><i class="fa-solid fa-xmark"></i></button>
</div>
{% endif %}
{% if request.session.status_message %}
<div class="banner status-message" role="status">
<i class="fa-solid fa-circle-check banner-icon"></i>
<pre>{{request.session.status_message}}</pre>
<button class="banner-close" type="button" aria-label="Dismiss"><i class="fa-solid fa-xmark"></i></button>
</div>
{% endif %}
<div class="page-head">{% block page_head %}{% endblock %}</div>
{% block content %}
{% endblock %}
</div>
</main>
{% block content %}
{% endblock %}
</div>
</div>
<div id="toast" role="status" aria-live="polite"></div>
</body>
</html>
+90 -54
View File
@@ -2,66 +2,102 @@
{% load mytags %}
{% block page_head %}<div><h1 class="page-title">Tests</h1><p class="page-sub">Pending, active and finished workloads</p></div>{% endblock %}
{% block content %}
<table class="test-list stripes hoverable">
<!-- Only show Pending tests for the front page of the Index -->
{% if paging.page == 1 %}
<!-- Currently Pending tests (Waiting to be approved) -->
{% if pending %}
<tr class="table-header"><th colspan='6'>Pending</th></tr>
{% for test in pending %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %}
<tr class="table-spacer"><th colspan='6'></th></tr>
{% endif %}
<!-- Currently Awaiting tests (Waiting for Artifacts) -->
{% if awaiting %}
<tr class="table-header"><th colspan='6'>Awaiting Artifacts</th></tr>
{% for test in awaiting %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %}
<tr class="table-spacer"><th colspan='6'></th></tr>
{% endif %}
<!-- Currently Running tests (Waiting to be completed) -->
{% if active %}
<tr class="table-header"><th colspan='6'>Active {{status}}</th></tr>
{% for test in active %}
<!-- Add two empty rows ( for the colouring scheme ) when changing prio -->
{% with prev_test=active|previous:forloop.counter0 %}
{% if prev_test and prev_test.priority != test.priority %}
<tr class="table-spacer-small"><th colspan='6'></th></tr>
<tr class="table-spacer-small"><th colspan='6'></th></tr>
{% endif %}
{% endwith %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %}
<tr class="table-spacer"><th colspan='6'></th></tr>
{% endif %}
<!-- Only show Pending tests for the front page of the Index -->
{% if paging.page == 1 %}
<!-- Currently Pending tests (Waiting to be approved) -->
{% if pending %}
<section class="card">
<header class="card-head">
<h2 class="card-title">Pending</h2>
<span class="count">{{ pending|length }}</span>
</header>
<table class="test-list stripes hoverable">
{% include "OpenBench/Blocks/testhead.html" %}
<tbody>
{% for test in pending %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %}
</tbody>
</table>
</section>
{% endif %}
<!-- Tests which have already finished -->
<tr class="table-header"><th colspan='6'>Finished</th></tr>
{% for test in completed %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %}
<!-- Currently Awaiting tests (Waiting for Artifacts) -->
{% if awaiting %}
<section class="card">
<header class="card-head">
<h2 class="card-title">Awaiting Artifacts</h2>
<span class="count">{{ awaiting|length }}</span>
</header>
<table class="test-list stripes hoverable">
{% include "OpenBench/Blocks/testhead.html" %}
<tbody>
{% for test in awaiting %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %}
</tbody>
</table>
</section>
{% endif %}
</table>
<!-- Currently Running tests (Waiting to be completed) -->
{% if active %}
<section class="card">
<header class="card-head">
<h2 class="card-title">Active {{status}}</h2>
<span class="count">{{ active|length }}</span>
</header>
<table class="test-list stripes hoverable">
{% include "OpenBench/Blocks/testhead.html" %}
<tbody>
{% for test in active %}
<!-- Add two empty rows ( for the colouring scheme ) when changing prio -->
{% with prev_test=active|previous:forloop.counter0 %}
{% if prev_test and prev_test.priority != test.priority %}
<tr class="table-spacer-small"><td colspan='6'></td></tr>
<tr class="table-spacer-small"><td colspan='6'></td></tr>
{% endif %}
{% endwith %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %}
</tbody>
</table>
</section>
{% endif %}
{% endif %}
<!-- Tests which have already finished -->
<section class="card">
<header class="card-head">
<h2 class="card-title">Finished</h2>
</header>
<table class="test-list stripes hoverable">
{% include "OpenBench/Blocks/testhead.html" %}
<tbody>
{% for test in completed %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% empty %}
<tr class="empty-row"><td colspan="6">No finished tests yet.</td></tr>
{% endfor %}
</tbody>
</table>
</section>
{% include "OpenBench/Blocks/pagebrowser.html" %}