diff options
| author | alex <alex@pdp7.net> | 2026-09-18 16:23:01 +0200 |
|---|---|---|
| committer | alex <alex@pdp7.net> | 2026-09-18 16:24:18 +0200 |
| commit | c79efb3411895cc8c489c4543e2da30c42f4080c (patch) | |
| tree | 4eb1c0dfd9d951d30f57dbca360960fa70b3a16e /blog | |
| parent | 9a263fddff0a14f51c9a6c9733de8b3b22c20294 (diff) | |
Add edit footer link
Diffstat (limited to 'blog')
| -rwxr-xr-x | blog/footers.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/blog/footers.py b/blog/footers.py index 268f236d..137bafd6 100755 --- a/blog/footers.py +++ b/blog/footers.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import pathlib +import subprocess import sys content = pathlib.Path(sys.argv[1]) @@ -11,16 +12,34 @@ CONTACT = { "en": "Send me email at alex at corcoles dot net.", } +EDIT_IN_GITHUB = { + "es": "Edita esta página.", + "en": "Edit this page.", +} + ENGLISH_PAGES = ('about.gmi', 'gemini.gmi',) +content_gmi_files = [str(p.relative_to(content)) for p in pathlib.Path(content).glob("**/*.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]] + + footer = [] + + footer.append(CONTACT[language]) + + edit_url = None + if relative_gmi in content_gmi_files: + edit_url = "https://github.com/alexpdp7/alexpdp7/edit/master/blog/content/" + relative_gmi + + if edit_url: + footer.append(f"=> {edit_url} {EDIT_IN_GITHUB[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" |
