openvibers/openvibe.mediahub Commits

Video: the navbar links Videos and Playlists (playlists were only reachable from a watch page) (#55)

OP OpenVibers committed 29 days ago · d1ebcb161f · 2 files, +11 −1

openvibe.video had no navbar links, so "Your playlists" (built: `/playlists`, the API, "Add to playlist" on every watch page) could only be reached from a watch page. The catalog still called playlists "not built yet".

The navbar now has **Videos** (`/`) and **Playlists** (`/playlists`), with the current one marked active, and the no-JS navigation has the same links. `test/video-pages.test.js` checks both.

The catalog line follows in Contracts.

Changes

ddiff --git a/server/video/layout.js b/server/video/layout.js
iindex cf95b32..10a9f62 100644
---- a/server/video/layout.js
++++ b/server/video/layout.js
@@@ -73,10 +73,11 @@ ${render(o.body)}
...(o.image ? { image: o.image, imageAlt: title } : {}),
...(o.ogType ? { type: o.ogType } : {}),
home: '/',
-- navLinks: [],
++ navLinks: NAV_LINKS,
navbar: {
service: 'media-hub',
apiBase: NETWORK_URL,
++ links: NAV_LINKS.map((l) => ({ ...l, active: l.href === '/' ? o.path === '/' : String(o.path || '').startsWith(l.href) })),
history: { type: 'page', title },
sessionUrl: '/auth/me',
loginUrl: '/auth/login?next={path}',
@@@ -89,6 +90,9 @@ ${render(o.body)}
});
}
++// The site's own places in the navbar: the videos, and your playlists (signed in; the page asks you to sign in).
++const NAV_LINKS = [{ label: 'Videos', href: '/' }, { label: 'Playlists', href: '/playlists' }];
++
/** Send a video page. Signed-out pages are public; a session cookie makes a page private, no-store. */
function send(res, status, o) {
if (!res.get('Cache-Control')) res.set('Cache-Control', o.cache || cache.htmlHeaders({ private: o.private, maxAge: 300 }));
ddiff --git a/test/video-pages.test.js b/test/video-pages.test.js
iindex 4cffab6..f9ada5a 100644
---- a/test/video-pages.test.js
++++ b/test/video-pages.test.js
@@@ -330,6 +330,12 @@ function countOccurrences(haystack, needle) {
assert.strictEqual(r.text, 'WEBVTT\n\n00:00:10.000 --> 00:00:30.000\nIntro & setup\n\n00:00:30.000 --> 00:00:45.000\nThe <main> part\n');
});
++ await check('the navbar names the site\'s places: Videos and Playlists, the current one active', async () => {
++ const home = (await getVideo('/')).text;
++ assert.match(home, /"links":\[\{"label":"Videos","href":"\/","active":true\},\{"label":"Playlists","href":"\/playlists","active":false\}\]/);
++ assert.ok(home.includes('href="/playlists"'), 'the no-JS nav links Playlists too');
++ });
++
await check('/updates: the shared update log on the video host, one heading, in the sitemap', async () => {
const r = await getVideo('/updates');
assert.strictEqual(r.status, 200);