source: Klonkt/src/middleware/render.js@ 495b019

Last change on this file since 495b019 was 495b019, checked in by Bart <bart@…>, 2 days ago

Lay-outthema's: een pakket, de beheerder kiest, en de zijbalk als eerste

Een lay-out is nu een pakket: een map in src/themes/ met een theme.json (id,
naam, versie, contract, stylesheet) en de stylesheet zelf. De zijbalk is het
eerste ingebouwde thema; een thema van buiten installeren komt later en gaat
door dezelfde lader, zodat er één vorm is.

Dezelfde markup, een ander stelsel: een thema verandert geen template. Het
contract (1) is de afspraak over de ids en klassen waar het op mag bouwen; een
thema op een ander contract valt terug op de gewone kop in plaats van half te
werken. Elke regel staat onder html[data-layout="<id>"], en een toets bewaakt
dat, zodat een thema niets raakt zolang het niet gekozen is.

WIE KIEST: de beheerder, in het sitebeheer (sites.layout). Een bezoeker niet
-- de server zet data-layout zelf, het bezoekersscript met localStorage is
weg, en ?layout= werkt alleen als voorproefje voor wie de site beheert. Het
beheer houdt altijd de gewone kop, ook bij navigeren via htmx (de lay-out reist
mee in pcmsNav): een kapot thema mag je nooit buitensluiten van de instelling
waarmee je het uitzet.

Geserveerd op /themes/<id>/<versie>/<bestand>, met de versie in het pad als
cache-buster; alleen wat het pakket zelf noemt komt eruit. De actor noemt het
gekozen thema als shaer:theme, zodat Shaer het van zijn eigen site kan halen
in plaats van er zelf een te kiezen.

Co-Authored-By: Claude Opus 5.5 <claude@…>

  • Property mode set to 100644
