From baf5bf89e79fd92fb68fd0d59c0e9facdad21525 Mon Sep 17 00:00:00 2001 From: Curtis <110percent@riseup.net> Date: Sat, 26 Feb 2022 19:00:06 -0500 Subject: [PATCH] Implement requested changes --- src/parser.nim | 1 - src/parserutils.nim | 6 ++++++ src/types.nim | 2 +- src/views/tweet.nim | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/parser.nim b/src/parser.nim index 778187b..aa55f60 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -3,7 +3,6 @@ import strutils, options, tables, times, math import packedjson, packedjson/deserialiser import types, parserutils, utils import experimental/parser/unifiedcard -import std/strutils proc parseUser(js: JsonNode; id=""): User = if js.isNull: return diff --git a/src/parserutils.nim b/src/parserutils.nim index a605ea4..e0b2669 100644 --- a/src/parserutils.nim +++ b/src/parserutils.nim @@ -133,6 +133,12 @@ proc getTombstone*(js: JsonNode): string = result = js{"tombstoneInfo", "richText", "text"}.getStr result.removeSuffix(" Learn more") +proc getSource*(js: JsonNode): string = + let + raw_src = js["source"].getStr + src = raw_src.substr(raw_src.find('>') + 1, raw_src.rfind('<') - 1) + return src + proc extractSlice(js: JsonNode): Slice[int] = result = js["indices"][0].getInt ..< js["indices"][1].getInt diff --git a/src/types.nim b/src/types.nim index f28e90a..98433aa 100644 --- a/src/types.nim +++ b/src/types.nim @@ -174,8 +174,8 @@ type available*: bool tombstone*: string location*: string - stats*: TweetStats source*: string + stats*: TweetStats retweet*: Option[Tweet] attribution*: Option[User] mediaTags*: seq[User] diff --git a/src/views/tweet.nim b/src/views/tweet.nim index b6f8d7e..6e6f3af 100644 --- a/src/views/tweet.nim +++ b/src/views/tweet.nim @@ -344,7 +344,7 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0; renderQuote(tweet.quote.get(), prefs, path) if mainTweet: - p(class="tweet-published"): text getTime(tweet) & " · " & tweet.source + p(class="tweet-published"): text &"{getTime(tweet)} · {tweet.source}" if tweet.mediaTags.len > 0: renderMediaTags(tweet.mediaTags)