source: Klonkt/src/views/pages/timeline.ejs@ df0516a

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

feat(fediverse): auto-boost a followed account ('feature an artist')

Phase 1 of the Cirkels-on-AP rework. A followed account can be marked auto-boost:
their new top-level posts are automatically re-Announced (boosted) to your own
followers. Toggle in the /tijdlijn following list + a checkbox on the follow box.
ap_following.auto_boost column (migrated), setAutoBoost(), hook in handleInbox's
timeline loop, POST /tijdlijn/autoboost. nl/en/de.

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

  • Property mode set to 100644
File size: 9.9 KB
RevLine 
[914eb9f]1<div class="tl-wrap">
2 <h1 class="tl-title"><%= t('tl.title') %></h1>
3 <p class="tl-lead"><%= t('tl.lead') %></p>
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="/tijdlijn/follow" class="tl-follow">
8 <input type="text" name="handle" placeholder="@naam@server.social" autocomplete="off" spellcheck="false" required>
9 <button type="submit" class="btn btn-primary"><%= t('tl.follow_btn') %></button>
[f278df9]10 <label class="tl-follow-ab" title="<%= t('tl.autoboost_hint') %>"><input type="checkbox" name="auto_boost" value="1"> 🔁 <%= t('tl.autoboost_follow') %></label>
[914eb9f]11 </form>
12
13 <% if (following && following.length) { %>
14 <h2 class="tl-sub"><%= t('tl.following') %> (<%= following.length %>)</h2>
15 <ul class="tl-foll-list">
16 <% following.forEach(function(f){ %>
17 <li class="tl-foll">
18 <span class="tl-foll-av"><% if (f.icon) { %><img src="<%= f.icon %>" alt=""><% } else { %><%= (f.name || '?').charAt(0).toUpperCase() %><% } %></span>
19 <span class="tl-foll-meta">
20 <a href="<%= f.url || f.actor_uri %>" target="_blank" rel="nofollow noopener"><%= f.name || f.handle %></a>
21 <span class="tl-foll-handle"><%= f.handle %></span>
22 <% if (f.status === 'pending') { %><span class="tl-pending"><%= t('tl.pending') %></span><% } %>
23 </span>
[f278df9]24 <form method="post" action="/tijdlijn/autoboost" class="tl-foll-ab" title="<%= t('tl.autoboost_hint') %>">
25 <input type="hidden" name="actor_uri" value="<%= f.actor_uri %>">
26 <label><input type="checkbox" name="auto_boost" value="1" <%= f.auto_boost ? 'checked' : '' %> onchange="this.form.submit()"> 🔁 <%= t('tl.autoboost') %></label>
27 </form>
[914eb9f]28 <form method="post" action="/tijdlijn/unfollow"><input type="hidden" name="actor_uri" value="<%= f.actor_uri %>"><button type="submit" class="tl-unfollow"><%= t('tl.unfollow') %></button></form>
29 </li>
30 <% }); %>
31 </ul>
32 <% } %>
33
34 <h2 class="tl-sub"><%= t('tl.feed') %></h2>
35 <% if (!timeline || !timeline.length) { %>
36 <p class="tl-empty"><%= t('tl.empty') %></p>
37 <% } else { %>
38 <ol class="tl-feed">
39 <% timeline.forEach(function(p){ %>
40 <li class="tl-item">
41 <span class="tl-avatar"><% if (p.author_icon) { %><img src="<%= p.author_icon %>" alt="" loading="lazy"><% } else { %><%= (p.author_name || '?').charAt(0).toUpperCase() %><% } %></span>
42 <div class="tl-itembody">
43 <div class="tl-meta">
44 <a class="tl-author" href="<%= p.author_url || p.author_uri %>" target="_blank" rel="nofollow noopener"><%= p.author_name %></a>
45 <span class="tl-handle"><%= p.author_handle %></span>
46 <% if (p.published || p.created_at) { %><span class="tl-time"><%= formatDateTime(p.published || p.created_at) %></span><% } %>
47 </div>
48 <div class="tl-content"><%- p.content %></div>
49 <% var media = []; try { media = JSON.parse(p.media_json || '[]'); } catch (e) { media = []; } %>
50 <% media.filter(function(m){ return !m.type || /^image\//.test(m.type); }).forEach(function(m){ %><img class="tl-media" src="<%= m.url %>" alt="" loading="lazy"><% }); %>
51 <% if (p.url) { %><p class="tl-orig"><a href="<%= p.url %>" target="_blank" rel="nofollow noopener"><%= t('tl.view_original') %></a></p><% } %>
[d988fa0]52 <div class="tl-actions">
53 <form method="post" action="/tijdlijn/like" class="tl-act-form"><input type="hidden" name="note" value="<%= p.id %>"><input type="hidden" name="author" value="<%= p.author_uri %>"><button type="submit" class="tl-act" title="<%= t('fedi.likes') %>">⭐</button></form>
54 <form method="post" action="/tijdlijn/boost" class="tl-act-form"><input type="hidden" name="note" value="<%= p.id %>"><input type="hidden" name="author" value="<%= p.author_uri %>"><button type="submit" class="tl-act" title="<%= t('fedi.boosts') %>">🔁</button></form>
55 <button type="button" class="tl-act fedi-remote-reply-btn" data-fedi-uri="<%= p.id %>" data-fedi-ph="<%= t('fedi.remote_ph') %>" title="<%= t('fedi.remote_reply') %>">↩</button>
[f5c3870]56 <form method="post" action="/blokkeren/add" class="tl-act-form" onsubmit="return confirm('<%= t('tl.block') %>?');"><input type="hidden" name="target" value="<%= p.author_uri %>"><button type="submit" class="tl-act" title="<%= t('tl.block') %>">🚫</button></form>
[d988fa0]57 </div>
[914eb9f]58 </div>
59 </li>
60 <% }); %>
61 </ol>
62 <% } %>
63</div>
64
65<style>
66 .tl-wrap { max-width: 640px; margin: 2rem auto; padding: 0 1rem; }
67 .tl-title { margin: 0 0 .25rem; }
68 .tl-lead { color: var(--ink-soft, #888); margin: 0 0 1.25rem; }
69 .tl-sub { font-size: 1.1rem; margin: 1.75rem 0 .75rem; }
70 .tl-follow { display: flex; gap: .5rem; margin: 0 0 1rem; flex-wrap: wrap; }
71 .tl-follow input { flex: 1; min-width: 200px; height: 2.4rem; padding: 0 .9rem; border-radius: 999px; font: inherit;
72 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); }
73 .tl-foll-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
74 .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); }
75 .tl-foll-av, .tl-avatar { 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); }
76 .tl-foll-av img, .tl-avatar img { width: 100%; height: 100%; object-fit: cover; }
77 .tl-foll-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
78 .tl-foll-handle, .tl-handle { color: var(--ink-soft, #888); font-size: .82rem; }
79 .tl-pending { font-size: .72rem; color: var(--ink-soft, #999); }
80 .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; }
81 .tl-unfollow:hover { color: var(--ink, #000); }
82 .tl-empty { color: var(--ink-soft, #888); }
83 .tl-feed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .9rem; }
84 .tl-item { display: flex; gap: .75rem; padding: .9rem 1rem; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--ink, #000) 9%, transparent); background: color-mix(in srgb, var(--ink, #000) 3%, transparent); }
85 .tl-itembody { flex: 1; min-width: 0; }
86 .tl-meta { display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; }
87 .tl-author { font-weight: 600; color: var(--ink, inherit); text-decoration: none; }
88 .tl-author:hover { text-decoration: underline; }
89 .tl-time { color: var(--ink-soft, #999); font-size: .8rem; margin-left: auto; }
90 .tl-content { margin: .3rem 0 0; line-height: 1.5; overflow-wrap: anywhere; }
91 .tl-content p { margin: .25rem 0; } .tl-content p:first-child { margin-top: 0; }
92 .tl-media { max-width: 100%; height: auto; border-radius: 10px; margin: .5rem 0 0; display: block; }
93 .tl-orig { margin: .5rem 0 0; font-size: .82rem; }
94 .tl-orig a { color: var(--accent, #06c); }
[d988fa0]95 .tl-actions { display: flex; gap: .35rem; margin-top: .55rem; }
96 .tl-act-form { margin: 0; }
97 .tl-act { background: none; border: 1px solid color-mix(in srgb, var(--ink, #000) 14%, transparent); border-radius: 999px; padding: .2rem .6rem; cursor: pointer; font-size: .9rem; color: var(--ink-soft, #888); }
98 .tl-act:hover { color: var(--ink, #000); border-color: color-mix(in srgb, var(--accent, #888) 50%, transparent); }
[914eb9f]99</style>
[d988fa0]100
101<script>
102(function(){
103 if (window.__fediRemoteWired) return; window.__fediRemoteWired = true;
104 var current = null, currentBtn = null;
105 function close(){ if (current) { current.remove(); current = null; currentBtn = null; } }
106 function go(raw, uri){ var d=(raw||'').trim().replace(/^@?[^@\s]*@/,'').replace(/^https?:\/\//i,'').replace(/\/.*$/,'').trim(); if(d) location.href='https://'+d+'/authorize_interaction?uri='+encodeURIComponent(uri||''); }
107 function place(f, b){ var r=b.getBoundingClientRect(); f.style.top=(r.bottom+window.scrollY+6)+'px'; f.style.left=Math.max(8, Math.min(r.left+window.scrollX, window.scrollX+window.innerWidth-340))+'px'; }
108 document.addEventListener('click', function(e){
109 if (e.target.closest && e.target.closest('.fedi-remote-cancel')) { close(); return; }
110 if (current && e.target.closest && e.target.closest('.fedi-remote-form')) return;
111 var b = e.target.closest && e.target.closest('.fedi-remote-reply-btn');
112 if (b) {
113 e.preventDefault();
114 if (currentBtn === b) { close(); return; }
115 close();
116 var f = document.createElement('form'); f.className='fedi-remote-form'; f.dataset.uri = b.getAttribute('data-fedi-uri')||'';
117 f.innerHTML = '<input type="text" autocomplete="off" spellcheck="false"><button type="submit" class="btn btn-primary fedi-remote-go" aria-label="ok">&rarr;</button><button type="button" class="fedi-remote-cancel" aria-label="x">&times;</button>';
[f6c414e]118 f.querySelector('input').placeholder = b.getAttribute('data-fedi-ph') || 'mastodon.social';
[d988fa0]119 document.body.appendChild(f); place(f, b); current=f; currentBtn=b; f.querySelector('input').focus();
120 return;
121 }
122 if (current) close();
123 });
124 document.addEventListener('submit', function(e){ var f=e.target.closest && e.target.closest('.fedi-remote-form'); if(!f) return; e.preventDefault(); go(f.querySelector('input').value, f.dataset.uri); });
125 document.addEventListener('keydown', function(e){ if (e.key === 'Escape') close(); });
126 window.addEventListener('scroll', close, true);
127})();
128</script>
Note: See TracBrowser for help on using the repository browser.