Add user-defined permalinks for recordings #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/custom-permalinks"
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?
Recordings can now have an optional custom permalink, so a share link reads
/v/product-demoinstead of/v/aB3xK9pq.What you get
/v/{slug}and the original/v/{id}both resolve (a slug match wins), so old links never break.How it works
videos.slugcolumn + a unique index, created indb.init_db()(SQLite cannot add aUNIQUEcolumn viaALTER TABLE;NULL= "use the id", and a unique index still allows manyNULLs).PATCH /api/videos/{id}acceptsslug: server-side normalize (lowercase, non-alphanumeric runs to-, capped 80), collision + id-shadow guards to409, invalid to400, empty clears toNULL./v/{key}resolvesWHERE slug=? OR id=? ORDER BY (slug=?) DESC.Verified
TestClient smoke test, 18 checks: set/normalize, resolve by slug and by id, duplicate 409, id-shadow 409, invalid 400, clear + 404-after-clear + id-still-resolves, reuse-after-clear, and the editor renders on the watch page.
Migration is additive and idempotent; existing videos get a
NULLslug so their URLs are unchanged.Recordings can now have an optional custom slug, so a share link reads /v/product-demo instead of /v/aB3xK9pq. Owners/admins set or clear the permalink from a new editor on the watch page; the original id link keeps working, and the share button + library/thread/reply links prefer the slug. - schema: videos.slug + a unique index, created in db.init_db() (ALTER TABLE can't add a UNIQUE column inline; NULL slug = "use the id", and a unique index still allows many NULLs) - /v/{key} resolves by slug or id (a slug match wins); PATCH /api/videos accepts "slug" with server-side normalize, collision + id-shadow guards (409), invalid (400) and clear-to-NULL - watch page: permalink editor panel (owner/admin) with live preview; the address bar + Copy-link stay canonical via history.replaceState Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>