Micropub `name` was dropped; store it as the note's '# Heading' first line, which is how StarPunk titles work. q=source returned /notes/<slug> (a 404) and a name for every note; it now returns the real permalink and name only for titled notes, without the heading in content. Titled notes no longer show their title twice (Note.body_html, excerpt). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.2 KiB
2.2 KiB
v2.3.3: Micropub titles, q=source URL, single title display
Found while building tuipub, a terminal Micropub client, against StarPunk.
Problems
- Micropub
namedropped.handle_createcalledextract_title()and threw the result away. StarPunk has no title column:Note.titleis derived from the content's first line, and a# Headingfirst line marks a titled note (Q22). So anamesent by a client never showed up. q=sourceURL wrong. It built{SITE_URL}notes/{slug}, but the route is/note/<slug>, so the URL was a 404.q=sourcename wrong. It returnednote.titlefor every note. For untitled notes that is just the first line of the content, so clients saw anamethey never sent.- Title shown twice.
note.htmlrenders the title as<h1 class="p-name">and then the whole content, which includes the# Headingagain. Home-page previews did the same with the excerpt.
Decisions
- Store
nameas a# {name}first line (micropub.add_title_heading) rather than adding a title column. This matches how titled notes already work everywhere (pages, feeds, search, admin editor), and needs no migration. If the content already starts with that exact heading, it isn't added twice. models.split_title()is the single definition of "title heading": the first non-blank line starting with#(the same rule as the templates'has_explicit_title).q=sourceuses it to returnname+contentthe way they were posted.Note.body_htmlrenders the content without the title heading;note.htmluses it.Note.excerptalso leaves the title out.Note.htmlis unchanged, so feeds and syndication behave as before (feed items carry a separate title anyway).extract_title()no longer derives a fallback title from content: that value was never used.
Tests
tests/test_micropub.py: name stored as heading, no duplicate heading,q=sourceurl equals the Location permalink,nameonly for titled notes, round trip.tests/test_models.py:split_title,body_html, excerpt without title.- Checked end to end with tuipub against a local dev server: titled post → page shows the title once,
q=sourcereturnsname,contentand a working url.