Rename replaceUrl to replaceUrls

This commit is contained in:
Zed 2021-12-27 02:27:49 +01:00
parent 0e01ecb001
commit 9e413e1f8c
7 changed files with 11 additions and 11 deletions

View file

@ -89,7 +89,7 @@ proc resolve*(url: string; prefs: Prefs): Future[string] {.async.} =
let client = newAsyncHttpClient(maxRedirects=0) let client = newAsyncHttpClient(maxRedirects=0)
try: try:
let resp = await client.request(url, HttpHead) let resp = await client.request(url, HttpHead)
result = resp.headers["location"].replaceUrl(prefs) result = resp.headers["location"].replaceUrls(prefs)
except: except:
discard discard
finally: finally:

View file

@ -47,8 +47,8 @@ proc shortLink*(text: string; length=28): string =
if result.len > length: if result.len > length:
result = result[0 ..< length] & "" result = result[0 ..< length] & ""
proc replaceUrl*(url: string; prefs: Prefs; absolute=""): string = proc replaceUrls*(body: string; prefs: Prefs; absolute=""): string =
result = url result = body
if prefs.replaceYouTube.len > 0 and ytRegex in result: if prefs.replaceYouTube.len > 0 and ytRegex in result:
result = result.replace(ytRegex, prefs.replaceYouTube) result = result.replace(ytRegex, prefs.replaceYouTube)

View file

@ -69,7 +69,7 @@ routes:
get "/i/redirect": get "/i/redirect":
let url = decodeUrl(@"url") let url = decodeUrl(@"url")
if url.len == 0: resp Http404 if url.len == 0: resp Http404
redirect(replaceUrl(url, cookiePrefs())) redirect(replaceUrls(url, cookiePrefs()))
error Http404: error Http404:
resp Http404, showError("Page not found", cfg) resp Http404, showError("Page not found", cfg)

View file

@ -29,7 +29,7 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode =
if profile.bio.len > 0: if profile.bio.len > 0:
tdiv(class="profile-bio"): tdiv(class="profile-bio"):
p(dir="auto"): p(dir="auto"):
verbatim replaceUrl(profile.bio, prefs) verbatim replaceUrls(profile.bio, prefs)
if profile.location.len > 0: if profile.location.len > 0:
tdiv(class="profile-location"): tdiv(class="profile-location"):
@ -45,7 +45,7 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode =
if profile.website.len > 0: if profile.website.len > 0:
tdiv(class="profile-website"): tdiv(class="profile-website"):
span: span:
let url = replaceUrl(profile.website, prefs) let url = replaceUrls(profile.website, prefs)
icon "link" icon "link"
a(href=url): text shortLink(url) a(href=url): text shortLink(url)

View file

@ -33,7 +33,7 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname}
#proc renderRssTweet(tweet: Tweet; prefs: Prefs; cfg: Config): string = #proc renderRssTweet(tweet: Tweet; prefs: Prefs; cfg: Config): string =
#let tweet = tweet.retweet.get(tweet) #let tweet = tweet.retweet.get(tweet)
#let urlPrefix = getUrlPrefix(cfg) #let urlPrefix = getUrlPrefix(cfg)
#let text = replaceUrl(tweet.text, prefs, absolute=urlPrefix) #let text = replaceUrls(tweet.text, prefs, absolute=urlPrefix)
#if tweet.quote.isSome and get(tweet.quote).available: #if tweet.quote.isSome and get(tweet.quote).available:
# let quoteLink = getLink(get(tweet.quote)) # let quoteLink = getLink(get(tweet.quote))
<p>${text}<br><a href="${urlPrefix}${quoteLink}">${cfg.hostname}${quoteLink}</a></p> <p>${text}<br><a href="${urlPrefix}${quoteLink}">${cfg.hostname}${quoteLink}</a></p>

View file

@ -70,7 +70,7 @@ proc renderUser(user: Profile; prefs: Prefs): VNode =
linkUser(user, class="username") linkUser(user, class="username")
tdiv(class="tweet-content media-body", dir="auto"): tdiv(class="tweet-content media-body", dir="auto"):
verbatim replaceUrl(user.bio, prefs) verbatim replaceUrls(user.bio, prefs)
proc renderTimelineUsers*(results: Result[Profile]; prefs: Prefs; path=""): VNode = proc renderTimelineUsers*(results: Result[Profile]; prefs: Prefs; path=""): VNode =
buildHtml(tdiv(class="timeline")): buildHtml(tdiv(class="timeline")):

View file

@ -166,7 +166,7 @@ proc renderCardContent(card: Card): VNode =
proc renderCard(card: Card; prefs: Prefs; path: string): VNode = proc renderCard(card: Card; prefs: Prefs; path: string): VNode =
const smallCards = {app, player, summary, storeLink} const smallCards = {app, player, summary, storeLink}
let large = if card.kind notin smallCards: " large" else: "" let large = if card.kind notin smallCards: " large" else: ""
let url = replaceUrl(card.url, prefs) let url = replaceUrls(card.url, prefs)
buildHtml(tdiv(class=("card" & large))): buildHtml(tdiv(class=("card" & large))):
if card.video.isSome: if card.video.isSome:
@ -249,7 +249,7 @@ proc renderQuote(quote: Tweet; prefs: Prefs; path: string): VNode =
if quote.text.len > 0: if quote.text.len > 0:
tdiv(class="quote-text", dir="auto"): tdiv(class="quote-text", dir="auto"):
verbatim replaceUrl(quote.text, prefs) verbatim replaceUrls(quote.text, prefs)
if quote.hasThread: if quote.hasThread:
a(class="show-thread", href=getLink(quote)): a(class="show-thread", href=getLink(quote)):
@ -312,7 +312,7 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0;
tweetClass &= " tweet-bidi" tweetClass &= " tweet-bidi"
tdiv(class=tweetClass, dir="auto"): tdiv(class=tweetClass, dir="auto"):
verbatim replaceUrl(tweet.text, prefs) & renderLocation(tweet) verbatim replaceUrls(tweet.text, prefs) & renderLocation(tweet)
if tweet.attribution.isSome: if tweet.attribution.isSome:
renderAttribution(tweet.attribution.get()) renderAttribution(tweet.attribution.get())