aboutsummaryrefslogtreecommitdiff
path: root/src/mixins/comment.pug
diff options
context:
space:
mode:
Diffstat (limited to 'src/mixins/comment.pug')
-rw-r--r--src/mixins/comment.pug49
1 files changed, 33 insertions, 16 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 @@
1include ../utils 1include ../utils
2
3mixin 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
2mixin comment(com, isfirst) 17mixin 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