openvibers/openvibe.media Commits

Add visit history metadata (#386)

OP OpenVibers committed 3 days ago · 1dd5d8c0e2 · 2 files, +5 −2

* Record video and clip history with the public thumbnail, skipping private and mature pages.

* Keep video history metadata compatible

Changes

ddiff --git a/server/public/pages.js b/server/public/pages.js
iindex 71eac18..c74c053 100644
---- a/server/public/pages.js
++++ b/server/public/pages.js
@@@ -253,7 +253,7 @@ function renderWatchPage(kind, record, readiness = null) {
].filter(([, v]) => v != null),
updated: uploadDate || undefined,
} : undefined,
-- history: { type: isVod ? 'vod' : 'clip', title },
++ history: { type: isVod ? 'vod' : 'clip', title, image_url: thumb || null, private: (record.visibility || (record.is_public ? 'public' : 'private')) === 'private', mature: !!record.mature },
footer: { variant: 'compact' },
// A public or unlisted item has a Markdown twin; a private one is a person's own and has none.
agentLayer: (record.visibility || (record.is_public ? 'public' : 'private')) !== 'private',
ddiff --git a/test/public-pages.test.js b/test/public-pages.test.js
iindex 05c874f..6c45ca3 100644
---- a/test/public-pages.test.js
++++ b/test/public-pages.test.js
@@@ -46,7 +46,10 @@ const http = require('http');
assert.ok(/<script src="[^"]*theme-loader\.js\?v=[0-9a-f]{12}"><\/script>/.test(html), 'theme-loader is eager, before the first paint');
assert.ok(/\/shared\/web-runtime\.js\?v=[0-9a-f]{12}/.test(html), 'the shared web runtime from this site\'s own pinned copy');
assert.ok(/\/shared\/navbar\.js\?v=[0-9a-f]{12}/.test(html) && /\/shared\/footer\.js\?v=[0-9a-f]{12}/.test(html), 'the Frame from this site\'s own pinned copy');
-- assert.ok(html.includes('"service":"media"') && html.includes('"history":{"type":"vod","title":"Late night <build>"}'.replace('<', '\\u003c')));
++ assert.ok(html.includes('"service":"media"'));
++ const historyMeta = JSON.parse(html.match(/"history":(\{[^}]*\})/)[1]);
++ assert.deepStrictEqual([historyMeta.type, historyMeta.title, historyMeta.private, historyMeta.mature], ['vod', 'Late night <build>', false, false]);
++ assert.ok(historyMeta.image_url, 'the history row carries the video thumbnail');
assert.ok(html.includes('data-variant="compact"'), 'the server-rendered footer is compact');
// openvibe-shared/shell v2.10.0 boots the navbar but not the footer; page-frame adds the init so
// the "shipped X ago" line fills and the site's links survive a client render.