source: Klonkt/src/views/pages/connect.ejs@ ad10715

main
Last change on this file since ad10715 was b109a29, checked in by Robin <roboburr@…>, 8 weeks ago

Feature: Connect page merges following + followers into one view

/connect combines who you follow (ap_following) and who follows you
(ap_followers) into a single list keyed by actor_uri, each with a direction
badge (following →, follower ←, mutual ↔) and, for accounts we deliver to, a
light 'last delivery' line. Failing/never-reached followers move into a
collapsed 'Unreachable' section at the bottom with the remove action, keeping
the main list clean. The two Following/Followers tabs collapse into one
'Connect' tab; the old routes redirect to /connect so links keep working.
i18n NL/EN/DE. Verified locally: merge/direction/unreachable logic + render.

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

  • Property mode set to 100644
File size: 7.8 KB
Line 
1<div class="tl-wrap">
2 <%- include('../partials/fedi-tabs', { active: 'connect' }) %>
3 <h1 class="tl-title"><%= t('tl.connect') %></h1>
4 <% if (typeof success !== 'undefined' && success) { %><div class="alert alert-success"><%= success %></div><% } %>
5 <% if (typeof error !== 'undefined' && error) { %><div class="alert alert-error"><%= error %></div><% } %>
6
7 <form method="post" action="/news/follow" class="tl-follow">
8 <input type="text" name="handle" placeholder="@naam@server.social of site.com" autocomplete="off" spellcheck="false" required>
9 <button type="submit" class="btn btn-primary"><%= t('tl.follow_btn') %></button>
10 <label class="tl-follow-ab" title="<%= t('tl.autoboost_hint') %>"><input type="checkbox" name="auto_boost" value="1"> &#10024; <%= t('tl.autoboost_follow') %></label>
11 </form>
12
13 <%
14 var conns = connections || [];
15 var reachable = conns.filter(function (c) { return !c.unreachable; });
16 var unreachable = conns.filter(function (c) { return c.unreachable; });
17 // Display fields for one connection: name/handle (fallback: derive from actor_uri).
18 function connView(c) {
19 var host = '', user = '';
20 try { var u = new URL(c.actor_uri); host = u.hostname; user = (u.pathname.split('/').filter(Boolean).pop() || ''); } catch (e) {}
21 var handle = c.handle || (user ? ('@' + user + '@' + host) : c.actor_uri);
22 var display = c.name || handle;
23 return { handle: handle, display: display,
24 initial: String(display || '?').replace(/^@/, '').charAt(0).toUpperCase(),
25 profileUrl: c.url || c.actor_uri };
26 }
27 function arrow(dir) { return dir === 'mutual' ? '↔' : (dir === 'following' ? '→' : '←'); }
28 %>
29
30 <% if (reachable.length) { %>
31 <ul class="tl-foll-list">
32 <% reachable.forEach(function (c) { var v = connView(c); %>
33 <li class="tl-foll">
34 <span class="tl-foll-av"><% if (c.icon) { %><img src="<%= avatar(c.icon, 96) %>" alt=""><% } else { %><%= v.initial %><% } %></span>
35 <span class="tl-foll-meta">
36 <a href="<%= v.profileUrl %>" target="_blank" rel="nofollow noopener"><%= v.display %></a>
37 <span class="conn-sub">
38 <span class="conn-dir conn-dir--<%= c.direction %>"><%= arrow(c.direction) %> <%= t('tl.dir_' + c.direction) %></span>
39 <% if (c.follower && c.last_delivery_at) { %><span class="conn-deliv">&middot; <%= t('tl.last_delivery') %>: <%= formatDateTime(c.last_delivery_at) %></span><% } %>
40 </span>
41 </span>
42 <% if (c.following) { %>
43 <form method="post" action="/news/autoboost" class="tl-foll-ab" title="<%= t('tl.autoboost_hint') %>">
44 <input type="hidden" name="actor_uri" value="<%= c.actor_uri %>">
45 <label><input type="checkbox" name="auto_boost" value="1" <%= c.auto_boost ? 'checked' : '' %> data-autosubmit> &#10024; <%= t('tl.autoboost') %></label>
46 </form>
47 <form method="post" action="/news/unfollow"><input type="hidden" name="actor_uri" value="<%= c.actor_uri %>"><button type="submit" class="tl-unfollow"><%= t('tl.unfollow') %></button></form>
48 <% } %>
49 </li>
50 <% }); %>
51 </ul>
52 <% } else { %>
53 <p class="tl-empty"><%= t('tl.connect_empty') %></p>
54 <% } %>
55
56 <% if (unreachable.length) { %>
57 <details class="conn-unreach">
58 <summary>&#9888; <%= t('tl.unreachable') %> (<%= unreachable.length %>)</summary>
59 <p class="conn-unreach-lead"><%= t('tl.unreachable_lead') %></p>
60 <ul class="tl-foll-list">
61 <% unreachable.forEach(function (c) { var v = connView(c); %>
62 <li class="tl-foll is-stale">
63 <span class="tl-foll-av"><% if (c.icon) { %><img src="<%= avatar(c.icon, 96) %>" alt=""><% } else { %><%= v.initial %><% } %></span>
64 <span class="tl-foll-meta">
65 <a href="<%= v.profileUrl %>" target="_blank" rel="nofollow noopener"><%= v.display %></a>
66 <span class="conn-sub">
67 <span class="conn-dir conn-dir--<%= c.direction %>"><%= arrow(c.direction) %> <%= t('tl.dir_' + c.direction) %></span>
68 <% if (c.last_delivery_at) { %><span class="conn-deliv">&middot; <%= t('tl.last_delivery') %>: <%= formatDateTime(c.last_delivery_at) %></span><% } else { %><span class="conn-never">&middot; <%= t('tl.never_delivered') %></span><% } %>
69 <% if (c.last_error_at) { %><span class="conn-err">&middot; <%= t('tl.delivery_failed') %>: <%= formatDateTime(c.last_error_at) %></span><% } %>
70 </span>
71 </span>
72 <% if (c.follower_id) { %>
73 <form method="post" action="/followers/<%= c.follower_id %>/remove" onsubmit="return confirm('<%= t('tl.remove_confirm') %>')">
74 <button type="submit" class="tl-unfollow"><%= t('tl.remove_follower') %></button>
75 </form>
76 <% } %>
77 </li>
78 <% }); %>
79 </ul>
80 </details>
81 <% } %>
82</div>
83
84<style>
85 .tl-wrap { max-width: 640px; margin: 1rem auto; padding: 0 1rem; }
86 .tl-title { margin: 0 0 .75rem; }
87 .tl-empty { color: var(--ink-soft, #888); }
88 .tl-follow { display: flex; gap: .5rem; margin: 0 0 1.25rem; flex-wrap: wrap; align-items: center; }
89 .tl-follow input[type="text"] { flex: 1; min-width: 200px; height: 2.4rem; padding: 0 .9rem; border-radius: 999px; font: inherit;
90 border: 1px solid color-mix(in srgb, var(--ink, #000) 18%, transparent); background: color-mix(in srgb, var(--ink, #000) 4%, transparent); color: var(--ink, #000); }
91 .tl-follow-ab { font-size: .85rem; color: var(--ink-soft, #888); display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
92 .tl-foll-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
93 .tl-foll { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: 12px; background: color-mix(in srgb, var(--ink, #000) 4%, transparent); }
94 .tl-foll.is-stale { background: color-mix(in srgb, #c0392b 10%, transparent); }
95 .tl-foll-av { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: color-mix(in srgb, var(--accent, #888) 20%, transparent); color: var(--accent, #555); }
96 .tl-foll-av img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
97 .tl-foll-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
98 .tl-foll-meta a { color: var(--ink, inherit); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
99 .tl-foll-meta a:hover { text-decoration: underline; }
100 .conn-sub { font-size: .78rem; color: var(--ink-soft, #888); display: inline-flex; flex-wrap: wrap; gap: .35rem; align-items: baseline; }
101 .conn-dir { font-weight: 600; }
102 .conn-dir--mutual { color: var(--accent, #06c); }
103 .conn-dir--following { color: color-mix(in srgb, var(--ink, #000) 62%, transparent); }
104 .conn-dir--follower { color: color-mix(in srgb, var(--ink, #000) 62%, transparent); }
105 .conn-never, .conn-err { color: #c0392b; }
106 .tl-foll-ab { margin: 0; font-size: .8rem; color: var(--ink-soft, #888); cursor: pointer; }
107 .tl-foll-ab label { display: inline-flex; align-items: center; gap: .25rem; cursor: pointer; }
108 .tl-unfollow { background: none; border: 1px solid color-mix(in srgb, var(--ink, #000) 18%, transparent); border-radius: 8px; padding: .25rem .6rem; font-size: .8rem; color: var(--ink-soft, #888); cursor: pointer; white-space: nowrap; }
109 .tl-unfollow:hover { color: var(--ink, #000); }
110 .conn-unreach { margin: 1.25rem 0 0; border-top: 1px solid color-mix(in srgb, var(--ink, #000) 10%, transparent); padding-top: .75rem; }
111 .conn-unreach summary { cursor: pointer; font-weight: 600; color: #c0392b; }
112 .conn-unreach-lead { font-size: .8rem; color: var(--ink-soft, #888); margin: .5rem 0 .75rem; }
113</style>
Note: See TracBrowser for help on using the repository browser.