1- var now = new Date()
2include ../mixins/head
3include ../mixins/header
4include ../mixins/footer
5include ../mixins/utils
6doctype html
7html
8 +head(`${paste.title} · ${didHandleMap[paste.authorDid]}`)
9 body
10 main#content
11 +header(ownDid, didHandleMap)
12 h1 #{paste.title}
13 p.post-info
14 | @#{didHandleMap[paste.authorDid]} ·
15 | #{timeDifference(now, Date.parse(paste.createdAt))} ago ·
16 | #{paste.lang} ·
17 | #{paste.code.split('\n').length} loc ·
18 a(href=`/r/${paste.shortUrl}`) raw
19 | ·
20 button#copy-btn(type="button" onclick="copyToClipboard()" data-code=paste.code) copy
21 | ·
22 | #{comments.length} #{pluralize(comments.length, 'comment')}
23 div.highlighted-code !{paste.highlightedCode}
24 hr
25
26 if comments.length != 0
27 h1(id="comments") comments
28 div.comments
29 each comment in comments
30 div.comment(id=`${encodeURIComponent(comment.uri)}`)
31 p.comment-info
32 a(href=`/u/${comment.authorDid}`)
33 | @#{didHandleMap[comment.authorDid]}
34 | ·
35 | #{timeDifference(now, Date.parse(paste.createdAt))} ago
36 pre.comment-body #{comment.body}
37
38 if ownDid
39 form(action=`/${encodeURIComponent(paste.uri)}/comment` method="post").post-form
40 div.post-row
41 textarea#code(name="comment" rows="5" placeholder="add a comment" required).post-input-code
42
43 div.post-submit-row
44 button(type="submit").post-input-submit zonk!
45 else
46 p
47 a(href="/login") login
48 | to post a comment
49
50 +footer()
51 script.
52 async function copyToClipboard() {
53 const copyBtn = document.getElementById('copy-btn');
54 const originalText = copyBtn.textContent;
55
56 try {
57 const code = copyBtn.dataset.code;
58 await navigator.clipboard.writeText(code);
59 copyBtn.textContent = 'copied!';
60 copyBtn.style.color = 'var(--accent)';
61
62 setTimeout(() => {
63 copyBtn.textContent = originalText;
64 copyBtn.style.color = '';
65 }, 1500);
66 } catch (err) {
67 console.error('Failed to copy: ', err);
68 copyBtn.textContent = 'copy failed';
69 setTimeout(() => {
70 copyBtn.textContent = originalText;
71 }, 1500);
72 }
73 }