From 9ee290847500e3694190e593b87256b80a5996b2 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Fri, 6 Sep 2024 18:15:39 +0200 Subject: [PATCH] website: Add git the git hash and subject to the bottom of the pages. Without this change, we have no idea if the website we see on https://gnu.org/software/gnuboot/ is using the latest git commit. It also allows anyone to spot and report to us that the website has the wrong revision. With this change we can also potentially spot issues in the website generation for instance when the website should have been regenerated and it wasn't, or from an archive or web page file, get to the git commit it was generated from. Signed-off-by: Denis 'GNUtoo' Carikli Acked-by: Adrien 'neox' Bourmault --- website/.gitignore | 2 ++ website/Makefile.am | 29 +++++++++++++++++-- website/build.sh | 4 +++ .../{footer.include => footer.include.tmpl} | 0 4 files changed, 33 insertions(+), 2 deletions(-) rename website/pages/{footer.include => footer.include.tmpl} (100%) diff --git a/website/.gitignore b/website/.gitignore index a2e526e..7a28985 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -27,3 +27,5 @@ /site.cfg /untitled/ /website.tar.gz +/pages/footer.include +/pages/footer-git-commit.include diff --git a/website/Makefile.am b/website/Makefile.am index 37384d5..1153f92 100644 --- a/website/Makefile.am +++ b/website/Makefile.am @@ -30,11 +30,36 @@ index.html: index.html.tmpl history/git-history.jpg: history/git-history.dot dot -T jpg history/git-history.dot > "$@" +# We need force the regeneration of the page because if only the git +# commit changes, there is no way to know about it. In addition the +# full website is regenerated each time the build target is run, so +# generating one more page has insignificant performance impact. +.PHONY: pages/footer-git-commit.include +pages/footer-git-commit.include: + rm -f $@ + + printf "This page was generated with %s from the commit %s\n" \ + "[Untitled](https://untitled.vimuser.org/)" \ + "`git show --no-patch HEAD --pretty=\"%h\"`" \ + >> $@ + + printf "(\"%s\").\n" \ + "`git show --no-patch HEAD --pretty=\"%s\"`" \ + >> $@ + + printf "\n" >> $@ + +pages/footer.include: pages/footer.include.tmpl pages/footer-git-commit.include + cat \ + pages/footer.include.tmpl \ + pages/footer-git-commit.include \ + > $@ + site.cfg: site.cfg.tmpl sed -e "s#WEBSITE_PREFIX#$(WEBSITE_PREFIX)#g" "$^" > "$@" if WANT_GUIX -build: site.cfg +build: site.cfg pages/footer.include guix time-machine \ --commit=c15a1cd88f80a90437f4b0159f22dfc84b9e6851 \ -- shell \ @@ -53,7 +78,7 @@ build: site.cfg -- \ ./build.sh $(BUILD_OPTIONS) else -build: site.cfg +build: site.cfg pages/footer.include ./build.sh $(BUILD_OPTIONS) endif diff --git a/website/build.sh b/website/build.sh index 3e8892b..1ef9d3e 100755 --- a/website/build.sh +++ b/website/build.sh @@ -148,5 +148,9 @@ if [ "${download_only}" -eq 0 ] ; then copy_website "untitled/www/lbwww/" cd untitled + + # Remove "This HTML page was generated by the Untitled Static Site + # Generator." at the bottom of each page as it is already mentionned above. + sed 's/^SHAMELESS_PLUG=".*"/SHAMELESS_PLUG=""/g' -i lang/*/strings.cfg ./build sites lbwww fi diff --git a/website/pages/footer.include b/website/pages/footer.include.tmpl similarity index 100% rename from website/pages/footer.include rename to website/pages/footer.include.tmpl