From 38df06e8f5085fbe96cb8517841392bf3109e1f1 Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 27 Dec 2021 02:22:31 +0100 Subject: [PATCH] Add more link replacements to RSS preferences --- src/types.nim | 3 +++ src/views/rss.nimf | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/types.nim b/src/types.nim index d9fc747..2bc2309 100644 --- a/src/types.nim +++ b/src/types.nim @@ -224,7 +224,10 @@ 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 151d91d..f76be33 100644 --- a/src/views/rss.nimf +++ b/src/views/rss.nimf @@ -2,6 +2,13 @@ #import strutils, xmltree, strformat, options #import ../types, ../utils, ../formatters # +#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 = #if tweet.pinned: result = "Pinned: " #elif retweet.len > 0: result = &"RT by @{retweet}: " @@ -74,7 +81,6 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname} #end proc # #proc renderTimelineRss*(timeline: Timeline; profile: Profile; cfg: Config; multi=false): string = -#let prefs = Prefs(replaceTwitter: cfg.hostname, replaceYouTube: cfg.replaceYouTube) #let urlPrefix = getUrlPrefix(cfg) #result = "" #let user = (if multi: "" else: "@") & profile.username @@ -99,14 +105,13 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname} 128 #if timeline.content.len > 0: -${renderRssTweets(timeline.content, prefs, cfg)} +${renderRssTweets(timeline.content, getPrefs(cfg), cfg)} #end if #end proc # #proc renderListRss*(tweets: seq[Tweet]; list: List; cfg: Config): string = -#let prefs = Prefs(replaceTwitter: cfg.hostname, replaceYouTube: cfg.replaceYouTube) #let link = &"{getUrlPrefix(cfg)}/{list.username}/lists/{list.name}" #result = "" @@ -118,13 +123,12 @@ ${renderRssTweets(timeline.content, prefs, cfg)} ${getDescription(list.name & " by @" & list.username, cfg)} en-us 40 -${renderRssTweets(tweets, prefs, cfg)} +${renderRssTweets(tweets, getPrefs(cfg), cfg)} #end proc # #proc renderSearchRss*(tweets: seq[Tweet]; name, param: string; cfg: Config): string = -#let prefs = Prefs(replaceTwitter: cfg.hostname, replaceYouTube: cfg.replaceYouTube) #let link = &"{getUrlPrefix(cfg)}/search" #let escName = xmltree.escape(name) #result = "" @@ -137,7 +141,7 @@ ${renderRssTweets(tweets, prefs, cfg)} ${getDescription("Search \"" & escName & "\"", cfg)} en-us 40 -${renderRssTweets(tweets, prefs, cfg)} +${renderRssTweets(tweets, getPrefs(cfg), cfg)} #end proc