selfhostable, read-only reddit client
1include ../mixins/comment
2include ../mixins/header
3include ../mixins/head
4include ../mixins/postUtils
5include ../utils
6
7- var post = data.post
8- var comments = data.comments
9- var viewQuery = 'view=' + (query && query.view ? query.view : 'compact')
10- var sortQuery = 'sort=' + (query && query.sort ? query.sort + (query.t ? '&t=' + query.t : '') : 'hot')
11doctype html
12html
13 +head(post.title)
14 script.
15 function toggleDetails(details_id) {
16 var detailsElement = document.getElementById(details_id);
17 if (detailsElement) {
18 detailsElement.open = !detailsElement.open;
19 }
20 }
21
22 body
23 main#content
24 +header(user)
25 div.hero
26 h3.sub-title
27 if from
28 a(href=`${from}#${post.id}`) <- back
29 |
30 | ·
31 |
32 a(href=`/r/${post.subreddit}?${sortQuery}&${viewQuery}`) r/#{post.subreddit}
33
34 div.info-container
35 - var domain = (new URL(post.url)).hostname
36 p
37 | #{fmtnum(post.ups)} ↑
38 | · by u/#{post.author}
39 | ·
40 | #{timeDifference(Date.now(), post.created * 1000)}
41 | ·
42 if domain !== 'www.reddit.com'
43 a(href=`${post.url}`) submission url ↗
44 | ·
45 a(href=`https://reddit.com${post.permalink}`) reddit ↗
46
47 h2.post-title
48 != post.title
49
50 div.image-viewer.main-content
51 if isPostGallery(post)
52 div.gallery
53 each item in postGalleryItems(post)
54 div.gallery-item
55 a(href=`/media/${item.url}`)
56 img(src=item.url loading="lazy")
57 div.gallery-item-idx
58 | #{`${item.idx}/${item.total}`}
59 else if isPostImage(post)
60 a(href=`/media/${post.url}`)
61 img(src=post.url).post-media
62 else if isPostVideo(post)
63 - var url = post.secure_media.reddit_video.dash_url
64 video(controls data-dashjs-player src=`${url}`).post-media
65 else if isPostLink(post)
66 a(href=post.url)
67 | #{post.url}
68
69 if post.selftext_html
70 div.self-text
71 != convertInlineImageLinks(post.selftext_html)
72
73 hr
74
75 div.comments-container
76 - var total = comments.length
77 each child, index in comments
78 - var next_idx = index + 1
79 - var prev_idx = index - 1
80 - var next_com = next_idx < total ? comments[next_idx] : null
81 - var prev_com = prev_idx >= 0 ? comments[prev_idx] : null
82 - var next_id = next_com ? next_com.data.id : null
83 - var prev_id = prev_com ? prev_com.data.id : null
84 +comment(child, true, post.id, next_id, prev_id)