Changeset 6dd26e5 in Klonkt for src/views/partials
- Timestamp:
- 07/30/2026 11:48:53 AM (6 weeks ago)
- Branches:
- main
- Children:
- 1f640ff
- Parents:
- 67f7150
- Location:
- src/views/partials
- Files:
-
- 2 edited
-
post-card.ejs (modified) (6 diffs)
-
post-tile.ejs (modified) (3 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 ============================================================ */ -
src/views/partials/post-tile.ejs
r67f7150 r6dd26e5 11 11 // content instead, like the Cirkel card: first <video> (with its poster) or 12 12 // first <img>. 13 let _cVideo = null, _cPoster = null, _cImg = null ;13 let _cVideo = null, _cPoster = null, _cImg = null, _cAudio = false, _cWave = null; 14 14 if (!_hasCover && post.content) { 15 15 const vm = String(post.content).match(/<video[^>]*\ssrc="([^"]+)"[^>]*>/i); 16 16 if (vm) { _cVideo = vm[1]; const pm = vm[0].match(/poster="([^"]+)"/i); if (pm) _cPoster = pm[1]; } 17 else { const im = String(post.content).match(/<img[^>]*\ssrc="([^"]+)"/i); if (im) _cImg = im[1]; } 17 else { 18 const im = String(post.content).match(/<img[^>]*\ssrc="([^"]+)"/i); 19 if (im) _cImg = im[1]; 20 else { 21 // An audio post (Robins vraag, 30-7): the waveform the upload leg drew 22 // (data-poster) goes OVER the gradient, so the tile keeps its own hue. 23 const am = String(post.content).match(/<audio[^>]*>/i); 24 if (am) { _cAudio = true; const wm = am[0].match(/data-poster="([^"]+)"/i); if (wm) _cWave = wm[1]; } 25 } 26 } 18 27 } 19 const _showCover = _hasCover || !!_cVideo || !!_cImg; 28 const _showCover = _hasCover || !!_cVideo || !!_cImg; // the wave keeps the gradient 29 // A C2S post has no title: fall back to the post's own words, and for a 30 // media-only post to a friendly type label instead of "(untitled)". A tile 31 // that already shows its picture needs no forced label at all. 32 let _title = post.title || ''; 33 if (!_title && post.content) { 34 const _txt = String(post.content).replace(/<[^>]*>/g, ' ').replace(/&[a-zA-Z#0-9]+;/g, ' ').replace(/\s+/g, ' ').trim(); 35 if (_txt) _title = _txt.length > 64 ? _txt.slice(0, 63).replace(/\s+\S*$/, '') + '…' : _txt; 36 } 37 if (!_title) _title = _cAudio ? '♪ audio' : (_cVideo || _cImg) ? '' : '(untitled)'; 20 38 const _typeLabel = (post.type && post.type !== 'post') ? post.type : ''; 21 39 const _src = post.source_name || ''; // bron-site (cirkel-feed: van welke site komt deze post) … … 30 48 <% 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"<% } %>> 31 49 32 <% if (post.cover_image_url) { %><img class="grid-tile-img" src="<%= thumb(post.cover_image_url, 480) %>" alt="" loading="lazy" decoding="async"<% if (post.cover_video_url) { %> data-ios-mp4="<%= post.cover_video_url %>"<% } %>><% } else if (post.cover_video_url) { %><video class="grid-tile-img" src="<%= post.cover_video_url %>" poster="<%= thumb(post.cover_video_url, 480) %>" autoplay loop muted playsinline></video><% } else if (_cVideo) { %><video class="grid-tile-img" src="<%= _cVideo %>"<% if (_cPoster) { %> poster="<%= _cPoster %>"<% } %> autoplay loop muted playsinline preload="metadata"></video><% } else if (_cImg) { %><img class="grid-tile-img" src="<%= _cImg %>" alt="" loading="lazy" decoding="async"><% } %>50 <% if (post.cover_image_url) { %><img class="grid-tile-img" src="<%= thumb(post.cover_image_url, 480) %>" alt="" loading="lazy" decoding="async"<% if (post.cover_video_url) { %> data-ios-mp4="<%= post.cover_video_url %>"<% } %>><% } else if (post.cover_video_url) { %><video class="grid-tile-img" src="<%= post.cover_video_url %>" poster="<%= thumb(post.cover_video_url, 480) %>" autoplay loop muted playsinline></video><% } else if (_cVideo) { %><video class="grid-tile-img" src="<%= _cVideo %>"<% if (_cPoster) { %> poster="<%= _cPoster %>"<% } %> autoplay loop muted playsinline preload="metadata"></video><% } else if (_cImg) { %><img class="grid-tile-img" src="<%= _cImg %>" alt="" loading="lazy" decoding="async"><% } else if (_cWave) { %><img class="grid-tile-img grid-tile-wave" src="<%= _cWave %>" alt="" loading="lazy" decoding="async"><% } %> 33 51 34 52 <% if (_typeLabel) { %> … … 43 61 <% if (_hasCover) { %> 44 62 <div class="grid-tile-overlay"> 45 <strong><%= post.title || '(untitled)'%></strong>63 <strong><%= _title %></strong> 46 64 <% if (_src) { %><span class="grid-tile-overlay-src">van <%= _src %></span><% } %> 47 65 </div> 48 66 <% } else { %> 49 <span class="grid-tile-title"><%= post.title || '(untitled)'%></span>67 <span class="grid-tile-title"><%= _title %></span> 50 68 <% if (_src) { %><span class="grid-tile-gradient-src">van <%= _src %></span><% } %> 51 69 <% } %>
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)