aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2026-02-01 10:24:24 +0100
committeralexpdp7 <alex@corcoles.net>2026-02-01 11:35:23 +0100
commitf94e0a1bc1aea34cb4eadd2305ddf724722cd9b9 (patch)
tree154bf7029790cbaddc9c5f772f968de0ea07bacf
parent1fc83c64825483e36f766f8fc7f927f3ca68afa5 (diff)
Create redirections file for slash removalmaster
-rw-r--r--blog_v2/src/blog/__init__.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/blog_v2/src/blog/__init__.py b/blog_v2/src/blog/__init__.py
index 80ccb5b..15d6e4f 100644
--- a/blog_v2/src/blog/__init__.py
+++ b/blog_v2/src/blog/__init__.py
@@ -64,6 +64,17 @@ def migrate(from_: pathlib.Path, to: pathlib.Path):
reconstruct += "\n"
g.write_text(reconstruct)
+ # Build old URL slash removal redirect list
+ redirections = textwrap.dedent("""
+ # This is a list of the pre-migration URLs of this blog.
+ # URLs in this list might had been linked with a trailing slash.
+ # Use Apache httpd's RewriteMap to preserve only old URLs
+ """).lstrip()
+ for g in to.glob("**/*.gmi"):
+ url = str(g.relative_to(to).with_suffix(""))
+ redirections += f"{url}/ {url}\n"
+ pathlib.Path(to / "redirections.txt").write_text(redirections)
+
def build(from_: pathlib.Path, to: pathlib.Path):
TITLE = "El blog es mío"