Commit 49c030d83f
49c030d83f2b56507825304fe7b6a1e862b1843c
parent: 9ed1f35adf
Verified · cmc ci/build: failure ci/lint: success
cmc <hello@cleberg.net> · 2026-08-31 03:37 UTC
Use a placeholder for the footer version, and trim comments
Layout: unified · split
README.md
−4
| @@ -129,10 +129,6 @@ orgo can also build and preview on its own, without `build.py`: |
| 129 | 129 | orgo serve content -o /tmp/preview |
| 130 | 130 | ``` |
| 131 | 131 | |
| 132 | | Such a preview skips the footer rewrite, so it prints whatever version |
| 133 | | `content/templates/base.html` currently hardcodes rather than the one that |
| 134 | | built it. |
| 135 | | |
| 136 | 132 | ## Deployment |
| 137 | 133 | |
| 138 | 134 | Production builds rewrite image URLs to root-relative ones |
build.py
+5 −8
| @@ -78,10 +78,9 @@ def rewrite_img_urls(build_dir=".build"): |
| 78 | 78 | print(f"Rewrote {count} img.cleberg.net references to /img/") |
| 79 | 79 | |
| 80 | 80 | |
| 81 | | # The footer's "Powered by orgo <version>" note. Anchored on the whole phrase rather |
| 82 | | # than on a placeholder token, so the template stays valid HTML on its own and a page |
| 83 | | # already carrying a version is rewritten the same way as a freshly rendered one — and |
| 84 | | # so prose that happens to end a paragraph with a link to orgo is left alone. |
| 81 | # The footer's "Powered by orgo <version>" note. Matching the whole phrase rewrites a |
| 82 | # page carrying an old version as readily as one still carrying the template's |
| 83 | # placeholder, and leaves prose that ends a paragraph with a link to orgo alone. |
| 85 | 84 | ORGO_NOTE = re.compile( |
| 86 | 85 | r'(Powered by <a href="https://gitbay\.org/krz/orgo">orgo</a> )[^<]*(</p>)' |
| 87 | 86 | ) |
| @@ -115,8 +114,8 @@ def rewrite_orgo_version(build_dir): |
| 115 | 114 | |
| 116 | 115 | The whole point of this is that the note cannot go stale, so a footer that no longer |
| 117 | 116 | matches is a failure and not a no-op — matching nothing anywhere means the note was |
| 118 | | removed or its markup changed, and a silent pass would leave the site claiming |
| 119 | | whatever the template last hardcoded. |
| 117 | removed or its markup changed, and a silent pass would ship the template's |
| 118 | placeholder to every page. |
| 120 | 119 | """ |
| 121 | 120 | version = orgo_version() |
| 122 | 121 | count = 0 |
| @@ -223,8 +222,6 @@ def main(): |
| 223 | 222 | |
| 224 | 223 | if os.environ.get("BUILD", "").casefold() == "true": |
| 225 | 224 | run_orgo_build(build_dir) |
| 226 | | # Both environments: a dev preview showing a stale version is the same defect |
| 227 | | # as a deployed page showing one. |
| 228 | 225 | rewrite_orgo_version(build_dir) |
| 229 | 226 | # The onion needs same-origin images; dev previews keep the absolute URLs. |
| 230 | 227 | # Runs over every page, not just the re-rendered ones, so a page carried over |
content/templates/base.html
+1 −4
| @@ -93,10 +93,7 @@ |
| 93 | 93 | <a href="{{ root }}tips/index.html">Tips</a> · |
| 94 | 94 | <a href="https://iheartrss.com/">I ♥ RSS</a> |
| 95 | 95 | <p>[ <a href="https://krz.sh">krz</a> · <a href="https://audit-labs.dev">audit labs</a> ]</p> |
| 96 | | {#- The version is rewritten in the built HTML by build.py, which reads it from the |
| 97 | | orgo that just ran. What is written here is the seed and the fallback: a build |
| 98 | | that bypasses build.py (`orgo serve`) prints it as-is. #} |
| 99 | | <p>Powered by <a href="https://gitbay.org/krz/orgo">orgo</a> 0.22.0</p> |
| 96 | <p>Powered by <a href="https://gitbay.org/krz/orgo">orgo</a> ORGO_VERSION</p> |
| 100 | 97 | </footer> |
| 101 | 98 | </body> |
| 102 | 99 | </html> |