Display content attribution
This commit is contained in:
parent
a01265fa48
commit
0b5c15ce67
|
@ -199,6 +199,14 @@ proc getTweetMedia*(tweet: Tweet; node: XmlNode) =
|
||||||
let player = node.select(".PlayableMedia")
|
let player = node.select(".PlayableMedia")
|
||||||
if player == nil: return
|
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"):
|
if "gif" in player.attr("class"):
|
||||||
tweet.gif = some getGif(player.select(".PlayableMedia-player"))
|
tweet.gif = some getGif(player.select(".PlayableMedia-player"))
|
||||||
elif "video" in player.attr("class"):
|
elif "video" in player.attr("class"):
|
||||||
|
|
|
@ -88,7 +88,24 @@
|
||||||
margin-left: -58px;
|
margin-left: -58px;
|
||||||
width: 48px;
|
width: 48px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
border-radius: 50%;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.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
|
tombstone*: string
|
||||||
stats*: TweetStats
|
stats*: TweetStats
|
||||||
retweet*: Option[Retweet]
|
retweet*: Option[Retweet]
|
||||||
|
attribution*: Option[Profile]
|
||||||
quote*: Option[Quote]
|
quote*: Option[Quote]
|
||||||
card*: Option[Card]
|
card*: Option[Card]
|
||||||
gif*: Option[Gif]
|
gif*: Option[Gif]
|
||||||
|
|
|
@ -188,6 +188,11 @@ proc renderReply(quote: Quote): VNode =
|
||||||
if i > 0: text " "
|
if i > 0: text " "
|
||||||
a(href=("/" & u)): text "@" & u
|
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 =
|
proc renderQuoteMedia(quote: Quote): VNode =
|
||||||
buildHtml(tdiv(class="quote-media-container")):
|
buildHtml(tdiv(class="quote-media-container")):
|
||||||
if quote.thumb.len > 0:
|
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"):
|
tdiv(class="tweet-content media-body", dir="auto"):
|
||||||
verbatim replaceUrl(tweet.text, prefs)
|
verbatim replaceUrl(tweet.text, prefs)
|
||||||
|
|
||||||
|
if tweet.attribution.isSome:
|
||||||
|
renderAttribution(tweet.attribution.get())
|
||||||
|
|
||||||
if tweet.quote.isSome:
|
if tweet.quote.isSome:
|
||||||
renderQuote(tweet.quote.get(), prefs)
|
renderQuote(tweet.quote.get(), prefs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue