aboutsummaryrefslogtreecommitdiff
path: root/src/mixins/post.pug
blob: 027e42f50b79d45e3d54c2254b34eba6ebfbd91a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
include ../utils
include postUtils
mixin post(p)
  article.post
    div.post-container
      div.post-text
        div.title-container
          a(href=`/comments/${p.id}`)
            != p.title
          span.domain   (#{p.domain})
        div.info-container 
          p
            | #{fmtnum(p.ups)}span.post-author
              |  · 
              | u/#{p.author} 
            |  · 
            | #{timeDifference(Date.now(), p.created * 1000)}
            |  · 
            a(href=`/r/${p.subreddit}`) r/#{p.subreddit}
            |  · 
            a(href=`/comments/${p.id}`) #{fmtnum (p.num_comments)}div.media-preview
        if isPostGallery(p)
          - var item = postGalleryItems(p)[0]
          img(src=item.url onclick=`toggleDetails('${p.id}')`) 
        else if isPostImage(p)
          - var url = postThumbnail(p)
          img(src=url onclick=`toggleDetails('${p.id}')`)
        else if isPostVideo(p)
          - var url = p.secure_media.reddit_video.scrubber_media_url
          video(src=url data-dashjs-player width='100px' height='100px' onclick=`toggleDetails('${p.id}')`)
        else if isPostLink(p)
          a(href=p.url)
            | ↗

    if isPostGallery(p)
      details(id=`${p.id}`)
        summary.expand-post expand gallery
        div.gallery
          each item in postGalleryItems(p)
            div.gallery-item
              div.gallery-item-idx
                | #{`${item.idx}/${item.total}`}
              a(href=`/media/${item.url}`)
                img(src=item.url loading="lazy")
        button(onclick=`toggleDetails('${p.id}')`) close
    else if isPostImage(p)
      details(id=`${p.id}`)
        summary.expand-post expand image
        a(href=`/media/${p.url}`)
          img(src=p.url loading="lazy").post-media
        button(onclick=`toggleDetails('${p.id}')`) close
    else if isPostVideo(p)
      details(id=`${p.id}`)
        summary.expand-post expand video
        - var url = p.secure_media.reddit_video.dash_url
        video(src=url controls data-dashjs-player loading="lazy").post-media
        button(onclick=`toggleDetails('${p.id}')`) close
    else if isPostLink(p)
      details(id=`${p.id}`)
        summary.expand-post expand link
        a(href=`${p.url}`)
          | #{p.url}
        br
        button(onclick=`toggleDetails('${p.id}')`) close