Changeset 6dd26e5 in Klonkt for src/views/partials/post-card.ejs
- Timestamp:
- 07/30/2026 11:48:53 AM (6 weeks ago)
- Branches:
- main
- Children:
- 1f640ff
- Parents:
- 67f7150
- File:
-
- 1 edited
-
src/views/partials/post-card.ejs (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/views/partials/post-card.ejs
r67f7150 r6dd26e5 19 19 // Content-derived fallback (see post-tile.ejs): a C2S post's media lives in 20 20 // its content, and the card fronts it from there. 21 let _cVideo = null, _cPoster = null, _cImg = null ;21 let _cVideo = null, _cPoster = null, _cImg = null, _cAudio = false, _cWave = null; 22 22 if (!_realCover && post.content) { 23 23 const vm = String(post.content).match(/<video[^>]*\ssrc="([^"]+)"[^>]*>/i); 24 24 if (vm) { _cVideo = vm[1]; const pm = vm[0].match(/poster="([^"]+)"/i); if (pm) _cPoster = pm[1]; } 25 else { const im = String(post.content).match(/<img[^>]*\ssrc="([^"]+)"/i); if (im) _cImg = im[1]; } 26 } 27 const _hasCover = _realCover || !!_cVideo || !!_cImg; 25 else { 26 const im = String(post.content).match(/<img[^>]*\ssrc="([^"]+)"/i); 27 if (im) _cImg = im[1]; 28 else { 29 // An audio post (Robins vraag, 30-7): the upload leg drew a waveform 30 // (data-poster on the tag); the card fronts it like a cover. 31 const am = String(post.content).match(/<audio[^>]*>/i); 32 if (am) { _cAudio = true; const wm = am[0].match(/data-poster="([^"]+)"/i); if (wm) _cWave = wm[1]; } 33 } 34 } 35 } 36 const _hasCover = _realCover || !!_cVideo || !!_cImg || !!_cWave; 37 // A C2S post has no title: fall back to the post's own words, then to a 38 // friendly type label instead of "(zonder titel)". 39 let _title = post.title || ''; 40 if (!_title && post.content) { 41 const _txt = String(post.content).replace(/<[^>]*>/g, ' ').replace(/&[a-zA-Z#0-9]+;/g, ' ').replace(/\s+/g, ' ').trim(); 42 if (_txt) _title = _txt.length > 64 ? _txt.slice(0, 63).replace(/\s+\S*$/, '') + '…' : _txt; 43 } 44 if (!_title) _title = _cAudio ? '♪ audio' : _cVideo ? '▶ video' : '(zonder titel)'; 28 45 const _typeLabel = (post.type && post.type !== 'overig' && post.type !== 'post') ? post.type : ''; 29 46 const _isPinned = !!post.pinned; … … 57 74 <a class="post-list-cover<%= post.nsfw ? ' nsfw-media' : '' %>" href="<%= _href %>" 58 75 <% if (_ext) { %>target="_blank" rel="noopener"<% } else { %>hx-get="<%= _href %>?partial=1" hx-target="#pcms-main" hx-swap="innerHTML" hx-push-url="<%= _href %>" hx-indicator="#pcms-loading"<% } %> 59 aria-label="<%= post.title || '(zonder titel)'%>" tabindex="-1">76 aria-label="<%= _title %>" tabindex="-1"> 60 77 <% if (post.cover_image_url) { %><img src="<%= thumb(post.cover_image_url, 480) %>" 61 78 srcset="<%= thumb(post.cover_image_url, 320) %> 320w, <%= thumb(post.cover_image_url, 640) %> 640w, <%= thumb(post.cover_image_url, 1280) %> 1280w" 62 79 sizes="(min-width: 768px) 120px, 100vw" 63 80 alt="" loading="lazy" decoding="async"<% if (post.cover_video_url) { %> data-ios-mp4="<%= post.cover_video_url %>"<% } %>> 64 <% } else if (post.cover_video_url) { %><video src="<%= post.cover_video_url %>" poster="<%= thumb(post.cover_video_url, 480) %>" autoplay loop muted playsinline></video><% } else if (_cVideo) { %><video src="<%= _cVideo %>"<% if (_cPoster) { %> poster="<%= _cPoster %>"<% } %> autoplay loop muted playsinline preload="metadata"></video><% } else if (_cImg) { %><img src="<%= _cImg %>" alt="" loading="lazy" decoding="async"><% } %>81 <% } else if (post.cover_video_url) { %><video src="<%= post.cover_video_url %>" poster="<%= thumb(post.cover_video_url, 480) %>" autoplay loop muted playsinline></video><% } else if (_cVideo) { %><video src="<%= _cVideo %>"<% if (_cPoster) { %> poster="<%= _cPoster %>"<% } %> autoplay loop muted playsinline preload="metadata"></video><% } else if (_cImg) { %><img src="<%= _cImg %>" alt="" loading="lazy" decoding="async"><% } else if (_cWave) { %><img class="post-cover-wave" src="<%= _cWave %>" alt="" loading="lazy" decoding="async"><% } %> 65 82 <% if (post.nsfw) { %><span class="nsfw-veil"><%- include('nsfw-veil', { cw: post.content_warning }) %></span><% } %> 66 83 </a> … … 68 85 <a class="post-list-cover nsfw-media" href="<%= _href %>" 69 86 <% if (_ext) { %>target="_blank" rel="noopener"<% } else { %>hx-get="<%= _href %>?partial=1" hx-target="#pcms-main" hx-swap="innerHTML" hx-push-url="<%= _href %>" hx-indicator="#pcms-loading"<% } %> 70 aria-label="<%= post.title || '(zonder titel)'%>" tabindex="-1">87 aria-label="<%= _title %>" tabindex="-1"> 71 88 <span class="nsfw-veil"><%- include('nsfw-veil', { cw: post.content_warning }) %></span> 72 89 </a> … … 89 106 <a href="<%= _href %>" 90 107 <% if (_ext) { %>target="_blank" rel="noopener"<% } else { %>hx-get="<%= _href %>?partial=1" hx-target="#pcms-main" hx-swap="innerHTML" hx-push-url="<%= _href %>" hx-indicator="#pcms-loading"<% } %>> 91 <%= post.title || '(zonder titel)'%>108 <%= _title %> 92 109 </a> 93 110 </h3> … … 189 206 } 190 207 208 /* Audio cover (Shaer): white-on-transparent waveform on its own accent 209 gradient, contained so the shape reads at 120px and full-bleed alike. */ 210 /* (see also .grid-tile-wave in style.css for the grid tiles) */ 191 211 /* Pinned indicator */ 192 212 .post-list-item.is-pinned .post-list-title a { … … 233 253 234 254 /* ============================================================ 255 AUDIO COVER (shared) — Shaer audio post (Robins vraag, 30-7): 256 the waveform PNG is white on transparent; give it its own accent 257 gradient and contain it so the shape reads at 120px and full-bleed. 258 ============================================================ */ 259 .post-list-cover .post-cover-wave { 260 width: 100%; height: 100%; 261 object-fit: contain !important; 262 padding: 14% 8%; 263 background-image: linear-gradient(135deg, 264 color-mix(in srgb, var(--accent, #888) 26%, var(--paper-2, var(--paper))) 0%, 265 color-mix(in srgb, var(--accent, #888) 8%, var(--paper-2, var(--paper))) 100%); 266 } 267 268 /* ============================================================ 235 269 PIN + DRAFT INDICATORS (shared) 236 270 ============================================================ */
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)