source: Klonkt/src/views/partials/profile-header.ejs@ f3551ec

main
Last change on this file since f3551ec was 1b99225, checked in by Robin Genis <roboburr@…>, 2 months ago

feat(profile): click avatar -> profile summary modal (contacts, since, premium)

Clicking the profile photo now opens a summary card: enlarged photo, name, premium/free
badge, bio, all profile links (with telegram/phone/whatsapp added to the platform
catalog + tel:/mailto: hrefs), and 'On Klonkt since <date>'. Replaces the bare image
lightbox. New i18n profile.since/profile.free.

  • Property mode set to 100644
File size: 17.4 KB
Line 
1<!-- Profile header (v9 structure)
2 Body class controls collapse:
3 .on-home → full size, avatar + bio + links
4 .on-post → compact, just avatar + name
5 .on-special → compact (archive/search/tag pages)
6 .on-admin → hidden (admin pages don't show profile)
7-->
8
9<%
10// Show profile-header unless we're on an admin page or the site explicitly
11// disabled it via profile_enabled=0.
12const _showProfile = site
13 && (site.profile_enabled === undefined || site.profile_enabled !== 0)
14 && !(typeof bodyClass !== 'undefined' && bodyClass.indexOf('on-admin') >= 0);
15
16// profile_name and profile_bio used to be optional overrides exposed in the
17// admin form. P62 removed those form fields — title and description are the
18// single source of truth. We still consult the override columns first for
19// backward compat with any legacy data, but the form no longer writes them.
20const _displayName = (site && (site.profile_name || site.title)) || '';
21const _bioText = (site && (site.profile_bio || site.description || site.tagline)) || '';
22
23// Parse profile_links JSON column once.
24let _profileLinks = [];
25if (site && site.profile_links) {
26 try { _profileLinks = JSON.parse(site.profile_links) || []; } catch (e) { _profileLinks = []; }
27}
28
29// Profile-summary (lightbox) helpers — used by the avatar + the summary modal.
30const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
31const _avatarUrl = (site && site.profile_photo) || ((typeof siteOwnerAvatar !== 'undefined' && siteOwnerAvatar) || '');
32const _platforms = (typeof platforms_catalog !== 'undefined' && platforms_catalog) || {};
33const _linkHref = function (p, u) { u = String(u || '').trim(); if (p === 'email' && u && u.indexOf('mailto:') !== 0) return 'mailto:' + u; if (p === 'phone' && u && !/^tel:/i.test(u)) return 'tel:' + u.replace(/[^\d+]/g, ''); return u; };
34const _linkVal = function (u) { return String(u || '').replace(/^(mailto:|tel:|https?:\/\/)/i, '').replace(/\/$/, ''); };
35const _isPrem = (typeof isPremium !== 'undefined' && isPremium);
36let _sinceStr = ''; try { if (site && site.created_at) _sinceStr = new Date(site.created_at).toLocaleDateString('nl-NL', { day: '2-digit', month: 'short', year: 'numeric' }); } catch (e) {}
37%>
38
39<% if (_showProfile) { %>
40<aside class="profile-header" aria-label="Site profile">
41 <div class="container profile-header-inner">
42
43 <% if (_avatarUrl) { %>
44 <%# With a real photo: clicking opens the profile-summary modal (photo + details). %>
45 <button type="button" class="profile-photo" data-pf-summary aria-label="<%= _displayName || 'Profile' %>">
46 <img src="<%= _avatarUrl %>" alt="">
47 </button>
48 <% } else { %>
49 <a class="profile-photo" href="<%= _base %>/"
50 hx-get="<%= _base %>/?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
51 hx-push-url="<%= _base %>/" hx-indicator="#pcms-loading" aria-label="Home">
52 <% if (site.enable_audio_player && (typeof audioEnabled === 'undefined' || audioEnabled)) { %>
53 <span class="profile-photo-fallback profile-photo-fallback--music" aria-hidden="true">
54 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
55 <path d="M9 17V5l12-2v12"/>
56 <circle cx="6" cy="17" r="3"/>
57 <circle cx="18" cy="15" r="3"/>
58 </svg>
59 </span>
60 <% } else { %>
61 <span class="profile-photo-fallback" aria-hidden="true"><%= (_displayName || '?').charAt(0).toUpperCase() %></span>
62 <% } %>
63 </a>
64 <% } %>
65
66 <div class="profile-info">
67 <h2 class="profile-name">
68 <a href="<%= (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '' %>/"
69 hx-get="<%= (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '' %>/?partial=1"
70 hx-target="#pcms-main" hx-swap="innerHTML"
71 hx-push-url="<%= (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '' %>/"
72 hx-indicator="#pcms-loading">
73 <%= _displayName %>
74 </a>
75 </h2>
76 <% if (_bioText) { %>
77 <p class="profile-bio"><%= _bioText %></p>
78 <% } %>
79
80 <%# Follow-via-fediverse: a compact icon in the links row (keeps the header
81 short), and hidden for the owner — you don't follow yourself. %>
82 <% var _showFollow = (typeof canManageFedi === 'undefined' || !canManageFedi) && site && site.slug && (typeof apEnabled === 'undefined' || apEnabled); %>
83 <% if (_profileLinks.length || _showFollow) { %>
84 <% const _platforms = (typeof platforms_catalog !== 'undefined' && platforms_catalog) || {}; %>
85 <ul class="profile-links" aria-label="External links">
86 <% _profileLinks.forEach(function(l) {
87 const meta = _platforms[l.platform];
88 if (!meta) return; %>
89 <li>
90 <a class="profile-link profile-link--<%= l.platform %>"
91 href="<%= l.platform === 'email' && l.url.indexOf('mailto:') !== 0 ? ('mailto:' + l.url) : l.url %>"
92 target="<%= l.platform === 'email' ? '_self' : '_blank' %>"
93 rel="noopener noreferrer"
94 aria-label="<%= meta.label %>"
95 title="<%= meta.label %>"
96 style="--brand: <%= meta.brand %>">
97 <%- meta.svg %>
98 </a>
99 </li>
100 <% }); %>
101 <% if (_showFollow) { %>
102 <li style="order:-1">
103 <button type="button" class="profile-link profile-fedi-link" data-fedi-actor-slug="<%= site.slug %>"
104 aria-label="<%= t('fedi.profile_follow') %>" title="<%= t('fedi.profile_follow') %>"><svg viewBox="151 31 530 530" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><g transform="translate(6.6789703,-32.495842)"><path d="M257.1,266.8c-4.9,9.4-12.6,17.1-22.1,22l121.3,121.8l29.2-14.8L257.1,266.8z M417.1,427.4l-29.2,14.8l61.5,61.7c4.9-9.4,12.6-17.1,22.1-22L417.1,427.4z"/><path d="M557.5,315l-68.7,34.8l5.1,32.4l77.7-39.4C564.1,335.2,559.2,325.5,557.5,315z M448.9,370l-162.4,82.3c7.5,7.6,12.4,17.3,14.1,27.8L454,402.4L448.9,370z"/><path d="M396.7,167.3l-78.4,153l23.1,23.2l83-162C414,179.7,404.3,174.7,396.7,167.3z M298,360l-39.7,77.5c10.5,1.8,20.2,6.7,27.7,14.2l35.1-68.5L298,360z"/><path d="M234.3,289.1c-8,4-16.9,5.9-25.8,5.4c-1.7-0.1-3.3-0.3-5-0.5l23.2,148.2c8-4,16.9-5.9,25.8-5.4c1.7,0.1,3.3,0.3,5,0.5L234.3,289.1z"/><path d="M300.8,480.8c0.5,3.4,0.7,6.9,0.5,10.4c-0.4,7.1-2.3,14-5.5,20.4l148.2,23.8c-0.5-3.4-0.7-6.9-0.5-10.4c0.4-7.1,2.3-14,5.5-20.4L300.8,480.8z"/><path d="M572.1,343.3l-68.4,133.6c10.5,1.8,20.2,6.7,27.7,14.2l68.4-133.6C589.4,355.8,579.7,350.8,572.1,343.3z"/><path d="M478.8,154.4c-4.9,9.4-12.6,17.1-22.1,22l105.9,106.4c4.9-9.4,12.6-17.1,22.1-22L478.8,154.4z"/><path d="M382.1,138.9l-133.9,67.9c7.5,7.6,12.4,17.3,14.1,27.8l133.9-67.9C388.7,159.1,383.8,149.4,382.1,138.9z"/><path d="M456.5,176.6c-8.1,4.1-17.1,6.1-26.2,5.6c-1.5-0.1-3-0.3-4.5-0.5l11.9,76l32.4,5.2L456.5,176.6z M444.5,301.8l28.1,179.6c7.9-3.9,16.7-5.7,25.4-5.2c1.8,0.1,3.6,0.3,5.4,0.6L476.8,307L444.5,301.8z"/><path d="M262.4,235.2c0.6,3.5,0.7,7,0.6,10.6c-0.4,7-2.2,13.9-5.4,20.2l76,12.2l14.9-29.2L262.4,235.2z M392.7,256.1l-14.9,29.2l179.6,28.9c-0.5-3.4-0.7-6.9-0.5-10.3c0.4-7.1,2.3-14.1,5.5-20.5L392.7,256.1z"/><circle cx="433" cy="130.6" r="47"/><circle cx="608.4" cy="306.6" r="47"/><circle cx="495.1" cy="527.8" r="47"/><circle cx="249.7" cy="488.4" r="47"/><circle cx="211.3" cy="242.9" r="47"/></g></svg></button>
105 </li>
106 <% } %>
107 </ul>
108 <% } %>
109 </div>
110
111 </div>
112</aside>
113
114<%# Profile-summary modal — opened by clicking the avatar. Shows photo + title + subtitle
115 + contact details + start date + premium status. %>
116<% if (_avatarUrl) { %>
117<div class="pf-summary">
118 <div class="pf-summary-card" role="dialog" aria-label="<%= _displayName %>">
119 <button type="button" class="pf-summary-close" aria-label="Sluiten">&times;</button>
120 <img class="pf-summary-photo" src="<%= _avatarUrl %>" alt="">
121 <h3 class="pf-summary-name"><%= _displayName %></h3>
122 <span class="pf-summary-prem<%= _isPrem ? ' is-prem' : '' %>"><%= _isPrem ? '★ Premium' : t('profile.free') %></span>
123 <% if (_bioText) { %><p class="pf-summary-bio"><%= _bioText %></p><% } %>
124 <% if (_profileLinks.length) { %>
125 <ul class="pf-summary-links">
126 <% _profileLinks.forEach(function (l) { var meta = _platforms[l.platform]; if (!meta) return; var href = _linkHref(l.platform, l.url); var ext = (l.platform !== 'email' && l.platform !== 'phone'); %>
127 <li>
128 <a href="<%= href %>" <% if (ext) { %>target="_blank" rel="noopener noreferrer"<% } %> style="--brand: <%= meta.brand %>">
129 <span class="pf-summary-ico" aria-hidden="true"><%- meta.svg %></span>
130 <span class="pf-summary-rowtext"><span class="pf-summary-lbl"><%= meta.label %></span><span class="pf-summary-val"><%= _linkVal(l.url) %></span></span>
131 </a>
132 </li>
133 <% }); %>
134 </ul>
135 <% } %>
136 <% if (_sinceStr) { %><p class="pf-summary-since"><%= t('profile.since') %> <%= _sinceStr %></p><% } %>
137 </div>
138</div>
139<% } %>
140<script>
141(function () {
142 if (window.__pcmsFediFollowWired) return;
143 window.__pcmsFediFollowWired = true;
144 document.addEventListener('click', function (e) {
145 var b = e.target.closest && e.target.closest('.profile-fedi-link');
146 if (!b) return;
147 var raw = window.prompt(<%- JSON.stringify(t('fedi.remote_prompt')) %>, '');
148 if (!raw) return;
149 // Strip a full @user@host handle (and any scheme/path) down to the server host.
150 var server = raw.trim().replace(/^@?[^@\s]*@/, '').replace(/^https?:\/\//i, '').replace(/\/.*$/, '').trim();
151 if (!server) return;
152 var actor = location.origin + '/ap/users/' + encodeURIComponent(b.getAttribute('data-fedi-actor-slug') || '');
153 location.href = 'https://' + server + '/authorize_interaction?uri=' + encodeURIComponent(actor);
154 });
155})();
156
157/* Profile summary: click the avatar to open a modal with photo + details. */
158(function () {
159 if (window.__pcmsLightboxWired) return; window.__pcmsLightboxWired = true;
160 function close() { var m = document.querySelector('.pf-summary.is-open'); if (m) m.classList.remove('is-open'); }
161 document.addEventListener('click', function (e) {
162 if (e.target.closest && e.target.closest('.pf-summary-close')) { e.preventDefault(); close(); return; }
163 var open = document.querySelector('.pf-summary.is-open');
164 if (open && e.target === open) { close(); return; } /* click on backdrop */
165 var t = e.target.closest && e.target.closest('.profile-photo[data-pf-summary]');
166 if (!t) return;
167 e.preventDefault();
168 var root = (t.closest && t.closest('#pcms-chrome')) || document;
169 var modal = root.querySelector('.pf-summary') || document.querySelector('.pf-summary');
170 if (modal) modal.classList.add('is-open');
171 });
172 document.addEventListener('keydown', function (e) { if (e.key === 'Escape') close(); });
173})();
174</script>
175<% } %>
176
177<style>
178/* Profile header (v9 collapse pattern) */
179.profile-header {
180 border-bottom: 1px solid var(--rule);
181 background: var(--paper);
182 padding: 1.5rem 0;
183 transition: padding 250ms cubic-bezier(.4,0,.2,1);
184}
185.profile-header-inner {
186 max-width: 800px;
187 margin: 0 auto;
188 padding: 0 1rem;
189 display: flex;
190 align-items: center;
191 gap: 1.25rem;
192 transition: gap 250ms;
193}
194.profile-photo {
195 flex-shrink: 0;
196 display: block;
197 width: 80px;
198 height: 80px;
199 padding: 0;
200 border-radius: 50%;
201 overflow: hidden;
202 background: var(--paper-2);
203 border: 2px solid var(--rule);
204 transition: width 250ms, height 250ms;
205 cursor: pointer;
206 font: inherit;
207 -webkit-appearance: none;
208 appearance: none;
209}
210.profile-photo[data-lightbox] { cursor: zoom-in; }
211.profile-photo:hover {
212 border-color: var(--accent);
213}
214.profile-photo img {
215 width: 100%;
216 height: 100%;
217 object-fit: cover;
218 pointer-events: none;
219}
220.profile-photo-fallback {
221 display: flex;
222 align-items: center;
223 justify-content: center;
224 width: 100%;
225 height: 100%;
226 font-family: var(--font-display, serif);
227 font-size: 2rem;
228 font-weight: 700;
229 color: var(--ink-soft);
230 background: var(--paper-2);
231 pointer-events: none;
232}
233.profile-photo-fallback--music {
234 color: var(--accent);
235}
236.profile-photo-fallback--music svg {
237 width: 50%;
238 height: 50%;
239}
240.profile-info {
241 flex: 1;
242 min-width: 0;
243}
244.profile-name {
245 font-family: var(--font-display, serif);
246 font-size: 1.75rem;
247 margin: 0 0 0.25rem;
248 line-height: 1.2;
249}
250.profile-name a {
251 color: var(--ink);
252 text-decoration: none;
253}
254.profile-bio {
255 margin: 0;
256 color: var(--ink-soft);
257 font-size: 0.95rem;
258 line-height: 1.4;
259}
260
261/* Compact mode on post / special pages */
262.on-post .profile-header,
263.on-special .profile-header,
264.on-search .profile-header,
265.on-archive .profile-header {
266 padding: 0.75rem 0;
267}
268.on-post .profile-photo,
269.on-special .profile-photo,
270.on-search .profile-photo,
271.on-archive .profile-photo {
272 width: 40px;
273 height: 40px;
274 border-width: 1px;
275}
276.on-post .profile-photo-fallback,
277.on-special .profile-photo-fallback,
278.on-search .profile-photo-fallback,
279.on-archive .profile-photo-fallback {
280 font-size: 1rem;
281}
282.on-post .profile-name,
283.on-special .profile-name,
284.on-search .profile-name,
285.on-archive .profile-name {
286 font-size: 1.1rem;
287 margin: 0;
288}
289.on-post .profile-bio,
290.on-special .profile-bio,
291.on-search .profile-bio,
292.on-archive .profile-bio {
293 display: none;
294}
295
296/* Hide on admin pages */
297.on-admin .profile-header { display: none; }
298
299/* Mobile tweaks */
300@media (max-width: 600px) {
301 .profile-photo { width: 64px; height: 64px; }
302 .profile-photo-fallback { font-size: 1.5rem; }
303 .profile-name { font-size: 1.4rem; }
304}
305
306/* Social / streaming icon row */
307.profile-links {
308 list-style: none;
309 margin: 0.5rem 0 0;
310 padding: 0;
311 display: flex;
312 gap: 0.5rem;
313 flex-wrap: wrap;
314}
315.profile-link {
316 display: inline-flex;
317 align-items: center;
318 justify-content: center;
319 width: 36px;
320 height: 36px;
321 border-radius: 50%;
322 background: var(--paper-2);
323 color: var(--ink-soft);
324 text-decoration: none;
325 transition: background 120ms, color 120ms, transform 100ms ease;
326}
327.profile-link:hover {
328 background: var(--brand, var(--accent));
329 color: white;
330 transform: translateY(-1px);
331}
332.profile-link svg { width: 18px; height: 18px; display: block; }
333
334/* Compact mode collapses social links too (post pages) */
335.on-post .profile-links,
336.on-special .profile-links,
337.on-archive .profile-links { display: none; }
338
339/* Follow-via-fediverse: compact icon button, sits in the links row */
340.profile-fedi-link { border: 0; padding: 0; background: var(--paper-2); cursor: pointer; -webkit-appearance: none; appearance: none; }
341/* The fediverse logo is an open line-network, so it reads smaller than a solid
342 glyph at 18px — render it larger INSIDE the same 36px circle (circle unchanged). */
343.profile-fedi-link svg { width: 22px; height: 22px; }
344
345/* Profile-summary modal (click the avatar) */
346.profile-photo[data-pf-summary] { cursor: zoom-in; }
347.pf-summary { position: fixed; inset: 0; z-index: 2147483600; display: none;
348 align-items: center; justify-content: center; padding: 4vmin;
349 background: rgba(0,0,0,.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
350.pf-summary.is-open { display: flex; }
351.pf-summary-card { position: relative; width: 100%; max-width: 380px; max-height: 90vh; overflow-y: auto;
352 background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 20px;
353 padding: 1.75rem 1.5rem; box-shadow: 0 20px 60px rgba(0,0,0,.4); text-align: center; }
354.pf-summary-close { position: absolute; top: .6rem; right: .7rem; width: 36px; height: 36px; border: 0;
355 border-radius: 50%; background: var(--paper-2); color: var(--ink-soft); font-size: 1.5rem; line-height: 1;
356 cursor: pointer; display: flex; align-items: center; justify-content: center; }
357.pf-summary-close:hover { color: var(--ink); }
358.pf-summary-photo { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; margin: 0 auto .9rem;
359 display: block; border: 3px solid var(--paper-2); background: #fff; }
360.pf-summary-name { font-family: var(--font-display, serif); font-size: 1.4rem; margin: 0 0 .35rem; }
361.pf-summary-prem { display: inline-block; margin: 0 0 .7rem; padding: .15rem .6rem; border-radius: 999px;
362 font-size: .75rem; font-weight: 600; background: var(--paper-2); color: var(--ink-soft); }
363.pf-summary-prem.is-prem { background: color-mix(in srgb, #e8b04b 22%, transparent); color: #b8860b; }
364.pf-summary-bio { color: var(--ink-soft); font-size: .92rem; line-height: 1.5; margin: 0 0 1rem; }
365.pf-summary-links { list-style: none; padding: 0; margin: .25rem 0 1rem; display: flex; flex-direction: column; gap: .4rem; text-align: left; }
366.pf-summary-links a { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: 12px;
367 text-decoration: none; color: var(--ink); background: var(--paper-2); transition: background .12s; }
368.pf-summary-links a:hover { background: color-mix(in srgb, var(--brand, var(--accent)) 16%, var(--paper-2)); }
369.pf-summary-ico { flex: 0 0 22px; width: 22px; height: 22px; color: var(--brand, var(--ink-soft)); display: inline-flex; }
370.pf-summary-ico svg { width: 22px; height: 22px; }
371.pf-summary-rowtext { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
372.pf-summary-lbl { font-size: .72rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }
373.pf-summary-val { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
374.pf-summary-since { color: var(--ink-soft); font-size: .8rem; margin: 0; }
375</style>
Note: See TracBrowser for help on using the repository browser.