aboutsummaryrefslogtreecommitdiff
path: root/blog/footers.py
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2026-09-18 15:50:00 +0200
committeralex <alex@pdp7.net>2026-09-18 15:50:00 +0200
commit9a263fddff0a14f51c9a6c9733de8b3b22c20294 (patch)
treed76fc421710a7ba9ea1143636a4618b2cbe6d012 /blog/footers.py
parente791066955ecb94d0c553e618e0dc1fb9ae152f4 (diff)
Add footer generation, clean up build process slightly
Diffstat (limited to 'blog/footers.py')
-rwxr-xr-xblog/footers.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/blog/footers.py b/blog/footers.py
new file mode 100755
index 00000000..268f236d
--- /dev/null
+++ b/blog/footers.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import pathlib
+import sys
+
+content = pathlib.Path(sys.argv[1])
+
+print("Generating footers...")
+
+CONTACT = {
+ "es": "Envíame email a alex arroba corcoles punto net.",
+ "en": "Send me email at alex at corcoles dot net.",
+}
+
+ENGLISH_PAGES = ('about.gmi', 'gemini.gmi',)
+
+
+for gmi in pathlib.Path.cwd().glob("**/*.gmi"):
+ relative_gmi = str(gmi.relative_to(pathlib.Path.cwd()))
+ if relative_gmi == "index.gmi":
+ # index.gmi is endless, no footer for that one
+ continue
+ language = "en" if relative_gmi in ENGLISH_PAGES or relative_gmi.startswith("notes/") else "es"
+ footer = [CONTACT[language]]
+ gmi_content = gmi.read_text()
+ assert gmi_content.endswith("\n"), f"{gmi} has no trailing new line"
+ assert not gmi_content.endswith("\n\n"), f"{gmi} has extra empty blank line"
+ gmi.write_text(gmi_content + "\n" + "\n".join(footer) + "\n")