Changeset 72ec6a4 in Klonkt for src/middleware
- Timestamp:
- 07/31/2026 06:55:59 PM (6 weeks ago)
- Branches:
- main
- Children:
- 17546af
- Parents:
- bfa6fa1
- Location:
- src/middleware
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/middleware/render.js
rbfa6fa1 r72ec6a4 200 200 canManageFedi, 201 201 apEnabled: apEnabled(), 202 // Cirkel = the artists you feature (auto-boost) . Shown when AP is on and you203 // auto-boost ≥1 account, or (legacy) on a circle-tenancy site.202 // Cirkel = the artists you feature (auto-boost): shown when AP is on and 203 // you auto-boost at least one account. 204 204 hasCirkel: !!(_site && apEnabled() && (ActivityPubService.autoBoostCount(_site.slug) > 0 || ActivityPubService.boostedCount(_site.slug) > 0)), 205 205 isViewer: _isViewer, … … 213 213 audioTracks: data.audioTracks || res.locals.audioTracks || [], 214 214 siteUrlBase: res.locals.siteUrlBase || '', 215 tenancy: res.locals.tenancy || 'solo',216 hubTitle: getSetting('hub_title') || '',217 215 footerNewsletter: getSetting('footer_newsletter') === '1', // newsletter sign-up in footer (premium) 218 216 agendaEnabled: getSetting('agenda_enabled') === '1', // show agenda/events in the pill (premium, opt-in) -
src/middleware/site.js
rbfa6fa1 r72ec6a4 10 10 11 11 import db from '../config/database.js'; 12 import { getTenancy } from '../services/SettingsService.js';13 12 import { audioUrl } from '../services/AudioStreamService.js'; 14 13 import { audioEnabled } from '../config/features.js'; … … 27 26 28 27 export function resolveSite(req, res, next) { 29 const tenancy = getTenancy(); 30 res.locals.tenancy = tenancy; // also available in views 31 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 if (tenancy === 'hub') { 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 const m = req.path.match(/^\/(sites|user)\/([a-zA-Z0-9_-]+)(\/.*)?$/); 39 if (m) { 40 if (m[1] === 'sites') { 41 return res.redirect(301, req.originalUrl.replace(/^\/sites\//, '/user/')); 42 } 43 const site = db.prepare('SELECT * FROM sites WHERE slug = ?').get(m[2]); 44 if (site) { 45 res.locals.site = site; 46 req.url = (m[3] || '/'); // strip /user/:slug zodat downstream de rest ziet 47 res.locals.siteUrlBase = `/user/${m[2]}`; 48 return next(); 49 } 50 } 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 } 55 56 // Solo (or hub without a match): pin to the primary/main site. 28 // One instance is one owner (Robins besluit, 31-7): there is one site tree, 29 // pinned to the primary site. The /user/:slug routing that hub mode needed 30 // is gone with it. 57 31 const defaultSite = getPrimarySite(); 58 32 if (defaultSite) {
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)