Display content attribution
This commit is contained in:
parent
a01265fa48
commit
0b5c15ce67
4 changed files with 35 additions and 1 deletions
|
@ -199,6 +199,14 @@ proc getTweetMedia*(tweet: Tweet; node: XmlNode) =
|
|||
let player = node.select(".PlayableMedia")
|
||||
if player == nil: return
|
||||
|
||||
let attrib = player.select(".PlayableMedia-attribution")
|
||||
if attrib != nil:
|
||||
tweet.attribution = some Profile(
|
||||
username: attrib.attr("href").strip(chars={'/'}),
|
||||
fullname: attrib.selectText(".fullname"),
|
||||
userpic: attrib.selectAttr(".avatar", "src")
|
||||
)
|
||||
|
||||
if "gif" in player.attr("class"):
|
||||
tweet.gif = some getGif(player.select(".PlayableMedia-player"))
|
||||
elif "video" in player.attr("class"):
|
||||
|
|
|
@ -88,7 +88,24 @@
|
|||
margin-left: -58px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
.avatar {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.attribution {
|
||||
display: flex;
|
||||
pointer-events: all;
|
||||
margin: 10px 0;
|
||||
|
||||
.avatar {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: var(--fg_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -148,6 +148,7 @@ type
|
|||
tombstone*: string
|
||||
stats*: TweetStats
|
||||
retweet*: Option[Retweet]
|
||||
attribution*: Option[Profile]
|
||||
quote*: Option[Quote]
|
||||
card*: Option[Card]
|
||||
gif*: Option[Gif]
|
||||
|
|
|
@ -188,6 +188,11 @@ proc renderReply(quote: Quote): VNode =
|
|||
if i > 0: text " "
|
||||
a(href=("/" & u)): text "@" & u
|
||||
|
||||
proc renderAttribution(profile: Profile): VNode =
|
||||
buildHtml(a(class="attribution", href=("/" & profile.username))):
|
||||
img(class="avatar", width="20", height="20", src=profile.getUserpic("_200x200"))
|
||||
strong: text profile.fullname
|
||||
|
||||
proc renderQuoteMedia(quote: Quote): VNode =
|
||||
buildHtml(tdiv(class="quote-media-container")):
|
||||
if quote.thumb.len > 0:
|
||||
|
@ -258,6 +263,9 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class="";
|
|||
tdiv(class="tweet-content media-body", dir="auto"):
|
||||
verbatim replaceUrl(tweet.text, prefs)
|
||||
|
||||
if tweet.attribution.isSome:
|
||||
renderAttribution(tweet.attribution.get())
|
||||
|
||||
if tweet.quote.isSome:
|
||||
renderQuote(tweet.quote.get(), prefs)
|
||||
|
||||
|
|
Loading…
Reference in a new issue