Add more link replacements to RSS preferences
This commit is contained in:
parent
3c45630062
commit
38df06e8f5
|
@ -224,7 +224,10 @@ type
|
||||||
redisMaxConns*: int
|
redisMaxConns*: int
|
||||||
redisPassword*: string
|
redisPassword*: string
|
||||||
|
|
||||||
|
replaceTwitter*: string
|
||||||
replaceYouTube*: string
|
replaceYouTube*: string
|
||||||
|
replaceReddit*: string
|
||||||
|
replaceInstagram*: string
|
||||||
|
|
||||||
Rss* = object
|
Rss* = object
|
||||||
feed*, cursor*: string
|
feed*, cursor*: string
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
#import strutils, xmltree, strformat, options
|
#import strutils, xmltree, strformat, options
|
||||||
#import ../types, ../utils, ../formatters
|
#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 =
|
#proc getTitle(tweet: Tweet; prefs: Prefs; retweet: string): string =
|
||||||
#if tweet.pinned: result = "Pinned: "
|
#if tweet.pinned: result = "Pinned: "
|
||||||
#elif retweet.len > 0: result = &"RT by @{retweet}: "
|
#elif retweet.len > 0: result = &"RT by @{retweet}: "
|
||||||
|
@ -74,7 +81,6 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname}
|
||||||
#end proc
|
#end proc
|
||||||
#
|
#
|
||||||
#proc renderTimelineRss*(timeline: Timeline; profile: Profile; cfg: Config; multi=false): string =
|
#proc renderTimelineRss*(timeline: Timeline; profile: Profile; cfg: Config; multi=false): string =
|
||||||
#let prefs = Prefs(replaceTwitter: cfg.hostname, replaceYouTube: cfg.replaceYouTube)
|
|
||||||
#let urlPrefix = getUrlPrefix(cfg)
|
#let urlPrefix = getUrlPrefix(cfg)
|
||||||
#result = ""
|
#result = ""
|
||||||
#let user = (if multi: "" else: "@") & profile.username
|
#let user = (if multi: "" else: "@") & profile.username
|
||||||
|
@ -99,14 +105,13 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname}
|
||||||
<height>128</height>
|
<height>128</height>
|
||||||
</image>
|
</image>
|
||||||
#if timeline.content.len > 0:
|
#if timeline.content.len > 0:
|
||||||
${renderRssTweets(timeline.content, prefs, cfg)}
|
${renderRssTweets(timeline.content, getPrefs(cfg), cfg)}
|
||||||
#end if
|
#end if
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
#end proc
|
#end proc
|
||||||
#
|
#
|
||||||
#proc renderListRss*(tweets: seq[Tweet]; list: List; cfg: Config): string =
|
#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}"
|
#let link = &"{getUrlPrefix(cfg)}/{list.username}/lists/{list.name}"
|
||||||
#result = ""
|
#result = ""
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
<description>${getDescription(list.name & " by @" & list.username, cfg)}</description>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<ttl>40</ttl>
|
<ttl>40</ttl>
|
||||||
${renderRssTweets(tweets, prefs, cfg)}
|
${renderRssTweets(tweets, getPrefs(cfg), cfg)}
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
#end proc
|
#end proc
|
||||||
#
|
#
|
||||||
#proc renderSearchRss*(tweets: seq[Tweet]; name, param: string; cfg: Config): string =
|
#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 link = &"{getUrlPrefix(cfg)}/search"
|
||||||
#let escName = xmltree.escape(name)
|
#let escName = xmltree.escape(name)
|
||||||
#result = ""
|
#result = ""
|
||||||
|
@ -137,7 +141,7 @@ ${renderRssTweets(tweets, prefs, cfg)}
|
||||||
<description>${getDescription("Search \"" & escName & "\"", cfg)}</description>
|
<description>${getDescription("Search \"" & escName & "\"", cfg)}</description>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<ttl>40</ttl>
|
<ttl>40</ttl>
|
||||||
${renderRssTweets(tweets, prefs, cfg)}
|
${renderRssTweets(tweets, getPrefs(cfg), cfg)}
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
#end proc
|
#end proc
|
||||||
|
|
Loading…
Reference in New Issue