source: Klonkt/src/views/partials/fedi-node.ejs@ 34e63f0

main
Last change on this file since 34e63f0 was 34e63f0, checked in by roboburr <roboburr@…>, 5 weeks ago

De antwoordpoort ook in Klonkts eigen web-UI (shaer-r4c, vervolg)

De poort weigert nu in deliverReply, dus het antwoord komt er niet doorheen --
maar de webinterface toonde het veld gewoon nog. Precies de knop-die-niet-werkt
waar ik in de app-code tegen waarschuwde: een kind duwt tegen een deur die op
slot zit en krijgt geen uitleg.

res.locals.mayReply staat er nu een keer, naast res.locals.site, zodat geen route
hem apart hoeft door te geven.

NIET IN DE PARTIAL ZELF, en dat scheelde een fout. reply-editor.ejs leek het
knooppunt -- vier includes, een plek -- maar hij wordt ook voor BEWERKEN gebruikt
(msg-edit, /fediverse/:id/edit). Een guard daarbinnen had het bewerken van een
eigen bericht meegesloopt.

Dus per include, en in Berichten precies de tak die de server ook kiest:
/messages/reply gaat naar deliverReply als er een interaction+post is (een
antwoord, valt onder de poort) en anders naar deliverDirectNote (een bericht,
andere poort). Alleen de eerste verdwijnt.

De vier gewijzigde templates compileren; de suite (686) blijft groen.

  • Property mode set to 100644
