source: Klonkt/src/views/pages/post.ejs@ b2c3699

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

Remove dead .post-like-row CSS (the element is gone)

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

  • Property mode set to 100644
File size: 19.8 KB
RevLine 
[b94c08e]1<%
[834bcc3]2// In hub mode the site is accessible under /user/<slug>; all site-scoped links
3// (tag, edit, delete, comments) must carry that prefix otherwise they fall back
4// to the primary site → 404 / wrong site. In solo mode _base = ''.
[b94c08e]5const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
6%>
[7bc636b]7<article class="container post-page">
[74544fb]8
[834bcc3]9 <%# Navigation across ALL posts — ABOVE the post (shared partial). %>
[1e2e9e7]10 <%- include('../partials/post-nav', { newerPost: newerPost, olderPost: olderPost }) %>
[74544fb]11
[7bc636b]12 <% if (post.cover_image_url) { %>
13 <figure class="post-cover">
14 <img src="<%= post.cover_image_url %>" alt="">
15 </figure>
16 <% } %>
17
18 <header class="post-header">
19 <h1 class="post-title"><%= post.title %></h1>
20 <div class="post-meta">
21 <a class="author" href="/users/<%= encodeURIComponent(post.author_username) %>"
22 hx-get="/users/<%= encodeURIComponent(post.author_username) %>?partial=1"
23 hx-target="#pcms-main" hx-swap="innerHTML"
24 hx-push-url="/users/<%= encodeURIComponent(post.author_username) %>"
25 hx-indicator="#pcms-loading"><%= post.author_username %></a>
26 <span class="meta-sep">·</span>
27 <time datetime="<%= post.published_at || post.created_at %>"><%= formatDate(post.published_at || post.created_at) %></time>
28 <% if (post.status !== 'published') { %>
29 <span class="meta-sep">·</span>
30 <span class="status-badge status-<%= post.status %>"><%= post.status %></span>
31 <% } %>
32 </div>
33 </header>
34
35 <div class="post-content">
36 <%- post.content_html %>
37 </div>
38
39 <% if (post.tags && post.tags.length > 0) { %>
40 <div class="post-tags">
41 <% post.tags.forEach(t => { %>
[b94c08e]42 <a class="tag" href="<%= _base %>/tag/<%= encodeURIComponent(t) %>"
43 hx-get="<%= _base %>/tag/<%= encodeURIComponent(t) %>?partial=1"
[7bc636b]44 hx-target="#pcms-main" hx-swap="innerHTML"
[b94c08e]45 hx-push-url="<%= _base %>/tag/<%= encodeURIComponent(t) %>"
[7bc636b]46 hx-indicator="#pcms-loading">#<%= t %></a>
47 <% }); %>
48 </div>
49 <% } %>
50
51 <!-- Inline admin actions: only visible if user has permission -->
52 <% if (user && (permissions.canEditPost(user, post, site) || permissions.canDeletePost(user, post, site))) { %>
53 <aside class="post-actions">
54 <% if (permissions.canEditPost(user, post, site)) { %>
[b94c08e]55 <a href="<%= _base %>/posts/<%= post.slug %>/edit" class="btn"
56 hx-get="<%= _base %>/posts/<%= post.slug %>/edit?partial=1" hx-target="#pcms-main"
57 hx-push-url="<%= _base %>/posts/<%= post.slug %>/edit" hx-indicator="#pcms-loading">
[7bc636b]58 ✏️ Edit
59 </a>
60 <% } %>
61 <% if (permissions.canDeletePost(user, post, site)) { %>
[b94c08e]62 <form method="post" action="<%= _base %>/posts/<%= post.slug %>/delete" style="display:inline" onsubmit="return confirm('Delete this post?')">
[7bc636b]63 <button type="submit" class="btn btn-danger">🗑 Delete</button>
64 </form>
65 <% } %>
66 </aside>
67 <% } %>
68
[aadb11e]69 <!-- Fediverse interactions — single place: ⭐ like (clickable) + 🔁/💬 counts + reply -->
70 <% var _postAbsUrl = (typeof ogOrigin !== 'undefined' && ogOrigin ? ogOrigin : '') + (typeof _base !== 'undefined' && _base ? _base : '') + '/' + post.slug; %>
71 <% var _fedi = (typeof fediverse !== 'undefined' && fediverse) ? fediverse : { thread: [], likeCount: 0, announceCount: 0 }; %>
72 <% if (post.status === 'published') { %>
[3a2c9d3]73 <section class="post-fediverse post-comments" id="fediverse">
74 <h2 class="comments-heading"><%= t('fedi.heading') %></h2>
[c16e0a5]75 <p class="fedi-stats">
[aadb11e]76 <button type="button" class="fedi-stat-btn fedi-remote-reply-btn" data-fedi-uri="<%= _postAbsUrl %>" data-fedi-ph="<%= t('fedi.remote_ph') %>" title="<%= t('like.fedi_title') %>">⭐ <%= _fedi.likeCount %></button>
77 <span title="<%= t('fedi.boosts') %>">🔁 <%= _fedi.announceCount %></span>
78 <span title="<%= t('fedi.replies') %>">💬 <%= (_fedi.thread || []).length %></span>
[c16e0a5]79 </p>
[aadb11e]80 <% if (_fedi.thread && _fedi.thread.length) { %>
[3a2c9d3]81 <ol class="comments-list">
[aadb11e]82 <% _fedi.thread.forEach(function(n){ %>
[a885afc]83 <li class="comment"><%- include('../partials/fedi-node', { n: n, t: t, canManageSite: (typeof canManageSite !== 'undefined' ? canManageSite : false), _base: _base, siteAvatar: (typeof siteAvatar !== 'undefined' ? siteAvatar : null), formatDateTime: formatDateTime }) %></li>
[c16e0a5]84 <% }); %>
[3a2c9d3]85 </ol>
[c16e0a5]86 <% } %>
[aadb11e]87 <div class="post-fediverse-cta">
88 <button type="button" class="btn fedi-remote-reply-btn" data-fedi-uri="<%= _postAbsUrl %>" data-fedi-ph="<%= t('fedi.remote_ph') %>">
89 <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 17 4 12 9 7"/><path d="M20 18v-2a4 4 0 0 0-4-4H4"/></svg>
90 <%= t('fedi.remote_reply') %>
91 </button>
92 </div>
[c16e0a5]93 </section>
94 <% } %>
[594cc50]95 <script>
96 (function(){
97 if (window.__fediRemoteWired) return; window.__fediRemoteWired = true;
[0dba092]98 var current = null, currentBtn = null;
99 function close(){ if (current) { current.remove(); current = null; currentBtn = null; } }
[40cf2ef]100 function go(raw, uri){
101 var d = (raw||'').trim().replace(/^@?[^@\s]*@/, '').replace(/^https?:\/\//i, '').replace(/\/.*$/, '').trim();
102 if (d) location.href = 'https://' + d + '/authorize_interaction?uri=' + encodeURIComponent(uri||'');
103 }
[0dba092]104 function place(f, b){
105 var r = b.getBoundingClientRect();
106 f.style.top = (r.bottom + window.scrollY + 6) + 'px';
107 f.style.left = Math.max(8, Math.min(r.left + window.scrollX, window.scrollX + window.innerWidth - 340)) + 'px';
108 }
[594cc50]109 document.addEventListener('click', function(e){
[0dba092]110 if (e.target.closest && e.target.closest('.fedi-remote-cancel')) { close(); return; }
111 if (current && e.target.closest && e.target.closest('.fedi-remote-form')) return; // click inside → keep
[594cc50]112 var b = e.target.closest && e.target.closest('.fedi-remote-reply-btn');
[0dba092]113 if (b) {
114 e.preventDefault();
115 if (currentBtn === b) { close(); return; } // toggle off
116 close();
117 var f = document.createElement('form');
118 f.className = 'fedi-remote-form';
119 f.dataset.uri = b.getAttribute('data-fedi-uri') || '';
120 f.innerHTML = '<input type="text" autocomplete="off" spellcheck="false">'
121 + '<button type="submit" class="btn btn-primary fedi-remote-go" aria-label="ok">&rarr;</button>'
122 + '<button type="button" class="fedi-remote-cancel" aria-label="x">&times;</button>';
[f6c414e]123 f.querySelector('input').placeholder = b.getAttribute('data-fedi-ph') || 'mastodon.social';
[0dba092]124 document.body.appendChild(f); // floating popover → no layout reflow
125 place(f, b); current = f; currentBtn = b;
126 f.querySelector('input').focus();
127 return;
128 }
129 if (current) close(); // click anywhere else closes it
[40cf2ef]130 });
131 document.addEventListener('submit', function(e){
132 var f = e.target.closest && e.target.closest('.fedi-remote-form');
[0dba092]133 if (!f) return; e.preventDefault();
[40cf2ef]134 go(f.querySelector('input').value, f.dataset.uri);
[594cc50]135 });
[0dba092]136 document.addEventListener('keydown', function(e){ if (e.key === 'Escape') close(); });
137 window.addEventListener('scroll', close, true);
[594cc50]138 })();
139 </script>
[3d7312a]140
[7bc636b]141
142 <%# ── Related posts (3-card grid) ─────────────────────────────
143 Always shown if at least one related post exists. Selection logic
144 lives server-side: same-tag posts ranked by overlap, falling back
145 to most-recent if there's no tag overlap. %>
146 <% if (relatedPosts && relatedPosts.length > 0) { %>
147 <section class="post-related" aria-labelledby="related-heading">
[fe86013]148 <h2 class="post-related-heading" id="related-heading"><%= t('related.title') %></h2>
[7bc636b]149 <ul class="post-related-grid">
150 <% relatedPosts.forEach(function(rp) { %>
151 <li class="post-related-card">
[d54dade]152 <a href="<%= rp._urlBase || '' %>/<%= rp.slug %>"<% if (!rp._urlBase) { %>
[7bc636b]153 hx-get="/<%= rp.slug %>?partial=1" hx-target="#pcms-main"
[d54dade]154 hx-push-url="/<%= rp.slug %>" hx-indicator="#pcms-loading"<% } %>>
[7bc636b]155 <% if (rp.cover_image_url) { %>
156 <span class="post-related-cover"
157 style="background-image: url('<%= rp.cover_image_url %>')"
158 aria-hidden="true"></span>
159 <% } else { %>
160 <span class="post-related-cover post-related-cover--empty" aria-hidden="true"></span>
161 <% } %>
162 <span class="post-related-meta">
163 <span class="post-related-date"><%= formatDate(rp.published_at) %></span>
164 <span class="post-related-title"><%= rp.title %></span>
165 </span>
166 </a>
167 </li>
168 <% }); %>
169 </ul>
170 </section>
171 <% } %>
172
173</article>
174<style>
[8e29f77]175.post-page { max-width: 720px; margin: 0.5rem auto 2rem; padding: 0 1rem; }
[7bc636b]176.post-cover { margin: 0 0 2rem; border-radius: 8px; overflow: hidden; }
177.post-cover img { width: 100%; height: auto; display: block; }
178.post-header { margin-bottom: 2rem; }
179.post-title { font-family: var(--font-display, serif); font-size: 2.5rem; line-height: 1.1; margin: 0 0 1rem; }
180@media (max-width: 600px) { .post-title { font-size: 1.85rem; } }
181.post-meta { font-size: 0.9rem; color: var(--ink-muted); }
182.author { font-weight: 500; color: var(--ink-soft); text-decoration: none; }
183.author:hover { color: var(--accent); }
184.post-content { font-family: var(--font-body, serif); font-size: 1.1rem; line-height: 1.7; color: var(--ink); }
185.post-content p { margin: 1.2em 0; }
[535f955]186.like-btn {
187 display: inline-flex; align-items: center; gap: 0.45rem;
188 padding: 0.4rem 0.85rem; border: 1px solid var(--rule); border-radius: 999px;
189 background: var(--paper-2); color: var(--ink); font: inherit; font-size: 0.95rem;
190 cursor: pointer; text-decoration: none; transition: border-color 120ms, color 120ms, background 120ms;
191}
192.like-btn:hover { border-color: var(--accent); }
193.like-btn .like-heart { font-size: 1.1rem; line-height: 1; }
194.like-btn.is-liked { border-color: var(--accent); color: var(--accent); }
195.like-btn.is-liked .like-heart { color: var(--accent); }
196.like-btn .like-count { font-variant-numeric: tabular-nums; }
[7bc636b]197.post-content h2 { font-family: var(--font-display, serif); font-size: 1.6rem; margin: 2rem 0 1rem; }
198.post-content h3 { font-family: var(--font-display, serif); font-size: 1.3rem; margin: 1.5rem 0 0.75rem; }
199.post-content a { color: var(--accent); }
200.post-content code { background: var(--paper-2); padding: 0.1em 0.4em; border-radius: 3px; font-family: var(--font-mono, monospace); font-size: 0.9em; }
201.post-content pre { background: var(--paper-2); padding: 1rem; border-radius: 6px; overflow-x: auto; }
202.post-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1.5rem 0; color: var(--ink-soft); font-style: italic; }
203.post-content img { max-width: 100%; height: auto; border-radius: 6px; }
204.post-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 2rem 0; }
205.tag { background: var(--paper-2); color: var(--ink-soft); padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.85rem; text-decoration: none; transition: background 120ms, color 120ms; }
206.tag:hover { background: var(--accent); color: white; }
207.post-actions { display: flex; gap: 0.5rem; margin: 2rem 0; padding: 1rem; background: var(--paper-2); border-radius: 6px; flex-wrap: wrap; }
208
209/* ============================================================
210 Comments
211 ============================================================ */
212.post-comments {
213 margin-top: 3rem;
214 padding-top: 2rem;
215 border-top: 1px solid var(--rule);
216}
217.comments-heading {
218 font-family: var(--font-display, serif);
219 font-size: 1.5rem;
220 margin: 0 0 1.5rem;
221}
222.comments-empty { color: var(--ink-muted, var(--ink-soft)); margin: 0 0 1.5rem; }
223.comments-pending-flash {
224 background: rgba(40, 160, 90, 0.15);
225 color: #2a9d5e;
226 border: 1px solid rgba(40, 160, 90, 0.3);
227 padding: 0.75rem 1rem;
228 border-radius: 6px;
229 margin-bottom: 1rem;
230 font-size: 0.9rem;
231}
232.comments-empty a { color: var(--accent); }
233
234.comments-list, .comment-replies {
235 list-style: none;
236 padding: 0;
237 margin: 0 0 2rem;
238}
239
240.comment {
241 display: flex;
242 gap: 0.85rem;
243 padding: 1rem 0;
244 border-top: 1px solid var(--rule);
245}
246.comments-list > .comment:first-child { border-top: 0; padding-top: 0; }
247
248.comment-avatar {
249 flex-shrink: 0;
250 width: 40px;
251 height: 40px;
252 border-radius: 50%;
253 background: var(--paper-2);
254 border: 1px solid var(--rule);
255 overflow: hidden;
256 display: inline-flex;
257 align-items: center;
258 justify-content: center;
259}
260.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
261.comment-avatar span {
262 font-family: var(--font-display, serif);
263 font-weight: 700;
264 color: var(--accent);
265}
266
267.comment-body { flex: 1; min-width: 0; }
268.comment-meta {
269 display: flex;
270 gap: 0.5rem;
271 align-items: baseline;
272 font-size: 0.85rem;
273 margin-bottom: 0.3rem;
274}
275.comment-author { color: var(--ink); font-weight: 600; text-decoration: none; }
276.comment-author:hover { color: var(--accent); }
277.comment-time { color: var(--ink-muted, var(--ink-soft)); }
278.comment-content {
279 white-space: pre-wrap;
280 word-wrap: break-word;
281 color: var(--ink);
282 line-height: 1.5;
283 font-size: 0.95rem;
284}
285
286.comment-actions {
287 display: flex;
288 gap: 0.5rem;
289 margin-top: 0.4rem;
290}
291.comment-reply-btn, .comment-delete-btn {
292 background: none;
293 border: 0;
294 color: var(--ink-muted, var(--ink-soft));
295 font-size: 0.8rem;
296 cursor: pointer;
297 padding: 0.2rem 0;
298 font-family: inherit;
299 text-transform: uppercase;
300 letter-spacing: 0.04em;
301}
302.comment-reply-btn:hover { color: var(--accent); }
303.comment-delete-btn:hover { color: #c33; }
304
305.comment-replies {
306 margin-top: 1rem;
307 margin-left: 0;
308 border-left: 2px solid var(--rule);
309 padding-left: 1rem;
310}
311.comment-reply { padding: 0.75rem 0; }
312.comment-replies > .comment-reply:first-child { border-top: 0; padding-top: 0; }
313.comment-reply .comment-avatar { width: 32px; height: 32px; }
314.comment-reply .comment-avatar span { font-size: 0.85rem; }
315
316.comment-form, .comment-reply-form {
317 display: flex;
318 flex-direction: column;
319 gap: 0.6rem;
320 background: var(--paper-2);
321 border: 1px solid var(--rule);
322 border-radius: 8px;
323 padding: 1rem;
324 margin-top: 1rem;
325}
326.comment-form-label { display: flex; flex-direction: column; gap: 0.4rem; }
327.comment-form-label > span { font-size: 0.85rem; color: var(--ink-muted, var(--ink-soft)); }
328.comment-form textarea, .comment-reply-form textarea {
329 width: 100%;
330 resize: vertical;
331 min-height: 70px;
332 padding: 0.65rem 0.85rem;
333 border: 1px solid var(--rule);
334 border-radius: 5px;
335 background: var(--paper);
336 color: var(--ink);
337 font-family: inherit;
338 font-size: 0.95rem;
339 line-height: 1.4;
340 box-sizing: border-box;
341}
342.comment-form button { align-self: flex-start; }
343.comment-reply-form-actions { display: flex; gap: 0.5rem; }
[834bcc3]344/* Show the reply form only AFTER clicking REPLY. The display:flex above would
345 otherwise override the [hidden] attribute → form was always open. */
[e25438a]346.comment-reply-form[hidden] { display: none; }
[834bcc3]347/* DELETE button is inside a <form>; display:contents makes it a direct flex-sibling
348 of REPLY → pixel-perfect alignment + equal gap. */
[e25438a]349.comment-actions form { display: contents; }
[7bc636b]350
351.comments-login-cta { margin-top: 1.5rem; text-align: center; }
352
353/* ─── Related posts (3-card grid above pinned-nav) ─────────────── */
354.post-related {
355 margin: 3rem auto 1.5rem;
356 /* Break out of the 720px article column so the cards have room to breathe.
357 Cap at 1100 to match other wide content. */
358 max-width: 1100px;
359 padding: 0 1rem;
360}
361.post-related-heading {
362 font-family: var(--font-ui, system-ui), sans-serif;
363 font-size: 0.75rem;
364 font-weight: 600;
365 text-transform: uppercase;
366 letter-spacing: 0.15em;
367 color: var(--ink-muted, var(--ink-soft));
368 margin: 0 0 1rem;
369}
370.post-related-grid {
371 list-style: none;
372 padding: 0; margin: 0;
373 display: grid;
374 grid-template-columns: repeat(3, minmax(0, 1fr));
375 gap: 1rem;
376}
377@media (max-width: 880px) { .post-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
378@media (max-width: 540px) { .post-related-grid { grid-template-columns: 1fr; } }
379
380.post-related-card {
381 background: var(--paper);
382 border: 1px solid var(--rule);
383 border-radius: 10px;
384 overflow: hidden;
385 transition: border-color 150ms, transform 150ms;
386}
387.post-related-card:hover { border-color: var(--accent); transform: translateY(-2px); }
388.post-related-card a {
389 display: block;
390 color: inherit;
391 text-decoration: none;
392}
393.post-related-cover {
394 display: block;
395 aspect-ratio: 16 / 10;
396 background: var(--paper-2) center/cover no-repeat;
397}
398.post-related-cover--empty {
399 background-image: linear-gradient(135deg,
400 color-mix(in srgb, var(--accent) 12%, var(--paper-2)),
401 var(--paper-2));
402}
403.post-related-meta {
404 display: flex; flex-direction: column; gap: 0.4rem;
405 padding: 0.85rem 1rem 1.1rem;
406}
407.post-related-date {
408 font-size: 0.78rem;
409 color: var(--ink-muted, var(--ink-soft));
410 font-variant-numeric: tabular-nums;
411}
412.post-related-title {
413 font-family: var(--font-display, serif);
414 font-size: 1.1rem;
415 font-weight: 600;
416 color: var(--ink);
417 line-height: 1.25;
418}
419
420/* ─── Pinned navigation cards (v9 style) ───────────────────────── */
421.post-pinned-nav {
422 display: grid;
423 grid-template-columns: 1fr 1fr;
424 gap: 1rem;
425 margin: 1.5rem auto 2rem;
426 max-width: 1100px;
427 padding: 0 1rem;
428}
429@media (max-width: 600px) {
430 .post-pinned-nav { grid-template-columns: 1fr; }
431}
432
433.post-pinned-card {
434 display: flex; align-items: center; gap: 1rem;
435 padding: 1rem 1.25rem;
436 border: 1.5px solid color-mix(in srgb, var(--accent) 50%, transparent);
437 background: color-mix(in srgb, var(--accent) 6%, var(--paper));
438 border-radius: 10px;
439 text-decoration: none;
440 color: var(--ink);
441 transition: border-color 150ms, background 150ms, transform 150ms;
442 min-height: 88px;
443}
444.post-pinned-card:hover {
445 border-color: var(--accent);
446 background: color-mix(in srgb, var(--accent) 11%, var(--paper));
447 transform: translateY(-2px);
448}
449.post-pinned-arrow {
450 font-size: 1.6rem;
451 color: var(--accent);
452 flex-shrink: 0;
453 line-height: 1;
454}
455.post-pinned-card--next {
456 /* "Volgende" card aligns text to the right with the arrow on the right
457 side, mirroring v9 — the arrow is on the OPPOSITE end from the body. */
458 flex-direction: row-reverse;
459 text-align: right;
460}
461.post-pinned-body {
462 display: flex; flex-direction: column; gap: 0.25rem;
463 flex: 1; min-width: 0;
464}
465.post-pinned-label {
466 font-family: var(--font-ui, system-ui), sans-serif;
467 font-size: 0.7rem; font-weight: 600;
468 text-transform: uppercase;
469 letter-spacing: 0.1em;
470 color: var(--accent);
471}
472.post-pinned-title {
473 font-family: var(--font-display, serif);
474 font-size: 1.05rem; font-weight: 600;
475 color: var(--ink);
476 line-height: 1.25;
477 overflow: hidden;
478 text-overflow: ellipsis;
479 display: -webkit-box;
480 -webkit-line-clamp: 2;
481 -webkit-box-orient: vertical;
482}
483.post-pinned-cta {
484 font-size: 0.78rem;
485 color: var(--accent);
486 font-weight: 500;
487}
488
489/* Edge-of-stack indicator: dashed border, muted styling. */
490.post-pinned-card--edge {
491 flex-direction: column;
492 align-items: flex-start;
493 justify-content: center;
494 gap: 0.35rem;
495 border-style: dashed;
496 background: transparent;
497 color: var(--ink-muted, var(--ink-soft));
498 cursor: default;
499}
500.post-pinned-card--edge:hover {
501 /* Edge cards aren't clickable — undo the lift effect. */
502 transform: none;
503 border-color: color-mix(in srgb, var(--accent) 50%, transparent);
504 background: transparent;
505}
506.post-pinned-edge-label {
507 font-family: var(--font-ui, system-ui), sans-serif;
508 font-size: 0.72rem;
509 font-weight: 600;
510 text-transform: uppercase;
511 letter-spacing: 0.15em;
512 color: var(--accent);
513}
514.post-pinned-edge-title {
515 font-family: var(--font-display, serif);
516 font-size: 1.05rem;
517 font-weight: 600;
518 color: var(--ink);
519}
520</style>
Note: See TracBrowser for help on using the repository browser.