source: Klonkt/src/views/pages/admin.ejs@ 91094a4

main
Last change on this file since 91094a4 was 91094a4, checked in by roboburr <roboburr@…>, 3 months ago

Download-for-email (premium feature #2)

Fan leaves their email -> receives the file; address is added to the mailing list
(source 'download', single opt-in so the download is not behind a confirm barrier).
Reuses SubscriberService (#1).

  • DB: audio_tracks.downloadable (default 0).
  • admin-audio: per-track no-JS toggle (POST /admin/audio/:id/downloadable) + ⬇ button in the admin list (premium-gated); downloadable also in the /api/:id whitelist.
  • routes/download.js (premium-gated): GET /downloads (list), GET /download/:id (capture page), POST /download/:id (save email + session grant), GET /download/:id/bestand (serves attachment from storage/audio, 15-min session window, path-traversal guards).
  • views: pages/downloads.ejs + pages/download.ejs (form/ready, auto-start download).
  • admin dashboard: ⬇ Downloads link (premium, non-hub).

node --check passed. Nothing else reuses this; #8 notify reuses subscribers.

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

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