File size: 20.0 KB
RevLine 
[7bc636b]1/**
2 * Render helper — THE pattern for the entire app.
3 *
4 * Two modes:
5 * 1. HTMX request → render just the page content (no shell)
6 * 2. Full page request → render content, then embed in shell
7 *
8 * Usage:
9 * renderPage(req, res, 'pages/home', { posts, ...data })
10 */
11
[83faa57]12import fs from 'fs';
[7bc636b]13import path from 'path';
14import { fileURLToPath } from 'url';
15import ejs from 'ejs';
[8cb1dc7]16import db from '../config/database.js';
[7bc636b]17import PermissionsService from '../services/PermissionsService.js';
[8afbdd6]18import { isViewer } from './auth.js';
[283f618]19import { getSetting, apEnabled } from '../services/SettingsService.js';
[8aa85d0]20import { isPremium as isPremiumInstance, premiumEnabled, premiumUnlocked } from '../services/PatreonService.js';
[3597763]21import { emojiHtml, emojiName, parseQuote } from '../services/NoteRender.js';
[e951b7c]22import ActivityPubService from '../services/ActivityPubService.js';
[495b019]23import ThemeService from '../services/ThemeService.js';
[74c5abc]24import { imgProxyUrl } from '../services/ThumbnailService.js';
[cb01666]25import { audioEnabled as audioFeatureEnabled } from '../config/features.js';
[73abbfd]26
27// Add the per-request CSP nonce to every <script> tag that doesn't already have one, so the
28// strict script-src (nonce + 'strict-dynamic') allows them — including scripts in htmx
29// partials. HTML-escaped "&lt;script" in rendered content (e.g. sanitized post bodies) won't
30// match, so this only touches real tags.
[c6185fa]31export function injectCspNonce(html, nonce) {
[73abbfd]32 if (!html || !nonce) return html;
33 return String(html).replace(/<script(?![^>]*\snonce=)/gi, () => `<script nonce="${nonce}"`);
34}
[7bc636b]35import { PLATFORMS as PLATFORMS_CATALOG } from '../services/PlatformIcons.js';
[03fa548]36import { t as i18nT, resolveLang, SUPPORTED as LANGS, LANG_NAMES } from '../services/i18n.js';
[7bc636b]37
38const __dirname = path.dirname(fileURLToPath(import.meta.url));
39const VIEWS_DIR = path.join(__dirname, '..', 'views');
40
[d9ad6c5]41/**
42 * Render a post body to an HTML string with the SAME partial de Krant uses.
43 *
44 * For surfaces that are not an EJS page: the Guardian PWA builds its cards in
45 * the browser, so it gets the finished HTML in its state blob instead of the
46 * raw columns. One renderer, so a post cannot drift into looking different
47 * depending on where you run into it.
48 */
49export function renderNoteBody(nb, lang) {
50 if (!nb || !nb.content) return '';
51 const _l = lang || 'nl';
52 // ejs.renderFile hands back a Promise even with async:false, and the callers
53 // here are plain synchronous route code. Compile the file ourselves instead;
54 // `filename` is what lets the partial's own relative includes resolve.
55 const file = path.join(VIEWS_DIR, 'partials', 'note-body.ejs');
56 try {
57 return ejs.render(fs.readFileSync(file, 'utf8'), {
58 nb,
59 t: (key, vars) => i18nT(_l, key, vars),
60 emojiHtml,
61 emojiName,
62 noteQuote: parseQuote,
63 thumb: (url, w) => (typeof url === 'string' && /^https?:\/\//i.test(url) ? imgProxyUrl(url, w || 480) : url),
64 avatar: (url, w) => (typeof url === 'string' && /^https?:\/\//i.test(url) ? imgProxyUrl(url, w || 128) : url),
65 }, { filename: file, async: false });
66 } catch (e) {
67 console.warn('[render] note body failed:', e.message);
68 return '';
69 }
70}
71
[834bcc3]72// App version (from package.json) + short commit hash (from .klonkt-version, written by
73// the deploy script) — shown in the footer next to "Klonkt Beta". The hash is updated
74// automatically on every deploy, so the displayed version is never stale.
[83faa57]75let APP_VERSION = '';
76try {
77 APP_VERSION = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf8')).version || '';
[3bb8719]78 try {
79 const sha = fs.readFileSync(path.join(__dirname, '..', '..', '.klonkt-version'), 'utf8').trim().slice(0, 7);
80 if (sha) APP_VERSION += ' · ' + sha;
[834bcc3]81 } catch { /* no .klonkt-version (local dev) */ }
82} catch { /* no version available */ }
[83faa57]83
[834bcc3]84// Site timezone (Admin → Settings). Empty = server default (UTC). Applied to
85// all server-side formatted dates so they display in the site's timezone instead of UTC.
[421c2d4]86const siteTimezone = () => getSetting('timezone') || undefined;
87
[a7bcf66]88/**
89 * Read a stored timestamp as the moment it actually is.
90 *
91 * SQLite's CURRENT_TIMESTAMP writes UTC without saying so ("2026-07-28
92 * 18:20:33"), and new Date() reads a string in that shape as LOCAL time. That
93 * is right only as long as the server runs on UTC; set the machine to
94 * Europe/Amsterdam and every stored date silently shifts two hours. So say UTC
95 * out loud. Anything already carrying a zone (AP `published` ends in Z) is left
96 * to the normal parser.
97 */
98const parseStamp = (v) => {
99 if (!v) return null;
[0202104]100 if (typeof v === 'number') { // epoch ms (e.g. an availability endTime)
101 const d = new Date(v);
102 return Number.isNaN(d.getTime()) ? null : d;
103 }
[a7bcf66]104 const s = String(v);
105 const d = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}(:\d{2})?$/.test(s)
106 ? new Date(`${s.replace(' ', 'T')}Z`)
107 : new Date(s);
108 return Number.isNaN(d.getTime()) ? null : d;
109};
110
[fd8faf5]111export const formatDate = (iso) => {
[a7bcf66]112 const d = parseStamp(iso);
113 return d ? d.toLocaleDateString('nl-NL', { timeZone: siteTimezone(), day: 'numeric', month: 'long', year: 'numeric' }) : '';
[7bc636b]114};
115
[a7bcf66]116/** A timestamp in the site's own timezone (Beheer → Instellingen). Exported so
117 * surfaces outside the EJS pages (the Guardian PWA) read the same clock. */
118export const formatDateTime = (iso) => {
119 const d = parseStamp(iso);
120 return d ? d.toLocaleString('nl-NL', { timeZone: siteTimezone(), dateStyle: 'medium', timeStyle: 'short' }) : '';
[7bc636b]121};
122
123export async function renderPage(req, res, viewName, data = {}) {
124 // Decide: partial (HTMX) or full?
125 const isPartial = req.headers['hx-request'] === 'true' || req.query.partial === '1';
126
[834bcc3]127 // Prevent the browser from caching an htmx PARTIAL (only #pcms-main, without <head>/CSS)
128 // under the same URL and serving it as a full page on "back" → unstyled HTML.
129 // Vary: HX-Request separates partial and full responses in the cache;
130 // no-store on the partial forces "back" to always re-fetch the full page.
131 // (Vary also applies to intermediate caches / Cloudflare.)
[d5e78f7]132 res.setHeader('Vary', 'HX-Request');
[e2ea5c4]133 // A full HTML page must always be revalidated so an online visitor gets the
134 // fresh site, never a heuristically-cached copy. no-cache (not no-store) still
135 // allows bfcache and conditional requests. Partials stay no-store (see above).
136 res.setHeader('Cache-Control', isPartial ? 'no-store' : 'no-cache');
[d5e78f7]137
[834bcc3]138 // Does this (non-god) user own a site? Determines whether they see an "Admin"
139 // entry (artist self-manage). god always sees admin (by role).
[1ee967d]140 let _u = req.session?.user || null;
[834bcc3]141 // Refresh avatar + role from the DB so a stale session (e.g. after an
142 // avatar change or role switch) heals itself without a new login.
[1ee967d]143 if (_u && _u.id) {
[cca2e89]144 const _fresh = db.prepare('SELECT role, lang FROM users WHERE id = ?').get(_u.id);
145 if (_fresh) _u = { ..._u, role: _fresh.role, lang: _fresh.lang };
146 // ONE image: a user's avatar everywhere (nav, account, comments) is simply their SITE
147 // photo — there is no separate account avatar. Falls back to the initial-letter
148 // placeholder when the site has no photo yet.
149 const _sp = db.prepare("SELECT profile_photo FROM sites WHERE owner_id = ? AND profile_photo IS NOT NULL ORDER BY is_primary DESC, created_at ASC LIMIT 1").get(_u.id);
150 _u = { ..._u, avatar_url: (_sp && _sp.profile_photo) || null };
[1ee967d]151 }
[8cb1dc7]152 const userOwnsSite = !!(_u && _u.role !== 'god' &&
153 db.prepare('SELECT 1 FROM sites WHERE owner_id = ? LIMIT 1').get(_u.id));
154
[ab544fd]155 const _site = data.site || res.locals.site || null;
[cca2e89]156 // The site header uses the SITE photo (site.profile_photo) — the one and only image,
157 // set in site settings. (No separate account-avatar fallback anymore.)
158 const siteOwnerAvatar = null;
[ab544fd]159
[834bcc3]160 // Viewer mode: may view everything, change nothing. Views use canMutate
161 // to hide/disable write buttons (post, save, delete).
[8afbdd6]162 const _isViewer = isViewer(_u);
163
[07de464]164 // Embeds are framed broadly (frame-src https: globally), EXCEPT on authorize_interaction:
165 // that page renders untrusted remote content next to the interact buttons, so lock its
166 // frame-src down to 'self' (no embeds → no clickjacking/overlay over the buttons).
167 if (viewName === 'pages/authorize-interaction') {
168 try {
169 const csp = res.getHeader('Content-Security-Policy');
170 if (csp) res.setHeader('Content-Security-Policy', String(csp).replace(/frame-src [^;]*/i, "frame-src 'self'"));
171 } catch { /* best-effort */ }
172 }
[5421ce1]173
[834bcc3]174 // Who sees the "Admin" link? god/admin, a site owner (artist self-manage),
175 // and a viewer (may view Admin read-only). One source of truth,
176 // mirrored in topnav/hub-nav/profile sheet — otherwise the link gets hidden
177 // for those who should see it (viewer didn't see it anywhere before).
[a3169f5]178 const _role = _u ? _u.role : null;
179 const canSeeBeheer = !!(_u && (_role === 'god' || _role === 'admin' || _role === 'kijker' || userOwnsSite));
[f5c3870]180 // Who may use the fediverse client (timeline/notifications/blocking) — actual
181 // site managers only (these routes are requireSiteManager; viewers are excluded).
182 const canManageFedi = !!(_u && (_role === 'god' || _role === 'admin' || userOwnsSite));
[a3169f5]183
[834bcc3]184 // Interface language: session choice (this session) → logged-in user's own preference
185 // (users.lang) → admin-set default (Admin → Settings) → env → browser → nl.
[5e61b17]186 const _lang = resolveLang(req, {
187 userLang: _u && _u.lang,
188 defaultLang: getSetting('default_lang'),
189 });
[03fa548]190
[495b019]191 // Lay-out (experimental/theme): wie de site beheert, mag met ?layout= een
192 // ander thema voorproeven; een bezoeker kiest niets.
193 const _canManageSite = !!(_u && (_role === 'god' || _role === 'admin' || userOwnsSite));
194 const _isAdminPage = String(viewName || '').startsWith('pages/admin')
195 || String(data.bodyClass || '').split(/\s+/).includes('on-admin');
196 const _preview = typeof req.query.layout === 'string' ? req.query.layout : null;
197 const _layout = ThemeService.resolveLayout(_site, { isAdminPage: _isAdminPage, canManage: _canManageSite, preview: _preview });
198 const _siteLayout = _site && _site.layout ? ThemeService.getLayout(_site.layout) : null;
199 const _previewLayout = (_canManageSite && _preview) ? ThemeService.getLayout(_preview) : null;
200 const _layoutSheets = [...new Set([_siteLayout, _previewLayout].filter(Boolean)
201 .map((m) => ThemeService.layoutStylesheetUrl(m)))];
202
[7bc636b]203 // Common locals
204 const locals = {
[8cb1dc7]205 user: _u,
[03fa548]206 lang: _lang,
207 t: (key, vars) => i18nT(_lang, key, vars),
208 langs: LANGS.map((c) => ({ code: c, name: LANG_NAMES[c], active: c === _lang })),
[421c2d4]209 timezone: getSetting('timezone') || '',
[e951b7c]210 notifUnread: (canManageFedi && _site) ? ActivityPubService.countUnseenNotifications(_site.slug) : 0,
[8cb1dc7]211 userOwnsSite,
[a3169f5]212 canSeeBeheer,
[f5c3870]213 canManageFedi,
[283f618]214 apEnabled: apEnabled(),
[72ec6a4]215 // Cirkel = the artists you feature (auto-boost): shown when AP is on and
216 // you auto-boost at least one account.
[5045c30]217 hasCirkel: !!(_site && apEnabled() && (ActivityPubService.autoBoostCount(_site.slug) > 0 || ActivityPubService.boostedCount(_site.slug) > 0)),
[8afbdd6]218 isViewer: _isViewer,
219 canMutate: !_isViewer,
[1b4d5dd]220 isPremium: isPremiumInstance(),
221 premiumEnabled: premiumEnabled(),
[8aa85d0]222 premiumUnlocked: premiumUnlocked(),
[ab544fd]223 siteOwnerAvatar,
224 site: _site,
[cb01666]225 audioEnabled: audioFeatureEnabled(),
[7bc636b]226 audioTracks: data.audioTracks || res.locals.audioTracks || [],
227 siteUrlBase: res.locals.siteUrlBase || '',
[746d98a]228 // De wardmodus (middleware/ward-profile.js): een bezoeker van een ward-site ziet
229 // alleen het profiel, en de chrome biedt dan niets aan wat toch dicht is.
230 wardProfile: !!res.locals.wardProfile,
[834bcc3]231 footerNewsletter: getSetting('footer_newsletter') === '1', // newsletter sign-up in footer (premium)
232 agendaEnabled: getSetting('agenda_enabled') === '1', // show agenda/events in the pill (premium, opt-in)
[7bc636b]233 platforms_catalog: PLATFORMS_CATALOG,
234 permissions: PermissionsService,
235 formatDate,
236 formatDateTime,
[3597763]237 // Render the Shaer-native bits server-side so the web timeline matches the
238 // apps: FEP-9098 custom emojis in content/names, and the FEP-044f quote.
239 emojiHtml, // (html, emoji_json) → HTML with :shortcode: as <img>
240 emojiName, // (text, emoji_json) → escaped name with :shortcode: as <img>
241 noteQuote: parseQuote, // (quote_json) → the resolved quoted-post object or null
[f79a471]242 // Rewrite a local /media/<file> cover to its on-demand downscaled thumbnail
243 // (crisp grid/list images). External URLs + already-thumb URLs pass through.
[041a0df]244 thumb: (url, w) => {
245 if (!url || typeof url !== 'string') return url;
246 // Local cover → local thumb route; remote (federated) cover → signed downscale
247 // proxy (same as avatars), so remote line-art covers aren't browser-downscaled jagged.
248 if (url.startsWith('/media/') && !url.startsWith('/media/thumb/')) return `/media/thumb/${w || 480}/${url.slice(7)}`;
249 if (/^https?:\/\//i.test(url)) return imgProxyUrl(url, w || 480);
250 return url;
251 },
[74c5abc]252 // Crisp avatars: a local /media avatar goes through the local thumb route; a REMOTE
253 // (fediverse) avatar through the signed downscaling proxy. Same downscale, the remote
254 // one is just fetched first. Default 128px (covers feed 44px → profile ~120px).
255 avatar: (url, w) => {
256 if (!url || typeof url !== 'string') return url;
257 if (url.startsWith('/media/') && !url.startsWith('/media/thumb/')) return `/media/thumb/${w || 128}/${url.slice(7)}`;
258 if (/^https?:\/\//i.test(url)) return imgProxyUrl(url, w || 128);
259 return url;
260 },
[3487567]261 // pageTitleKey (translated with the resolved language) wins over a raw pageTitle string,
262 // so admin page titles aren't hardcoded in one language. Falls back to the site title.
263 pageTitle: (data.pageTitleKey ? i18nT(_lang, data.pageTitleKey, data.pageTitleVars) : data.pageTitle)
264 || (data.site && data.site.title) || 'Klonkt',
[83faa57]265 appVersion: APP_VERSION,
[7bc636b]266 bodyClass: data.bodyClass || 'on-home',
[495b019]267 // De lay-out van deze pagina (experimental/theme). null = de gewone kop.
268 // Beheerpagina's altijd de gewone kop; ?layout= alleen voor wie de site
269 // beheert (zie ThemeService.resolveLayout).
270 layoutTheme: _layout ? { id: _layout.id, name: _layout.name } : null,
271 // De stylesheets die mee moeten: die van de site en, bij een voorproefje,
272 // die van het voorproefje. Ze staan er ook op een pagina die zelf geen
273 // lay-out draagt (beheer): hun regels gelden alleen onder data-layout, en
274 // wie vanuit het beheer naar de site navigeert heeft ze dan al.
275 layoutSheets: _layoutSheets,
[e64a49b]276 // Welke module(s) deze pagina nodig heeft (shaer-bqr). De shell zet ze op
277 // body[data-js]; de bootstrap daar importeert ze uit /assets/js/mod/.
278 // Alleen kleine letters, cijfers, streepjes en spaties -- de naam wordt een
279 // pad.
280 pageJs: /^[a-z0-9 -]*$/.test(String(data.pageJs || '')) ? (data.pageJs || '') : '',
[7bc636b]281 socialDescr: data.socialDescr || '',
282 socialImage: data.socialImage || '',
283 cspNonce: () => '',
284 currentPath: req.path,
[69815b2]285 // Absolute origin (for building absolute URLs like the generated og:image).
286 ogOrigin: (process.env.PUBLIC_BASE_URL || `${req.protocol}://${req.get('host') || ''}`).replace(/\/+$/, ''),
[7bc636b]287 ...data,
288 };
289
290 try {
291 // Step 1: Render the page view to HTML
292 const viewPath = path.join(VIEWS_DIR, viewName + '.ejs');
293 const pageContent = await ejs.renderFile(viewPath, locals, { async: false });
294
295 if (isPartial) {
[42e7616]296 // A "Load more" append (hx-swap=beforeend into a sub-list) is NOT a
297 // navigation: it only adds rows to the existing page. It must NOT touch
298 // the site chrome or the body class. Emitting the nav HX-Trigger + OOB
299 // chrome here (below) rebuilds the header for the DEFAULT bodyClass —
300 // which, on a 'on-special' page like Messages, swaps in the full Klonkt
301 // header that the page had hidden. So for an append, send content only.
302 if (req.query.append === '1') {
303 return res.send(injectCspNonce(pageContent, res.locals.cspNonce));
304 }
[00d54bc]305 // HTMX: just send the content. Set HX-Trigger for body class swap.
306 // HTTP-header values are Latin-1 only — a title with an em-dash, smart
307 // quote or emoji (e.g. "Welkom — gebouwd met Klonkt") would make
308 // setHeader throw ERR_INVALID_CHAR and 500 the partial, so the card
309 // looks "unclickable". Escape any non-ASCII to \uXXXX: the header stays
310 // ASCII-safe and remains valid JSON that htmx parses back unchanged.
[834bcc3]311 // Per-site accent + palette live in the shell <head> (style#pcms-site-accent
312 // + html[data-palette]) and are NOT swapped during htmx navigation. Send them along
313 // so the client updates them — otherwise an artist inherits the previous page's
314 // colours (e.g. hub-purple instead of their own green). Same derivation as shell.ejs.
[a3e2f17]315 const _navAccent = (_site && _site.accent && /^#[0-9a-fA-F]{6}$/.test(_site.accent))
[9b851e7]316 ? _site.accent : '#e8b04b';
[dd7e2a2]317 const _navPalette = (_site && _site.palette) ? _site.palette : 'klonkt';
[1e172f3]318 // Welke modules de nieuwe pagina wil (shaer-bqr). De bootstrap in de shell
319 // zet dit op de body en haalt op wat er nieuw bij staat; 'chrome' hoort er
320 // altijd bij, want die komt bij elke navigatie opnieuw binnen.
321 const _navJs = ('chrome ' + (locals.pageJs || '')).trim();
[00d54bc]322 const triggerJson = JSON.stringify({
[495b019]323 pcmsNav: { bodyClass: locals.bodyClass, accent: _navAccent, palette: _navPalette, js: _navJs, layout: locals.layoutTheme ? locals.layoutTheme.id : 'top' },
[7bc636b]324 pcmsPostSwap: data.post ? {
325 title: data.post.title,
326 slug: data.post.slug,
327 pageTitle: locals.pageTitle,
328 } : null,
[00d54bc]329 }).replace(/[€-￿]/g, (ch) => '\\u' + ch.charCodeAt(0).toString(16).padStart(4, '0'));
330 res.setHeader('HX-Trigger-After-Settle', triggerJson);
[834bcc3]331 // Render the site chrome out-of-band so the header (topnav/profile header/
332 // view-switcher) ALWAYS matches the new page/artist on navigation —
333 // while the audio player (separate in document.body) keeps playing (no
334 // interruption). htmx replaces #pcms-chrome via hx-swap-oob. Non-critical:
335 // if it fails, the old chrome remains (no crash).
[3cd1aaa]336 let oobChrome = '';
337 try {
338 oobChrome = await ejs.renderFile(
339 path.join(VIEWS_DIR, 'partials', 'chrome.ejs'),
340 { ...locals, oob: true },
341 { async: false },
342 );
[834bcc3]343 } catch (e) { /* skip chrome OOB */ }
[73abbfd]344 return res.send(injectCspNonce(pageContent + oobChrome, res.locals.cspNonce));
[7bc636b]345 }
346
[73abbfd]347 // Full: wrap content in shell (rendered to a string so we can inject the CSP nonce).
[7bc636b]348 locals.pageContent = pageContent;
[73abbfd]349 const shellHtml = await ejs.renderFile(path.join(VIEWS_DIR, 'shell.ejs'), locals, { async: false });
350 res.send(injectCspNonce(shellHtml, res.locals.cspNonce));
[7bc636b]351 } catch (err) {
352 console.error('[renderPage] Error rendering', viewName, err);
353 if (process.env.NODE_ENV === 'production') {
354 return res.status(500).send('Internal Server Error');
355 }
356 // Dev: surface the underlying cause prominently. EJS rewrites err.message
357 // to include the file/line/code-context, so we also surface name+stack
358 // separately in case the message was truncated or empty.
359 const escape = (s) => String(s == null ? '' : s)
360 .replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
361 res.status(500).send(`<!doctype html>
362<meta charset="utf-8">
363<title>Render error: ${escape(viewName)}</title>
364<style>
365 body { font: 14px/1.5 ui-monospace, monospace; max-width: 1100px; margin: 2rem auto; padding: 0 1rem; background:#1a1a1a; color:#eee; }
366 h1 { color:#dc2626; font-family: ui-sans-serif, system-ui; }
367 h2 { color:#fb923c; font-size:1rem; margin-top:1.5rem; }
368 pre { background:#0a0a0a; border:1px solid #333; border-radius:6px; padding:1rem; overflow:auto; white-space:pre-wrap; word-break:break-word; }
369 .cause { background:#3d0a0a; border-color:#7a1a1a; color:#fca5a5; font-weight:600; }
370</style>
371<h1>Render error in ${escape(viewName)}</h1>
372<h2>Cause</h2>
373<pre class="cause">${escape(err.name || 'Error')}: ${escape(err.message || '(no message)')}</pre>
374<h2>Stack</h2>
375<pre>${escape(err.stack || '(no stack)')}</pre>
376${err.path ? `<h2>File</h2><pre>${escape(err.path)}</pre>` : ''}
377`);
378 }
379}
Note: See TracBrowser for help on using the repository browser.