Changeset 1ecbf71 in Klonkt for src/routes/posts.js
- Timestamp:
- 06/26/2026 02:01:26 PM (2 months ago)
- Branches:
- main
- Children:
- 297c77d
- Parents:
- 5e3be97
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
r5e3be97 r1ecbf71 580 580 581 581 // ==================== FEDIVERSE CLIENT: home timeline + following ==================== 582 // Build a direct embed iframe for the first embeddable link (YouTube/Spotify/ 583 // SoundCloud/Vimeo) in a remote post's content, so others' media plays inline. 584 function timelineEmbedHtml(html) { 585 if (!html) return null; 586 const re = /href=["']([^"']+)["']/gi; let m; const seen = new Set(); 587 while ((m = re.exec(html))) { 588 const u = m[1]; if (seen.has(u)) continue; seen.add(u); 589 let p; try { p = AudioEmbedService.detectProvider(u); } catch { p = null; } 590 if (!p) continue; 591 if (p.provider === 'youtube') return `<iframe class="tl-embed-frame" src="https://www.youtube-nocookie.com/embed/${p.id}" title="YouTube" loading="lazy" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`; 592 if (p.provider === 'spotify') return `<iframe class="tl-embed-frame tl-embed-spotify" src="https://open.spotify.com/embed/${p.type}/${p.id}" title="Spotify" loading="lazy" frameborder="0" allow="encrypted-media"></iframe>`; 593 if (p.provider === 'soundcloud') return `<iframe class="tl-embed-frame tl-embed-sc" src="https://w.soundcloud.com/player/?url=${encodeURIComponent(p.url)}&color=%23ff5500&visual=false" title="SoundCloud" loading="lazy" frameborder="0" allow="autoplay" scrolling="no"></iframe>`; 594 if (p.provider === 'vimeo') return `<iframe class="tl-embed-frame" src="https://player.vimeo.com/video/${p.id}" title="Vimeo" loading="lazy" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>`; 595 } 596 return null; 597 } 598 582 599 router.get('/tijdlijn', requireSiteManager, (req, res) => { 583 600 const site = res.locals.site; 584 const timeline = site ? ActivityPubService.getTimeline(site.slug, 60) : []; 601 const timeline = (site ? ActivityPubService.getTimeline(site.slug, 60) : []) 602 .map((p) => ({ ...p, embedHtml: timelineEmbedHtml(p.content) })); 585 603 renderPage(req, res, 'pages/timeline', { 586 604 pageTitle: 'Tijdlijn', bodyClass: 'on-special',
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)