diff options
Diffstat (limited to 'blog/footers.py')
| -rwxr-xr-x | blog/footers.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/blog/footers.py b/blog/footers.py index 4ec7f50d..ca0977ae 100755 --- a/blog/footers.py +++ b/blog/footers.py @@ -8,8 +8,8 @@ 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.", + "es": "=> {relative_root}/contacto Contacta conmigo.", + "en": "=> {relative_root}/contact Contact me.", } EDIT_IN_GITHUB = { @@ -17,7 +17,12 @@ EDIT_IN_GITHUB = { "en": "Edit this page.", } -ENGLISH_PAGES = ('about.gmi', 'gemini.gmi',) +PARENT = { + "es": "Subir.", + "en": "Go to parent." +} + +ENGLISH_PAGES = ('about.gmi', 'gemini.gmi', "contact.gmi",) content_gmi_files = [str(p.relative_to(content)) for p in pathlib.Path(content).glob("**/*.gmi")] @@ -31,7 +36,10 @@ for gmi in pathlib.Path.cwd().glob("**/*.gmi"): footer = [] - footer.append(CONTACT[language]) + relative_root = "/".join([".."] * (len(gmi.parts) - len(pathlib.Path.cwd().parts) - 1)) + + if relative_gmi not in ("contact.gmi", "contacto.gmi"): + footer.append(CONTACT[language].format(relative_root=relative_root)) content_source = None if relative_gmi in content_gmi_files: @@ -43,6 +51,15 @@ for gmi in pathlib.Path.cwd().glob("**/*.gmi"): if content_source: footer.append(f"=> https://github.com/alexpdp7/alexpdp7/edit/master/{content_source} {EDIT_IN_GITHUB[language]}") + closest_index = gmi.with_name("index.gmi") + while closest_index == gmi or closest_index.is_relative_to(pathlib.Path.cwd()) and not closest_index.exists(): + closest_index = closest_index.parent.parent / "index.gmi" + + closest_index = closest_index if closest_index.exists() else None + if closest_index: + index_link = "/".join([".."] * (len(gmi.parts) - len(closest_index.parts))) + "/" + footer.append(f"=> {index_link} {PARENT[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" |
