openvibers/openvibe.media Commits

Share the content-hashed Media card (#312)

OP OpenVibers committed 8 days ago · f60b546aaf · 2 files, +9 −1

Every page now advertises openvibe-shared/social's 1200x630 media card (with its ?v content hash, dimensions and the Twitter mirror) instead of the retired og-image.png. The old file and route stay for links already shared.

Changes

ddiff --git a/server/public/page-frame.js b/server/public/page-frame.js
iindex de38138..eccf7fd 100644
---- a/server/public/page-frame.js
++++ b/server/public/page-frame.js
@@@ -15,11 +15,13 @@ const config = require('../config');
const ovServe = require('openvibe-shared/serve');
const shell = require('openvibe-shared/shell');
const seoLib = require('openvibe-shared/seo');
++const social = require('openvibe-shared/social');
const appIcon = require('openvibe-shared/app-icon');
const NETWORK_URL = (config.network && config.network.url) || 'https://openvibe.network';
const SITE_NAME = 'OpenVibe.Media';
--const DEFAULT_OG_IMAGE = `${config.publicUrl}/og-image.png`;
++// The site's content-hashed share card (openvibe-shared/social), served from this site's own /shared copy.
++const DEFAULT_OG_IMAGE = `${config.publicUrl}${social.url('media')}`;
// Public base URL per app for canonical / "source" links (env-overridable JSON map).
const APP_PUBLIC_URLS = (() => {
ddiff --git a/test/public-pages.test.js b/test/public-pages.test.js
iindex 719c00e..4305b64 100644
---- a/test/public-pages.test.js
++++ b/test/public-pages.test.js
@@@ -169,6 +169,12 @@ const http = require('http');
assert.deepStrictEqual([r.status, r.headers.location], [301, 'https://openvibe.community/p/slug1'], 'the paste page is a redirect, no row needed');
r = await get('/', nav);
assert.strictEqual(r.status, 200);
++ const shareImage = /<meta property="og:image" content="([^"]+)">/.exec(r.body)?.[1] || '';
++ assert.match(shareImage, /^https:\/\/media\.test\/shared\/social\/media\.jpg\?v=[0-9a-f]{12}$/);
++ assert.ok(r.body.includes('<meta property="og:image:width" content="1200">'));
++ assert.ok(r.body.includes('<meta property="og:image:height" content="630">'));
++ assert.ok(r.body.includes('<meta name="twitter:card" content="summary_large_image">'));
++ assert.ok(r.body.includes(`<meta name="twitter:image" content="${shareImage}">`));
const ld = [...r.body.matchAll(/<script type="application\/ld\+json">([\s\S]*?)<\/script>/g)].flatMap((m) => JSON.parse(m[1])['@graph'] || []);
assert.ok(ld.some((x) => x['@type'] === 'WebSite'), 'the index names the site');
const org = ld.find((x) => x['@type'] === 'Organization');