From 78400d587ea5367d3424333913ff4f94ca3f1908 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Fri, 10 Apr 2020 13:34:23 +0100 Subject: Reimplement in Kotlin --- src/main/resources/application.properties | 1 + src/main/resources/static/stylesheets/style.css | 143 ++++++++++++++++++++++++ src/main/resources/templates/landing.ftlh | 58 ++++++++++ src/main/resources/templates/lib.ftlh | 62 ++++++++++ src/main/resources/templates/postDetail.ftlh | 19 ++++ src/main/resources/templates/posts.ftlh | 30 +++++ 6 files changed, 313 insertions(+) create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/static/stylesheets/style.css create mode 100644 src/main/resources/templates/landing.ftlh create mode 100644 src/main/resources/templates/lib.ftlh create mode 100644 src/main/resources/templates/postDetail.ftlh create mode 100644 src/main/resources/templates/posts.ftlh (limited to 'src/main/resources') diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..4d1b8ec --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.freemarker.settings.template_exception_handler=rethrow diff --git a/src/main/resources/static/stylesheets/style.css b/src/main/resources/static/stylesheets/style.css new file mode 100644 index 0000000..c561bb7 --- /dev/null +++ b/src/main/resources/static/stylesheets/style.css @@ -0,0 +1,143 @@ +html { + -webkit-text-size-adjust: 100%; +} + +body { + font-family: Verdana, Geneva, sans-serif; + font-size: 10pt; +} + +p { + margin: 5pt 0pt; +} + +.header { + background-color: #c0c0c0; + display: table; +} + +.subreddit-title { + font-weight: bold; + font-size: 15pt; + padding: 4pt 10pt; + display: table-cell; + vertical-align: middle; + text-decoration: none; + color: #000000; + white-space: nowrap; +} + +.header-links { + display: table-cell; + vertical-align: middle; + width: 100%; +} + +.header-links a { + color: #000000; +} + +.post-list { + display: table; + border-spacing: 5pt; +} + +.no-list-style { + list-style-type: none; + padding: 0; + margin: 0; +} + +.post { + color: #828282; + display: table-row; +} + +.post-body { + display: table-cell; + vertical-align: top; +} + +.post-thumbnail { + display: table-cell; + vertical-align: top; + width: 100px; + height: auto; +} + +.post-title { + color: #000000; + text-decoration: none; +} + +.post-domain { + font-size: 8pt; +} + +.post-info { + font-size: 7pt; +} + +.nowrap { + white-space: nowrap; +} + +.next-page-link { + padding: 10pt; +} + +.post-summary { + padding: 10pt 5pt; +} + +.subreddit-link { + color: #828282; +} + +.post-selftext { + padding: 0pt 15pt; +} + +.comments { + padding: 10pt 5pt; +} + +.comment-heading { + padding-left: 5pt; +} + +.comment { + margin-bottom: 10pt; +} + +.comment.child { + margin-left: 10pt; +} + +.comment-details { + font-size: 8pt; + color: #828282; +} + +summary { + outline: none; + margin-bottom: -5pt; +} + +blockquote { + background: #f9f9f9; + border-left: 5pt solid #ccc; + margin: 10pt 10pt 5pt; + padding: 2pt 10pt; +} + +pre { + background: #f9f9f9; + font-size: 8pt; + padding: 2pt 10pt; +} + +.landing-desc { + padding: 10pt 5pt; + font-size: 10pt; +} \ No newline at end of file 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"> +
+ reddit-lite + +
+
+

+ A lightweight, minimal, readonly Reddit client, designed for mobile devices or slow connections. Source is available on GitHub. +

+
+ Navigate to /r/<subreddit> or try some of the examples below: + +
+

You can also paste any Reddit link (post or comment) here to view the corresponding page in this client

+ + +
+ + + + \ 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> + + + ${title} + + + + + <#nested> + + + + +<#macro header subreddit> +
+ /r/${subreddit} + + <#nested> + +
+ + +<#macro postSummary post> +
+
+ ${post.title} + (${post.domain}) +
+ +
+ + +<#macro postComment comment> +
+ <#if comment.author?has_content> +
+ + ${comment.author} <#if comment.flairText?has_content>${comment.flairText} | ${comment.relativeCreatedDate} | <@pluralise comment.score "point"/> + +
${comment.bodyHtmlUnescaped?no_esc}
+ <#list comment.replies as childComment> + <@postComment childComment/> + +
+ <#else> + TODO Load more comments... + +
+ + +<#macro pluralise count word> + <#if count == 1> + ${count} ${word} + <#else> + ${count} ${word}s + + \ 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/> + +
+ <@postSummary postDetail.post/> +
+ + ${(postDetail.selftextHtmlUnescaped?no_esc)!""} + +
<@pluralise postDetail.commentCount, "comment"/>
+
+ <#list postDetail.comments as comment> + <@postComment comment/> + +
+ + \ 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= + <@header subreddit> + <#if showThumbs> + hide thumbnails + <#else> + show thumbnails + + + +
    + <#list posts as post> +
  1. +
    + <#if showThumbs && !post.isSelfPost() && post.thumbnailUrl?has_content> + + + + + <@postSummary post/> +
    +
  2. + +
+ + next page > + + \ No newline at end of file -- cgit v1.2.3