From 043f47b11abc49c3e077945a553e98bb89840265 Mon Sep 17 00:00:00 2001 From: Zed Date: Tue, 8 Oct 2019 13:28:57 +0200 Subject: [PATCH] Show published date under main tweets Fixes #59 --- src/formatters.nim | 3 +++ src/sass/tweet/_base.scss | 6 ++++++ src/views/status.nim | 3 ++- src/views/tweet.nim | 6 +++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/formatters.nim b/src/formatters.nim index 5423582..61c9085 100644 --- a/src/formatters.nim +++ b/src/formatters.nim @@ -130,6 +130,9 @@ proc getTime*(tweet: Tweet): string = proc getRfc822Time*(tweet: Tweet): string = tweet.time.format("ddd', 'd MMM yyyy HH:mm:ss 'GMT'") +proc getTweetTime*(tweet: Tweet): string = + tweet.time.format("h:mm tt' ยท 'MMM d', 'YYYY") + proc getLink*(tweet: Tweet | Quote): string = if tweet.id.len == 0: return &"/{tweet.profile.username}/status/{tweet.id}" diff --git a/src/sass/tweet/_base.scss b/src/sass/tweet/_base.scss index a5fe739..391ce0a 100644 --- a/src/sass/tweet/_base.scss +++ b/src/sass/tweet/_base.scss @@ -69,6 +69,12 @@ margin-left: 4px; } +.tweet-published { + margin: 0; + margin-top: 5px; + color: $grey; +} + .tweet-avatar { display: contents !important; diff --git a/src/views/status.nim b/src/views/status.nim index 667d6e7..048908a 100644 --- a/src/views/status.nim +++ b/src/views/status.nim @@ -35,7 +35,8 @@ proc renderConversation*(conversation: Conversation; prefs: Prefs; path: string) tdiv(class="main-tweet"): let afterClass = if hasAfter: "thread thread-line" else: "" - renderTweet(conversation.tweet, prefs, path, class=afterClass) + renderTweet(conversation.tweet, prefs, path, class=afterClass, + mainTweet=true) if hasAfter: tdiv(class="after-tweet thread-line"): diff --git a/src/views/tweet.nim b/src/views/tweet.nim index 6fc0d9c..4527cf4 100644 --- a/src/views/tweet.nim +++ b/src/views/tweet.nim @@ -222,7 +222,8 @@ proc renderQuote(quote: Quote; prefs: Prefs): VNode = text "Show this thread" proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; - index=0; total=(-1); last=false; showThread=false): VNode = + index=0; total=(-1); last=false; showThread=false; + mainTweet=false): VNode = var divClass = class if index == total or last: divClass = "thread-last " & class @@ -262,6 +263,9 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; elif tweet.poll.isSome: renderPoll(tweet.poll.get()) + if mainTweet: + p(class="tweet-published"): text getTweetTime(tweet) + if not prefs.hideTweetStats: renderStats(tweet.stats, views)