Changeset 515cf1a in Klonkt


Ignore:
Timestamp:
06/28/2026 10:39:11 AM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
73cffc3
Parents:
0596945
Message:

fix(nsfw): warn on cover-less NSFW posts everywhere (related, list, news)

A sensitive post with no cover image showed no warning in the related-posts grid, the list
view, or the News feed (text-only). Now they all get the click-to-reveal veil over a
placeholder (cards) or over the content (text-only News post), matching the grid tile.

  • views/pages/post.ejs — veil on the empty related-cover placeholder
  • views/partials/post-card.ejs — placeholder cover + veil when nsfw and no cover
  • views/pages/news.ejs — blur the content for a text-only sensitive post
Location:
src/views
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/news.ejs

    r0596945 r515cf1a  
    101101          </div>
    102102
    103           <div class="tl-content"><%- p.content %></div>
    104 
    105103          <%
    106104            var media = []; try { media = JSON.parse(p.media_json || '[]'); } catch (e) { media = []; }
     
    109107            var auds = media.filter(function(m){ return m && m.url && m.type && /^audio\//.test(m.type); });
    110108            var _nsfwVisual = !!p.nsfw && (imgs.length || vids.length || auds.length);
     109            var _nsfwText = !!p.nsfw && !(imgs.length || vids.length || auds.length);
    111110          %>
     111          <% if (_nsfwText) { %>
     112            <div class="tl-content nsfw-media"><span class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= p.cw || t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></span><%- p.content %></div>
     113          <% } else { %>
     114            <div class="tl-content"><%- p.content %></div>
     115          <% } %>
    112116          <% if (_nsfwVisual) { %><div class="nsfw-media"><% } %>
    113117          <% if (imgs.length) { %>
  • src/views/pages/post.ejs

    r0596945 r515cf1a  
    181181                      aria-hidden="true"><% if (rp.nsfw) { %><span class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= rp.content_warning || t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></span><% } %></span>
    182182              <% } else { %>
    183                 <span class="post-related-cover post-related-cover--empty" aria-hidden="true"></span>
     183                <span class="post-related-cover post-related-cover--empty<%= rp.nsfw ? ' nsfw-media' : '' %>" aria-hidden="true"><% if (rp.nsfw) { %><span class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= rp.content_warning || t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></span><% } %></span>
    184184              <% } %>
    185185              <span class="post-related-meta">
  • src/views/partials/post-card.ejs

    r0596945 r515cf1a  
    4343}
    4444%>
    45 <li class="post-list-item<%= _hasCover ? ' has-cover' : '' %><%= (_isPinned || _isBoost) ? ' is-pinned' : '' %>">
     45<li class="post-list-item<%= (_hasCover || post.nsfw) ? ' has-cover' : '' %><%= (_isPinned || _isBoost) ? ' is-pinned' : '' %>">
    4646
    4747  <% if (_hasCover) { %>
     
    5151      <img src="<%= post.cover_image_url %>" alt="" loading="lazy" decoding="async">
    5252      <% if (post.nsfw) { %><span class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= post.content_warning || t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></span><% } %>
     53    </a>
     54  <% } else if (post.nsfw) { %>
     55    <a class="post-list-cover nsfw-media" href="<%= _href %>"
     56       <% 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"<% } %>
     57       aria-label="<%= post.title || '(zonder titel)' %>" tabindex="-1">
     58      <span class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= post.content_warning || t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></span>
    5359    </a>
    5460  <% } %>
Note: See TracChangeset for help on using the changeset viewer.