[projects/pld-builder.new] queue.html: when the data is from, not the time now
arekm
arekm at pld-linux.org
Sun Nov 15 03:29:58 CET 2026
commit 066e03b2880dd04c75f79839d902d367ea90475e
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sun Nov 15 02:14:06 2026 +0100
queue.html: when the data is from, not the time now
The clock went on in the browser, saying nothing of how old the page was.
The header now gives when the page was written and how long ago, and the
ages on the page go on counting while it stays open.
PLD_Builder/queue_html.py | 5 +++--
PLD_Builder/script.js | 23 ++++++++---------------
PLD_Builder/style.css | 2 +-
3 files changed, 12 insertions(+), 18 deletions(-)
---
diff --git a/PLD_Builder/queue_html.py b/PLD_Builder/queue_html.py
index 8ea01ca..e46df8f 100644
--- a/PLD_Builder/queue_html.py
+++ b/PLD_Builder/queue_html.py
@@ -40,6 +40,7 @@ def write(f, requests):
def page(requests):
newest_first = sorted(requests, key=lambda r: r.no, reverse=True)
history = db.ok_builds({b.spec for r in requests for b in r.batches if not b.is_command()})
+ now = time.time()
return (
'<!DOCTYPE html>\n'
'<html lang="en">\n'
@@ -57,8 +58,8 @@ def page(requests):
'<span id="shown"></span>\n'
'<label>Requester <select id="requester"><option value="">everyone</option></select></label>\n'
'<label><input type="checkbox" id="unfinished"> only failed or unfinished</label>\n'
- # the time now, on the clock of the times below: the script keeps it going
- f'<time id="clock" data-offset="{time.localtime().tm_gmtoff}" data-zone="{time.strftime("%Z")}"></time>\n'
+ f'<span id="written" title="When this page was written: it is written again when the queue changes">'
+ f'data from {exact(now)}, <time class=ago datetime="{iso(now)}"></time></span>\n'
'</header>\n'
+ builders_line(requests)
+ f'<main style="--builders: {len(config.binary_builders)}">\n'
diff --git a/PLD_Builder/script.js b/PLD_Builder/script.js
index 0a94fbb..621cbd0 100644
--- a/PLD_Builder/script.js
+++ b/PLD_Builder/script.js
@@ -16,24 +16,17 @@ function elapsed(el) {
return span((Date.now() - new Date(el.getAttribute('datetime'))) / 1000);
}
-// the time now, in the zone of the page's times: the builder's offset, not the reader's
-var clock = document.getElementById('clock');
+// counted here and not by the builder, and kept going: the page is written only when the queue changes
function tick() {
- var d = new Date(Date.now() + clock.dataset.offset * 1000);
- var two = function(n) { return String(n).padStart(2, '0'); };
- clock.textContent = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ')[d.getUTCMonth()] + ' ' + d.getUTCDate() + ' '
- + two(d.getUTCHours()) + ':' + two(d.getUTCMinutes()) + ':' + two(d.getUTCSeconds()) + ' ' + clock.dataset.zone;
+ document.querySelectorAll('time.ago').forEach(function(el) {
+ el.textContent = elapsed(el) + ' ago';
+ });
+ document.querySelectorAll('time.since').forEach(function(el) {
+ el.textContent = elapsed(el);
+ });
}
tick();
-setInterval(tick, 1000);
-
-// counted here and not by the builder: the page is written only when the queue changes
-document.querySelectorAll('time.ago').forEach(function(el) {
- el.textContent = elapsed(el) + ' ago';
-});
-document.querySelectorAll('time.since').forEach(function(el) {
- el.textContent = elapsed(el);
-});
+setInterval(tick, 30000);
// a build much longer than the same one on the other builders: something drags on there
document.querySelectorAll('.builders').forEach(function(row) {
diff --git a/PLD_Builder/style.css b/PLD_Builder/style.css
index a094375..9f2d5fc 100644
--- a/PLD_Builder/style.css
+++ b/PLD_Builder/style.css
@@ -37,7 +37,7 @@ select, input {
margin-left: -18px;
}
-#clock {
+#written {
margin-left: auto;
white-space: nowrap;
}
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/066e03b2880dd04c75f79839d902d367ea90475e
More information about the pld-cvs-commit
mailing list