Changeset d9ad6c5 in Klonkt for src/views/partials/tl-item.ejs
- Timestamp:
- 07/28/2026 06:17:36 PM (6 weeks ago)
- Branches:
- main
- Children:
- a7bcf66
- Parents:
- 2708282
- File:
-
- 1 edited
-
src/views/partials/tl-item.ejs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/views/partials/tl-item.ejs
r2708282 rd9ad6c5 10 10 </div> 11 11 12 <% 13 var media = []; try { media = JSON.parse(p.media_json || '[]'); } catch (e) { media = []; } 14 var imgs = media.filter(function(m){ return m && m.url && (!m.type || /^image\//.test(m.type)); }); 15 var vids = media.filter(function(m){ return m && m.url && m.type && /^video\//.test(m.type); }); 16 var auds = media.filter(function(m){ return m && m.url && m.type && /^audio\//.test(m.type); }); 17 var _nsfwVisual = !!p.nsfw && (imgs.length || vids.length || auds.length); 18 var _nsfwText = !!p.nsfw && !(imgs.length || vids.length || auds.length); 19 %> 20 <% if (_nsfwText) { %> 21 <div class="tl-content nsfw-media"><span class="nsfw-veil"><%- include('../partials/nsfw-veil', { cw: p.cw }) %></span><%- emojiHtml(p.content, p.emoji_json) %></div> 22 <% } else { %> 23 <div class="tl-content"><%- emojiHtml(p.content, p.emoji_json) %></div> 24 <% } %> 25 <% 26 // One card for both: a fediverse quote and an external embed look 27 // identical; only where they came from differs. An embed carries a 28 // title and a thumbnail, never an iframe. 29 var _quote = noteQuote(p.quote_json); 30 if (!_quote) { 31 var _emb = noteQuote(p.embed_json); 32 // The title comes from a third-party oEmbed provider, so it is 33 // escaped here: the quote card renders `content` as HTML (fine for 34 // AP content, which we sanitise on the way in, but not for this). 35 if (_emb) _quote = { url: _emb.url, author: _emb.author || (_emb.provider ? { name: _emb.provider } : null), 36 content: _emb.title ? ('<p>' + emojiName(_emb.title, null) + '</p>') : '', media: _emb.media || [] }; 37 } 38 %> 39 <% if (_quote) { %><%- include('../partials/quote-card', { q: _quote }) %><% } %> 40 <% if (_nsfwVisual) { %><div class="nsfw-media"><% } %> 41 <% if (imgs.length) { %> 42 <div class="tl-media"> 43 <% imgs.forEach(function(m){ %> 44 <a class="tl-media-img" href="<%= m.url %>" target="_blank" rel="noopener"><img src="<%= thumb(m.url, 1280) %>" alt="" loading="lazy" decoding="async"></a> 45 <% }); %> 46 </div> 47 <% } %> 48 <% vids.forEach(function(m){ %><video class="tl-media-video" src="<%= m.url %>" poster="<%= thumb(m.url, 1280) %>" controls preload="metadata" playsinline></video><% }); %> 49 <% /* A Klonkt audio post carries an embed player (embedHtml/embedUrl) that already 50 covers these tracks, so don't ALSO render the raw Audio attachments as bare 51 players here. Posts without a Klonkt embed (e.g. a plain remote audio) keep them. */ %> 52 <% if (!p.embedHtml && !p.embedUrl) { auds.forEach(function(m){ %><audio class="tl-media-audio" src="<%= m.url %>" controls preload="none"></audio><% }); } %> 53 <% if (_nsfwVisual) { %><div class="nsfw-veil"><%- include('../partials/nsfw-veil', { cw: p.cw }) %></div></div><% } %> 12 <% /* Content, quote/preview card and media: shared with Berichten and the 13 Guardian PWA so a post looks the same wherever it turns up. 14 suppressAudio: a Klonkt audio post carries an embed player below 15 that already covers these tracks, so don't ALSO render the raw 16 Audio attachments as bare players. */ %> 17 <%- include('../partials/note-body', { nb: Object.assign({}, p, { suppressAudio: !!(p.embedHtml || p.embedUrl) }) }) %> 54 18 55 19 <% if (p.embedHtml) { %><div class="tl-embed"><%- p.embedHtml %></div><% } %>
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)