index: retrieve git log from cached text include
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 7 Nov 2021 04:36:31 +0000 (05:36 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 9 Nov 2021 03:14:15 +0000 (04:14 +0100)
While git is fast, it still results in a ~50ms command for an otherwise
static ~5ms landing page.  Run `make -B UPDATE` as post-commit git hook
(and post-rewrite, and post-checkout) on live checkouts.

.gitignore
Makefile
index.plp

index d5797717cb18a79604e7b6918809474e2b539d06..142f46ae6992d47b00cafd3a1b295b7e3cce3784 100644 (file)
@@ -5,6 +5,7 @@
 # derived contents
 /sitemap.xml
 /light.css
+/UPDATE
 /plan.plp
 /word/*.min.js
 
index e635f5fc4bf2396b7856a8e85c0a0e5e2665bc27..aaf92839dbb4a64a251dc9f031b934a1dd2b272f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-all: sitemap.xml light.css plan.plp data/digraphs.inc.pl data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.inc.pl word
+all: sitemap.xml light.css plan.plp UPDATE data/digraphs.inc.pl data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.inc.pl word
 more: all
 
 .PHONY: force # applied to download after 2 hours
@@ -20,6 +20,9 @@ light.css: tools/stripcss base.css
 plan.plp: TODO
        kramdown $< >$@
 
+UPDATE: $(download)
+       $(call cmdsave,git log -1 --date=short --pretty="%ad    %s")
+
 word: word/put.min.js data/wordlist.en.json data/wordlist.nl.json data/wordlist.ru.json data/wordpairs.json
 
 word/put.js: $(download)
index c2e939bc90b569f7cac2daeaf456a6567f30c00f..468e92731e84ec4d421f620895dd43416b61f340 100644 (file)
--- a/index.plp
+++ b/index.plp
@@ -15,6 +15,7 @@ Html({
                ' title="RSS feed of repository updates"',
                ' href="http://git.shiar.nl/sheet.git/rss">',
        ],
+       data => ['UPDATE'],
 });
 
 :>
@@ -28,8 +29,7 @@ Originally created by Mischa <span class="family-name">Poslawsky</span>,
 but you're free to use, print, alter, and redistribute under the AGPL license.
 </p>
 <:
-my @format = ('--date=short', "--pretty=%ad (%ar)\t%s");
-if (open my $log, '-|', git => 'log', -1, @format) {{
+if (open my $log, '<', 'UPDATE') {{
        my $line = readline $log;
        $line or next;  # explicitly ignore empty input
        EscapeHTML $line;