]> cat aescling's git repositories - blog.git/commitdiff
templatize the template files
authorcat æscling <aescling@cat.family>
Fri, 27 Feb 2026 01:42:40 +0000 (20:42 -0500)
committercat æscling <aescling@cat.family>
Fri, 27 Feb 2026 01:49:54 +0000 (20:49 -0500)
to make them DRYer

Makefile
template/article.xhtml.sh [new file with mode: 0755]
template/article.xhtml.template [deleted file]
template/common/footer.xhtml.template.fragment [new file with mode: 0644]
template/common/intro.xhtml.template.fragment [new file with mode: 0644]
template/common/style-body.xhtml.template.fragment [new file with mode: 0644]
template/index.xhtml.sh [new file with mode: 0755]
template/index.xhtml.template [deleted file]

index 48f1a3d52061d45dc738640988be2ea22cae7c0e..f13c31c3584755d36db567c49eebd24bd7d49c80 100644 (file)
--- 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 (executable)
index 0000000..ecdaad2
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+
+cat template/common/intro.xhtml.template.fragment
+
+cat <<'EOF'
+    <meta content="${sblg-stripbase}.xhtml" property="og:url" />
+    <meta content="${sblg-title}: of æsc and smoke: a blog by cat æscling" property="og:title" />
+    <meta content="${sblg-aside}" property="og:description" />
+    <title>${sblg-title}: of æsc and smoke: a blog by cat æscling</title>
+EOF
+
+cat template/common/style-body.xhtml.template.fragment
+
+cat <<'EOF'
+      <h1><a href="/">of æsc and smoke</a></h1>
+
+      <p>a blog by cat æscling</p>
+    </header>
+
+    <article data-sblg-article="1"></article>
+
+<!--
+i can't currently get sblg -C to work purropurrly, so don't do this fur now
+    <nav id="article-nav">
+      <ul>
+        <li><a href="${sblg-first-stripbase}.xhtml">&#x3C;&#x3C; furst</a></li>
+        <li><a href="${sblg-prev-stripbase}.xhtml">&#x3C; purrevious</a></li>
+        <li><a href="${sblg-next-stripbase}.xhtml">next &#x3E;</a></li>
+        <li><a href="${sblg-last-stripbase}.xhtml">last &#x3E;&#x3E;</a></li>
+      </ul>
+    </nav>
+-->
+EOF
+
+cat template/common/footer.xhtml.template.fragment
diff --git a/template/article.xhtml.template b/template/article.xhtml.template
deleted file mode 100644 (file)
index 5d00d69..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<!DOCTYPE html>
-
-<html lang="en-X-catspeak" xml:lang="en-X-catspeak"
-  xmlns="http://www.w3.org/1999/xhtml">
-  <head prefix="og: http://ogp.me/ns#">
-    <meta charset="utf-8" />
-    <meta content="width=device-width, initial-scale=1.0"
-      name="viewport" />
-    <link href="/atom.xml" rel="alternate" />
-    <meta content="${sblg-titletext}: of smoke and æsc"
-      property="og:title" />
-    <title>${sblg-titletext}: of smoke and æsc</title>
-
-    <style>
-html {
-    font-family: serif;
-    font-size: 14pt;
-    line-height: 1.28;
-    color: #F0B2D8;
-    background: #3B3B3B;
-}
-
-body {
-    background: #1F4505;
-    max-width: 72ch;
-    margin: 0 auto;
-    padding: 1rem;
-    margin-top: 2rem;
-    padding: 1rem;
-    filter: drop-shadow(.5rem .5rem 0.064rem #1c1c1c);
-    border: outset 4px #592846;
-}
-
-h1 {
-    font-family: sans-serif;
-    font-size: 18pt;
-}
-
-article,
-footer {
-    border-top: solid 1px #E63CA4;
-}
-
-footer {
-    font-size: 10pt;
-}
-
-article h1 {
-    font-size: 16pt;
-}
-
-a,
-a:visited {
-    color: #31B9DB;
-}
-
-a:active,
-a:hover,
-a:focus {
-    background: #31B9DB;
-    color: #1F4505;
-}
-
-header {
-    font-size: 12pt;
-}
-
-header p,
-time {
-    font-style: italic;
-}
-
-header,
-footer {
-    text-align: center;
-}
-       </style></head>
-
-  <body>
-    <header>
-      <h1><a href="/">of smoke and æsc</a></h1>
-
-      <p>a blog by cat æscling</p>
-    </header>
-
-    <article data-sblg-article="1"></article>
-
-    <footer>
-      <p>licensed under <a
-        href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA
-        4.0</a></p>
-    </footer>
-  </body>
-</html>
diff --git a/template/common/footer.xhtml.template.fragment b/template/common/footer.xhtml.template.fragment
new file mode 100644 (file)
index 0000000..c835ffe
--- /dev/null
@@ -0,0 +1,7 @@
+    <footer>
+      <p>licensed under <a
+        href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA
+        4.0</a></p>
+    </footer>
+  </body>
+</html>
diff --git a/template/common/intro.xhtml.template.fragment b/template/common/intro.xhtml.template.fragment
new file mode 100644 (file)
index 0000000..fe7d8c4
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+
+<html lang="en-X-catspeak" xml:lang="en-X-catspeak"
+  xmlns="http://www.w3.org/1999/xhtml">
+  <head prefix="og: http://ogp.me/ns#">
+    <meta charset="utf-8" />
+    <meta content="width=device-width, initial-scale=1.0"
+      name="viewport" />
+    <link href="/atom.xml" rel="alternate" type="application/atom+xml"
+       />
diff --git a/template/common/style-body.xhtml.template.fragment b/template/common/style-body.xhtml.template.fragment
new file mode 100644 (file)
index 0000000..81832d6
--- /dev/null
@@ -0,0 +1,73 @@
+    <style>
+html {
+    font-family: serif;
+    font-size: 14pt;
+    line-height: 1.28;
+    color: #F0B2D8;
+    background: #3B3B3B;
+}
+
+body {
+    background: #1F4505;
+    max-width: 72ch;
+    margin: 0 auto;
+    padding: 1rem;
+    margin-top: 2rem;
+    padding: 1rem;
+    filter: drop-shadow(.5rem .5rem 0.064rem #1c1c1c);
+    border: outset 4px #592846;
+}
+
+h1 {
+    font-family: sans-serif;
+    font-size: 18pt;
+}
+
+article header,
+nav,
+footer {
+    border-top: solid 1px #E63CA4;
+}
+
+footer {
+    font-size: 10pt;
+}
+
+a,
+a:visited {
+    color: #31B9DB;
+}
+
+a:active,
+a:hover,
+a:focus {
+    background: #31B9DB;
+    color: #1F4505;
+}
+
+header {
+    font-size: 12pt;
+}
+
+header p,
+time {
+    font-style: italic;
+}
+
+header,
+footer {
+    text-align: center;
+}
+
+#article-nav {
+    text-align: center;
+}
+
+#article-nav ul li {
+    display: inline;
+    padding: 1rem;
+}
+       </style></head>
+
+  <body>
+    <header>
diff --git a/template/index.xhtml.sh b/template/index.xhtml.sh
new file mode 100755 (executable)
index 0000000..3dc92f7
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh -e
+
+cat template/common/intro.xhtml.template.fragment
+
+cat <<'EOF'
+    <meta content="/" property="og:url" />
+    <meta content="of æsc and smoke: a blog by cat æscling" property="og:title" />
+    <title>of æsc and smoke: a blog by cat æscling</title>
+EOF
+
+cat template/common/style-body.xhtml.template.fragment
+
+cat <<'EOF'
+      <h1>of æsc and smoke</h1>
+
+      <p>a blog by cat æscling</p>
+    </header>
+
+    <nav data-sblg-nav="1"></nav>
+EOF
+
+cat template/common/footer.xhtml.template.fragment
diff --git a/template/index.xhtml.template b/template/index.xhtml.template
deleted file mode 100644 (file)
index d1b0e68..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<!DOCTYPE html>
-
-<html lang="en-X-catspeak" xml:lang="en-X-catspeak"
-  xmlns="http://www.w3.org/1999/xhtml">
-  <head prefix="og: http://ogp.me/ns#">
-    <meta charset="utf-8" />
-    <meta content="width=device-width, initial-scale=1.0"
-      name="viewport" />
-    <meta content="/" property="og:url" />
-    <meta content="of smoke and æsc" property="og:title" />
-    <link href="/atom.xml" rel="alternate" />
-    <title>of smoke and æsc: a blog by cat æscling</title>
-
-    <style>
-html {
-    font-family: serif;
-    font-size: 14pt;
-    line-height: 1.28;
-    color: #F0B2D8;
-    background: #3B3B3B;
-}
-
-body {
-    background: #1F4505;
-    max-width: 72ch;
-    margin: 0 auto;
-    padding: 1rem;
-    margin-top: 2rem;
-    padding: 1rem;
-    filter: drop-shadow(.5rem .5rem 0.064rem #1c1c1c);
-    border: outset 4px #592846;
-}
-
-h1 {
-    font-family: sans-serif;
-    font-size: 18pt;
-}
-
-nav,
-footer {
-    border-top: solid 1px #E63CA4;
-}
-
-footer {
-    font-size: 10pt;
-}
-
-a,
-a:visited {
-    color: #31B9DB;
-}
-
-a:active,
-a:hover,
-a:focus {
-    background: #31B9DB;
-    color: #1F4505;
-}
-
-header {
-    font-size: 12pt;
-}
-
-header p {
-    font-style: italic;
-}
-
-header,
-footer {
-    text-align: center;
-}
-       </style></head>
-
-  <body>
-    <header>
-      <h1>of smoke and æsc</h1>
-
-      <p>a blog by cat æscling</p>
-    </header>
-
-    <nav data-sblg-nav="1"></nav>
-
-    <footer>
-      <p>licensed under <a
-        href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA
-        4.0</a></p>
-    </footer>
-  </body>
-</html>