source: Klonkt/src/views/pages/account.ejs@ 9b851e7

main
Last change on this file since 9b851e7 was 5e61b17, checked in by roboburr <roboburr@…>, 3 months ago

feat(i18n): admin-configurable language — personal + default for visitors

  • users.lang column: personal interface language per account (follows across devices/sessions). Switcher (/lang/:code) and Account select both write it.
  • app_setting default_lang: admin picks the default language for visitors in Admin → Settings (overrides env/browser; empty = automatic).
  • resolveLang priority: session choice → users.lang → default_lang (DB) → env KLONKT_DEFAULT_LANG → browser → nl.
  • Account: language select; admin-settings: default language select. NL/EN/DE keys.

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

  • Property mode set to 100644
File size: 15.5 KB
Line 
1<div class="container ax-page">
2
3 <header class="ax-header">
4 <a href="/" class="ax-back" aria-label="<%= t('acct.back_home') %>">←</a>
5 <div>
6 <h1><%= t('acct.title') %></h1>
7 <p class="ax-tagline"><%= t('acct.subtitle') %></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><%= t('acct.viewer_mode') %></strong>
19 <span><%= t('acct.viewer_note') %></span>
20 </div>
21 </div>
22 <% } %>
23
24 <%# ── PROFILE ────────────────────────────────────────────── %>
25 <section class="ax-card">
26 <div class="ax-card-title"><%= t('acct.profile') %></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="<%= t('acct.avatar_change') %>">
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"><%= t('acct.member_since') %> <%= 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"><%= t('acct.avatar_remove') %></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><%= t('acct.email') %></span>
72 <input type="email" name="email" value="<%= account.email || '' %>" maxlength="254" autocomplete="email" placeholder="<%= t('acct.email_ph') %>">
73 </label>
74 <label class="ax-field">
75 <span><%= t('acct.bio') %></span>
76 <textarea name="bio" rows="3" maxlength="500" placeholder="<%= t('acct.bio_ph') %>"><%= account.bio || '' %></textarea>
77 </label>
78 <div class="ax-form-actions">
79 <button type="submit" class="ax-btn ax-btn-primary"><%= t('acct.save') %></button>
80 </div>
81 </form>
82 <% } else { %>
83 <div class="ax-form ax-form-bio">
84 <label class="ax-field">
85 <span><%= t('acct.bio') %></span>
86 <textarea rows="3" disabled placeholder="<%= t('acct.bio_empty') %>"><%= account.bio || '' %></textarea>
87 </label>
88 </div>
89 <% } %>
90 </section>
91
92 <%# ── PERSOONLIJKE TAAL ───────────────────────────────────── %>
93 <% if (canMutate) { %>
94 <section class="ax-card">
95 <div class="ax-card-title"><%= t('acct.lang_label') %></div>
96 <form action="/account/lang" method="post" class="ax-form">
97 <label class="ax-field">
98 <span><%= t('acct.lang_label') %> <small><%= t('acct.lang_hint') %></small></span>
99 <select name="lang">
100 <% langs.forEach(function(l){ var sel = (account && account.lang) ? (account.lang === l.code) : l.active; %>
101 <option value="<%= l.code %>"<%= sel ? ' selected' : '' %>><%= l.name %></option>
102 <% }); %>
103 </select>
104 </label>
105 <div class="ax-form-actions">
106 <button type="submit" class="ax-btn ax-btn-primary"><%= t('acct.save') %></button>
107 </div>
108 </form>
109 </section>
110 <% } %>
111
112 <%# ── SITE (eigenaar mag de naam van z'n site aanpassen) ── %>
113 <% if (typeof editableSite !== 'undefined' && editableSite && canMutate) { %>
114 <section class="ax-card">
115 <div class="ax-card-title"><%= t('acct.site') %></div>
116 <form action="/account/site" method="post" class="ax-form">
117 <label class="ax-field">
118 <span><%= t('acct.site_name') %> <small><%= t('acct.site_name_hint') %></small></span>
119 <input type="text" name="site_title" value="<%= editableSite.title || '' %>" maxlength="200" required>
120 </label>
121 <label class="ax-field">
122 <span><%= t('acct.tagline') %> <small><%= t('acct.tagline_hint') %></small></span>
123 <input type="text" name="site_tagline" value="<%= editableSite.tagline || '' %>" maxlength="200">
124 </label>
125 <div class="ax-form-actions">
126 <button type="submit" class="ax-btn ax-btn-primary"><%= t('acct.site_save') %></button>
127 </div>
128 </form>
129 </section>
130 <% } %>
131
132 <%# ── WACHTWOORD ────────────────────────────────────────── %>
133 <%# In kijker-modus geen wachtwoord-sectie (niets te wijzigen). %>
134 <% if (canMutate) { %>
135 <% if (hasPassword) { %>
136 <section class="ax-card">
137 <div class="ax-card-title"><%= t('acct.password_change') %></div>
138 <form action="/account/password" method="post" class="ax-form">
139 <label class="ax-field">
140 <span><%= t('acct.password_current') %></span>
141 <input type="password" name="current" required autocomplete="current-password">
142 </label>
143 <div class="ax-row ax-row-2">
144 <label class="ax-field">
145 <span><%= t('acct.password_new') %> <small><%= t('acct.password_min') %></small></span>
146 <input type="password" name="new_password" required minlength="8" autocomplete="new-password">
147 </label>
148 <label class="ax-field">
149 <span><%= t('acct.password_confirm') %></span>
150 <input type="password" name="confirm" required minlength="8" autocomplete="new-password">
151 </label>
152 </div>
153 <div class="ax-form-actions">
154 <button type="submit" class="ax-btn ax-btn-primary"><%= t('acct.password_change') %></button>
155 </div>
156 </form>
157 </section>
158
159 <% if (typeof googleAvailable !== 'undefined' && googleAvailable) { %>
160 <section class="ax-card">
161 <div class="ax-card-title"><%= t('acct.google_login') %></div>
162 <% if (typeof googleLinked !== 'undefined' && googleLinked) { %>
163 <p class="ax-tagline" style="margin:0 0 1rem"><%= t('acct.google_linked') %></p>
164 <form action="/account/google/unlink" method="post">
165 <button type="submit" class="ax-btn"><%= t('acct.google_unlink') %></button>
166 </form>
167 <% } else { %>
168 <p class="ax-tagline" style="margin:0 0 1rem"><%= t('acct.google_link_hint') %></p>
169 <a href="/auth/google/link" class="ax-btn ax-btn-primary" data-full-load><%= t('acct.google_link') %></a>
170 <% } %>
171 </section>
172 <% } %>
173 <% } else { %>
174 <section class="ax-card">
175 <div class="ax-card-title"><%= t('acct.login') %></div>
176 <p class="ax-tagline" style="margin:0"><%= t('acct.login_google_only', { email: account.email }) %></p>
177 </section>
178 <% } %>
179 <% } %>
180
181</div>
182
183<style>
184.ax-page { max-width: 720px; margin: 1.5rem auto 4rem; padding: 0 1rem; }
185.ax-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 1.5rem; }
186.ax-header h1 { font-family: var(--font-display, serif); font-size: 1.75rem; margin: 0 0 0.25rem; }
187.ax-tagline { color: var(--ink-muted, var(--ink-soft)); margin: 0; font-size: 0.9rem; }
188.ax-back {
189 display: inline-flex; align-items: center; justify-content: center;
190 width: 40px; height: 40px;
191 border: 1px solid var(--rule); border-radius: 8px;
192 background: var(--paper); color: var(--ink); text-decoration: none;
193 font-size: 1.1rem; flex-shrink: 0; transition: border-color 120ms;
194}
195.ax-back:hover { border-color: var(--accent); }
196
197.ax-flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
198.ax-flash-ok { background: rgba(40,160,90,.15); color: #2a9d5e; border: 1px solid rgba(40,160,90,.3); }
199.ax-flash-err { background: rgba(200,60,60,.15); color: #c33; border: 1px solid rgba(200,60,60,.3); }
200
201/* ─── Kijker-modus notice ──────────────────────────────────────── */
202.ax-viewer-note {
203 display: flex; align-items: flex-start; gap: 0.75rem;
204 padding: 0.85rem 1rem; margin-bottom: 1rem;
205 border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
206 border-left: 3px solid var(--accent);
207 border-radius: 10px;
208 background: color-mix(in srgb, var(--accent) 8%, var(--paper));
209}
210.ax-viewer-ico { font-size: 1.1rem; line-height: 1.4; }
211.ax-viewer-note strong { display: block; font-size: 0.92rem; }
212.ax-viewer-note span { color: var(--ink-muted, var(--ink-soft)); font-size: 0.85rem; }
213.ax-profile-avatar-static { flex-shrink: 0; }
214.ax-form-bio textarea:disabled { opacity: 0.7; cursor: default; }
215
216/* ─── Cards ────────────────────────────────────────────────────── */
217.ax-card {
218 background: var(--paper);
219 border: 1px solid var(--rule);
220 border-radius: 12px;
221 padding: 1.25rem;
222 margin-bottom: 1rem;
223}
224.ax-card-title {
225 font-family: var(--font-display, serif);
226 font-size: 1.15rem;
227 font-weight: 600;
228 margin-bottom: 1rem;
229}
230
231/* ─── Form fields ──────────────────────────────────────────────── */
232.ax-form { display: flex; flex-direction: column; gap: 0.85rem; }
233.ax-form-bio { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
234.ax-row { display: grid; gap: 0.85rem; }
235.ax-row-2 { grid-template-columns: 1fr 1fr; }
236@media (max-width: 600px) { .ax-row-2 { grid-template-columns: 1fr; } }
237
238.ax-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
239.ax-field > span {
240 font-size: 0.8rem; font-weight: 600;
241 color: var(--ink-soft);
242 display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap;
243}
244.ax-field > span small { font-weight: 400; color: var(--ink-muted); font-size: 0.95em; }
245.ax-field input[type="text"],
246.ax-field input[type="email"],
247.ax-field input[type="password"],
248.ax-field input[type="url"],
249.ax-field select,
250.ax-field textarea {
251 width: 100%;
252 box-sizing: border-box;
253 padding: 0.6rem 0.75rem;
254 border: 1px solid var(--rule);
255 border-radius: 6px;
256 background: var(--paper-2);
257 color: var(--ink);
258 font-family: var(--font-ui, system-ui), sans-serif;
259 font-size: 0.95rem;
260 -webkit-appearance: none; appearance: none;
261 transition: border-color 120ms;
262}
263.ax-field textarea { resize: vertical; min-height: 70px; font-family: inherit; }
264.ax-field input:focus, .ax-field select:focus, .ax-field textarea:focus {
265 outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
266}
267
268/* ─── File upload ─────────────────────────────────────────────── */
269.ax-file-control {
270 display: flex; align-items: center; gap: 0.5rem;
271 flex-wrap: wrap;
272 position: relative;
273 min-height: 40px;
274}
275.ax-file-control input[type="file"] {
276 position: absolute; inset: 0;
277 opacity: 0; cursor: pointer;
278 z-index: 2;
279}
280.ax-file-btn { pointer-events: none; }
281.ax-file-name {
282 font-size: 0.85rem;
283 color: var(--ink);
284 word-break: break-all;
285 flex: 1; min-width: 0;
286}
287.ax-file-name[data-empty] { color: var(--ink-muted, var(--ink-soft)); }
288
289.ax-form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.25rem; }
290
291/* ─── Buttons ──────────────────────────────────────────────────── */
292.ax-btn {
293 display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
294 padding: 0.55rem 1rem;
295 border: 1px solid var(--rule); background: var(--paper-2);
296 color: var(--ink);
297 font-family: var(--font-ui, system-ui), sans-serif;
298 font-size: 0.9rem; font-weight: 500;
299 text-decoration: none; border-radius: 6px;
300 cursor: pointer; min-height: 40px;
301 transition: background 120ms, border-color 120ms;
302 -webkit-tap-highlight-color: transparent;
303}
304.ax-btn:hover { border-color: var(--accent); }
305.ax-btn-secondary { background: var(--paper-2); }
306.ax-btn-primary, a.ax-btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
307.ax-btn-primary:hover, a.ax-btn-primary:hover { opacity: 0.92; border-color: var(--accent); color: #fff; }
308
309/* ─── Profile ID row ──────────────────────────────────────────── */
310.ax-profile-id {
311 display: flex; align-items: center; gap: 1rem;
312 padding-bottom: 1rem;
313 border-bottom: 1px solid var(--rule);
314 margin-bottom: 1rem;
315}
316.ax-avatar-form { margin: 0; flex-shrink: 0; }
317.ax-avatar-wrap {
318 position: relative; display: block;
319 width: 84px; height: 84px; cursor: pointer;
320}
321.ax-profile-avatar {
322 width: 84px; height: 84px;
323 border-radius: 50%;
324 overflow: hidden;
325 background: var(--paper-2); /* neutral so transparent avatars blend */
326 color: var(--accent); /* accent only for the fallback initial */
327 display: inline-flex; align-items: center; justify-content: center;
328 font-family: var(--font-display, serif);
329 font-size: 1.7rem; font-weight: 600;
330 border: 1px solid var(--rule);
331 transition: border-color 120ms;
332}
333.ax-avatar-wrap:hover .ax-profile-avatar { border-color: var(--accent); }
334.ax-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
335.ax-avatar-edit {
336 position: absolute; right: -2px; bottom: -2px;
337 width: 28px; height: 28px; border-radius: 50%;
338 background: var(--accent); color: #fff;
339 display: flex; align-items: center; justify-content: center;
340 border: 3px solid var(--paper);
341 transition: transform 120ms;
342}
343.ax-avatar-wrap:hover .ax-avatar-edit { transform: scale(1.08); }
344.ax-avatar-remove { margin-top: 0.45rem; }
345.ax-linkbtn {
346 background: none; border: 0; padding: 0; cursor: pointer;
347 color: var(--ink-muted, var(--ink-soft)); font-size: 0.8rem; text-decoration: underline;
348 font-family: var(--font-ui, system-ui), sans-serif;
349}
350.ax-linkbtn:hover { color: #c33; }
351.ax-profile-meta { min-width: 0; }
352.ax-profile-name { font-weight: 600; font-size: 1.1rem; }
353.ax-profile-role,
354.ax-profile-joined {
355 color: var(--ink-muted, var(--ink-soft));
356 font-size: 0.85rem;
357}
358
359@media (max-width: 480px) {
360 .ax-profile-id { flex-direction: column; align-items: flex-start; gap: 0.75rem; text-align: left; }
361}
362</style>
Note: See TracBrowser for help on using the repository browser.