source: Klonkt/src/views/pages/admin.ejs@ 1794fac

main
Last change on this file since 1794fac was 37edecd, checked in by roboburr <roboburr@…>, 3 months ago

Link-in-bio + click stats (premium feature #6)

Linktree-style page from the existing sites.profile_links (JSON [{platform,url}])
+ PLATFORMS icons. Clicks counted per url.

  • DB: link_clicks (site_id, url, clicks), PK (site_id,url).
  • routes/linkbio.js (premium-gated): GET /links (page with profile_links as buttons), GET /links/go/:i (counts click per url + 302 redirect). Open-redirect safe: only redirects to a url in the site's own profile_links; http(s)/mailto only.
  • view pages/linkbio.ejs (photo/name/bio + brand-coloured buttons with SVG icons).
  • admin-stats: link-clicks section (top 50, per url) for the current site.
  • admin dashboard: 🔗 Link-in-bio link (premium, non-hub).

node --check passed.

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

  • Property mode set to 100644
File size: 9.0 KB
RevLine 
[7bc636b]1<div class="container admin-page">
[6351545]2 <h1>Beheer</h1>
3 <% if (tenancy === 'hub') { %>
[8afbdd6]4 <p class="admin-tagline">Hub-modus — bedrijfssite met gebruikers, elk hun eigen Klonkt Hub.</p>
[6351545]5 <% } else { %>
6 <p class="admin-tagline">Solo-modus — jouw site.</p>
7 <% } %>
[7bc636b]8
9 <nav class="admin-quick-links" aria-label="Beheer-snelkoppelingen">
[6351545]10 <% if (tenancy === 'hub') { %>
11 <a href="/admin/sites" class="btn">🌐 Sites</a>
12 <a href="/admin/users" class="btn">👥 Gebruikers</a>
13 <a href="/admin/audio" class="btn">🎵 Audio</a>
14 <a href="/admin/playlists" class="btn">📃 Playlists</a>
15 <a href="/admin/comments" class="btn">💬 Reacties</a>
[6623453]16 <% if (primarySite) { %><a href="/admin/seo" class="btn">🔎 SEO</a><% } %>
[6351545]17 <a href="/admin/settings" class="btn">⚙️ Instellingen</a>
18 <% } else { %>
19 <a href="/posts/new" class="btn">✍️ Nieuwe post</a>
20 <a href="/admin/audio" class="btn">🎵 Audio</a>
21 <a href="/admin/comments" class="btn">💬 Reacties</a>
22 <% if (primarySite) { %>
23 <a href="/admin/sites/<%= primarySite.slug %>/edit" class="btn">🎨 Uiterlijk</a>
[bdc3c1e]24 <% } else { %>
25 <a href="/admin/sites/new" class="btn">🎨 Maak je site aan</a>
[6351545]26 <% } %>
[6e9a95b]27 <% if (tenancy === 'circle') { %>
28 <a href="/admin/circle" class="btn">🔗 Cirkel</a>
29 <% } %>
[6623453]30 <% if (primarySite) { %><a href="/admin/seo" class="btn">🔎 SEO</a><% } %>
[6351545]31 <a href="/admin/settings" class="btn">⚙️ Instellingen</a>
32 <% } %>
[d549549]33 <% if (typeof premiumUnlocked === 'undefined' || premiumUnlocked) { %>
34 <a href="/admin/stats" class="btn">📊 Statistieken</a>
[2e247e4]35 <a href="/admin/newsletter" class="btn">✉️ Nieuwsbrief</a>
36 <% if (tenancy !== 'hub' && primarySite) { %><a href="/pers" class="btn" target="_blank">📰 Perskit</a><% } %>
[91094a4]37 <% if (tenancy !== 'hub' && primarySite) { %><a href="/downloads" class="btn" target="_blank">⬇ Downloads</a><% } %>
[37edecd]38 <% if (tenancy !== 'hub' && primarySite) { %><a href="/links" class="btn" target="_blank">🔗 Link-in-bio</a><% } %>
[d549549]39 <% } %>
[ff08153]40 <a href="/admin/updates" class="btn">🔄 Updates</a>
[7bc636b]41 </nav>
42
43 <div class="admin-stats">
[6351545]44 <% if (tenancy === 'hub') { %>
45 <div class="stat-card"><div class="stat-num"><%= stats.users %></div><div class="stat-label">Gebruikers</div></div>
46 <div class="stat-card"><div class="stat-num"><%= stats.sites %></div><div class="stat-label">Sites</div></div>
47 <% } %>
48 <div class="stat-card"><div class="stat-num"><%= stats.posts %></div><div class="stat-label">Posts</div></div>
49 <div class="stat-card"><div class="stat-num"><%= stats.published %></div><div class="stat-label">Gepubliceerd</div></div>
[7bc636b]50 </div>
51
[f45fc82]52 <% if (typeof posts !== 'undefined' && posts && posts.length) { %>
53 <% var _drafts = posts.filter(function(p){ return p.isDraft; }).length; %>
54 <h2>Posts<% if (_drafts) { %> <span class="pl-draftcount"><%= _drafts %> concept<%= _drafts === 1 ? '' : 'en' %></span><% } %></h2>
55 <ul class="post-admin-list">
56 <% posts.forEach(function(p) { %>
57 <li class="pal-row<%= p.isDraft ? ' is-draft' : '' %>">
58 <a class="pal-title" href="<%= p.editUrl %>">
59 <% if (p.isDraft) { %><span class="pal-badge">Concept</span><% } %>
60 <span class="pal-name"><%= p.title || '(zonder titel)' %></span>
61 </a>
62 <span class="pal-actions">
63 <a class="pal-link" href="<%= p.editUrl %>">Bewerken</a>
64 <% if (!p.isDraft) { %><a class="pal-link" href="<%= p.viewUrl %>">Bekijk</a><% } %>
65 </span>
66 </li>
67 <% }); %>
68 </ul>
69 <% } %>
70
[7bc636b]71 <% if (sites && sites.length) { %>
72 <h2>Sites</h2>
73 <table class="admin-table">
74 <thead>
75 <tr><th>Slug</th><th>Title</th><th>Owner</th><th>Created</th></tr>
76 </thead>
77 <tbody>
78 <% sites.forEach(function(s) { %>
79 <tr>
80 <td><code><%= s.slug %></code></td>
81 <td><%= s.title %></td>
82 <td><%= s.owner_username || '—' %></td>
83 <td><%= formatDate(s.created_at) %></td>
84 </tr>
85 <% }); %>
86 </tbody>
87 </table>
88 <% } %>
89
90 <% if (users && users.length) { %>
91 <h2>Users</h2>
92 <table class="admin-table">
93 <thead>
94 <tr><th>Username</th><th>Email</th><th>Role</th><th>Joined</th></tr>
95 </thead>
96 <tbody>
97 <% users.forEach(function(u) { %>
98 <tr>
99 <td><%= u.username %></td>
100 <td><%= u.email %></td>
101 <td><span class="role-pill role-<%= u.role %>"><%= u.role %></span></td>
102 <td><%= formatDate(u.created_at) %></td>
103 </tr>
104 <% }); %>
105 </tbody>
106 </table>
107 <% } %>
108
109</div>
110
111<style>
112.admin-page { max-width: 1000px; margin: 3rem auto; padding: 0 1rem; }
113.admin-page h1 { font-family: var(--font-display, serif); font-size: 2rem; margin: 0 0 0.25rem; }
114.admin-page h2 { font-family: var(--font-display, serif); font-size: 1.4rem; margin: 2rem 0 0.75rem; }
115.admin-tagline { color: var(--ink-muted); margin: 0 0 2rem; }
116.admin-tagline em { font-style: normal; opacity: 0.7; }
117
[f45fc82]118/* Posts/concepten-lijst */
119.pl-draftcount { font-family: var(--font-ui, system-ui); font-size: 0.8rem; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding: 0.1rem 0.55rem; border-radius: 99px; vertical-align: middle; }
120.post-admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
121.pal-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0.9rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper-2); transition: border-color 120ms; }
122.pal-row:hover { border-color: var(--accent); }
123.pal-row.is-draft { border-left: 3px solid var(--accent); }
124.pal-title { display: inline-flex; align-items: center; gap: 0.6rem; min-width: 0; color: var(--ink); text-decoration: none; font-weight: 600; }
125.pal-title:hover { color: var(--accent); }
126.pal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
127.pal-badge { flex-shrink: 0; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding: 0.1rem 0.5rem; border-radius: 99px; }
128.pal-actions { display: flex; gap: 0.75rem; flex-shrink: 0; }
129.pal-link { color: var(--ink-muted); font-size: 0.85rem; text-decoration: none; white-space: nowrap; }
130.pal-link:hover { color: var(--accent); text-decoration: underline; }
131
[7bc636b]132/* Quick-links grid — mobile-first.
133 auto-fit + minmax means: as many equal columns as fit, each at least 140px.
134 Mobile (~360-440px): 2 per row.
135 Tablet (~480-700px): 3 per row.
136 Desktop (≥ ~720px): all 5 in a single row. */
137.admin-quick-links {
138 display: grid;
139 grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
140 gap: 0.5rem;
141 margin: 0 0 1.5rem;
142 padding: 0;
143}
144.admin-quick-links .btn {
145 justify-content: center;
146 padding: 0.7rem 0.9rem;
147 font-weight: 600;
148 text-align: center;
149}
150.admin-quick-links .btn:hover {
151 background: color-mix(in srgb, var(--accent) 8%, var(--paper-2));
152 border-color: var(--accent);
153}
154
155.admin-stats {
156 display: grid;
157 grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
158 gap: 0.75rem;
159 margin-bottom: 1rem;
160}
161.stat-card {
162 background: var(--paper-2);
163 border: 1px solid var(--rule);
164 border-radius: 8px;
165 padding: 1rem 1.25rem;
166 text-align: center;
167}
168.stat-num {
169 font-size: 2rem;
170 font-weight: 700;
171 color: var(--accent);
172 line-height: 1;
173 font-family: var(--font-display, serif);
174}
175.stat-label {
176 color: var(--ink-muted);
177 font-size: 0.85rem;
178 text-transform: uppercase;
179 letter-spacing: 0.05em;
180 margin-top: 0.25rem;
181}
182
183.admin-table {
184 width: 100%;
185 border-collapse: collapse;
186 background: var(--paper-2);
187 border: 1px solid var(--rule);
188 border-radius: 8px;
189 overflow: hidden;
190}
191.admin-table th, .admin-table td {
192 padding: 0.6rem 0.9rem;
193 text-align: left;
194 border-bottom: 1px solid var(--rule);
195}
196.admin-table th {
197 background: var(--paper);
198 font-weight: 600;
199 font-size: 0.85rem;
200 text-transform: uppercase;
201 letter-spacing: 0.05em;
202 color: var(--ink-muted);
203}
204.admin-table tr:last-child td { border-bottom: 0; }
205.admin-table code { background: var(--paper); padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.85rem; }
206
207.role-pill {
208 display: inline-block;
209 padding: 0.1rem 0.5rem;
210 border-radius: 10px;
211 font-size: 0.75rem;
212 text-transform: uppercase;
213 letter-spacing: 0.05em;
214 background: var(--paper);
215 color: var(--ink-muted);
216}
217.role-pill.role-god { background: var(--accent); color: white; }
218.role-pill.role-admin { background: var(--paper); color: var(--accent); border: 1px solid var(--accent); }
219
220.admin-todo {
221 margin: 2rem 0 0;
222 padding: 0.75rem 1rem;
223 background: var(--paper-2);
224 border-left: 3px solid var(--accent);
225 border-radius: 4px;
226 font-size: 0.9rem;
227 color: var(--ink-muted);
228}
229
230@media (max-width: 600px) {
231 .admin-table { font-size: 0.85rem; }
232 .admin-table th, .admin-table td { padding: 0.45rem 0.6rem; }
233}
234</style>
Note: See TracBrowser for help on using the repository browser.