parent
7590dc1cda
commit
dcac7e4a26
3 changed files with 13 additions and 25 deletions
|
@ -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"
|
||||
|
||||
|
|
|
@ -229,11 +229,6 @@ type
|
|||
redisMaxConns*: int
|
||||
redisPassword*: string
|
||||
|
||||
replaceTwitter*: string
|
||||
replaceYouTube*: string
|
||||
replaceReddit*: string
|
||||
replaceInstagram*: string
|
||||
|
||||
Rss* = object
|
||||
feed*, cursor*: string
|
||||
|
||||
|
|
|
@ -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))
|
||||
<p>${text}<br><a href="${urlPrefix}${quoteLink}">${cfg.hostname}${quoteLink}</a></p>
|
||||
|
@ -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
|
||||
<item>
|
||||
<title>${getTitle(tweet, prefs, retweet)}</title>
|
||||
<title>${getTitle(tweet, retweet)}</title>
|
||||
<dc:creator>@${tweet.profile.username}</dc:creator>
|
||||
<description><![CDATA[${renderRssTweet(tweet, prefs, cfg).strip(chars={'\n'})}]]></description>
|
||||
<description><![CDATA[${renderRssTweet(tweet, cfg).strip(chars={'\n'})}]]></description>
|
||||
<pubDate>${getRfc822Time(tweet)}</pubDate>
|
||||
<guid>${urlPrefix & link}</guid>
|
||||
<link>${urlPrefix & link}</link>
|
||||
|
@ -106,7 +99,7 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname}
|
|||
<height>128</height>
|
||||
</image>
|
||||
#if timeline.content.len > 0:
|
||||
${renderRssTweets(timeline.content, getPrefs(cfg), cfg)}
|
||||
${renderRssTweets(timeline.content, cfg)}
|
||||
#end if
|
||||
</channel>
|
||||
</rss>
|
||||
|
@ -124,7 +117,7 @@ ${renderRssTweets(timeline.content, getPrefs(cfg), cfg)}
|
|||
<description>${getDescription(list.name & " by @" & list.username, cfg)}</description>
|
||||
<language>en-us</language>
|
||||
<ttl>40</ttl>
|
||||
${renderRssTweets(tweets, getPrefs(cfg), cfg)}
|
||||
${renderRssTweets(tweets, cfg)}
|
||||
</channel>
|
||||
</rss>
|
||||
#end proc
|
||||
|
@ -142,7 +135,7 @@ ${renderRssTweets(tweets, getPrefs(cfg), cfg)}
|
|||
<description>${getDescription("Search \"" & escName & "\"", cfg)}</description>
|
||||
<language>en-us</language>
|
||||
<ttl>40</ttl>
|
||||
${renderRssTweets(tweets, getPrefs(cfg), cfg)}
|
||||
${renderRssTweets(tweets, cfg)}
|
||||
</channel>
|
||||
</rss>
|
||||
#end proc
|
||||
|
|
Loading…
Reference in a new issue