diff --git a/src/parser.nim b/src/parser.nim index d3d62cf..1a7c073 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -189,6 +189,7 @@ proc parseTweet(js: JsonNode): Tweet = replyId: js{"in_reply_to_status_id_str"}.getId, text: js{"full_text"}.getStr, time: js{"created_at"}.getTime, + source: getSource(js), hasThread: js{"self_thread"}.notNull, available: true, user: User(id: js{"user_id_str"}.getStr), diff --git a/src/parserutils.nim b/src/parserutils.nim index a605ea4..4929c2a 100644 --- a/src/parserutils.nim +++ b/src/parserutils.nim @@ -133,6 +133,10 @@ proc getTombstone*(js: JsonNode): string = result = js{"tombstoneInfo", "richText", "text"}.getStr result.removeSuffix(" Learn more") +proc getSource*(js: JsonNode): string = + let src = js{"source"}.getStr + result = src.substr(src.find('>') + 1, src.rfind('<') - 1) + 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 9a6ad7f..98433aa 100644 --- a/src/types.nim +++ b/src/types.nim @@ -174,6 +174,7 @@ type available*: bool tombstone*: string location*: string + source*: string stats*: TweetStats retweet*: Option[Tweet] attribution*: Option[User] diff --git a/src/views/tweet.nim b/src/views/tweet.nim index 8b712a6..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) + p(class="tweet-published"): text &"{getTime(tweet)} ยท {tweet.source}" if tweet.mediaTags.len > 0: renderMediaTags(tweet.mediaTags) diff --git a/tests/test_card.py b/tests/test_card.py index 7fd233c..e497649 100644 --- a/tests/test_card.py +++ b/tests/test_card.py @@ -11,7 +11,7 @@ card = [ ['nim_lang/status/1136652293510717440', 'Version 0.20.0 released', 'We are very proud to announce Nim version 0.20. This is a massive release, both literally and figuratively. It contains more than 1,000 commits and it marks our release candidate for version 1.0!', - 'nim-lang.org', True], + 'nim-lang.org', False], ['voidtarget/status/1094632512926605312', 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too)', @@ -25,11 +25,6 @@ card = [ ] no_thumb = [ - ['Bountysource/status/1141879700639215617', - 'Post a bounty on kivy/plyer!', - 'Automation and Screen Reader Support', - 'bountysource.com'], - ['brent_p/status/1088857328680488961', 'Hts Nim Sugar', 'hts-nim is a library that allows one to use htslib via the nim programming language. Nim is a garbage-collected language that compiles to C and often has similar performance. I have become very...',