openvibers/openvibe.mediahub Commits

Pics: load ov-upload.js from Shared, not as a site file (#409)

OP OpenVibers committed 2 days ago · bdf59e6cd5 · 2 files, +7 −1

The home listed Shared's ov-upload.js among the site's own scripts, so it asked
openvibe.pics/ov-upload.js (404, refused as text/html) and the duplicate check's
hasher never loaded. It is a shared script now, as on Video's upload page.

Changes

ddiff --git a/server/pics/pages.js b/server/pics/pages.js
iindex 68844ac..dfee42e 100644
---- a/server/pics/pages.js
++++ b/server/pics/pages.js
@@@ -282,7 +282,9 @@ ${signedIn(req) ? html`<label>Who can open it <select name="audience">${audience
seo.jsonLd.faq(faq),
],
styles: ['kit.css', 'showcase.css'],
-- scripts: ['js/pics.js', 'js/pics-gallery.js', 'ov-upload.js'],
++ scripts: ['js/pics.js', 'js/pics-gallery.js'],
++ // pics.js's duplicate check hashes with window.OVUpload: Shared's file, served from /shared/, not the site's.
++ sharedScripts: ['ov-upload.js'],
body: html`${raw(showcase.hero({
title: 'Share pictures.', accent: 'Discover something new.',
lede: 'Drop a picture, get a link to share or embed anywhere: on a forum, in a chat, on your site. Browse what people chose to publish, or keep yours unlisted. Location and camera details are removed from every file.',
ddiff --git a/test/pics.test.js b/test/pics.test.js
iindex efad4d6..1054a54 100644
---- a/test/pics.test.js
++++ b/test/pics.test.js
@@@ -82,6 +82,10 @@ function multipart(fields, file) {
const home = (await t.get('/', { headers: PICS })).text;
assert.strictEqual((home.match(/<h1[\s>]/g) || []).length, 1, 'one h1');
assert.match(home, /<title>OpenVibe\.Pics: share and embed pictures with a link<\/title>/);
++ // The duplicate check's hasher is Shared's ov-upload.js, from /shared/; the site never serves its own (a 404
++ // the 11-11 browser sweep found).
++ assert.ok(!/src="[^"]*\/ov-upload\.js\?v=dev"/.test(home) && !home.includes('src="/ov-upload.js'), 'not loaded as a site file');
++ assert.match(home, /<script src="[^"]*\/shared\/[^"]*ov-upload[^"]*\.js[^"]*" defer><\/script>/, 'loaded from Shared');
const sections = ['How it works', 'The links a picture gets', 'Upload from your own app', 'What a free account gets', 'Questions', 'More on OpenVibe'];
// The showcase kit puts every section title in a span inside its heading.
assert.deepStrictEqual(sections.filter((h) => !home.includes(`${h}</span></h2>`)), [], 'every section is there');