source: Klonkt/src/views/pages/account.ejs@ 544cd86

main
Last change on this file since 544cd86 was 8afbdd6, checked in by roboburr <roboburr@…>, 3 months ago

feat: viewer role + artists directory + Klonkt Hub Beta rebrand

Viewer role (replaces the separate view-mode/readonly toggle):

  • 'kijker' is now a real role (VALID_ROLES) selectable in Admin. May view EVERYTHING including Admin, but cannot modify anything.
  • isViewer(user) (= role kijker or legacy readonly flag) is the source; requireGod/requireSiteManager(BySlug) let a viewer through (viewing), the global guard 403s every write. Existing readonly accounts are migrated on each role change (readonly=0).
  • Write leaks via GET patched: /prutter/new (INSERT) blocks for viewers, /prutter/:id skips markAsRead (UPDATE); WS upgrade rejects viewers (the HTTP guard doesn't cover WebSockets).
  • Clean "Viewer mode" page (viewer-blocked) instead of raw 403 text; styled sticky banner; account page shows read-only UI instead of an upload button that silently 403s. canMutate hides write buttons.

Scalability (>50 artists):

  • Hub home shows max 24 (most active first) + "All N artists ->".
  • New searchable, paginated /artiesten directory (hub only).
  • 'user' + 'artiesten' reserved as slugs.

Rebrand PrutFolio v1 -> Klonkt Hub Beta (footer, PWA manifest, account/
admin texts, default page title, startup, README; internal package +
PWA id 'prutfolio' remain for stability).

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

  • Property mode set to 100644
File size: 12.5 KB
Line 
1<div class="container ax-page">
2
3 <header class="ax-header">
4 <a href="/" class="ax-back" aria-label="Terug naar home">←</a>
5 <div>
6 <h1>Account</h1>
7 <p class="ax-tagline">Profiel en avatar.</p>
8 </div>
9 </header>
10
11 <% if (success) { %><div class="ax-flash ax-flash-ok"><%= success %></div><% } %>
12 <% if (error) { %><div class="ax-flash ax-flash-err"><%= error %></div><% } %>
13
14 <% if (isViewer) { %>
15 <div class="ax-viewer-note" role="note">
16 <span class="ax-viewer-ico" aria-hidden="true">👁️</span>
17 <div>
18 <strong>Kijker-modus</strong>
19 <span>Dit is een demo-account. Je kunt alles bekijken, maar niets wijzigen — ook geen foto of bio.</span>
20 </div>
21 </div>
22 <% } %>
23
24 <%# ── PROFILE ────────────────────────────────────────────── %>
25 <section class="ax-card">
26 <div class="ax-card-title">Profiel</div>
27
28 <div class="ax-profile-id">
29 <% if (canMutate) { %>
30 <form action="/account/avatar" method="post" enctype="multipart/form-data" class="ax-avatar-form">
31 <label class="ax-avatar-wrap" title="Klik om je foto te wijzigen">
32 <span class="ax-profile-avatar">
33 <% if (account.avatar_url) { %>
34 <img src="<%= account.avatar_url %>" alt="">
35 <% } else { %>
36 <span><%= account.username.charAt(0).toUpperCase() %></span>
37 <% } %>
38 </span>
39 <span class="ax-avatar-edit" aria-hidden="true">
40 <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
41 </span>
42 <input type="file" name="avatar" accept="image/jpeg,image/png,image/webp,image/gif" onchange="this.form.submit()" hidden>
43 </label>
44 </form>
45 <% } else { %>
46 <span class="ax-profile-avatar ax-profile-avatar-static">
47 <% if (account.avatar_url) { %>
48 <img src="<%= account.avatar_url %>" alt="">
49 <% } else { %>
50 <span><%= account.username.charAt(0).toUpperCase() %></span>
51 <% } %>
52 </span>
53 <% } %>
54 <div class="ax-profile-meta">
55 <div class="ax-profile-name"><%= account.username %></div>
56 <div class="ax-profile-role"><%= account.role %> · <%= account.email %></div>
57 <% if (account.created_at) { %>
58 <div class="ax-profile-joined">Lid sinds <%= formatDate(account.created_at) %></div>
59 <% } %>
60 <% if (account.avatar_url && canMutate) { %>
61 <form action="/account/avatar/remove" method="post" class="ax-avatar-remove">
62 <button type="submit" class="ax-linkbtn">Foto verwijderen</button>
63 </form>
64 <% } %>
65 </div>
66 </div>
67
68 <% if (canMutate) { %>
69 <form action="/account/profile" method="post" class="ax-form ax-form-bio">
70 <label class="ax-field">
71 <span>Bio</span>
72 <textarea name="bio" rows="3" maxlength="500" placeholder="Een korte regel over jezelf"><%= account.bio || '' %></textarea>
73 </label>
74 <div class="ax-form-actions">
75 <button type="submit" class="ax-btn ax-btn-primary">Bio opslaan</button>
76 </div>
77 </form>
78 <% } else { %>
79 <div class="ax-form ax-form-bio">
80 <label class="ax-field">
81 <span>Bio</span>
82 <textarea rows="3" disabled placeholder="Geen bio"><%= account.bio || '' %></textarea>
83 </label>
84 </div>
85 <% } %>
86 </section>
87
88 <%# ── WACHTWOORD ────────────────────────────────────────── %>
89 <%# In kijker-modus geen wachtwoord-sectie (niets te wijzigen). %>
90 <% if (canMutate) { %>
91 <% if (hasPassword) { %>
92 <section class="ax-card">
93 <div class="ax-card-title">Wachtwoord wijzigen</div>
94 <form action="/account/password" method="post" class="ax-form">
95 <label class="ax-field">
96 <span>Huidig wachtwoord</span>
97 <input type="password" name="current" required autocomplete="current-password">
98 </label>
99 <div class="ax-row ax-row-2">
100 <label class="ax-field">
101 <span>Nieuw wachtwoord <small>(min 8 tekens)</small></span>
102 <input type="password" name="new_password" required minlength="8" autocomplete="new-password">
103 </label>
104 <label class="ax-field">
105 <span>Bevestig nieuw wachtwoord</span>
106 <input type="password" name="confirm" required minlength="8" autocomplete="new-password">
107 </label>
108 </div>
109 <div class="ax-form-actions">
110 <button type="submit" class="ax-btn ax-btn-primary">Wachtwoord wijzigen</button>
111 </div>
112 </form>
113 </section>
114 <% } else { %>
115 <section class="ax-card">
116 <div class="ax-card-title">Inloggen</div>
117 <p class="ax-tagline" style="margin:0">Je bent ingelogd via Google (<%= account.email %>). Er is geen apart wachtwoord.</p>
118 </section>
119 <% } %>
120 <% } %>
121
122</div>
123
124<style>
125.ax-page { max-width: 720px; margin: 1.5rem auto 4rem; padding: 0 1rem; }
126.ax-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 1.5rem; }
127.ax-header h1 { font-family: var(--font-display, serif); font-size: 1.75rem; margin: 0 0 0.25rem; }
128.ax-tagline { color: var(--ink-muted, var(--ink-soft)); margin: 0; font-size: 0.9rem; }
129.ax-back {
130 display: inline-flex; align-items: center; justify-content: center;
131 width: 40px; height: 40px;
132 border: 1px solid var(--rule); border-radius: 8px;
133 background: var(--paper); color: var(--ink); text-decoration: none;
134 font-size: 1.1rem; flex-shrink: 0; transition: border-color 120ms;
135}
136.ax-back:hover { border-color: var(--accent); }
137
138.ax-flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
139.ax-flash-ok { background: rgba(40,160,90,.15); color: #2a9d5e; border: 1px solid rgba(40,160,90,.3); }
140.ax-flash-err { background: rgba(200,60,60,.15); color: #c33; border: 1px solid rgba(200,60,60,.3); }
141
142/* ─── Kijker-modus notice ──────────────────────────────────────── */
143.ax-viewer-note {
144 display: flex; align-items: flex-start; gap: 0.75rem;
145 padding: 0.85rem 1rem; margin-bottom: 1rem;
146 border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
147 border-left: 3px solid var(--accent);
148 border-radius: 10px;
149 background: color-mix(in srgb, var(--accent) 8%, var(--paper));
150}
151.ax-viewer-ico { font-size: 1.1rem; line-height: 1.4; }
152.ax-viewer-note strong { display: block; font-size: 0.92rem; }
153.ax-viewer-note span { color: var(--ink-muted, var(--ink-soft)); font-size: 0.85rem; }
154.ax-profile-avatar-static { flex-shrink: 0; }
155.ax-form-bio textarea:disabled { opacity: 0.7; cursor: default; }
156
157/* ─── Cards ────────────────────────────────────────────────────── */
158.ax-card {
159 background: var(--paper);
160 border: 1px solid var(--rule);
161 border-radius: 12px;
162 padding: 1.25rem;
163 margin-bottom: 1rem;
164}
165.ax-card-title {
166 font-family: var(--font-display, serif);
167 font-size: 1.15rem;
168 font-weight: 600;
169 margin-bottom: 1rem;
170}
171
172/* ─── Form fields ──────────────────────────────────────────────── */
173.ax-form { display: flex; flex-direction: column; gap: 0.85rem; }
174.ax-form-bio { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
175.ax-row { display: grid; gap: 0.85rem; }
176.ax-row-2 { grid-template-columns: 1fr 1fr; }
177@media (max-width: 600px) { .ax-row-2 { grid-template-columns: 1fr; } }
178
179.ax-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
180.ax-field > span {
181 font-size: 0.8rem; font-weight: 600;
182 color: var(--ink-soft);
183 display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap;
184}
185.ax-field > span small { font-weight: 400; color: var(--ink-muted); font-size: 0.95em; }
186.ax-field input[type="text"],
187.ax-field input[type="email"],
188.ax-field input[type="password"],
189.ax-field input[type="url"],
190.ax-field select,
191.ax-field textarea {
192 width: 100%;
193 box-sizing: border-box;
194 padding: 0.6rem 0.75rem;
195 border: 1px solid var(--rule);
196 border-radius: 6px;
197 background: var(--paper-2);
198 color: var(--ink);
199 font-family: var(--font-ui, system-ui), sans-serif;
200 font-size: 0.95rem;
201 -webkit-appearance: none; appearance: none;
202 transition: border-color 120ms;
203}
204.ax-field textarea { resize: vertical; min-height: 70px; font-family: inherit; }
205.ax-field input:focus, .ax-field select:focus, .ax-field textarea:focus {
206 outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
207}
208
209/* ─── File upload ─────────────────────────────────────────────── */
210.ax-file-control {
211 display: flex; align-items: center; gap: 0.5rem;
212 flex-wrap: wrap;
213 position: relative;
214 min-height: 40px;
215}
216.ax-file-control input[type="file"] {
217 position: absolute; inset: 0;
218 opacity: 0; cursor: pointer;
219 z-index: 2;
220}
221.ax-file-btn { pointer-events: none; }
222.ax-file-name {
223 font-size: 0.85rem;
224 color: var(--ink);
225 word-break: break-all;
226 flex: 1; min-width: 0;
227}
228.ax-file-name[data-empty] { color: var(--ink-muted, var(--ink-soft)); }
229
230.ax-form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.25rem; }
231
232/* ─── Buttons ──────────────────────────────────────────────────── */
233.ax-btn {
234 display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
235 padding: 0.55rem 1rem;
236 border: 1px solid var(--rule); background: var(--paper-2);
237 color: var(--ink);
238 font-family: var(--font-ui, system-ui), sans-serif;
239 font-size: 0.9rem; font-weight: 500;
240 text-decoration: none; border-radius: 6px;
241 cursor: pointer; min-height: 40px;
242 transition: background 120ms, border-color 120ms;
243 -webkit-tap-highlight-color: transparent;
244}
245.ax-btn:hover { border-color: var(--accent); }
246.ax-btn-secondary { background: var(--paper-2); }
247.ax-btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
248.ax-btn-primary:hover { opacity: 0.92; border-color: var(--accent); }
249
250/* ─── Profile ID row ──────────────────────────────────────────── */
251.ax-profile-id {
252 display: flex; align-items: center; gap: 1rem;
253 padding-bottom: 1rem;
254 border-bottom: 1px solid var(--rule);
255 margin-bottom: 1rem;
256}
257.ax-avatar-form { margin: 0; flex-shrink: 0; }
258.ax-avatar-wrap {
259 position: relative; display: block;
260 width: 84px; height: 84px; cursor: pointer;
261}
262.ax-profile-avatar {
263 width: 84px; height: 84px;
264 border-radius: 50%;
265 overflow: hidden;
266 background: var(--paper-2); /* neutral so transparent avatars blend */
267 color: var(--accent); /* accent only for the fallback initial */
268 display: inline-flex; align-items: center; justify-content: center;
269 font-family: var(--font-display, serif);
270 font-size: 1.7rem; font-weight: 600;
271 border: 1px solid var(--rule);
272 transition: border-color 120ms;
273}
274.ax-avatar-wrap:hover .ax-profile-avatar { border-color: var(--accent); }
275.ax-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
276.ax-avatar-edit {
277 position: absolute; right: -2px; bottom: -2px;
278 width: 28px; height: 28px; border-radius: 50%;
279 background: var(--accent); color: #fff;
280 display: flex; align-items: center; justify-content: center;
281 border: 3px solid var(--paper);
282 transition: transform 120ms;
283}
284.ax-avatar-wrap:hover .ax-avatar-edit { transform: scale(1.08); }
285.ax-avatar-remove { margin-top: 0.45rem; }
286.ax-linkbtn {
287 background: none; border: 0; padding: 0; cursor: pointer;
288 color: var(--ink-muted, var(--ink-soft)); font-size: 0.8rem; text-decoration: underline;
289 font-family: var(--font-ui, system-ui), sans-serif;
290}
291.ax-linkbtn:hover { color: #c33; }
292.ax-profile-meta { min-width: 0; }
293.ax-profile-name { font-weight: 600; font-size: 1.1rem; }
294.ax-profile-role,
295.ax-profile-joined {
296 color: var(--ink-muted, var(--ink-soft));
297 font-size: 0.85rem;
298}
299
300@media (max-width: 480px) {
301 .ax-profile-id { flex-direction: column; align-items: flex-start; gap: 0.75rem; text-align: left; }
302}
303</style>
Note: See TracBrowser for help on using the repository browser.