diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2020-04-10 13:34:23 +0100 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2020-04-10 13:34:23 +0100 |
| commit | 78400d587ea5367d3424333913ff4f94ca3f1908 (patch) | |
| tree | 2cf5f5ff8069740b0b7dd00853a4ea8c13d6e05c /src/main/resources/templates | |
| parent | d5a608143ad2250d8b35b9e4a488d39faaf5a021 (diff) | |
| download | reddit-lite-78400d587ea5367d3424333913ff4f94ca3f1908.tar.xz reddit-lite-78400d587ea5367d3424333913ff4f94ca3f1908.zip | |
Reimplement in Kotlin
Diffstat (limited to 'src/main/resources/templates')
| -rw-r--r-- | src/main/resources/templates/landing.ftlh | 58 | ||||
| -rw-r--r-- | src/main/resources/templates/lib.ftlh | 62 | ||||
| -rw-r--r-- | src/main/resources/templates/postDetail.ftlh | 19 | ||||
| -rw-r--r-- | src/main/resources/templates/posts.ftlh | 30 |
4 files changed, 169 insertions, 0 deletions
diff --git a/src/main/resources/templates/landing.ftlh b/src/main/resources/templates/landing.ftlh new file mode 100644 index 0000000..4e99c17 --- /dev/null +++ b/src/main/resources/templates/landing.ftlh @@ -0,0 +1,58 @@ +<#include 'lib.ftlh'> + +<@wrapper title="Reddit-lite"> + <div class="header"> + <a class="subreddit-title">reddit-lite</a> + <span class="header-links"> </span> + </div> + <div class="landing-desc"> + <p> + A lightweight, minimal, readonly Reddit client, designed for mobile devices or slow connections. Source is available on <a href="https://github.com/jamesbarnett91/reddit-lite">GitHub</a>. + </p> + <div> + Navigate to /r/<subreddit> or try some of the examples below: + <ul> + <li> + <a href="/r/popular">Reddit frontpage (popular subreddits)</a> + </li> + <li> + <a href="/r/programming">/r/programming</a> + </li> + <li> + <a href="/r/webdev">/r/webdev</a> + </li> + <li> + <a href="/r/videos">/r/videos</a> + </li> + <li> + <a href="/r/youtubehaiku">/r/youtubehaiku</a> + </li> + <li> + <a href="/r/worldnews">/r/worldnews/</a> + </li> + <li> + <a href="/r/food">/r/food</a> + </li> + </ul> + </div> + <p>You can also paste any Reddit link (post or comment) here to view the corresponding page in this client</p> + <input id="reddit-link" placeholder="https://reddit.com/r/example/comments/1jke3nj2/some_example_post"> </input> <button id="view-link">view in reddit-lite</button> + <p id="link-error" hidden >specified link does not contain "reddit.com"</p> + </div> + + <script> + document.addEventListener("DOMContentLoaded", function() { + document.getElementById("view-link").onclick = function(e) { + var link = document.getElementById("reddit-link").value; + var linkTokens = link.split("reddit.com"); + if(linkTokens.length === 2) { + window.location = linkTokens[1]; + } + else { + document.getElementById("link-error").removeAttribute('hidden'); + } + } + }); + </script> + +</@wrapper>
\ No newline at end of file diff --git a/src/main/resources/templates/lib.ftlh b/src/main/resources/templates/lib.ftlh new file mode 100644 index 0000000..9b9e96b --- /dev/null +++ b/src/main/resources/templates/lib.ftlh @@ -0,0 +1,62 @@ +<#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}">/r/${subreddit}</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>
\ No newline at end of file diff --git a/src/main/resources/templates/postDetail.ftlh b/src/main/resources/templates/postDetail.ftlh new file mode 100644 index 0000000..576e6e1 --- /dev/null +++ b/src/main/resources/templates/postDetail.ftlh @@ -0,0 +1,19 @@ +<#include 'lib.ftlh'> + +<@wrapper title="/r/${subreddit}"> + <@header subreddit/> + + <div class="post-summary"> + <@postSummary postDetail.post/> + </div> + + ${(postDetail.selftextHtmlUnescaped?no_esc)!""} + + <div class="comment-heading"><@pluralise postDetail.commentCount, "comment"/></div> + <div class="comments"> + <#list postDetail.comments as comment> + <@postComment comment/> + </#list> + </div> + +</@wrapper>
\ No newline at end of file diff --git a/src/main/resources/templates/posts.ftlh b/src/main/resources/templates/posts.ftlh new file mode 100644 index 0000000..56dbd1b --- /dev/null +++ b/src/main/resources/templates/posts.ftlh @@ -0,0 +1,30 @@ +<#include 'lib.ftlh'> + +<@wrapper title="/r/${subreddit}"> + <#assign thumbnailUrlFragment>/r/${subreddit}?after=${postAfterId!}&showThumbs=</#assign> + <@header subreddit> + <#if showThumbs> + <a href='${thumbnailUrlFragment}false'>hide thumbnails</a> + <#else> + <a href='${thumbnailUrlFragment}true'>show thumbnails</a> + </#if> + </@header> + + <ol class="post-list no-list-style"> + <#list posts as post> + <li> + <div class="post"> + <#if showThumbs && !post.isSelfPost() && post.thumbnailUrl?has_content> + <a class="post-title" href="${post.primaryLink}"> + <img src="${post.thumbnailUrl}" class="post-thumbnail"> </img> + </a> + </#if> + <@postSummary post/> + </div> + </li> + </#list> + </ol> + + <a class="next-page-link" href="/r/${subreddit}?after=${nextPostId}&showThumbs=${showThumbs?c}">next page ></a> + +</@wrapper>
\ No newline at end of file |