From dcac7e4a264e6a981a2a3034eb29b8452266a20f Mon Sep 17 00:00:00 2001 From: Zed Date: Thu, 30 Dec 2021 02:00:31 +0100 Subject: [PATCH] Simplify default preferences handling Closes #441 --- src/prefs_impl.nim | 6 +++--- src/types.nim | 5 ----- src/views/rss.nimf | 27 ++++++++++----------------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/prefs_impl.nim b/src/prefs_impl.nim index d4a0b6b..8435af4 100644 --- a/src/prefs_impl.nim +++ b/src/prefs_impl.nim @@ -92,15 +92,15 @@ genPrefs: "Autoplay gifs" "Link replacements (blank to disable)": - replaceTwitter(input, "nitter.net"): + replaceTwitter(input, ""): "Twitter -> Nitter" placeholder: "Nitter hostname" - replaceYouTube(input, "piped.kavin.rocks"): + replaceYouTube(input, ""): "YouTube -> Piped/Invidious" placeholder: "Piped hostname" - replaceReddit(input, "teddit.net"): + replaceReddit(input, ""): "Reddit -> Teddit/Libreddit" placeholder: "Teddit hostname" diff --git a/src/types.nim b/src/types.nim index 59f141b..c577244 100644 --- a/src/types.nim +++ b/src/types.nim @@ -229,11 +229,6 @@ type redisMaxConns*: int redisPassword*: string - replaceTwitter*: string - replaceYouTube*: string - replaceReddit*: string - replaceInstagram*: string - Rss* = object feed*, cursor*: string diff --git a/src/views/rss.nimf b/src/views/rss.nimf index b6538ad..afdd231 100644 --- a/src/views/rss.nimf +++ b/src/views/rss.nimf @@ -1,16 +1,9 @@ #? stdtmpl(subsChar = '$', metaChar = '#') ## SPDX-License-Identifier: AGPL-3.0-only #import strutils, xmltree, strformat, options -#import ../types, ../utils, ../formatters +#import ../types, ../utils, ../formatters, ../prefs # -#proc getPrefs(cfg: Config): Prefs = -#result.replaceTwitter = cfg.replaceTwitter -#result.replaceYouTube = cfg.replaceYouTube -#result.replaceReddit = cfg.replaceReddit -#result.replaceInstagram = cfg.replaceInstagram -#end proc -# -#proc getTitle(tweet: Tweet; prefs: Prefs; retweet: string): string = +#proc getTitle(tweet: Tweet; retweet: string): string = #if tweet.pinned: result = "Pinned: " #elif retweet.len > 0: result = &"RT by @{retweet}: " #elif tweet.reply.len > 0: result = &"R to @{tweet.reply[0]}: " @@ -31,10 +24,10 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname} #end proc # -#proc renderRssTweet(tweet: Tweet; prefs: Prefs; cfg: Config): string = +#proc renderRssTweet(tweet: Tweet; cfg: Config): string = #let tweet = tweet.retweet.get(tweet) #let urlPrefix = getUrlPrefix(cfg) -#let text = replaceUrls(tweet.text, prefs, absolute=urlPrefix) +#let text = replaceUrls(tweet.text, defaultPrefs, absolute=urlPrefix) #if tweet.quote.isSome and get(tweet.quote).available: # let quoteLink = getLink(get(tweet.quote))

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

@@ -60,7 +53,7 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname} #end if #end proc # -#proc renderRssTweets(tweets: seq[Tweet]; prefs: Prefs; cfg: Config): string = +#proc renderRssTweets(tweets: seq[Tweet]; cfg: Config): string = #let urlPrefix = getUrlPrefix(cfg) #var links: seq[string] #for t in tweets: @@ -71,9 +64,9 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname} # end if # links.add link - ${getTitle(tweet, prefs, retweet)} + ${getTitle(tweet, retweet)} @${tweet.profile.username} - + ${getRfc822Time(tweet)} ${urlPrefix & link} ${urlPrefix & link} @@ -106,7 +99,7 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname} 128 #if timeline.content.len > 0: -${renderRssTweets(timeline.content, getPrefs(cfg), cfg)} +${renderRssTweets(timeline.content, cfg)} #end if @@ -124,7 +117,7 @@ ${renderRssTweets(timeline.content, getPrefs(cfg), cfg)} ${getDescription(list.name & " by @" & list.username, cfg)} en-us 40 -${renderRssTweets(tweets, getPrefs(cfg), cfg)} +${renderRssTweets(tweets, cfg)} #end proc @@ -142,7 +135,7 @@ ${renderRssTweets(tweets, getPrefs(cfg), cfg)} ${getDescription("Search \"" & escName & "\"", cfg)} en-us 40 -${renderRssTweets(tweets, getPrefs(cfg), cfg)} +${renderRssTweets(tweets, cfg)} #end proc