diff options
Diffstat (limited to 'src/mixins')
-rw-r--r-- | src/mixins/comment.pug | 49 | ||||
-rw-r--r-- | src/mixins/post.pug | 8 |
2 files changed, 37 insertions, 20 deletions
diff --git a/src/mixins/comment.pug b/src/mixins/comment.pug index 2ec076f..3af1f53 100644 --- a/src/mixins/comment.pug +++ b/src/mixins/comment.pug | |||
@@ -1,24 +1,41 @@ | |||
1 | include ../utils | 1 | include ../utils |
2 | |||
3 | mixin infoContainer(data) | ||
4 | div.comment-info-container | ||
5 | div.info-item #{fmtnum(data.ups)} ↑ | ||
6 | div.info-item u/#{data.author} #{data.is_submitter ? '(OP)' : ''} | ||
7 | if data.collapsed_reason_code == "DELETED" | ||
8 | div.info-item | ||
9 | a(href=`https://undelete.pullpush.io${data.permalink}`) search on undelete | ||
10 | div.info-item #{timeDifference(Date.now(), data.created * 1000)} | ||
11 | |||
12 | - | ||
13 | function hasReplies(data) { | ||
14 | return data.replies && data.replies.data && data.replies.data.children && data.replies.data.children.length > 0; | ||
15 | } | ||
16 | |||
2 | mixin comment(com, isfirst) | 17 | mixin comment(com, isfirst) |
3 | - var data = com.data | 18 | - var data = com.data |
4 | - var kind = com.kind | 19 | - var kind = com.kind |
20 | - var hasReplyData = hasReplies(data) | ||
21 | |||
5 | if kind == "more" | 22 | if kind == "more" |
6 | div(class=`${isfirst?'first':''}`) | 23 | div(class=`${isfirst ? 'first' : ''}`) |
7 | div.more #{data.count} more comments | 24 | div.more #{data.count} more comments |
8 | else | 25 | else |
9 | div(class=`comment ${isfirst?'first':''}`) | 26 | div(class=`comment ${isfirst ? 'first' : ''}`) |
10 | div.comment-info-container | 27 | if hasReplyData |
11 | div.info-item #{fmtnum(data.ups)} ↑ | 28 | details(id=`${data.id}` open="") |
12 | div.info-item u/#{data.author} #{data.is_submitter?'(OP)':''} | 29 | summary.expand-comments |
13 | if data.collapsed_reason_code == "DELETED" | 30 | +infoContainer(data) |
14 | div.info-item | 31 | div.comment-body |
15 | a(href=`https://undelete.pullpush.io${data.permalink}`) search on undelete | 32 | != data.body_html |
16 | div.info-item #{timeDifference(Date.now(), data.created * 1000)} | 33 | |
17 | div.comment-body | 34 | div.replies |
18 | != data.body_html | ||
19 | div.replies | ||
20 | if data.replies | ||
21 | if data.replies.data | ||
22 | if data.replies.data.children | ||
23 | each reply in data.replies.data.children | 35 | each reply in data.replies.data.children |
24 | +comment(reply,false) | 36 | +comment(reply, false) |
37 | |||
38 | else | ||
39 | +infoContainer(data) | ||
40 | div.comment-body | ||
41 | != data.body_html | ||
diff --git a/src/mixins/post.pug b/src/mixins/post.pug index 287c422..23eb19f 100644 --- a/src/mixins/post.pug +++ b/src/mixins/post.pug | |||
@@ -40,7 +40,7 @@ mixin post(p) | |||
40 | if p.gallery_data | 40 | if p.gallery_data |
41 | if p.gallery_data.items | 41 | if p.gallery_data.items |
42 | details(id=`${p.id}`) | 42 | details(id=`${p.id}`) |
43 | summary expand gallery | 43 | summary.expand-post expand gallery |
44 | div.gallery | 44 | div.gallery |
45 | - var total = p.gallery_data.items.length | 45 | - var total = p.gallery_data.items.length |
46 | - var idx = 0 | 46 | - var idx = 0 |
@@ -58,19 +58,19 @@ mixin post(p) | |||
58 | button(onclick=`toggleDetails('${p.id}')`) close | 58 | button(onclick=`toggleDetails('${p.id}')`) close |
59 | if p.post_hint == "image" && p.thumbnail && p.thumbnail != "self" && p.thumbnail != "default" | 59 | if p.post_hint == "image" && p.thumbnail && p.thumbnail != "self" && p.thumbnail != "default" |
60 | details(id=`${p.id}`) | 60 | details(id=`${p.id}`) |
61 | summary expand image | 61 | summary.expand-post expand image |
62 | a(href=`/media/${p.url}`) | 62 | a(href=`/media/${p.url}`) |
63 | img(src=p.url loading="lazy").post-media | 63 | img(src=p.url loading="lazy").post-media |
64 | button(onclick=`toggleDetails('${p.id}')`) close | 64 | button(onclick=`toggleDetails('${p.id}')`) close |
65 | else if p.post_hint == "hosted:video" | 65 | else if p.post_hint == "hosted:video" |
66 | details(id=`${p.id}`) | 66 | details(id=`${p.id}`) |
67 | summary expand video | 67 | summary.expand-post expand video |
68 | - var url = p.secure_media.reddit_video.dash_url | 68 | - var url = p.secure_media.reddit_video.dash_url |
69 | video(src=url controls data-dashjs-player loading="lazy").post-media | 69 | video(src=url controls data-dashjs-player loading="lazy").post-media |
70 | button(onclick=`toggleDetails('${p.id}')`) close | 70 | button(onclick=`toggleDetails('${p.id}')`) close |
71 | else if !p.post_hint || (p.post_hint == "link" && p.thumbnail && p.thumbnail != "self" && p.thumbnail != "default") | 71 | else if !p.post_hint || (p.post_hint == "link" && p.thumbnail && p.thumbnail != "self" && p.thumbnail != "default") |
72 | details(id=`${p.id}`) | 72 | details(id=`${p.id}`) |
73 | summary expand link | 73 | summary.expand-post expand link |
74 | a(href=`${p.url}`) | 74 | a(href=`${p.url}`) |
75 | | #{p.url} | 75 | | #{p.url} |
76 | br | 76 | br |