summaryrefslogtreecommitdiff
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
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>
-rw-r--r--.gitignore3
-rw-r--r--public/index.html8
-rw-r--r--public/js/app.js2
-rw-r--r--server.js8
4 files changed, 15 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index e983519..5426b30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,6 @@ deploy/deploy.env
# Unused, and its source isn't recorded.
public/assets/sky/night-sky-4k.jpg
+
+# Local preview settings for Claude Code.
+.claude/
diff --git a/public/index.html b/public/index.html
index a5495c6..f42932e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -129,9 +129,9 @@
</pre>
<section id="rooms-view">
- <p class="heading">Open rooms</p>
+ <p class="heading">Open rooms:</p>
<ul id="room-list" class="rooms"></ul>
- <p id="no-rooms" hidden>No one's in a room right now.</p>
+ <p id="no-rooms" hidden>No active rooms right now.</p>
<p id="rooms-error" class="error" role="alert" hidden></p>
<button id="start-btn" class="primary" type="button">Start a room</button>
</section>
@@ -149,10 +149,10 @@
<div class="modes">
<label class="choice"><input type="radio" name="mode" value="open" aria-label="Open room">
<svg viewBox="0 0 48 32" aria-hidden="true"><circle cx="16" cy="9" r="5"/><path d="M6 29c0-6 4.5-10 10-10s10 4 10 10"/><circle cx="33" cy="10" r="4.5"/><path d="M28 19.5c1.5-.7 3.2-1 5-1 5.5 0 9 3.8 9 10.5"/></svg>
- <b>Open room</b><span>Listed here so anyone can join. Add a password to keep it to people you tell.</span></label>
+ <b>Open room</b><span>Listed publicly so anyone can join. Add a password for more privacy.</span></label>
<label class="choice"><input type="radio" name="mode" value="solo" aria-label="Just me">
<svg viewBox="0 0 48 32" aria-hidden="true"><circle cx="24" cy="9" r="5"/><path d="M14 29c0-6 4.5-10 10-10s10 4 10 10"/></svg>
- <b>Just me</b><span>Runs on this device only. Nothing is listed or shared.</span></label>
+ <b>Just me</b><span>Runs on your local device only. Nothing is listed or shared.</span></label>
</div>
</fieldset>
diff --git a/public/js/app.js b/public/js/app.js
index 586cfa3..a3151dc 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -626,8 +626,6 @@
showError($('rooms-error'), "Can't reach the server.");
return;
}
- document.title = site.name;
- $('site-name').textContent = site.name;
buildWorldChoices();
updateFields();
await refreshRooms();
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 }));