From 9e413e1f8c75302b61278d11df03c8517ce7eac1 Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 27 Dec 2021 02:27:49 +0100 Subject: [PATCH] Rename replaceUrl to replaceUrls --- src/api.nim | 2 +- src/formatters.nim | 4 ++-- src/nitter.nim | 2 +- src/views/profile.nim | 4 ++-- src/views/rss.nimf | 2 +- src/views/timeline.nim | 2 +- src/views/tweet.nim | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/api.nim b/src/api.nim index cf6f177..dd19238 100644 --- a/src/api.nim +++ b/src/api.nim @@ -89,7 +89,7 @@ proc resolve*(url: string; prefs: Prefs): Future[string] {.async.} = let client = newAsyncHttpClient(maxRedirects=0) try: let resp = await client.request(url, HttpHead) - result = resp.headers["location"].replaceUrl(prefs) + result = resp.headers["location"].replaceUrls(prefs) except: discard finally: diff --git a/src/formatters.nim b/src/formatters.nim index 164e0a7..7d5de91 100644 --- a/src/formatters.nim +++ b/src/formatters.nim @@ -47,8 +47,8 @@ proc shortLink*(text: string; length=28): string = if result.len > length: result = result[0 ..< length] & "…" -proc replaceUrl*(url: string; prefs: Prefs; absolute=""): string = - result = url +proc replaceUrls*(body: string; prefs: Prefs; absolute=""): string = + result = body if prefs.replaceYouTube.len > 0 and ytRegex in result: result = result.replace(ytRegex, prefs.replaceYouTube) diff --git a/src/nitter.nim b/src/nitter.nim index 20cf8df..c8c8f8b 100644 --- a/src/nitter.nim +++ b/src/nitter.nim @@ -69,7 +69,7 @@ routes: get "/i/redirect": let url = decodeUrl(@"url") if url.len == 0: resp Http404 - redirect(replaceUrl(url, cookiePrefs())) + redirect(replaceUrls(url, cookiePrefs())) error Http404: resp Http404, showError("Page not found", cfg) diff --git a/src/views/profile.nim b/src/views/profile.nim index 08404f1..8e516b9 100644 --- a/src/views/profile.nim +++ b/src/views/profile.nim @@ -29,7 +29,7 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode = if profile.bio.len > 0: tdiv(class="profile-bio"): p(dir="auto"): - verbatim replaceUrl(profile.bio, prefs) + verbatim replaceUrls(profile.bio, prefs) if profile.location.len > 0: tdiv(class="profile-location"): @@ -45,7 +45,7 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode = if profile.website.len > 0: tdiv(class="profile-website"): span: - let url = replaceUrl(profile.website, prefs) + let url = replaceUrls(profile.website, prefs) icon "link" a(href=url): text shortLink(url) diff --git a/src/views/rss.nimf b/src/views/rss.nimf index f76be33..8afdbe1 100644 --- a/src/views/rss.nimf +++ b/src/views/rss.nimf @@ -33,7 +33,7 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname} #proc renderRssTweet(tweet: Tweet; prefs: Prefs; cfg: Config): string = #let tweet = tweet.retweet.get(tweet) #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: # let quoteLink = getLink(get(tweet.quote))

${text}
${cfg.hostname}${quoteLink}

diff --git a/src/views/timeline.nim b/src/views/timeline.nim index 76e47c1..2a9862d 100644 --- a/src/views/timeline.nim +++ b/src/views/timeline.nim @@ -70,7 +70,7 @@ proc renderUser(user: Profile; prefs: Prefs): VNode = linkUser(user, class="username") 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 = buildHtml(tdiv(class="timeline")): diff --git a/src/views/tweet.nim b/src/views/tweet.nim index a16fdd5..873d441 100644 --- a/src/views/tweet.nim +++ b/src/views/tweet.nim @@ -166,7 +166,7 @@ proc renderCardContent(card: Card): VNode = proc renderCard(card: Card; prefs: Prefs; path: string): VNode = const smallCards = {app, player, summary, storeLink} 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))): if card.video.isSome: @@ -249,7 +249,7 @@ proc renderQuote(quote: Tweet; prefs: Prefs; path: string): VNode = if quote.text.len > 0: tdiv(class="quote-text", dir="auto"): - verbatim replaceUrl(quote.text, prefs) + verbatim replaceUrls(quote.text, prefs) if quote.hasThread: 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" tdiv(class=tweetClass, dir="auto"): - verbatim replaceUrl(tweet.text, prefs) & renderLocation(tweet) + verbatim replaceUrls(tweet.text, prefs) & renderLocation(tweet) if tweet.attribution.isSome: renderAttribution(tweet.attribution.get())