Changeset 837fc9c in Klonkt for src/views


Ignore:
Timestamp:
06/27/2026 07:51:44 AM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
92f6976
Parents:
aa45208
Message:

feat(posts): NSFW / sensitive content

Mark a post NSFW (checkbox in the editor, available to all). On-site the cover blurs in
feed/grid and the whole post blurs behind a 'Gevoelige inhoud' banner until clicked. In the
fediverse the Note gets sensitive:true + a content-warning summary (Mastodon CW). i18n NL/EN/DE.

Location:
src/views
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/post-edit.ejs

    raa45208 r837fc9c  
    237237          <input type="checkbox" name="noindex" value="1" <%= post.noindex ? 'checked' : '' %>>
    238238          <span>🚫 <%= t('pedit.noindex_label') %></span>
     239        </label>
     240        <label class="pe-checkbox">
     241          <input type="checkbox" name="nsfw" value="1" <%= post.nsfw ? 'checked' : '' %>>
     242          <span>🔞 <%= t('pedit.nsfw_label') %></span>
    239243        </label>
    240244        <% if (typeof premiumUnlocked === 'undefined' || premiumUnlocked) { %>
  • src/views/pages/post.ejs

    raa45208 r837fc9c  
    55const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
    66%>
    7 <article class="container post-page">
     7<article class="container post-page<%= post.nsfw ? ' nsfw-gate' : '' %>">
    88
    99  <%# Navigation across ALL posts — ABOVE the post (shared partial). %>
    1010  <%- include('../partials/post-nav', { newerPost: newerPost, olderPost: olderPost }) %>
     11
     12  <% if (post.nsfw) { %>
     13    <div class="nsfw-banner">
     14      <span class="nsfw-banner-icon">🔞</span>
     15      <span class="nsfw-banner-text"><%= t('post.nsfw_warning') %></span>
     16      <button type="button" class="nsfw-banner-btn nsfw-reveal"><%= t('post.nsfw_show') %></button>
     17    </div>
     18  <% } %>
    1119
    1220  <% if (post.cover_image_url) { %>
  • src/views/partials/post-card.ejs

    raa45208 r837fc9c  
    4646
    4747  <% if (_hasCover) { %>
    48     <a class="post-list-cover" href="<%= _href %>"
     48    <a class="post-list-cover<%= post.nsfw ? ' nsfw-media' : '' %>" href="<%= _href %>"
    4949       <% 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"<% } %>
    5050       aria-label="<%= post.title || '(zonder titel)' %>" tabindex="-1">
    5151      <img src="<%= post.cover_image_url %>" alt="" loading="lazy" decoding="async">
     52      <% if (post.nsfw) { %><span class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></span><% } %>
    5253    </a>
    5354  <% } %>
  • src/views/partials/post-tile.ejs

    raa45208 r837fc9c  
    1414const _ext = !!_external;
    1515%>
    16 <a class="grid-tile<%= _hasCover ? '' : ' grid-tile-gradient' %><%= (_isPinned || _isBoost) ? ' is-pinned' : '' %>"
     16<a class="grid-tile<%= _hasCover ? '' : ' grid-tile-gradient' %><%= (_isPinned || _isBoost) ? ' is-pinned' : '' %><%= post.nsfw ? ' nsfw-media' : '' %>"
    1717   href="<%= _href %>"
    1818   <% if (_hasCover) { %>style="background-image: url('<%= post.cover_image_url %>'); --tile-hue: <%= _tileHue %>;"<% } else { %>style="--tile-hue: <%= _tileHue %>;"<% } %>
     
    3737    <% if (_src) { %><span class="grid-tile-gradient-src">van <%= _src %></span><% } %>
    3838  <% } %>
     39  <% if (post.nsfw) { %><div class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></div><% } %>
    3940</a>
  • src/views/shell.ejs

    raa45208 r837fc9c  
    198198
    199199<!-- v9 stylesheet (full palette system) -->
    200 <link rel="stylesheet" href="/assets/css/style.css?v=55">
     200<link rel="stylesheet" href="/assets/css/style.css?v=56">
    201201<script>
    202202/* iOS safe-area, built by hand. env(safe-area-inset-top) resolves to 0 on this iOS in
     
    725725</script>
    726726
     727<!-- NSFW / sensitive content: click a veil/reveal to un-blur. Capture-phase so the
     728     click reveals instead of following the card link or firing htmx navigation. -->
     729<script>
     730(function () {
     731  if (window.__nsfwWired) return; window.__nsfwWired = true;
     732  document.addEventListener('click', function (e) {
     733    var hit = e.target.closest && e.target.closest('.nsfw-veil, .nsfw-reveal');
     734    if (!hit) return;
     735    e.preventDefault(); e.stopPropagation();
     736    var box = hit.closest('.nsfw-media, .nsfw-gate');
     737    if (box) box.classList.add('is-shown');
     738  }, true);
     739})();
     740</script>
     741
    727742<!-- Per-site custom footer HTML -->
    728743<% if (safeSite.custom_foot_html) { %>
Note: See TracChangeset for help on using the changeset viewer.