refactor: Centralize the /u/{username}/{slug} permalink scheme in a domain permalinks module #35
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
rosa/vernier#35
Loading…
Add table
Add a link
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
/u/{username}/{slug}URL layout is shared knowledge across ~15 modules. The domain crate owns a builder (post_source_url,crates/domain/src/services.rs:474) and a parser (resolve_post_url,crates/domain/src/services.rs:760), but the web crate re-derives the scheme by hand-formatting strings:crates/web/src/handlers/posts.rs:54,156,192crates/web/src/handlers/users.rs:507,532,555,606,630crates/web/src/handlers/micropub.rs:57crates/web/src/handlers/indieauth.rs:37,104,221crates/web/src/pages.rs,components.rs,layouts.rs(maud templates)Two costs:
UserName/Slugnewtypes never need URL-escaping — an invariant nothing states or enforces.Proposal
Add a small
permalinksmodule invernier-domainthat owns the scheme:profile_path(&UserName) -> Stringpost_path(&UserName, &Slug) -> StringUrlresolve_post_url) moves here as its inverseWeb handlers, maud templates, and the feed builders call it;
routes.rsstays the only place with Axum route templates. A deep module in the small-interface sense: a few one-line functions whose value is centralizing an invariant currently enforced by convention.Non-goals
routes.rsroute templates stay as-is (Axum needs its own syntax).