openvibers/openvibe.space Commits

The forum row is labelled Community, and the legal pages send Space's list (#299)

OP OpenVibers committed 1 days ago · f602cd5fd2 · 3 files, +60 −3

The one off-site row said "The forum" without naming the site that hosts it; it now says Community, as the bar already names its doors. /terms, /privacy and /dmca showed the shared navbar's fallback and now send the same Home / Spaces / Hosting / Community list as every other page.

Changes

ddiff --git a/server/app.js b/server/app.js
iindex 55fb013..bd7ae4a 100644
---- a/server/app.js
++++ b/server/app.js
@@@ -174,7 +174,16 @@ async function createApp(opts = {}) {
// /auth/me is the navbar's who-is-signed-in read on every page, so it is not counted with sign-ins: 60 page views in 15 minutes made a signed-in visitor look signed out.
app.use('/auth/', rateLimit({ windowMs: 15 * 60_000, max: 60, skip: (req) => req.path === '/me', standardHeaders: true, legacyHeaders: false }));
app.use('/auth', createAuthRoutes(config, auth));
-- { const legal = require('openvibe-shared/legal'); app.get(legal.PATHS, legal.handler({ id: 'space', service: 'space', host: 'openvibe.space', name: 'OpenVibe.Space', profile: 'ugc' })); app.get('/tos', (_req, res) => res.redirect(301, '/terms')); }
++ { const legal = require('openvibe-shared/legal');
++ // Shared's legal template starts the navbar without links, so /terms and /privacy showed its fallback
++ // (Home, My Account, Themes) instead of Space's own pages. Add Space's list to that init call.
++ const navLinks = JSON.stringify(require('./render/layout').navbarInit({ active: '' }).links.map(({ label, href }) => ({ label, href })));
++ app.get(legal.PATHS, (req, res, next) => {
++ const send = res.send.bind(res);
++ res.send = (body) => send(String(body).replace('try{OpenVibeNavbar.init({service:', `try{OpenVibeNavbar.init({links:${navLinks},service:`));
++ next();
++ }, legal.handler({ id: 'space', service: 'space', host: 'openvibe.space', name: 'OpenVibe.Space', profile: 'ugc' }));
++ app.get('/tos', (_req, res) => res.redirect(301, '/terms')); }
// /updates: what shipped on OpenVibe.Space, the shared update log every OpenVibe site has (it pointed at the
// community's log, which lists the community's changes, not this site's).
ddiff --git a/server/render/layout.js b/server/render/layout.js
iindex a9f0ea1..cd047e4 100644
---- a/server/render/layout.js
++++ b/server/render/layout.js
@@@ -70,7 +70,7 @@ function navbarInit(opts) {
{ label: 'Home', href: '/', active: opts.active === 'home' },
{ label: 'Spaces', href: '/spaces', active: opts.active === 'spaces' },
{ label: 'Hosting', href: '/dashboard' },
-- { label: 'The forum', href: `${config.communityUrl}/forum` },
++ { label: 'Community', href: `${config.communityUrl}/forum` },
],
menu: { after: [{ label: 'OpenVibe.Network', href: NETWORK_URL, icon: 'fa-globe' }] },
history: { type: opts.historyType || 'page', title: opts.historyTitle || opts.title },
@@@ -169,4 +169,4 @@ document.addEventListener('DOMContentLoaded', function () {
return html;
}
--module.exports = { renderPage, asset, assetVersion, abs, setRelease, escapeHtml, SITE_NAME, DEFAULT_DESCRIPTION, DEFAULT_OG_IMAGE };
++module.exports = { renderPage, asset, assetVersion, abs, setRelease, escapeHtml, SITE_NAME, DEFAULT_DESCRIPTION, DEFAULT_OG_IMAGE, navbarInit };
ddiff --git a/test/page-links.test.js b/test/page-links.test.js
nnew file mode 100644
iindex 0000000..66d5067
---- /dev/null
++++ b/test/page-links.test.js
@@@ -0,0 +1,48 @@
++'use strict';
++// Every page of openvibe.space gives the shared navbar the site's own page list (the owner, 2026-11-12): the forum
++// moved to OpenVibe.Community, so that row is named for where it goes, and the legal pages carry the same list.
++const assert = require('assert');
++const { boot, check, done } = require('./helpers/app');
++const { navbarInit } = require('../server/render/layout');
++
++function initLinks(html) {
++ const at = html.indexOf('OpenVibeNavbar.init');
++ if (at < 0) return null;
++ const start = html.indexOf('links', at);
++ const open = html.indexOf('[', start);
++ let depth = 0, q = null, esc = false;
++ for (let i = open; i < html.length; i += 1) {
++ const c = html[i];
++ if (q) { if (esc) esc = false; else if (c === '\\') esc = true; else if (c === q) q = null; continue; }
++ if (c === '"' || c === "'") { q = c; continue; }
++ if (c === '[') depth += 1; else if (c === ']') { depth -= 1; if (!depth) return JSON.parse(html.slice(open, i + 1)); }
++ }
++ return null;
++}
++
++(async () => {
++ const t = await boot();
++ try {
++ const own = navbarInit({ active: 'home' }).links.map(({ label, href }) => ({ label, href }));
++ await check('every page sends Space\'s own list, and the forum row names Community', async () => {
++ for (const path of ['/', '/spaces', '/dashboard', '/updates', '/terms', '/privacy', '/dmca']) {
++ const r = await t.get(path);
++ assert.ok([200, 301, 302, 303].includes(r.status), `${path} answered ${r.status}`);
++ if (r.status !== 200) continue;
++ const links = (initLinks(r.text) || []).map(({ label, href }) => ({ label, href }));
++ assert.deepStrictEqual(links, own, `${path} sends Space's list`);
++ }
++ const forum = own.find((l) => l.href.includes('openvibe.community'));
++ assert.ok(forum && forum.label === 'Community', 'the off-site forum is labelled with the site that hosts it');
++ });
++ await check('every row is a route or a labelled door', async () => {
++ for (const { href } of own) {
++ if (!href.startsWith('/')) continue;
++ const r = await t.get(href);
++ assert.notStrictEqual(r.status, 404, `${href} is a route`);
++ assert.ok(r.status < 500, `${href} does not fail (${r.status})`);
++ }
++ });
++ } finally { await t.close(); }
++ done();
++})().catch((e) => { console.error(e); process.exit(1); });