Cleaner image code
This commit is contained in:
parent
94b2187453
commit
0fee70eeba
3 changed files with 15 additions and 18 deletions
|
@ -34,13 +34,11 @@ proc reEmailToLink*(m: RegexMatch; s: string): string =
|
||||||
toLink("mailto://" & url, url)
|
toLink("mailto://" & url, url)
|
||||||
|
|
||||||
proc reUsernameToLink*(m: RegexMatch; s: string): string =
|
proc reUsernameToLink*(m: RegexMatch; s: string): string =
|
||||||
var
|
var username = ""
|
||||||
username = ""
|
var pretext = ""
|
||||||
pretext = ""
|
|
||||||
|
|
||||||
let
|
let pre = m.group(0)
|
||||||
pre = m.group(0)
|
let match = m.group(1)
|
||||||
match = m.group(1)
|
|
||||||
|
|
||||||
username = s[match[0]]
|
username = s[match[0]]
|
||||||
|
|
||||||
|
@ -56,8 +54,8 @@ proc linkifyText*(text: string): string =
|
||||||
result = result.replace(usernameRegex, reUsernameToLink)
|
result = result.replace(usernameRegex, reUsernameToLink)
|
||||||
result = result.replace(emailRegex, reEmailToLink)
|
result = result.replace(emailRegex, reEmailToLink)
|
||||||
result = result.replace(urlRegex, reUrlToLink)
|
result = result.replace(urlRegex, reUrlToLink)
|
||||||
result = result.replace(re"([A-z0-9\):.])<a", "$1 <a")
|
result = result.replace(re"([A-z0-9\):;.])<a", "$1 <a")
|
||||||
result = result.replace(re"</a> ([.,\)])", "</a>$1")
|
result = result.replace(re"</a>\s+([;.,\)])", "</a>$1")
|
||||||
|
|
||||||
proc stripTwitterUrls*(text: string): string =
|
proc stripTwitterUrls*(text: string): string =
|
||||||
result = text
|
result = text
|
||||||
|
@ -72,6 +70,9 @@ proc getUserpic*(userpic: string; style=""): string =
|
||||||
proc getUserpic*(profile: Profile; style=""): string =
|
proc getUserpic*(profile: Profile; style=""): string =
|
||||||
getUserPic(profile.userpic, style)
|
getUserPic(profile.userpic, style)
|
||||||
|
|
||||||
|
proc genImg*(url: string; class=""): string =
|
||||||
|
result = img(src = url.getSigUrl("pic"), class = class, alt = "Image")
|
||||||
|
|
||||||
proc linkUser*(profile: Profile; class=""): string =
|
proc linkUser*(profile: Profile; class=""): string =
|
||||||
let
|
let
|
||||||
username = "username" in class
|
username = "username" in class
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#end if
|
#end if
|
||||||
<div class="media-heading">
|
<div class="media-heading">
|
||||||
<div class="heading-name-row">
|
<div class="heading-name-row">
|
||||||
<img class="avatar" src=${tweet.profile.getUserpic("_bigger").getSigUrl("pic")}>
|
${genImg(tweet.profile.getUserpic("_bigger"), "avatar")}
|
||||||
<div class="fullname-and-username">
|
<div class="fullname-and-username">
|
||||||
${linkUser(tweet.profile, class="fullname")}
|
${linkUser(tweet.profile, class="fullname")}
|
||||||
${linkUser(tweet.profile, class="username")}
|
${linkUser(tweet.profile, class="username")}
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
<div class="quote-media-container">
|
<div class="quote-media-container">
|
||||||
<div class="quote-media">
|
<div class="quote-media">
|
||||||
#if quote.thumb.isSome():
|
#if quote.thumb.isSome():
|
||||||
<img src=${quote.thumb.get().getSigUrl("pic")}>
|
${genImg(quote.thumb.get())}
|
||||||
#if quote.badge.isSome():
|
#if quote.badge.isSome():
|
||||||
<div class="quote-badge">
|
<div class="quote-badge">
|
||||||
<div class="quote-badge-text">${quote.badge.get()}</div>
|
<div class="quote-badge-text">${quote.badge.get()}</div>
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
##TODO: why doesn't this work?
|
##TODO: why doesn't this work?
|
||||||
<a href=${getSigUrl(photo & "?name=orig", "pic")} target="_blank" class="image-attachment">
|
<a href=${getSigUrl(photo & "?name=orig", "pic")} target="_blank" class="image-attachment">
|
||||||
<div class="still-image" style="${flex}">
|
<div class="still-image" style="${flex}">
|
||||||
<img src=${getSigUrl(photo, "pic")} referrerpolicy="">
|
${genImg(photo)}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,11 +4,9 @@
|
||||||
#include "tweet.nimf"
|
#include "tweet.nimf"
|
||||||
#
|
#
|
||||||
#proc renderProfileCard*(profile: Profile): string =
|
#proc renderProfileCard*(profile: Profile): string =
|
||||||
#let pic = profile.getUserpic().getSigUrl("pic")
|
|
||||||
#let smallPic = profile.getUserpic("_200x200").getSigUrl("pic")
|
|
||||||
<div class="profile-card">
|
<div class="profile-card">
|
||||||
<a class="profile-card-avatar" href="${pic}">
|
<a class="profile-card-avatar" href="${profile.getUserPic().getSigUrl("pic")}">
|
||||||
<img src="${smallPic}">
|
${genImg(profile.getUserpic("_200x200"))}
|
||||||
</a>
|
</a>
|
||||||
<div class="profile-card-tabs">
|
<div class="profile-card-tabs">
|
||||||
<div class="profile-card-tabs-name">
|
<div class="profile-card-tabs-name">
|
||||||
|
@ -50,9 +48,7 @@
|
||||||
<div style="${profile.banner}" class="profile-banner-color"></div>
|
<div style="${profile.banner}" class="profile-banner-color"></div>
|
||||||
#else:
|
#else:
|
||||||
#let url = getSigUrl(profile.banner, "pic")
|
#let url = getSigUrl(profile.banner, "pic")
|
||||||
<a href="${url}">
|
<a href="${url}">${genImg(profile.banner)}</a>
|
||||||
<img src="${url}">
|
|
||||||
</a>
|
|
||||||
#end if
|
#end if
|
||||||
#end proc
|
#end proc
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue