aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/templates/lib.ftlh
blob: ee013a4396cf76b35117bf6b725eb4f0685ffe2a (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
67
68
69
70
<#macro wrapper title>
<html>
  <head>
    <title>${title}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <#nested>
  </body>
</html>
</#macro>

<#macro header subreddit>
  <div class="header">
    <a class="subreddit-title" href="/r/${subreddit}">
      <#if subreddit?contains("+")>
        <#list subreddit?split("+") as multiRedditName>
          <#if multiRedditName?is_first>/r/<#else>+</#if>${multiRedditName}
        </#list>
      <#else>
        /r/${subreddit}
      </#if>
    </a>
    <span class="header-links">
      <#nested>
    </span>
  </div>
</#macro>

<#macro postSummary post>
  <div class="post-body">
    <div>
      <a class="post-title" href="${post.primaryLink}">${post.title}</a>
      <span class="post-domain">(${post.domain})</span>
    </div>
    <div class="post-info">
      <span class="nowrap"><@pluralise post.score "point"/></span>
      <span class="nowrap">by ${post.author}</span>
      <span class="nowrap"> in <a class="subreddit-link" href="${post.subredditPath}">${post.subredditPath}</a></span>
      <span class="nowrap">${post.relativeCreatedDate}</span> | <span class="nowrap"><a href="${post.subredditPath}/comments/${post.id}"><@pluralise post.commentCount, "comment"/></a></span>
    </div>
  </div>
</#macro>

<#macro postComment comment>
  <div class="comment<#if comment.isChild()> child</#if>">
    <#if comment.author?has_content>
      <details open>
        <summary>
          <span class="comment-details">${comment.author} <#if comment.flairText?has_content>${comment.flairText}</#if> | ${comment.relativeCreatedDate} | <@pluralise comment.score "point"/></span>
        </summary>
        <div class="comment-text">${comment.bodyHtmlUnescaped?no_esc}</div>
        <#list comment.replies as childComment>
          <@postComment childComment/>
        </#list>
      </details>
    <#else>
      <a href="#">TODO Load more comments...</a>
    </#if>
  </div>
</#macro>

<#macro pluralise count word>
  <#if count == 1>
    ${count} ${word}
  <#else>
    ${count} ${word}s
  </#if>
</#macro>