alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit 35e5bb62b2a89c97a2bf6d50610de3d95d7a5617 (patch)
parent 537a54c1497d253bea489ed32faec92b15d843d3
Author: Alex Karle <alex@alexkarle.com>
Date:   Tue, 28 Dec 2021 23:51:10 -0500

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!).

Diffstat:
M.gitignore | 2--
MMakefile | 8++------
Abin/genpage | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dwww/footer.html | 5-----
Dwww/header.html | 32--------------------------------
5 files changed, 56 insertions(+), 45 deletions(-)

diff --git 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 @@ -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 @@ -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 <<EOM +<!DOCTYPE html> +<html lang="en"> +<head> +<meta charset="utf-8"/> +<meta name="viewport" content="width=device-width,initial-scale=1"> +<!-- Inspired by https://www.swyx.io/css-100-bytes/ --> +<style> +html { + max-width: 70ch; + padding: 3em 1em; + margin: auto; + font-size: 1em; + font-family: sans-serif; +} +footer { + margin-top: 50px; + font-size: .8em; +} +code { font-family: consolas, courier, monospace; } +h1 { font-size: 1.5em; } +h2 { font-size: 1.2em; } +h3 { font-size: 1.1em; } +blockquote, pre { + background: #f2f2f2; + overflow: auto; + padding: 10px; + border: 2px solid black; +} +</style> +<title>$title</title> +</head> +<body> +EOM + + +"$REPO/bin/gencrumbs" "${1%%txt}html" +nihdoc < "$1" + +cat <<EOM +<footer> + © 2019-2021 Alex Karle | <a href="/">Home</a> | <a href="/license.html">License</a> +</footer> +</body> +</html> +EOM diff --git a/www/footer.html b/www/footer.html @@ -1,5 +0,0 @@ -<footer> - © 2019-2021 Alex Karle | <a href="/">Home</a> | <a href="/license.html">License</a> -</footer> -</body> -</html> diff --git a/www/header.html b/www/header.html @@ -1,32 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> -<meta charset="utf-8"/> -<meta name="viewport" content="width=device-width,initial-scale=1"> -<!-- Inspired by https://www.swyx.io/css-100-bytes/ --> -<style> -html { - max-width: 70ch; - padding: 3em 1em; - margin: auto; - font-size: 1em; - font-family: sans-serif; -} -footer { - margin-top: 50px; - font-size: .8em; -} -code { font-family: consolas, courier, monospace; } -h1 { font-size: 1.5em; } -h2 { font-size: 1.2em; } -h3 { font-size: 1.1em; } -blockquote, pre { - background: #f2f2f2; - overflow: auto; - padding: 10px; - border: 2px solid black; -} -</style> -<title>alexkarle.com</title> -</head> -<body>