From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Sun, 24 Jun 2018 12:52:53 +0100 Subject: [PATCH] cgit.css: add dynamic age update In-Reply-To: <152982719141.10974.13155108541444051299.stgit@mail.warmcat.com> References: <152982719141.10974.13155108541444051299.stgit@mail.warmcat.com> Message-ID: <20180624115253.GM6584@john.keeping.me.uk> Subject should be "cgit.js: " not cgit.css! On Sun, Jun 24, 2018 at 03:59:51PM +0800, Andy Green wrote: > This patch updates the emitted "ages" dynamically on the client side. > > After updating on completion of the document load, it sets a timer > to update according to the smallest age it found. If there are any > ages listed in minutes, then it will update again in 10s (this can > never happen more than twelve times on a given page then). When the > most recent age is in hours, it updates every 5m. If days, then > every 30m and so on. > > This keeps the cost of the dynamic updates at worst once per 10s > and trending towards being trivially cheap after a couple of minutes. > The updates are done entirely on the client side without contact > with the server. > > To make this work reliably, since parsing datetimes is unreliable in > browser js, the unix time is added as an attribute to all age spans. > > To make that reliable cross-platform, the unix time is treated as a > uint64_t when it is formatted for printing. > > The rules for display conversion of the age is aligned with the > existing server-side rules in ui-shared.h. > > If the client or server-side time are not synchronized by ntpd etc, > ages shown on the client will not relate to the original ages computed > at the server. The client updates the ages immediately when the > DOM has finished loading, so in the case the times at the server and > client are not aligned, this patch changes what the user sees on the > page to reflect patch age compared to client time. > > If the server and client clocks are aligned, this patch makes no > difference to what is seen on the page. > > Signed-off-by: Andy Green If we're going to start depending on JS, should we take the robust approach to this and never generate relative times on the server? Or do so only for