Changeset 834bcc3 in Klonkt for src/middleware/site.js
- Timestamp:
- 06/23/2026 06:14:27 PM (3 months ago)
- Branches:
- main
- Children:
- d774679
- Parents:
- bb42dfb
- File:
-
- 1 edited
-
src/middleware/site.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/middleware/site.js
rbb42dfb r834bcc3 15 15 16 16 /** 17 * De primaire/hoofd-site — ÉÉN bron van waarheid (vervangt de "oudstesite ="18 * hoofd"-aanname die voorheen los in resolveSite/hub/account/admin stond).19 * Leest de expliciete is_primary-vlag; valt terug op de oudste als die (nog)20 * nergens staat, zodat bestaand gedrag exact behouden blijft.17 * The primary/main site — ONE source of truth (replaces the "oldest site =" 18 * main" assumption that was previously scattered across resolveSite/hub/account/admin). 19 * Reads the explicit is_primary flag; falls back to the oldest if it isn't set 20 * anywhere yet, so existing behaviour is preserved exactly. 21 21 */ 22 22 export function getPrimarySite() { … … 28 28 export function resolveSite(req, res, next) { 29 29 const tenancy = getTenancy(); 30 res.locals.tenancy = tenancy; // ook beschikbaar voorviews30 res.locals.tenancy = tenancy; // also available in views 31 31 32 // In HUB -mode mapt /user/:slug naar een specifieke site. In SOLO-mode bestaat33 // er maar één site: we slaan die routing over en pinnen op de primairesite.32 // In HUB mode /user/:slug maps to a specific site. In SOLO mode there is only 33 // one site: we skip that routing and pin to the primary site. 34 34 if (tenancy === 'hub') { 35 // Een Klonkt-site is canoniek bereikbaar via /user/:slug. /sites/:slug is een36 // legacy -alias → 301 naar de canonieke vorm zodat er één URL-schema overblijft37 // ( behoudt pad + querystring; raakt /admin/sites NIET, dat begint met/admin/).35 // A Klonkt site is canonically reachable via /user/:slug. /sites/:slug is a 36 // legacy alias → 301 to the canonical form so one URL scheme remains 37 // (preserves path + query string; does NOT touch /admin/sites, which starts with /admin/). 38 38 const m = req.path.match(/^\/(sites|user)\/([a-zA-Z0-9_-]+)(\/.*)?$/); 39 39 if (m) { … … 49 49 } 50 50 } 51 // ( Verwijderd: een dode "slug == hostname"-subdomein-hack. Slugs mogen geen52 // punten bevatten, dus die kon nooit matchen. Echte subdomein-routing zou de53 // subdom ein-LABEL tegen de slug matchen — een aparte feature, niet dit.)51 // (Removed: a dead "slug == hostname" subdomain hack. Slugs may not contain 52 // dots, so it could never match. Real subdomain routing would match the 53 // subdomain LABEL against the slug — a separate feature, not this.) 54 54 } 55 55 56 // Solo (o f hub zonder match): pin op de primaire/hoofd-site.56 // Solo (or hub without a match): pin to the primary/main site. 57 57 const defaultSite = getPrimarySite(); 58 58 if (defaultSite) { … … 79 79 80 80 try { 81 // m.filename = de kale bestandsnaam; de speelbare URL is de gated stream-route82 // (audioUrl). De media-tabel heeft GEEN url-kolom — de oude query selecteerde83 // m.url en faalde dus altijd stil (lege speler). Nu bouwen we de URL uitfilename.81 // m.filename = the bare filename; the playable URL is the gated stream route 82 // (audioUrl). The media table has NO url column — the old query selected 83 // m.url and always failed silently (empty player). Now we build the URL from filename. 84 84 const rows = db.prepare(` 85 85 SELECT t.id, t.title, t.artist, t.duration, t.position, m.filename
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)