Proper support for gif avatars

Fixes #160
This commit is contained in:
Zed 2020-06-10 18:34:56 +02:00
parent e4cbbf2fd5
commit bd386b3acf
3 changed files with 11 additions and 5 deletions

View File

@ -97,7 +97,7 @@ proc showTimeline*(request: Request; query: Query; cfg: Config; prefs: Prefs;
let pHtml = renderProfile(p, t, r, prefs, getPath())
result = renderMain(pHtml, request, cfg, prefs, pageTitle(p), pageDesc(p),
rss=rss, images = @[p.getUserpic("_200x200")])
rss=rss, images = @[p.getUserpic("_400x400")])
template respTimeline*(timeline: typed) =
let t = timeline

View File

@ -15,8 +15,11 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode =
buildHtml(tdiv(class="profile-card")):
tdiv(class="profile-card-info"):
let url = getPicUrl(profile.getUserPic())
var size = "_400x400"
if prefs.autoplayGifs and profile.userpic.endsWith("gif"):
size = ""
a(class="profile-card-avatar", href=url, target="_blank"):
genImg(profile.getUserpic("_400x400"))
genImg(profile.getUserpic(size))
tdiv(class="profile-card-tabs-name"):
linkUser(profile, class="profile-card-fullname")

View File

@ -15,7 +15,7 @@ proc renderMiniAvatar(profile: Profile): VNode =
buildHtml():
img(class="avatar mini", src=url)
proc renderHeader(tweet: Tweet; retweet=""): VNode =
proc renderHeader(tweet: Tweet; retweet: string; prefs: Prefs): VNode =
buildHtml(tdiv):
if retweet.len > 0:
tdiv(class="retweet-header"):
@ -27,7 +27,10 @@ proc renderHeader(tweet: Tweet; retweet=""): VNode =
tdiv(class="tweet-header"):
a(class="tweet-avatar", href=("/" & tweet.profile.username)):
genImg(tweet.profile.getUserpic("_normal"), class="avatar")
var size = "_normal"
if not prefs.autoplayGifs and tweet.profile.userpic.endsWith("gif"):
size = "_400x400"
genImg(tweet.profile.getUserpic(size), class="avatar")
tdiv(class="tweet-name-row"):
tdiv(class="fullname-and-username"):
@ -290,7 +293,7 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0;
tdiv(class="tweet-body"):
var views = ""
renderHeader(tweet, retweet)
renderHeader(tweet, retweet, prefs)
if not afterTweet and index == 0 and tweet.reply.len > 0 and
(tweet.reply.len > 1 or tweet.reply[0] != tweet.profile.username):