From 35e5bb62b2a89c97a2bf6d50610de3d95d7a5617 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Tue, 28 Dec 2021 23:51:10 -0500 Subject: [PATCH] Move header and footer script to generate titles The static header.html makes it so that the title has to be stuck on "alexkarle.com". Moving to a script means I can have dynamic titles based on the h1 (should only be one!). --- .gitignore | 2 -- Makefile | 8 ++------ bin/genpage | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ www/footer.html | 5 ----- www/header.html | 32 -------------------------------- 5 files changed, 56 insertions(+), 45 deletions(-) create mode 100755 bin/genpage delete mode 100644 www/footer.html delete mode 100644 www/header.html diff --git a/.gitignore b/.gitignore index 3894934..ca85e66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ # generated html *.html -!www/header.html -!www/footer.html !www/jam-tuesday/index.html !www/blog/my-old-man-orig.html diff --git a/Makefile b/Makefile index f6e9cf0..f70865e 100644 --- a/Makefile +++ b/Makefile @@ -56,12 +56,8 @@ gopher/phlog/atom.xml: $(PHLOG) gopher/bin/gophatom.sh ./gopher/bin/gophatom.sh > $@ # Inference rules (*.txt -> *.html) -$(HTML): Makefile www/header.html www/footer.html bin/gencrumbs +$(HTML): Makefile bin/genpage .SUFFIXES: .txt .html .txt.html: - @echo "building $@" - @(cat www/header.html; \ - ./bin/gencrumbs $@; \ - nihdoc < $< ; \ - cat www/footer.html) > $@ + ./bin/genpage $< > $@ diff --git a/bin/genpage b/bin/genpage new file mode 100755 index 0000000..92a6ee7 --- /dev/null +++ b/bin/genpage @@ -0,0 +1,54 @@ +#!/bin/sh +# nihdoc -> html with header and footer + +[ -z "$1" ] && echo "usage: genpage FILE" 1>&2 && exit 1 + +REPO=$(dirname "$(dirname "$0")") +title=$(grep '^# ' "$1" | cut -c3- | tr -d '`*_') + +cat < + + + + + + +$title + + +EOM + + +"$REPO/bin/gencrumbs" "${1%%txt}html" +nihdoc < "$1" + +cat < + © 2019-2021 Alex Karle | Home | License + + + +EOM diff --git a/www/footer.html b/www/footer.html deleted file mode 100644 index e34aaf5..0000000 --- a/www/footer.html +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/www/header.html b/www/header.html deleted file mode 100644 index 1a315b1..0000000 --- a/www/header.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - -alexkarle.com - - -- libgit2 1.1.1