From 0de9ac241da79bb5d4812ff31564444541873e0a Mon Sep 17 00:00:00 2001 From: =?utf8?q?cat=20=C3=A6scling?= Date: Thu, 26 Feb 2026 20:42:40 -0500 Subject: [PATCH] templatize the template files to make them DRYer --- Makefile | 5 + template/article.xhtml.sh | 35 +++++++ template/article.xhtml.template | 94 ------------------- .../common/footer.xhtml.template.fragment | 7 ++ template/common/intro.xhtml.template.fragment | 10 ++ .../common/style-body.xhtml.template.fragment | 73 ++++++++++++++ template/index.xhtml.sh | 22 +++++ template/index.xhtml.template | 89 ------------------ 8 files changed, 152 insertions(+), 183 deletions(-) create mode 100755 template/article.xhtml.sh delete mode 100644 template/article.xhtml.template create mode 100644 template/common/footer.xhtml.template.fragment create mode 100644 template/common/intro.xhtml.template.fragment create mode 100644 template/common/style-body.xhtml.template.fragment create mode 100755 template/index.xhtml.sh delete mode 100644 template/index.xhtml.template diff --git a/Makefile b/Makefile index 48f1a3d..f13c31c 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ _FORMATTED_ARTICLES=$(UNFORMATTED_ARTICLES:.unformatted=.xhtml) # later FORMATTED_ARTICLES=$(patsubst temp/%, %, $(_FORMATTED_ARTICLES)) +COMMONS=$(wildcard template/common/*) + # don't delete intermediate files when done; otherwise we always full rebuild .SECONDARY: @@ -52,6 +54,9 @@ $(OUTDIR)/atom.xml: temp/atom.unformatted_atom temp/atom.unformatted_atom: $(FORMATTED_ARTICLES) template/atom.xml.template sblg -t template/atom.xml.template -a -o $@ $(FORMATTED_ARTICLES) +template/%.template: template/%.sh $(COMMONS) + ./$< | hxnormalize -x >$@ + clean: rm temp/* rm $(OUTDIR)/* diff --git a/template/article.xhtml.sh b/template/article.xhtml.sh new file mode 100755 index 0000000..ecdaad2 --- /dev/null +++ b/template/article.xhtml.sh @@ -0,0 +1,35 @@ +#!/bin/sh -e + +cat template/common/intro.xhtml.template.fragment + +cat <<'EOF' + + + + ${sblg-title}: of æsc and smoke: a blog by cat æscling +EOF + +cat template/common/style-body.xhtml.template.fragment + +cat <<'EOF' +

of æsc and smoke

+ +

a blog by cat æscling

+ + +
+ + +EOF + +cat template/common/footer.xhtml.template.fragment diff --git a/template/article.xhtml.template b/template/article.xhtml.template deleted file mode 100644 index 5d00d69..0000000 --- a/template/article.xhtml.template +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - ${sblg-titletext}: of smoke and æsc - - - - -
-

of smoke and æsc

- -

a blog by cat æscling

-
- -
- - - - diff --git a/template/common/footer.xhtml.template.fragment b/template/common/footer.xhtml.template.fragment new file mode 100644 index 0000000..c835ffe --- /dev/null +++ b/template/common/footer.xhtml.template.fragment @@ -0,0 +1,7 @@ + + + diff --git a/template/common/intro.xhtml.template.fragment b/template/common/intro.xhtml.template.fragment new file mode 100644 index 0000000..fe7d8c4 --- /dev/null +++ b/template/common/intro.xhtml.template.fragment @@ -0,0 +1,10 @@ + + + + + + + diff --git a/template/common/style-body.xhtml.template.fragment b/template/common/style-body.xhtml.template.fragment new file mode 100644 index 0000000..81832d6 --- /dev/null +++ b/template/common/style-body.xhtml.template.fragment @@ -0,0 +1,73 @@ + + + +
diff --git a/template/index.xhtml.sh b/template/index.xhtml.sh new file mode 100755 index 0000000..3dc92f7 --- /dev/null +++ b/template/index.xhtml.sh @@ -0,0 +1,22 @@ +#!/bin/sh -e + +cat template/common/intro.xhtml.template.fragment + +cat <<'EOF' + + + of æsc and smoke: a blog by cat æscling +EOF + +cat template/common/style-body.xhtml.template.fragment + +cat <<'EOF' +

of æsc and smoke

+ +

a blog by cat æscling

+
+ + +EOF + +cat template/common/footer.xhtml.template.fragment diff --git a/template/index.xhtml.template b/template/index.xhtml.template deleted file mode 100644 index d1b0e68..0000000 --- a/template/index.xhtml.template +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - of smoke and æsc: a blog by cat æscling - - - - -
-

of smoke and æsc

- -

a blog by cat æscling

-
- - - - - - -- 2.47.3