summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorskylar <me@casper>2026-11-01 06:14:46 -0800
committerskylar <me@casper>2026-11-01 06:14:46 -0800
commit1816bf28453a873e1191f2a6a92844c47c20b189 (patch)
tree8ae00dbb627d9823b35ce60ed1c6506791d1ddbc /server.js
parente69ad01e700e80fa959dfee08cd556ca0d777ffd (diff)
Write the site name into the page on the serverHEADmain
The lobby showed the default name and then swapped in SITE_NAME once /api/site answered. The server now puts the name in index.html before sending it. Also rewords a few lobby lines and ignores the local .claude/ preview settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'server.js')
-rw-r--r--server.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/server.js b/server.js
index 0dc3f9a..b1e93bc 100644
--- a/server.js
+++ b/server.js
@@ -265,6 +265,14 @@ api.post('/rooms/:id/check', (req, res) => {
app.use('/api', api);
const publicDir = path.join(__dirname, 'public');
+
+// The page with the site's name already in it, so it never shows the default first.
+const escapeHtml = (text) => text.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
+const indexHtml = require('fs').readFileSync(path.join(publicDir, 'index.html'), 'utf8')
+ .replace('<title>Yesod</title>', `<title>${escapeHtml(SITE_NAME)}</title>`)
+ .replace('<b id="site-name">Yesod</b>', `<b id="site-name">${escapeHtml(SITE_NAME)}</b>`);
+app.get(['/', '/index.html'], (req, res) => res.set('Cache-Control', 'no-cache').type('html').send(indexHtml));
+
app.use('/assets', express.static(path.join(publicDir, 'assets'), { maxAge: '7d' }));
app.use('/vendor', express.static(path.join(publicDir, 'vendor'), { maxAge: '30d', immutable: true }));
app.use(express.static(publicDir, { maxAge: 0 }));