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

main
Last change on this file since dee7f02 was 67fe576, checked in by Robin Genis <roboburr@…>, 3 months ago

ux(fedi): owner can like/boost a fediverse comment directly too

Extends the owner-direct treatment to likes and boosts: under an inbound
fediverse comment the site owner now gets a star + boost button that go straight
through /posts/:slug/fedi-react (sendInteraction as the site), alongside the
direct reply. No 'your server' detour. Visitors are unchanged.

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 4.0 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="<%= n.actor_icon %>" 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"><%= n.actor_name %></a>
9 <% } else { %><span class="comment-author"><%= n.actor_name %></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"><%- n.content %></div>
14 <div class="comment-actions">
15 <% if (n.mine && typeof canManageSite !== 'undefined' && canManageSite && n.outboxId) { %>
16 <form method="post" action="<%= _base %>/fediverse/<%= n.outboxId %>/delete" onsubmit="return confirm('<%= t('fedi.delete_confirm') %>')">
17 <button type="submit" class="comment-delete-btn"><%= t('comments.delete') %></button>
18 </form>
19 <% } else if (!n.mine && typeof canManageSite !== 'undefined' && canManageSite && n.id && typeof postSlug !== 'undefined' && postSlug) { %>
20 <%# Owner: like / boost / reply directly AS the site — no "your server" detour (it's your own site). %>
21 <form method="post" action="<%= _base %>/posts/<%= postSlug %>/fedi-react" class="fedi-owner-react">
22 <input type="hidden" name="interaction_id" value="<%= n.id %>">
23 <input type="hidden" name="kind" value="like">
24 <button type="submit" class="comment-reply-btn">⭐ <%= t('fedi.like_short') %></button>
25 </form>
26 <form method="post" action="<%= _base %>/posts/<%= postSlug %>/fedi-react" class="fedi-owner-react">
27 <input type="hidden" name="interaction_id" value="<%= n.id %>">
28 <input type="hidden" name="kind" value="boost">
29 <button type="submit" class="comment-reply-btn">🔁 <%= t('fedi.boost_short') %></button>
30 </form>
31 <details class="fedi-owner-reply">
32 <summary class="comment-reply-btn">
33 <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>
34 <%= t('fedi.remote_reply_short') %>
35 </summary>
36 <form method="post" action="<%= _base %>/posts/<%= postSlug %>/fedi-reply" class="comment-reply-form">
37 <input type="hidden" name="interaction_id" value="<%= n.id %>">
38 <textarea name="text" rows="2" required placeholder="<%= t('fedi.reply_ph') %>"></textarea>
39 <div class="comment-reply-form-actions">
40 <button type="submit" class="btn"><%= t('fedi.send') %></button>
41 </div>
42 </form>
43 </details>
44 <% } else if (!n.mine && n.noteId) { %>
45 <button type="button" class="comment-reply-btn fedi-remote-reply-btn" data-fedi-uri="<%= n.noteId %>" data-fedi-ph="<%= t('fedi.remote_ph') %>">
46 <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>
47 <%= t('fedi.remote_reply_short') %>
48 </button>
49 <% } %>
50 </div>
51 <% if (n.children && n.children.length) { %>
52 <ol class="comment-replies">
53 <% n.children.forEach(function(c){ %>
54 <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>
55 <% }); %>
56 </ol>
57 <% } %>
58</div>
Note: See TracBrowser for help on using the repository browser.