Unify avatar class generation

This commit is contained in:
Zed
2022-01-14 03:16:09 +01:00
parent cc0e4b1668
commit 888e965f41
4 changed files with 15 additions and 11 deletions

View File

@@ -11,10 +11,10 @@ proc getSmallPic(url: string): string =
result &= ":small"
result = getPicUrl(result)
proc renderMiniAvatar(profile: Profile): VNode =
proc renderMiniAvatar(profile: Profile; prefs: Prefs): VNode =
let url = getPicUrl(profile.getUserPic("_mini"))
buildHtml():
img(class="avatar mini", src=url)
img(class=(prefs.getAvatarClass & " mini"), src=url)
proc renderHeader(tweet: Tweet; retweet: string; prefs: Prefs): VNode =
buildHtml(tdiv):
@@ -31,9 +31,7 @@ proc renderHeader(tweet: Tweet; retweet: string; prefs: Prefs): VNode =
var size = "_bigger"
if not prefs.autoplayGifs and tweet.profile.userPic.endsWith("gif"):
size = "_400x400"
let round = if prefs.squareAvatars: "" else: " round"
genImg(tweet.profile.getUserPic(size), class=(&"avatar{round}"))
genImg(tweet.profile.getUserPic(size), class=prefs.getAvatarClass)
tdiv(class="tweet-name-row"):
tdiv(class="fullname-and-username"):
@@ -203,9 +201,9 @@ proc renderReply(tweet: Tweet): VNode =
if i > 0: text " "
a(href=("/" & u)): text "@" & u
proc renderAttribution(profile: Profile): VNode =
proc renderAttribution(profile: Profile; prefs: Prefs): VNode =
buildHtml(a(class="attribution", href=("/" & profile.username))):
renderMiniAvatar(profile)
renderMiniAvatar(profile, prefs)
strong: text profile.fullname
if profile.verified:
icon "ok", class="verified-icon", title="Verified account"
@@ -244,7 +242,7 @@ proc renderQuote(quote: Tweet; prefs: Prefs; path: string): VNode =
tdiv(class="tweet-name-row"):
tdiv(class="fullname-and-username"):
renderMiniAvatar(quote.profile)
renderMiniAvatar(quote.profile, prefs)
linkUser(quote.profile, class="fullname")
linkUser(quote.profile, class="username")
@@ -323,7 +321,7 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0;
verbatim replaceUrls(tweet.text, prefs) & renderLocation(tweet)
if tweet.attribution.isSome:
renderAttribution(tweet.attribution.get())
renderAttribution(tweet.attribution.get(), prefs)
if tweet.card.isSome:
renderCard(tweet.card.get(), prefs, path)