File size: 7.4 KB
Line 
1<%# Renders one fediverse thread node (n). Expects: n, t, canManageSite, _base, siteAvatar, formatDateTime, postSlug %>
2<div class="comment-avatar">
3 <% if (n.actor_icon) { %><img src="<%= avatar(n.actor_icon, 96) %>" alt="" loading="lazy">
4 <% } else { %><span><%= (n.actor_name || '?').charAt(0).toUpperCase() %></span><% } %>
5</div>
6<div class="comment-body">
7 <div class="comment-meta">
8 <% if (n.actor_url) { %><a class="comment-author" href="<%= n.actor_url %>" rel="nofollow noopener" target="_blank"><%- emojiName(n.actor_name, n.actor_emoji_json) %></a>
9 <% } else { %><span class="comment-author"><%- emojiName(n.actor_name, n.actor_emoji_json) %></span><% } %>
10 <% if (n.actor_handle) { %><span class="fedi-handle"><%= n.actor_handle %></span><% } %>
11 <% if (n.created_at) { %><span class="comment-time"><%= formatDateTime(n.created_at) %></span><% } %>
12 </div>
13 <div class="comment-content"><%- emojiHtml(n.content, n.emoji_json) %></div>
14 <%# Rich replies: media on our own sent replies (attachments on the Note).
15 Visitors see these too, and the reply editor (owner-only) may not render,
16 so make sure the stylesheet is on the page either way. %>
17 <% if (n.media && n.media.length) { %>
18 <% if (!locals.__reAssets) { locals.__reAssets = 1; %><link rel="stylesheet" href="/assets/css/reply-editor.css"><% } %>
19 <div class="re-reply-media">
20 <% n.media.forEach(function (m) { %>
21 <% if ((m.mediaType || '').indexOf('image/') === 0) { %>
22 <a href="<%= m.url %>" target="_blank" rel="noopener"><img src="<%= m.url %>" alt="<%= m.name || '' %>" loading="lazy"></a>
23 <% } else if ((m.mediaType || '').indexOf('audio/') === 0) { %>
24 <audio controls preload="none" src="<%= m.url %>"></audio>
25 <% } else { %>
26 <video controls preload="metadata" src="<%= m.url %>"></video>
27 <% } %>
28 <% }); %>
29 </div>
30 <% } %>
31 <div class="comment-actions">
32 <% if (n.mine && typeof canManageSite !== 'undefined' && canManageSite && n.outboxId) { %>
33 <form method="post" action="<%= _base %>/fediverse/<%= n.outboxId %>/delete" data-confirm="<%= t('fedi.delete_confirm') %>">
34 <button type="submit" class="comment-delete-btn"><%= t('comments.delete') %></button>
35 </form>
36 <% } else if (!n.mine && typeof canManageSite !== 'undefined' && canManageSite && n.id && typeof postSlug !== 'undefined' && postSlug) { %>
37 <%# Owner: like / boost / reply directly AS the site — no "your server" detour (it's your own site). %>
38 <form method="post" action="<%= _base %>/posts/<%= postSlug %>/fedi-react" class="fedi-owner-react">
39 <input type="hidden" name="interaction_id" value="<%= n.id %>">
40 <input type="hidden" name="kind" value="like">
41 <button type="submit" class="fedi-cact fedi-cact-like<%= n.acted_like ? ' is-on' : '' %>" title="<%= n.acted_like ? t('fedi.unlike_short') : t('fedi.like_short') %>" aria-label="<%= n.acted_like ? t('fedi.unlike_short') : t('fedi.like_short') %>"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2.6l2.9 5.88 6.49.95-4.7 4.58 1.11 6.46L12 17.96l-5.8 3.06 1.1-6.46-4.69-4.58 6.49-.95z"/></svg></button>
42 </form>
43 <form method="post" action="<%= _base %>/posts/<%= postSlug %>/fedi-react" class="fedi-owner-react">
44 <input type="hidden" name="interaction_id" value="<%= n.id %>">
45 <input type="hidden" name="kind" value="boost">
46 <button type="submit" class="fedi-cact fedi-cact-boost<%= n.acted_boost ? ' is-on' : '' %>" title="<%= n.acted_boost ? t('tl.unboost') : t('fedi.boost_short') %>" aria-label="<%= n.acted_boost ? t('tl.unboost') : t('fedi.boost_short') %>"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg></button>
47 </form>
48 <% if (locals.mayReply !== false) { %>
49 <details class="fedi-owner-reply">
50 <summary class="fedi-cact fedi-cact-reply" title="<%= t('fedi.remote_reply_short') %>" aria-label="<%= t('fedi.remote_reply_short') %>"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 17 4 12 9 7"/><path d="M20 18v-2a4 4 0 0 0-4-4H4"/></svg></summary>
51 <%- include('reply-editor', {
52 action: _base + '/posts/' + postSlug + '/fedi-reply',
53 hiddenFields: [{ name: 'interaction_id', value: n.id }],
54 placeholder: t('fedi.reply_ph'),
55 submitLabel: t('fedi.send'),
56 rows: 2,
57 participants: n.participants || [],
58 }) %>
59 </details>
60 <% } %>
61 <%# Owner moderation: report to their instance + remove (tombstoned: never comes back via re-delivery or thread-crawl). %>
62 <form method="post" action="<%= _base %>/interactions/<%= n.id %>/report" class="fedi-owner-react" data-confirm="<%= t('fedi.mod_report_confirm') %>">
63 <button type="submit" class="fedi-cact fedi-cact-report" title="<%= t('fedi.report_send') %>" aria-label="<%= t('fedi.report_send') %>"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"/><line x1="4" y1="22" x2="4" y2="15"/></svg></button>
64 </form>
65 <form method="post" action="<%= _base %>/interactions/<%= n.id %>/remove" class="fedi-owner-react" data-confirm="<%= t('fedi.mod_remove_confirm') %>">
66 <button type="submit" class="fedi-cact fedi-cact-remove" title="<%= t('comments.delete') %>" aria-label="<%= t('comments.delete') %>"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg></button>
67 </form>
68 <% } else if (n.noteId) { %>
69 <%# Visitor: reply via YOUR OWN instance. Also on the site's own (mine) comments —
70 those are dereferenceable Notes (/ap/notes/<id>) too; without this a visitor
71 could not reply to the owner's comments at all (only the owner branches above
72 catch mine-nodes for managers, so this else-if never renders for the owner). %>
73 <button type="button" class="comment-reply-btn fedi-remote-reply-btn" data-fedi-uri="<%= n.noteId %>" data-fedi-ph="<%= t('fedi.remote_ph') %>">
74 <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 17 4 12 9 7"/><path d="M20 18v-2a4 4 0 0 0-4-4H4"/></svg>
75 <%= t('fedi.remote_reply_short') %>
76 </button>
77 <% } %>
78 </div>
79 <% if (n.children && n.children.length) { %>
80 <ol class="comment-replies">
81 <% n.children.forEach(function(c){ %>
82 <li class="comment comment-reply"><%- include('../partials/fedi-node', { n: c, t: t, canManageSite: (typeof canManageSite !== 'undefined' ? canManageSite : false), _base: _base, siteAvatar: (typeof siteAvatar !== 'undefined' ? siteAvatar : null), formatDateTime: formatDateTime, postSlug: (typeof postSlug !== 'undefined' ? postSlug : null) }) %></li>
83 <% }); %>
84 </ol>
85 <% } %>
86</div>
Note: See TracBrowser for help on using the repository browser.