Changeset fcd6964 in Klonkt for src/routes
- Timestamp:
- 07/24/2026 08:59:51 PM (7 weeks ago)
- Branches:
- main
- Children:
- c6185fa
- Parents:
- 3ffbedd
- Location:
- src/routes
- Files:
-
- 2 edited
-
guardian.js (modified) (4 diffs)
-
posts.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/guardian.js
r3ffbedd rfcd6964 10 10 */ 11 11 import express from 'express'; 12 import fs from 'fs';13 12 import path from 'path'; 14 13 import { fileURLToPath } from 'url'; … … 20 19 21 20 const router = express.Router(); 22 23 // Cache-bust the PWA assets: /assets is served with a 1-year cache, so without24 // a per-build version the browser keeps running an old guardian.js/css after a25 // deploy (that was exactly the "no feedback / not arriving" bug). The version26 // is the file's mtime at process start; a redeploy restarts us and bumps it.27 21 const __dir = path.dirname(fileURLToPath(import.meta.url)); 28 function assetVersion(rel) {29 try { return Math.floor(fs.statSync(path.join(__dir, '..', 'assets', rel)).mtimeMs).toString(36); }30 catch { return '0'; }31 }32 const ASSET_V = { js: assetVersion('js/guardian.js'), css: assetVersion('css/guardian.css') };33 22 34 23 /** The acting site: ?site=slug when owned, else the user's first site. */ … … 78 67 sites, 79 68 lang: L, 80 assetV: ASSET_V,81 69 t: (k, v) => i18nT(L, k, v), 82 70 cspNonce: res.locals.cspNonce, … … 125 113 res.json({ ok: true, committed: !!r.committed, readyToCommit: !!r.readyToCommit }); 126 114 }); 115 116 // ── PWA assets served no-cache, so an update is never masked by the 1-year 117 // /assets cache or a stuck install (that was the whole "nothing works after 118 // a deploy" bug). Small files; the browser revalidates and gets a 304 when 119 // unchanged, the fresh file when changed. 120 function pwaAsset(rel, type) { 121 return (req, res) => { 122 res.set('Cache-Control', 'no-cache'); 123 res.type(type); 124 res.sendFile(path.join(__dir, '..', 'assets', rel)); 125 }; 126 } 127 router.get('/app.js', pwaAsset('js/guardian.js', 'application/javascript')); 128 router.get('/app.css', pwaAsset('css/guardian.css', 'text/css')); 127 129 128 130 // ── Manage: release a committed ward (local Undo; federation is Fase 4). ── -
src/routes/posts.js
r3ffbedd rfcd6964 939 939 ? Guardianship.offersCollection(`${gMe}/queues/offers`, site.slug, gMe).orderedItems 940 940 : []).filter((o) => o['shaer:ward'] === gMe && o['shaer:needsMyAccept']); 941 // FEP-633c §2: who guards this account (committed). Shown so a ward can always 942 // see its guardians, not just pending offers. Derive a display @handle when the 943 // stored one is missing or is the escalation (inbox) handle rather than a @handle. 944 const guardianHandle = (uri, cached) => { 945 if (cached && cached.charAt(0) === '@') return cached; 946 try { const u = new URL(uri); return `@${u.pathname.split('/').filter(Boolean).pop()}@${u.host}`; } 947 catch { return uri; } 948 }; 949 const myGuardians = (site ? Guardianship.listGuardians(site.slug) : []) 950 .map((g) => ({ uri: g.other_uri, handle: guardianHandle(g.other_uri, g.other_handle) })); 941 951 renderPage(req, res, 'pages/messages', { 942 952 pageTitleKey: 'msg.title', bodyClass: 'on-special', items, seenAt, 943 hasMore, nextOffset: offset + FEED_PAGE, moreBase, guardianOffers, 953 hasMore, nextOffset: offset + FEED_PAGE, moreBase, guardianOffers, myGuardians, 944 954 success: req.query.success || null, error: req.query.error || null, 945 955 });
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)