| 1 | <%
|
|---|
| 2 | // Square Instagram-style tile for the .feed-grid view (v9 pattern).
|
|---|
| 3 | // - With cover → background-image, dark gradient overlay reveals title on hover/touch
|
|---|
| 4 | // - No cover → .grid-tile-gradient with the title centered (random hue per tile)
|
|---|
| 5 | const _tileHue = ((post.id || post.slug || '0').charCodeAt(0) * 7) % 360;
|
|---|
| 6 | const _isPinned = !!post.pinned;
|
|---|
| 7 | const _isBoost = !!post.isBoost;
|
|---|
| 8 | const _hasCover = !!post.cover_image_url || !!post.cover_video_url;
|
|---|
| 9 | // A C2S post carries its media IN the content (a cover next to it showed the
|
|---|
| 10 | // video twice on the post page). The tile derives its picture from the
|
|---|
| 11 | // content instead, like the Cirkel card: first <video> (with its poster) or
|
|---|
| 12 | // first <img>.
|
|---|
| 13 | let _cVideo = null, _cPoster = null, _cImg = null;
|
|---|
| 14 | if (!_hasCover && post.content) {
|
|---|
| 15 | const vm = String(post.content).match(/<video[^>]*\ssrc="([^"]+)"[^>]*>/i);
|
|---|
| 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]; }
|
|---|
| 18 | }
|
|---|
| 19 | const _showCover = _hasCover || !!_cVideo || !!_cImg;
|
|---|
| 20 | const _typeLabel = (post.type && post.type !== 'post') ? post.type : '';
|
|---|
| 21 | const _src = post.source_name || ''; // bron-site (cirkel-feed: van welke site komt deze post)
|
|---|
| 22 | const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
|
|---|
| 23 | const _external = post.external_url || null;
|
|---|
| 24 | const _href = _external || (_base + '/' + post.slug);
|
|---|
| 25 | const _ext = !!_external;
|
|---|
| 26 | %>
|
|---|
| 27 | <a class="grid-tile<%= _showCover ? '' : ' grid-tile-gradient' %><%= (_isPinned || _isBoost) ? ' is-pinned' : '' %><%= post.nsfw ? ' nsfw-media' : '' %>"
|
|---|
| 28 | href="<%= _href %>"
|
|---|
| 29 | style="--tile-hue: <%= _tileHue %>;"
|
|---|
| 30 | <% 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 |
|
|---|
| 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"><% } %>
|
|---|
| 33 |
|
|---|
| 34 | <% if (_typeLabel) { %>
|
|---|
| 35 | <span class="grid-tile-type"><%= _typeLabel %></span>
|
|---|
| 36 | <% } %>
|
|---|
| 37 | <% if (_isBoost) { %>
|
|---|
| 38 | <span class="grid-tile-pin grid-tile-boost"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m17 2 4 4-4 4"/><path d="M3 11v-1a4 4 0 0 1 4-4h14"/><path d="m7 22-4-4 4-4"/><path d="M21 13v1a4 4 0 0 1-4 4H3"/></svg>Boost</span>
|
|---|
| 39 | <% } else if (_isPinned) { %>
|
|---|
| 40 | <span class="grid-tile-pin"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg>Pinned</span>
|
|---|
| 41 | <% } %>
|
|---|
| 42 |
|
|---|
| 43 | <% if (_hasCover) { %>
|
|---|
| 44 | <div class="grid-tile-overlay">
|
|---|
| 45 | <strong><%= post.title || '(untitled)' %></strong>
|
|---|
| 46 | <% if (_src) { %><span class="grid-tile-overlay-src">van <%= _src %></span><% } %>
|
|---|
| 47 | </div>
|
|---|
| 48 | <% } else { %>
|
|---|
| 49 | <span class="grid-tile-title"><%= post.title || '(untitled)' %></span>
|
|---|
| 50 | <% if (_src) { %><span class="grid-tile-gradient-src">van <%= _src %></span><% } %>
|
|---|
| 51 | <% } %>
|
|---|
| 52 | <% if (post.nsfw) { %><div class="nsfw-veil"><%- include('nsfw-veil', { cw: post.content_warning }) %></div><% } %>
|
|---|
| 53 | </a>
|
|---|