feat: articles at /article/<slug> with slugs from their titles (v2.17.0, ADR-077)

Articles (notes with a title) move from /note/<slug> to /article/<slug>;
the other prefix 301-redirects. New articles take their slug from the
title (mp-slug still wins; notes keep timestamp slugs). A Micropub update
that adds or removes a title answers 201 with the new Location.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-11-12 12:27:31 -07:00
1 parent 66aecc2bcb
commit b7f8e1612c
26 files changed
+308 -60

No files matched your search

+22 -4
View File
@@ -8,7 +8,7 @@ No authentication required for these routes.
import hashlib
from datetime import datetime, timedelta, timezone
from flask import Blueprint, abort, render_template, Response, current_app, request, send_from_directory
from flask import Blueprint, abort, redirect, render_template, Response, current_app, request, send_from_directory, url_for
from starpunk.notes import list_notes, get_note
from starpunk.websub import embed_hub
@@ -354,18 +354,30 @@ def _note_was_deleted(slug: str) -> bool:
).fetchone():
return True
return db.execute(
"SELECT 1 FROM webmention_queue WHERE source_url = ? AND source_note_id IS NULL",
(absolute_url_for("public.note", slug=slug),),
"SELECT 1 FROM webmention_queue WHERE source_url IN (?, ?) AND source_note_id IS NULL",
(absolute_url_for("public.note", slug=slug), absolute_url_for("public.article", slug=slug)),
).fetchone() is not None
@bp.route("/note/<slug>")
def note(slug: str):
"""A note's permalink page; an article's /note/ URL redirects to /article/"""
return _permalink(slug, "public.note")
@bp.route("/article/<slug>")
def article(slug: str):
"""An article's permalink page (v2.17.0); a note's /article/ URL redirects to /note/"""
return _permalink(slug, "public.article")
def _permalink(slug: str, endpoint: str):
"""
Individual note permalink page
Individual note or article permalink page
Args:
slug: URL-safe note identifier
endpoint: The route the request came in on
Returns:
Rendered note template with full content
@@ -390,6 +402,12 @@ def note(slug: str):
abort(410)
abort(404)
# Each post has one URL: /article/ for articles, /note/ for notes (v2.17.0).
# The other one redirects, so links made before a title was added or
# removed keep working.
if note_obj.endpoint != endpoint:
return redirect(url_for(note_obj.endpoint, slug=slug), code=301)
# Get media for note (v1.2.0 Phase 3)
media = get_note_media(note_obj.id)