aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-17 19:18:40 -0700
committerAdam Soltys <[email protected]>2026-11-17 19:18:40 -0700
commitfd172aa8bf6f1bfd0c09f7a819bf2aeda65a5fbd (patch)
tree965ddf798ed57fd05cdc180086b7789fd9298af2
parent262c2e36096ae0a2c66a620d01ee9132de746670 (diff)
downloadcoinosv3-fd172aa8bf6f1bfd0c09f7a819bf2aeda65a5fbd.tar.gz
coinosv3-fd172aa8bf6f1bfd0c09f7a819bf2aeda65a5fbd.zip
A PAFF film link plays inside the post. "What would it take to embed a PAFF video in a Nostr feed, or to have it play in line like other videos and YouTube videos do?" … "Yes please" (Adam, 2026-11-17). PAFF now serves a bare player at paff.club/embed/movie/<slug> (and /embed/show/<slug>/sNeM), and its query string carries over from the share link (q quality, c copy, t start). A paff.club movie or episode link, with or without /play, shows as a 16:9 box: its backdrop and title from the page's own preview, a play button and a ↗ out to PAFF. The tap swaps in PAFF's player with autoplay, fullscreen and picture-in-picture allowed, and no repaint touches the box after that. It loads only on a tap, never on scroll, because a film starts a torrent swarm in the viewer's browser. link-preview-test (a film link is a player with backdrop and title, no frame until the tap, and the tap loads /embed/movie/1382-hackers-1995?q=1080p&t=4910), compose-preview and features-smoke pass.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6SwkivduFDDkMmnXjZ
-rw-r--r--src/features/messages.js63
-rw-r--r--src/i18n.js1
-rw-r--r--src/style.css7
-rw-r--r--tools/link-preview-test.js22
4 files changed, 90 insertions, 3 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 72707a5..158f0ee 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -7483,6 +7483,7 @@ export function messagesFeature(ctx) {
if (!url) continue;
if ((md && md[1]) || /\.(png|jpe?g|gif|webp|avif)(\?[^\s]*)?$/i.test(url)) urls.push(url);
else if (youtubeId(url)) urls.push('https://i.ytimg.com/vi/' + youtubeId(url) + '/hqdefault.jpg');
+ else if (paffEmbedUrl(url) && previews.get(url)?.image) urls.push(previews.get(url).image);
}
return urls;
}
@@ -9002,6 +9003,60 @@ export function messagesFeature(ctx) {
return frame;
}
+ // A PAFF film or episode link (paff.club/movie/<slug>[/play]?t=…, or
+ // /show/<slug>/s1e2[/play]) plays inside the post, as a YouTube link does:
+ // its backdrop and title (the page's own preview), a play button, and on
+ // the tap PAFF's bare player (/embed/…, the link's query kept: q quality,
+ // c copy, t start) in its place ("What would it take … to have it play in
+ // line like other videos and YouTube videos do?", Adam, 2026-11-17).
+ // Only ever on a tap, never on scroll: a PAFF film starts a torrent swarm
+ // in the viewer's browser.
+ function paffEmbedUrl(url) {
+ let u;
+ try { u = new URL(url); } catch { return null; }
+ if (u.hostname !== 'paff.club' && u.hostname !== 'www.paff.club') return null;
+ const m = u.pathname.match(/^\/(movie\/[^/]+|show\/[^/]+\/s\d+e\d+)(?:\/play)?\/?$/i);
+ return m ? 'https://paff.club/embed/' + m[1] + u.search : null;
+ }
+ function paffEmbed(url, pv) {
+ const embed = paffEmbedUrl(url);
+ const load = (box) => {
+ if (box.dataset.playing) return;
+ box.dataset.playing = '1';
+ // once playing, the box is the viewer's: no repaint rebuilds it (see youtubeEmbed)
+ box._skipMorph = true;
+ box.textContent = '';
+ const f = document.createElement('iframe');
+ f.src = embed;
+ f.title = pv?.title || 'PAFF';
+ f.allow = 'autoplay; fullscreen; picture-in-picture';
+ f.allowFullscreen = true;
+ f.referrerPolicy = 'strict-origin-when-cross-origin';
+ box.append(f);
+ };
+ return h('div', {
+ class: 'yt-embed paff-embed',
+ onClick: (e) => {
+ if (e.target.closest('.yt-open, iframe')) return;
+ e.stopPropagation(); e.preventDefault();
+ load(e.currentTarget);
+ },
+ },
+ pv?.image ? h('img', {
+ class: 'yt-poster', loading: 'lazy', alt: '',
+ src: !feedPaint || feedMedia(pv.image) ? pv.image : undefined,
+ onError: (e) => { e.target.style.display = 'none'; },
+ }) : null,
+ h('button', {
+ class: 'yt-play', type: 'button', 'aria-label': t('playVideo'), title: t('playVideo'),
+ }, h('span', { style: 'display:flex', html: '<svg width="30" height="30" viewBox="0 0 24 24" fill="currentColor" style="display:block"><path d="M8 5v14l11-7z"/></svg>' })),
+ h('div', { class: 'paff-title' }, pv?.title || 'PAFF'),
+ h('a', {
+ class: 'yt-open', href: url, target: '_blank', rel: 'noopener noreferrer',
+ title: t('openOnPaff'), onClick: (e) => e.stopPropagation(),
+ }, '↗'));
+ }
+
// ---- quoted notes ---------------------------------------------------------
// A nostr:note1/nevent1 in someone's post IS a post, so show it: the thing
// they're talking about, inside what they said about it. Fetched once per
@@ -10801,6 +10856,14 @@ export function messagesFeature(ctx) {
});
}
if (youtubeId(url)) return youtubeEmbed(url, youtubeId(url));
+ if (!label && paffEmbedUrl(url)) {
+ let pv = previews.get(url) || null;
+ if (feedPaint) {
+ if (!feedPaint.media.has('pv:' + url)) feedPaint.media.set('pv:' + url, pv);
+ pv = feedPaint.media.get('pv:' + url);
+ }
+ return paffEmbed(url, pv);
+ }
if (!label && previewable(url)) {
// a frozen feed row keeps the card (or the bare link) it first painted
let pv = previews.get(url) || null;
diff --git a/src/i18n.js b/src/i18n.js
index db7d267..d83633f 100644
--- a/src/i18n.js
+++ b/src/i18n.js
@@ -352,6 +352,7 @@ const STR = {
videoLargeHelp: "Videos over {mb} MB or above 1080p wait for a tap, so the feed doesn’t eat your data. The limit is lower on a slow or data-saving connection.",
videoMute: 'Mute',
openInYouTube: 'Open on YouTube',
+ openOnPaff: 'Open on PAFF',
accountsThisOne: 'signed in',
worthThen: 'Worth then',
worthNow: 'Worth now',
diff --git a/src/style.css b/src/style.css
index 4024f3b..38aa2ac 100644
--- a/src/style.css
+++ b/src/style.css
@@ -1152,6 +1152,13 @@ html.no-scroll { overflow: hidden; scrollbar-gutter: auto; }
.yt-embed:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }
.yt-embed:fullscreen .yt-shield { display: none; }
.yt-embed:fullscreen iframe { object-fit: contain; }
+/* a PAFF film: its title along the foot of the backdrop until it plays */
+.paff-title {
+ position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 12px 9px;
+ color: #fff; font-weight: 650; font-size: 14px; pointer-events: none;
+ background: linear-gradient(transparent, rgba(0, 0, 0, .7));
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
+}
/* A link, as the card its page describes: picture on top, title, a line,
the site. The whole card is the link. */
.link-card {
diff --git a/tools/link-preview-test.js b/tools/link-preview-test.js
index bf68bbc..a780c73 100644
--- a/tools/link-preview-test.js
+++ b/tools/link-preview-test.js
@@ -19,6 +19,7 @@ const POSTS = [
finalizeEvent({ kind: 1, created_at: now - 30, tags: [], content: 'Well, yeah https://news.example/story/1' }, AUTHOR),
finalizeEvent({ kind: 1, created_at: now - 60, tags: [], content: 'nothing here https://blank.example/page' }, AUTHOR),
finalizeEvent({ kind: 1, created_at: now - 90, tags: [], content: 'a picture http://localhost:5311/pic.png' }, AUTHOR),
+ finalizeEvent({ kind: 1, created_at: now - 120, tags: [], content: 'film night https://paff.club/movie/1382-hackers-1995/play?q=1080p&t=4910' }, AUTHOR),
];
const PROFILE = finalizeEvent({ kind: 0, created_at: now - 100, tags: [], content: JSON.stringify({ name: 'Linker', picture: 'http://localhost:5311/face.png' }) }, AUTHOR);
@@ -30,7 +31,7 @@ const server = Bun.serve({ port: 5311, fetch: (req) => {
const target = u.searchParams.get('url'); previewHits.push(target);
const meta = target === 'https://news.example/story/1'
? { url: target, title: 'Lawmakers doubt the plan', description: 'A story in one line.', image: 'http://localhost:5311/card.png', site: 'News Example' }
- : target === 'https://movies.example/movie/1382/play?t=4910'
+ : target === 'https://movies.example/movie/1382/play?t=4910' || target.startsWith('https://paff.club/movie/1382')
? { url: target, title: 'Hackers (1995) · from 1:21:50', description: 'Teenage hackers.', image: 'http://localhost:5311/movie.png', site: 'PAFF' }
: {};
return new Response(JSON.stringify(meta), { headers: { 'content-type': 'application/json', 'access-control-allow-origin': '*' } });
@@ -115,10 +116,25 @@ try {
check('...and its picture, already decoded', !!story?.thumb && story.thumbShown, JSON.stringify({ thumb: story?.thumb, shown: story?.thumbShown }));
check('a page with nothing to show stays a bare link', !!blank && blank.bareLink && !blank.card, JSON.stringify(blank));
check('a picture link is still a picture, not a card', !!pic && pic.img && !pic.card, JSON.stringify(pic));
+ // a PAFF film link plays in the post, PAFF's bare player loaded only on a tap
+ const paff = await page.evaluate(() => {
+ const r = [...document.querySelectorAll('.notes-feed > .row')].find((n) => /film night/.test(n.textContent));
+ const b = r && r.querySelector('.paff-embed');
+ return b && { title: b.querySelector('.paff-title')?.textContent, poster: !!b.querySelector('img.yt-poster'), frame: !!b.querySelector('iframe') };
+ });
+ check('a PAFF film link shows as a player with its backdrop and title', !!paff && paff.poster && /Hackers/.test(paff.title || '') && !paff.frame, JSON.stringify(paff));
+ const src = await page.evaluate(() => {
+ const b = [...document.querySelectorAll('.paff-embed')][0];
+ b.querySelector('.yt-play').click();
+ const f = b.querySelector('iframe'), s = f && f.getAttribute('src');
+ if (f) f.src = 'about:blank'; // (the test doesn't stream the film)
+ return s;
+ });
+ check('...and a tap loads PAFF\'s embed player there, the link\'s query kept', src === 'https://paff.club/embed/movie/1382-hackers-1995?q=1080p&t=4910', src);
check('the registrar was asked once per link', previewHits.filter((u) => u === 'https://news.example/story/1').length === 1 && !previewHits.some((u) => u.endsWith('.png')), JSON.stringify(previewHits));
let kept = 0; // written behind, a second after the card was learned
- for (let i = 0; i < 12 && !kept; i++) { kept = await page.evaluate(() => JSON.parse((window.coinosCache || localStorage).getItem('coinos-link-previews') || '[]').length); if (!kept) await sleep(300); }
- check('the card is remembered for next time', kept === 1, kept + ' kept');
+ for (let i = 0; i < 12 && kept < 2; i++) { kept = await page.evaluate(() => JSON.parse((window.coinosCache || localStorage).getItem('coinos-link-previews') || '[]').length); if (kept < 2) await sleep(300); }
+ check('the cards are remembered for next time', kept === 2, kept + ' kept'); // the story's and the film's
// a draft's preview shows the card too (Adam, 2026-11-17: a paff.club
// movie link stayed a bare URL in Preview), once the typing settles
const opened = await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((n) => (n.getAttribute('aria-label') || n.textContent).trim().toLowerCase() === 'new post'); if (b) { b.click(); return true; } return false; });