mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-23 07:15:37 +00:00
Minor retweet refactor
This commit is contained in:
parent
9b07199901
commit
c60280415e
|
@ -73,8 +73,10 @@ proc parseTweet*(node: XmlNode): Tweet =
|
||||||
|
|
||||||
let by = tweet.selectText(".js-retweet-text > a > b")
|
let by = tweet.selectText(".js-retweet-text > a > b")
|
||||||
if by.len > 0:
|
if by.len > 0:
|
||||||
result.retweetBy = some(by.stripText())
|
result.retweet = some(Retweet(
|
||||||
result.retweetId = some(tweet.attr("data-retweet-id"))
|
by: stripText(by),
|
||||||
|
id: tweet.attr("data-retweet-id")
|
||||||
|
))
|
||||||
|
|
||||||
let quote = tweet.select(".QuoteTweet-innerContainer")
|
let quote = tweet.select(".QuoteTweet-innerContainer")
|
||||||
if quote != nil:
|
if quote != nil:
|
||||||
|
|
|
@ -62,6 +62,10 @@ type
|
||||||
thumb*: Option[string]
|
thumb*: Option[string]
|
||||||
badge*: Option[string]
|
badge*: Option[string]
|
||||||
|
|
||||||
|
Retweet* = object
|
||||||
|
by*: string
|
||||||
|
id*: string
|
||||||
|
|
||||||
Tweet* = ref object
|
Tweet* = ref object
|
||||||
id*: string
|
id*: string
|
||||||
profile*: Profile
|
profile*: Profile
|
||||||
|
@ -72,9 +76,8 @@ type
|
||||||
retweets*: string
|
retweets*: string
|
||||||
likes*: string
|
likes*: string
|
||||||
pinned*: bool
|
pinned*: bool
|
||||||
|
retweet*: Option[Retweet]
|
||||||
quote*: Option[Quote]
|
quote*: Option[Quote]
|
||||||
retweetBy*: Option[string]
|
|
||||||
retweetId*: Option[string]
|
|
||||||
gif*: Option[Gif]
|
gif*: Option[Gif]
|
||||||
video*: Option[Video]
|
video*: Option[Video]
|
||||||
photos*: seq[string]
|
photos*: seq[string]
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#import ../types, ../formatters, ../utils
|
#import ../types, ../formatters, ../utils
|
||||||
#
|
#
|
||||||
#proc renderHeading(tweet: Tweet): string =
|
#proc renderHeading(tweet: Tweet): string =
|
||||||
#if tweet.retweetBy.isSome:
|
#if tweet.retweet.isSome:
|
||||||
<div class="retweet">
|
<div class="retweet">
|
||||||
<span>🔄 ${tweet.retweetBy.get()} retweeted</span>
|
<span>🔄 ${get(tweet.retweet).by} retweeted</span>
|
||||||
</div>
|
</div>
|
||||||
#end if
|
#end if
|
||||||
#if tweet.pinned:
|
#if tweet.pinned:
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
#
|
#
|
||||||
#for tweet in timeline.tweets:
|
#for tweet in timeline.tweets:
|
||||||
#if tweet.id in retweets: continue
|
#if tweet.id in retweets: continue
|
||||||
#elif tweet.retweetBy.isSome: retweets.add tweet.id
|
#elif tweet.retweet.isSome: retweets.add tweet.id
|
||||||
#end if
|
#end if
|
||||||
${renderTweet(tweet, "timeline-tweet")}
|
${renderTweet(tweet, "timeline-tweet")}
|
||||||
#end for
|
#end for
|
||||||
|
|
Loading…
Reference in a new issue