Use uri consistently for permalinks and fix Micropub Location header for likes/bookmarks #148
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The Micropub
Locationheader is wrong for likes and bookmarks (app/Services/Micropub/Handlers/EntryHandler.php):->url, which is the liked post's URL, not our/likes/{id}page.->uri, butBookmarkhas nouriattribute (onlylocal_uri), so theLocationheader is empty.The root cause is inconsistent naming for "this post's permalink on jonnybarnes.uk".
Naming: use
urifor our own permalinksurlis already a database column meaning the external thing on several models, so it can't also mean our page:urlcurrently means/likes/{id})local_uriuri(absolute), pluslink(relative)uriuriConvention:
uri= the absolute permalink on our site for every postable model, andurlstays free for "what it points at".uriis already the majority, andProcessWebMention, the syndication jobs,SendWebMentionsand the Micropub handlers all use it.Tasks
uri()accessor toLike(config('app.url').'/likes/'.$this->id)Bookmark::localUri()touri()and update the test that useslocal_uriEntryHandler: use->urifor likes and bookmarksLocationheader value for a like and a bookmark created via Micropubresources/views/templates/like.blade.phpuses the attribute instead of the hard-coded/likes/{id}(note/article templates use relative paths deliberately; leave them)Not planned: a shared
HasPermalinkinterface. It's more ceremony than this site needs.Optional follow-up: newbase60 IDs for likes and bookmarks
If we want them to match notes, switch likes and bookmarks to nb60 IDs. Do this after the
uriwork above, because thenuri()is the only place that builds the permalink.The catch: digits are valid nb60 characters (
0123456789ABC…), so an existing/likes/123would decode to 3723 instead of 123. That would 404 or show the wrong post. Like notes did (/note/{decId}→/notes/{nb60}), the nb60 pages need a new path, with 301 redirects from the old numeric ones.nb60idaccessor andnb60()scope onLikeandBookmark, copied fromNote, including the check for IDs too large for int4uri()usesnb60id/like/{nb60},/bookmark/{nb60}). Controllers takestring $urlIdand look it up through the scope, instead of automatic route model binding./likes/{id}and/bookmarks/{id}become 301 redirects (keepwhereNumber)Low priority. The short domain is gone, so the gain is mostly cosmetic (123 →
24). Neither type sends webmentions or gets syndicated, so few outside links exist.Separate follow-up: drop
notes.shorturlThe short domain has been dropped and nothing in
app,config, views or tests references shorturl any more. The only leftover is a deadnotes.shorturlcolumn (varchar 20). It has no non-null values locally, but check production before dropping it. This is a schema change, so do it on its own branch.🤖 Generated with Claude Code