openvibers/openvibe.mediahub Commits

Upload watch pages: Ask your agent chip beside Share (#320)

OP OpenVibers committed 6 days ago · 14cfd721ff · 2 files, +7 −2

An uploaded video's page is rendered by upload-routes.js, not the recording page: it gets the same chip, with the upload's title and public watch address.

Changes

ddiff --git a/server/video/upload-routes.js b/server/video/upload-routes.js
iindex d3310f0..d746a53 100644
---- a/server/video/upload-routes.js
++++ b/server/video/upload-routes.js
@@@ -22,7 +22,7 @@
const express = require('express');
const cache = require('openvibe-shared/cache-policy');
const { sameOrigin } = require('../http/principal');
--const { html, raw, notice } = require('../render/html');
++const { html, raw, notice, askAgent } = require('../render/html');
const { UploadError } = require('./uploads');
const REASON_TEXT = {
@@@ -363,7 +363,7 @@ ${what}
${channel ? html`<a class="ovv-avatar" href="/@${channel}" aria-hidden="true" tabindex="-1">${channel.slice(0, 1).toUpperCase()}${/^[A-Za-z0-9_]{1,32}$/.test(channel) ? html`<img src="${ctx.config.networkUrl}/avatar/${channel}" alt="" loading="lazy">` : ''}</a>` : ''}
<div class="ovv-byline-text">${channel ? html`<a class="ovv-channel-name" href="/@${channel}">@${channel}</a>` : ''}
</div>
--<div class="ovv-byline-actions">${saveForm}${raw(shareButton({ cls: 'ovv-btn', url: `${ctx.config.video.url}${watchPath}`, title: row.title, text: about, image: thumb || '', timeFrom: ready && vod ? '.ovv-player' : null }))}</div>
++<div class="ovv-byline-actions">${saveForm}${raw(shareButton({ cls: 'ovv-btn', url: `${ctx.config.video.url}${watchPath}`, title: row.title, text: about, image: thumb || '', timeFrom: ready && vod ? '.ovv-player' : null }))}${raw(askAgent({ text: `About the video “${row.title}” on OpenVibe.Video (${ctx.config.video.url}${watchPath}): ` }))}</div>
</div>
${row.description ? html`<section class="ovv-panel ovv-description"><p>${row.description}</p></section>` : ''}
${aiDone && ai.overview ? html`<section class="ovv-panel" aria-labelledby="h-ai"><h2 id="h-ai">About this video</h2><p>${ai.overview}</p><p class="ovv-fine">Written by AI from the video's sound and pictures (OpenVibe.AI, run on OpenVibe's own servers).</p>
ddiff --git a/test/video-uploads.test.js b/test/video-uploads.test.js
iindex b66b69e..3a535af 100644
---- a/test/video-uploads.test.js
++++ b/test/video-uploads.test.js
@@@ -107,6 +107,11 @@ function vreq(base, path, { method = 'GET', cookie, form, json, body, same = tru
assert.ok(page.text.includes('src="https://openvibe.media/v/vod-1.mp4"') && page.text.includes('data-ovv-hls="https://openvibe.media/o/med_vod1/master.m3u8"'), 'the file, and HLS on the same origin');
assert.ok(page.text.includes('Line one\nLine two'));
assert.ok(page.text.includes('<a class="ovv-channel-name" href="/@kim">@kim</a>'));
++ // The upload's watch page carries the Ask your agent chip beside Share too.
++ const asks = page.text.match(/<button[^>]*data-ov-ask[^>]*>/g) || [];
++ assert.strictEqual(asks.length, 1, 'one Ask your agent chip: ' + asks.join(' | '));
++ assert.match(asks[0], /data-ov-ask="About the video “Trip to the coast” on OpenVibe\.Video \(https:\/\/openvibe\.video\/watch\?v=[A-Za-z0-9_-]+\): "/);
++ assert.ok(asks[0].includes('class="ovk-ask ovk-btn'), 'the shared kit chip');
assert.ok(page.text.includes('Report this video'), 'others may report it');
assert.ok(!page.text.includes('Manage this video'));
const wid = [...t.media.vods.values()][0].watch_id;