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

+9 -4
View File
@@ -549,7 +549,7 @@ def _check_type(data: dict) -> None:
def _note_from_url(url: Optional[str], deleted: bool = False):
"""Find the note a URL points at (/note/<slug> on this site)"""
"""Find the note a URL points at (/note/<slug> or /article/<slug> on this site)"""
from urllib.parse import urlparse
from starpunk.database import get_db
@@ -560,7 +560,7 @@ def _note_from_url(url: Optional[str], deleted: bool = False):
if parsed.netloc and site.netloc and parsed.netloc != site.netloc:
raise MicropubValidationError("URL is not on this site")
parts = [p for p in parsed.path.split("/") if p]
if len(parts) != 2 or parts[0] not in ("note", "notes"):
if len(parts) != 2 or parts[0] not in ("note", "notes", "article", "articles"):
raise MicropubValidationError("URL is not a post on this site")
slug = parts[1]
if deleted:
@@ -678,7 +678,7 @@ def handle_create(data: dict, token_info: dict, files=None):
from starpunk.syndication import resolve_targets, select_targets
select_targets(note.id, resolve_targets(requested_targets))
return "", 201, {"Location": absolute_url_for("public.note", slug=note.slug)}
return "", 201, {"Location": note.url}
except InvalidNoteDataError as e:
raise MicropubValidationError(str(e))
@@ -820,6 +820,11 @@ def handle_update(data: dict, token_info: dict):
current_app.logger.error(f"Failed to update note via Micropub: {e}")
raise MicropubError("server_error", "Failed to update post", status_code=500)
# Adding or removing a title moves the post between /note/ and /article/:
# the spec says to answer 201 with the new URL (v2.17.0)
if bool(title) != bool(note.title):
from starpunk.utils import post_url
return "", 201, {"Location": post_url(note.slug, title)}
return "", 204
@@ -860,7 +865,7 @@ def note_to_mf2(note, wanted: Optional[list] = None) -> dict:
# HTML-authored content comes back as HTML (3.7.2, v2.9.0)
"content": [{"html": content} if note.content_format == "html" else content],
"published": [iso_utc(note.created_at)],
"url": [absolute_url_for("public.note", slug=note.slug)],
"url": [note.url],
"post-status": ["published" if note.published else "draft"],
}
if note.title: