|
|
@@ -1,13 +1,12 @@
|
|
|
#? stdtmpl(subsChar = '$', metaChad = '#')
|
|
|
#import strutils, xmltree, strformat
|
|
|
#import ../types, ../utils, ../formatters
|
|
|
-#const hostname {.strdefine.} = "nitter.net"
|
|
|
#
|
|
|
-#proc getTitle(tweet: Tweet; prefs: Prefs): string =
|
|
|
+#proc getTitle(tweet: Tweet; prefs: Prefs; hostname: string): string =
|
|
|
#if tweet.pinned: result = "Pinned: "
|
|
|
#elif tweet.retweet.isSome: result = "RT: "
|
|
|
#end if
|
|
|
-#result &= xmltree.escape(replaceUrl(tweet.text, prefs, rss=true))
|
|
|
+#result &= xmltree.escape(replaceUrl(tweet.text, prefs, absolute=hostname))
|
|
|
#if result.len > 0: return
|
|
|
#end if
|
|
|
#if tweet.photos.len > 0:
|
|
|
@@ -19,8 +18,8 @@
|
|
|
#end if
|
|
|
#end proc
|
|
|
#
|
|
|
-#proc renderRssTweet(tweet: Tweet; prefs: Prefs): string =
|
|
|
-#let text = replaceUrl(tweet.text, prefs, rss=true)
|
|
|
+#proc renderRssTweet(tweet: Tweet; prefs: Prefs; hostname: string): string =
|
|
|
+#let text = replaceUrl(tweet.text, prefs, absolute=hostname)
|
|
|
#if tweet.quote.isSome and get(tweet.quote).available:
|
|
|
#let quoteLink = hostname & getLink(get(tweet.quote))
|
|
|
<p>${text}<br><a href="https://${quoteLink}">${quoteLink}</a></p>
|
|
|
@@ -39,7 +38,7 @@
|
|
|
#end if
|
|
|
#end proc
|
|
|
#
|
|
|
-#proc renderRssTweets(tweets: seq[Tweet]; prefs: Prefs): string =
|
|
|
+#proc renderRssTweets(tweets: seq[Tweet]; prefs: Prefs; hostname: string): string =
|
|
|
#var links: seq[string]
|
|
|
#for tweet in tweets:
|
|
|
#let link = getLink(tweet)
|
|
|
@@ -47,9 +46,9 @@
|
|
|
#end if
|
|
|
#links.add link
|
|
|
<item>
|
|
|
- <title>${getTitle(tweet, prefs)}</title>
|
|
|
+ <title>${getTitle(tweet, prefs, hostname)}</title>
|
|
|
<dc:creator>@${tweet.profile.username}</dc:creator>
|
|
|
- <description><![CDATA[${renderRssTweet(tweet, prefs).strip(chars={'\n'})}]]></description>
|
|
|
+ <description><![CDATA[${renderRssTweet(tweet, prefs, hostname).strip(chars={'\n'})}]]></description>
|
|
|
<pubDate>${getRfc822Time(tweet)}</pubDate>
|
|
|
<guid>https://${hostname & link}</guid>
|
|
|
<link>https://${hostname & link}</link>
|
|
|
@@ -57,7 +56,7 @@
|
|
|
#end for
|
|
|
#end proc
|
|
|
#
|
|
|
-#proc renderTimelineRss*(timeline: Timeline; profile: Profile): string =
|
|
|
+#proc renderTimelineRss*(timeline: Timeline; profile: Profile; hostname: string): string =
|
|
|
#let prefs = Prefs(replaceTwitter: hostname, replaceYoutube: "invidio.us")
|
|
|
#result = ""
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
@@ -77,13 +76,13 @@
|
|
|
<height>128</height>
|
|
|
</image>
|
|
|
#if timeline != nil:
|
|
|
- ${renderRssTweets(timeline.content, prefs)}
|
|
|
+ ${renderRssTweets(timeline.content, prefs, hostname)}
|
|
|
#end if
|
|
|
</channel>
|
|
|
</rss>
|
|
|
#end proc
|
|
|
#
|
|
|
-#proc renderListRss*(tweets: seq[Tweet]; name, list: string): string =
|
|
|
+#proc renderListRss*(tweets: seq[Tweet]; name, list, hostname: string): string =
|
|
|
#let prefs = Prefs(replaceTwitter: hostname, replaceYoutube: "invidio.us")
|
|
|
#let link = &"https://{hostname}/{name}/lists/{list}"
|
|
|
#result = ""
|
|
|
@@ -96,12 +95,12 @@
|
|
|
<description>Twitter feed for: ${list} by @${name}. Generated by ${hostname}</description>
|
|
|
<language>en-us</language>
|
|
|
<ttl>40</ttl>
|
|
|
- ${renderRssTweets(tweets, prefs)}
|
|
|
+ ${renderRssTweets(tweets, prefs, hostname)}
|
|
|
</channel>
|
|
|
</rss>
|
|
|
#end proc
|
|
|
#
|
|
|
-#proc renderSearchRss*(tweets: seq[Tweet]; name, param: string): string =
|
|
|
+#proc renderSearchRss*(tweets: seq[Tweet]; name, param, hostname: string): string =
|
|
|
#let prefs = Prefs(replaceTwitter: hostname, replaceYoutube: "invidio.us")
|
|
|
#let link = &"https://{hostname}/search"
|
|
|
#result = ""
|
|
|
@@ -114,7 +113,7 @@
|
|
|
<description>Twitter feed for search "${name}". Generated by ${hostname}</description>
|
|
|
<language>en-us</language>
|
|
|
<ttl>40</ttl>
|
|
|
- ${renderRssTweets(tweets, prefs)}
|
|
|
+ ${renderRssTweets(tweets, prefs, hostname)}
|
|
|
</channel>
|
|
|
</rss>
|
|
|
#end proc
|