openvibers/openvibe.events Commits

Events' page list names its home and the GitHub guide for what they are (#315)

OP OpenVibers committed 1 days ago · 3b881efa28 · 3 files, +55 −6

The one row was "Guide" pointing at github.com, and the legal pages showed the shared navbar's fallback. The list is now Events (the home) and GitHub (the guide, labelled for where it goes) on the home, the update log, the legal pages and the 404.

Changes

ddiff --git a/server/app.js b/server/app.js
iindex 06f7084..cbf5ae0 100644
---- a/server/app.js
++++ b/server/app.js
@@@ -51,7 +51,14 @@ function createApp({ config, store, auth, keys, worker, realtime, metrics, dnsLo
// Terms, Privacy and DMCA in this site's own words (openvibe-shared/legal, profile 'service'; 11-03: the footer's
// legal links answered 404 here). The facts must match the code: change both together.
const legal = require('openvibe-shared/legal');
-- app.get(legal.PATHS, legal.handler({
++ // Shared's legal template starts the navbar without links, so /terms and /privacy showed its fallback
++ // (Home, My Account, Themes) instead of Events' own pages. Add Events' list to that init call.
++ const navLinks = JSON.stringify(require('./home').NAV_LINKS);
++ 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({
"host": "openvibe.events",
"name": "OpenVibe.Events",
"id": "events",
ddiff --git a/server/home.js b/server/home.js
iindex 8ae0313..560df3f 100644
---- a/server/home.js
++++ b/server/home.js
@@@ -26,6 +26,8 @@ const ovIcons = require('openvibe-shared/ov-icons');
const SITE_NAME = 'OpenVibe.Events';
const NETWORK_URL = 'https://openvibe.network';
const SOURCE = 'https://github.com/OpenVibers/OpenVibe.Events';
++// The site's own places, the same on every page. The guide lives on GitHub, so its row is named for where it goes.
++const NAV_LINKS = [{ label: 'Events', href: '/' }, { label: 'GitHub', href: `${SOURCE}#readme` }];
const DESCRIPTION = 'The OpenVibe network\'s event bus: publish once and every subscriber gets it signed, retried and replayable, '
+ 'by webhook, pull or realtime stream.';
@@@ -457,7 +459,7 @@ const UPDATES_FONT = "<style>:where(body){font-family:var(--ov-font,'Inter',-app
/** /updates: what shipped on this site, the network's shared update log (openvibe-shared/frame updatesBody). */
function renderUpdates({ siteUrl }) {
-- const links = [{ label: 'Guide', href: `${SOURCE}#readme` }];
++ const links = NAV_LINKS;
return shell.page({
name: SITE_NAME, service: 'events', lang: 'en',
title: `What shipped on ${SITE_NAME}`,
@@@ -483,7 +485,7 @@ function renderHome({ siteUrl, apiUrl, stats = null }) {
const nav = {
service: 'events',
apiBase: NETWORK_URL, sessionUrl: '/auth/me', loginUrl: '/auth/login?next={path}', logoutUrl: '/auth/logout?next={url}', silentLogin: '/auth/login?silent=1&next={url}',
-- links: [{ label: 'Guide', href: `${SOURCE}#readme` }],
++ links: NAV_LINKS,
history: { type: 'page', title: SITE_NAME },
};
const footer = FOOTER;
@@@ -507,7 +509,7 @@ function renderHome({ siteUrl, apiUrl, stats = null }) {
// The publisher the site's own WebSite node names by @id, so the reference resolves on the page.
seo.jsonLd.organization(),
]),
-- navbar: nav, footer, home: '/', navLinks: [{ label: 'Guide', href: `${SOURCE}#readme` }],
++ navbar: nav, footer, home: '/', navLinks: NAV_LINKS,
head: [
appIcon.headTags({ site: 'events' }),
`<link rel="stylesheet" href="${ovServe.url('kit.css')}"><script src="${ovServe.url('kit-web.js')}" defer></script>`,
@@@ -527,7 +529,7 @@ ${sections({ apiUrl, stats })}
*/
function renderNotFound({ siteUrl = 'https://openvibe.events' } = {}) {
const host = String(siteUrl).replace(/^https?:\/\//, '').replace(/\/.*$/, '');
-- const links = [{ label: 'Guide', href: `${SOURCE}#readme` }];
++ const links = NAV_LINKS;
return shell.page({
name: SITE_NAME, service: 'events', lang: 'en',
title: `Page not found · ${SITE_NAME}`,
@@@ -553,4 +555,4 @@ ${kit.pageHead({ title: `Page not found`, icon: 'live', back: { href: '/', label
});
}
--module.exports = { renderHome, renderUpdates, renderNotFound, HOME_CSP, DESCRIPTION, sections };
++module.exports = { renderHome, renderUpdates, renderNotFound, HOME_CSP, DESCRIPTION, sections, NAV_LINKS };
ddiff --git a/test/page-links.test.js b/test/page-links.test.js
nnew file mode 100644
iindex 0000000..1d31a26
---- /dev/null
++++ b/test/page-links.test.js
@@@ -0,0 +1,40 @@
++'use strict';
++// Every page of openvibe.events gives the shared navbar the site's own page list (the owner, 2026-11-12): the home,
++// /updates, /terms, /privacy and /dmca all send Events / GitHub, and the GitHub row is named for where it goes.
++const assert = require('assert');
++const { boot, suite } = require('./helpers');
++const { NAV_LINKS } = require('../server/home');
++
++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;
++}
++
++const t = suite('page-links');
++
++t('every page sends Events\' own list, and every row is labelled for where it goes', async () => {
++ const h = await boot();
++ try {
++ const own = NAV_LINKS.map(({ label, href }) => ({ label, href }));
++ assert.strictEqual(own[0].label, 'Events', 'the home row carries the site name');
++ for (const path of ['/', '/updates', '/terms', '/privacy', '/dmca']) {
++ const r = await fetch(h.base + path);
++ assert.strictEqual(r.status, 200, `${path} answered ${r.status}`);
++ const links = (initLinks(await r.text()) || []).map(({ label, href }) => ({ label, href }));
++ assert.deepStrictEqual(links, own, `${path} sends Events' list`);
++ }
++ assert.ok(/GitHub/.test(own[1].label) && own[1].href.startsWith('https://github.com/'), 'the off-site guide is named GitHub');
++ } finally { await h.stop(); }
++});
++
++t.run();