source: Klonkt/src/views/pages/authorize-interaction.ejs@ 3d37c67

main
Last change on this file since 3d37c67 was 3d37c67, checked in by Robin Genis <roboburr@โ€ฆ>, 2 months ago

feat(fedi): interact page like/boost are 2 icon+label toggle buttons

Replace the 'โ˜… Like this post' / '๐Ÿ” Boost this post' buttons with two pill buttons
(gold star + Like, green repeat + Boost) that are real toggles. New ap_my_reactions
table tracks your like/boost state on a REMOTE post; clicking again retracts (Undo
Like / Undo Announce). The like/boost POST now redirects back to the interact page so
the state shows in place (no more separate confirmation screen).

  • Property mode set to 100644
File size: 11.7 KB
Lineย 
1<div class="auth-interact">
2 <% if (typeof manage !== 'undefined' && manage) { %>
3 <%- include('../partials/fedi-tabs', { active: 'reacties' }) %>
4 <h1 class="auth-interact-title"><%= t('fedi.manage_title') %></h1>
5 <% if (!manage.length) { %>
6 <p class="auth-interact-note"><%= t('fedi.manage_empty') %></p>
7 <% } else { %>
8 <ul class="fedi-manage">
9 <% manage.forEach(function(m){ %>
10 <li class="fedi-manage-item">
11 <div class="fedi-manage-content"><%- m.content %></div>
12 <div class="fedi-manage-foot">
13 <span class="fedi-manage-meta"><% if (m.to_handle) { %>โ†’ <%= m.to_handle %><% } %><% if (m.created_at && typeof formatDateTime === 'function') { %> ยท <%= formatDateTime(m.created_at) %><% } %></span>
14 <form method="post" action="/fediverse/<%= m.id %>/delete" onsubmit="return confirm('<%= t('fedi.delete_confirm') %>')">
15 <button type="submit" class="fedi-del-btn"><%= t('comments.delete') %></button>
16 </form>
17 </div>
18 </li>
19 <% }); %>
20 </ul>
21 <% } %>
22 <p class="auth-interact-note"><a href="/"><%= t('fedi.remote_back') %></a></p>
23 <% } else if (typeof liked !== 'undefined' && liked) { %>
24 <h1 class="auth-interact-title">โ˜… <%= t('fedi.liked_title') %></h1>
25 <p class="auth-interact-note"><%= t('fedi.liked_done') %></p>
26 <p class="auth-interact-actions">
27 <% if (uri) { %><a class="btn" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.remote_view_original') %></a><% } %>
28 <a class="btn btn-primary" href="/"><%= t('fedi.remote_back') %></a>
29 </p>
30 <% } else if (typeof boosted !== 'undefined' && boosted) { %>
31 <h1 class="auth-interact-title">๐Ÿ” <%= t('fedi.boosted_title') %></h1>
32 <p class="auth-interact-note"><%= t('fedi.boosted_done') %></p>
33 <p class="auth-interact-actions">
34 <% if (uri) { %><a class="btn" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.remote_view_original') %></a><% } %>
35 <a class="btn btn-primary" href="/"><%= t('fedi.remote_back') %></a>
36 </p>
37 <% } else if (typeof followed !== 'undefined' && followed) { %>
38 <h1 class="auth-interact-title"><%= t('fedi.followed_title') %></h1>
39 <p class="auth-interact-note"><%= t('fedi.followed_done') %></p>
40 <p class="auth-interact-actions">
41 <% if (uri) { %><a class="btn" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.view_profile') %></a><% } %>
42 <a class="btn btn-primary" href="/"><%= t('fedi.remote_back') %></a>
43 </p>
44 <% } else if (typeof sent !== 'undefined' && sent) { %>
45 <h1 class="auth-interact-title"><%= t('fedi.remote_sent_title') %></h1>
46 <p class="auth-interact-note"><%= t('fedi.remote_sent') %></p>
47 <p class="auth-interact-actions">
48 <% if (uri) { %><a class="btn btn-primary" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.remote_view_original') %></a><% } %>
49 <a class="btn" href="/"><%= t('fedi.remote_back') %></a>
50 </p>
51 <% } else if (typeof followTarget !== 'undefined' && followTarget) { %>
52 <h1 class="auth-interact-title"><%= t('fedi.follow_heading') %></h1>
53 <p class="auth-interact-meta">
54 <%= t('fedi.follow_intro') %>
55 <a href="<%= followTarget.actor_url %>" rel="nofollow noopener" target="_blank"><strong><%= followTarget.actor_name %></strong></a>
56 <span class="fedi-handle"><%= followTarget.actor_handle %></span>
57 </p>
58 <form method="post" action="/authorize_interaction/follow" class="auth-interact-form">
59 <input type="hidden" name="uri" value="<%= followTarget.actor_uri %>">
60 <div class="auth-interact-actions">
61 <button type="submit" class="btn btn-primary"><%= t('fedi.follow_btn') %></button>
62 <a href="/" class="btn"><%= t('comments.cancel') %></a>
63 </div>
64 </form>
65 <p class="auth-interact-note"><%= t('fedi.remote_as', { site: siteTitle }) %></p>
66 <% } else { %>
67 <h1 class="auth-interact-title"><%= t('fedi.remote_title') %></h1>
68
69 <% if (!target) { %>
70 <p class="auth-interact-note"><%= t('fedi.remote_notfound') %></p>
71 <form method="get" action="/authorize_interaction" class="auth-interact-form">
72 <input type="url" name="uri" placeholder="https://โ€ฆ/een-post" value="<%= uri || '' %>" required>
73 <button type="submit" class="btn btn-primary"><%= t('fedi.remote_load') %></button>
74 </form>
75 <% } else { %>
76 <p class="auth-interact-meta">
77 <%= t('fedi.remote_replying_to') %>
78 <a href="<%= target.actor_url %>" rel="nofollow noopener" target="_blank"><strong><%= target.actor_name %></strong></a>
79 <span class="fedi-handle"><%= target.actor_handle %></span>
80 </p>
81 <blockquote class="auth-interact-preview">
82 <% if (target.content) { %><div class="auth-interact-content"><%- target.content %></div>
83 <% } else if (target.preview) { %><%= target.preview %><% } %>
84 <% (target.images || []).forEach(function(im){ %>
85 <img class="auth-interact-img" src="<%= im %>" alt="" loading="lazy">
86 <% }); %>
87 </blockquote>
88 <% if (target.url || uri) { %>
89 <a class="auth-view-src" href="<%= target.url || uri %>" target="_blank" rel="nofollow noopener">
90 <svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg>
91 <span><%= t('fedi.remote_view_original') %></span>
92 </a>
93 <% } %>
94 <div class="auth-interact-react">
95 <form method="post" action="/authorize_interaction/like">
96 <input type="hidden" name="uri" value="<%= uri %>">
97 <button type="submit" class="fedi-bigact fedi-bigact-like<%= (typeof reacted !== 'undefined' && reacted.liked) ? ' is-on' : '' %>">
98 <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>
99 <span><%= (typeof reacted !== 'undefined' && reacted.liked) ? t('fedi.unlike_short') : t('fedi.like_short') %></span>
100 </button>
101 </form>
102 <form method="post" action="/authorize_interaction/boost">
103 <input type="hidden" name="uri" value="<%= uri %>">
104 <button type="submit" class="fedi-bigact fedi-bigact-boost<%= (typeof reacted !== 'undefined' && reacted.boosted) ? ' is-on' : '' %>">
105 <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>
106 <span><%= (typeof reacted !== 'undefined' && reacted.boosted) ? t('tl.unboost') : t('fedi.boost_short') %></span>
107 </button>
108 </form>
109 </div>
110 <p class="auth-interact-or"><%= t('fedi.or_reply') %></p>
111 <p class="auth-interact-where">๐Ÿ’ฌ <%= t('fedi.reply_where') %></p>
112 <form method="post" action="/authorize_interaction" class="auth-interact-form">
113 <input type="hidden" name="uri" value="<%= uri %>">
114 <textarea name="text" rows="4" required placeholder="<%= t('fedi.reply_ph') %>"></textarea>
115 <div class="auth-interact-actions">
116 <button type="submit" class="btn"><%= t('fedi.send') %></button>
117 <a href="<%= uri %>" class="btn"><%= t('comments.cancel') %></a>
118 </div>
119 </form>
120 <p class="auth-interact-note"><%= t('fedi.remote_as', { site: siteTitle }) %></p>
121 <% } %>
122 <% } %>
123</div>
124
125<style>
126 .auth-interact { max-width: 640px; margin: 1rem auto; padding: 0 1rem; }
127 .auth-interact-title { margin: 0 0 1rem; }
128 .auth-interact-meta { color: var(--ink-soft, #888); margin: 0 0 .75rem; }
129 .auth-interact-preview {
130 margin: 0 0 1rem; padding: .75rem 1rem; border-left: 3px solid var(--accent, #888);
131 background: color-mix(in srgb, var(--ink, #000) 4%, transparent); border-radius: 0 12px 12px 0;
132 color: var(--ink, inherit);
133 }
134 .auth-interact-form { display: flex; flex-direction: column; gap: .75rem; }
135 .auth-interact-form textarea, .auth-interact-form input[type=url] {
136 width: 100%; box-sizing: border-box; padding: .6rem .8rem; font: inherit; resize: vertical;
137 border-radius: 12px; border: 1px solid color-mix(in srgb, var(--ink, #000) 18%, transparent);
138 background: var(--paper, #fff); color: var(--ink, #000);
139 }
140 .auth-interact-actions { display: flex; gap: .5rem; align-items: center; }
141 .auth-interact-note { color: var(--ink-soft, #999); font-size: .85rem; margin-top: 1rem; }
142 .auth-interact-where { margin: .25rem 0 .85rem; padding: .6rem .8rem; font-size: .85rem; line-height: 1.5; border-radius: 10px; background: color-mix(in srgb, var(--accent, #888) 12%, transparent); color: var(--ink, inherit); }
143 .auth-interact-content { line-height: 1.55; }
144 .auth-interact-content p { margin: .35rem 0; }
145 .auth-interact-content p:first-child { margin-top: 0; }
146 .auth-interact-img { max-width: 100%; height: auto; border-radius: 10px; margin: .5rem 0 0; display: block; }
147 .auth-interact-orig { margin: .75rem 0 0; font-size: .85rem; }
148 .auth-interact-orig a { color: var(--accent, #06c); }
149 .auth-view-src { display: inline-flex; align-items: center; gap: .5rem; margin: 0 0 1.1rem; padding: .6rem 1rem;
150 border: 1px solid color-mix(in srgb, var(--accent, #888) 45%, transparent); border-radius: 12px;
151 background: color-mix(in srgb, var(--accent, #888) 10%, transparent); color: var(--accent, #06c);
152 text-decoration: none; font-weight: 600; font-size: .92rem; transition: background .15s, border-color .15s; }
153 .auth-view-src:hover { background: color-mix(in srgb, var(--accent, #888) 18%, transparent); border-color: var(--accent, #888); }
154 .auth-interact-react { display: flex; gap: .6rem; flex-wrap: wrap; margin: 0 0 .25rem; }
155 .auth-interact-react form { margin: 0; }
156 .fedi-bigact { display: inline-flex; align-items: center; gap: .5rem; padding: .55rem 1.1rem; border-radius: 999px;
157 border: 1px solid color-mix(in srgb, var(--ink, #000) 14%, transparent);
158 background: color-mix(in srgb, var(--ink, #000) 4%, transparent);
159 color: var(--ink, inherit); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; white-space: nowrap;
160 transition: background .12s, border-color .12s; }
161 .fedi-bigact svg { width: 17px; height: 17px; flex: 0 0 17px; }
162 .fedi-bigact-like svg { color: #e8b04b; }
163 .fedi-bigact-like:hover, .fedi-bigact-like.is-on { background: color-mix(in srgb, #e8b04b 16%, transparent); border-color: color-mix(in srgb, #e8b04b 55%, transparent); }
164 .fedi-bigact-boost svg { color: #2fa85a; }
165 .fedi-bigact-boost:hover, .fedi-bigact-boost.is-on { background: color-mix(in srgb, #2fa85a 16%, transparent); border-color: color-mix(in srgb, #2fa85a 55%, transparent); }
166 .fedi-manage { list-style: none; padding: 0; margin: 1.25rem 0 1rem; display: flex; flex-direction: column; gap: .7rem; }
167 .fedi-manage-item { padding: .85rem 1rem; border-radius: 14px; background: color-mix(in srgb, var(--ink, #000) 4%, transparent); border: 1px solid color-mix(in srgb, var(--ink, #000) 9%, transparent); }
168 .fedi-manage-content { line-height: 1.5; overflow-wrap: anywhere; }
169 .fedi-manage-content p { margin: .15rem 0; }
170 .fedi-manage-content p:first-child { margin-top: 0; }
171 .fedi-manage-content p:last-child { margin-bottom: 0; }
172 .fedi-manage-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .6rem; flex-wrap: wrap; }
173 .fedi-manage-meta { color: var(--ink-soft, #999); font-size: .8rem; }
174 .fedi-del-btn { border: 1px solid color-mix(in srgb, #d9534f 50%, transparent); background: color-mix(in srgb, #d9534f 12%, transparent); color: #e06b66; border-radius: 8px; padding: .3rem .75rem; font-size: .82rem; cursor: pointer; transition: background .15s ease; }
175 .fedi-del-btn:hover { background: color-mix(in srgb, #d9534f 24%, transparent); }
176</style>
Note: See TracBrowser for help on using the repository browser.