Add more link replacements to RSS preferences

This commit is contained in:
Zed 2021-12-27 02:22:31 +01:00
parent 3c45630062
commit 38df06e8f5
2 changed files with 13 additions and 6 deletions

View File

@ -224,7 +224,10 @@ type
redisMaxConns*: int
redisPassword*: string
replaceTwitter*: string
replaceYouTube*: string
replaceReddit*: string
replaceInstagram*: string
Rss* = object
feed*, cursor*: string

View File

@ -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}
<height>128</height>
</image>
#if timeline.content.len > 0:
${renderRssTweets(timeline.content, prefs, cfg)}
${renderRssTweets(timeline.content, getPrefs(cfg), cfg)}
#end if
</channel>
</rss>
#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 = ""
<?xml version="1.0" encoding="UTF-8"?>
@ -118,13 +123,12 @@ ${renderRssTweets(timeline.content, prefs, cfg)}
<description>${getDescription(list.name & " by @" & list.username, cfg)}</description>
<language>en-us</language>
<ttl>40</ttl>
${renderRssTweets(tweets, prefs, cfg)}
${renderRssTweets(tweets, getPrefs(cfg), cfg)}
</channel>
</rss>
#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)}
<description>${getDescription("Search \"" & escName & "\"", cfg)}</description>
<language>en-us</language>
<ttl>40</ttl>
${renderRssTweets(tweets, prefs, cfg)}
${renderRssTweets(tweets, getPrefs(cfg), cfg)}
</channel>
</rss>
#end proc