openvibers/openvibe.mediahub Commits
Video: the navbar links Videos and Playlists (playlists were only reachable from a watch page) (#55)
Changes
@@@ -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 }));@@@ -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);
@@ -73,10 +73,11 @@ ${render(o.body)}
@@ -73,10 +73,11 @@ ${render(o.body)}
...(o.image ? { image: o.image, imageAlt: title } : {}),
...(o.image ? { image: o.image, imageAlt: title } : {}),
...(o.ogType ? { type: o.ogType } : {}),
...(o.ogType ? { type: o.ogType } : {}),
home: '/',
home: '/',
- navLinks: [],
+ navLinks: NAV_LINKS,
navbar: {
navbar: {
service: 'media-hub',
service: 'media-hub',
apiBase: NETWORK_URL,
apiBase: NETWORK_URL,
+ links: NAV_LINKS.map((l) => ({ ...l, active: l.href === '/' ? o.path === '/' : String(o.path || '').startsWith(l.href) })),
history: { type: 'page', title },
history: { type: 'page', title },
sessionUrl: '/auth/me',
sessionUrl: '/auth/me',
loginUrl: '/auth/login?next={path}',
loginUrl: '/auth/login?next={path}',
@@ -89,6 +90,9 @@ ${render(o.body)}
@@ -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. */
/** Send a video page. Signed-out pages are public; a session cookie makes a page private, no-store. */
function send(res, status, o) {
function send(res, status, o) {
if (!res.get('Cache-Control')) res.set('Cache-Control', o.cache || cache.htmlHeaders({ private: o.private, maxAge: 300 }));
if (!res.get('Cache-Control')) res.set('Cache-Control', o.cache || cache.htmlHeaders({ private: o.private, maxAge: 300 }));
@@ -330,6 +330,12 @@ function countOccurrences(haystack, needle) {
@@ -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');
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 () => {
await check('/updates: the shared update log on the video host, one heading, in the sitemap', async () => {
const r = await getVideo('/updates');
const r = await getVideo('/updates');
assert.strictEqual(r.status, 200);
assert.strictEqual(r.status, 200);