From fd172aa8bf6f1bfd0c09f7a819bf2aeda65a5fbd Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 17 Nov 2026 19:18:40 -0700 Subject: 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/ (and /embed/show//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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6SwkivduFDDkMmnXjZ --- src/features/messages.js | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/features/messages.js') 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/[/play]?t=…, or + // /show//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: '' })), + 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; -- cgit v1.2.3