@@ -19,51 +19,58 @@
|
||||
#end if
|
||||
#end proc
|
||||
#
|
||||
#proc renderRssTweet(tweet: Tweet; prefs: Prefs; hostname: string): string =
|
||||
#proc getDescription(desc: string; cfg: Config): string =
|
||||
Twitter feed for: ${desc}. Generated by ${cfg.hostname}
|
||||
#end proc
|
||||
#
|
||||
#proc renderRssTweet(tweet: Tweet; prefs: Prefs; cfg: Config): string =
|
||||
#let tweet = tweet.retweet.get(tweet)
|
||||
#let text = replaceUrl(tweet.text, prefs, absolute=hostname)
|
||||
#let urlPrefix = getUrlPrefix(cfg)
|
||||
#let text = replaceUrl(tweet.text, prefs, absolute=urlPrefix)
|
||||
#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>
|
||||
# let quoteLink = getLink(get(tweet.quote))
|
||||
<p>${text}<br><a href="${urlPrefix}${quoteLink}">${cfg.hostname}${quoteLink}</a></p>
|
||||
#else:
|
||||
<p>${text}</p>
|
||||
#end if
|
||||
#if tweet.photos.len > 0:
|
||||
#for photo in tweet.photos:
|
||||
<img src="https://${hostname}${getPicUrl(photo)}" style="max-width:250px;" />
|
||||
#end for
|
||||
# for photo in tweet.photos:
|
||||
<img src="${urlPrefix}${getPicUrl(photo)}" style="max-width:250px;" />
|
||||
# end for
|
||||
#elif tweet.video.isSome:
|
||||
<img src="https://${hostname}${getPicUrl(get(tweet.video).thumb)}" style="max-width:250px;" />
|
||||
<img src="${urlPrefix}${getPicUrl(get(tweet.video).thumb)}" style="max-width:250px;" />
|
||||
#elif tweet.gif.isSome:
|
||||
#let thumb = &"https://{hostname}{getPicUrl(get(tweet.gif).thumb)}"
|
||||
#let url = &"https://{hostname}{getPicUrl(get(tweet.gif).url)}"
|
||||
# let thumb = &"{urlPrefix}{getPicUrl(get(tweet.gif).thumb)}"
|
||||
# let url = &"{urlPrefix}{getPicUrl(get(tweet.gif).url)}"
|
||||
<video poster="${thumb}" autoplay muted loop style="max-width:250px;">
|
||||
<source src="${url}" type="video/mp4"</source></video>
|
||||
#end if
|
||||
#end proc
|
||||
#
|
||||
#proc renderRssTweets(tweets: seq[Tweet]; prefs: Prefs; hostname: string): string =
|
||||
#proc renderRssTweets(tweets: seq[Tweet]; prefs: Prefs; cfg: Config): string =
|
||||
#let urlPrefix = getUrlPrefix(cfg)
|
||||
#var links: seq[string]
|
||||
#for t in tweets:
|
||||
#let retweet = if t.retweet.isSome: t.profile.username else: ""
|
||||
#let tweet = if retweet.len > 0: t.retweet.get else: t
|
||||
#let link = getLink(tweet)
|
||||
#if link in links: continue
|
||||
#end if
|
||||
#links.add link
|
||||
<item>
|
||||
<title>${getTitle(tweet, prefs, retweet)}</title>
|
||||
<dc:creator>@${tweet.profile.username}</dc:creator>
|
||||
<description><![CDATA[${renderRssTweet(tweet, prefs, hostname).strip(chars={'\n'})}]]></description>
|
||||
<pubDate>${getRfc822Time(tweet)}</pubDate>
|
||||
<guid>https://${hostname & link}</guid>
|
||||
<link>https://${hostname & link}</link>
|
||||
</item>
|
||||
# let retweet = if t.retweet.isSome: t.profile.username else: ""
|
||||
# let tweet = if retweet.len > 0: t.retweet.get else: t
|
||||
# let link = getLink(tweet)
|
||||
# if link in links: continue
|
||||
# end if
|
||||
# links.add link
|
||||
<item>
|
||||
<title>${getTitle(tweet, prefs, retweet)}</title>
|
||||
<dc:creator>@${tweet.profile.username}</dc:creator>
|
||||
<description><![CDATA[${renderRssTweet(tweet, prefs, cfg).strip(chars={'\n'})}]]></description>
|
||||
<pubDate>${getRfc822Time(tweet)}</pubDate>
|
||||
<guid>${urlPrefix & link}</guid>
|
||||
<link>${urlPrefix & link}</link>
|
||||
</item>
|
||||
#end for
|
||||
#end proc
|
||||
#
|
||||
#proc renderTimelineRss*(timeline: Timeline; profile: Profile; hostname: string; multi=false): string =
|
||||
#let prefs = Prefs(replaceTwitter: hostname, replaceYouTube: "invidious.snopyta.org")
|
||||
#proc renderTimelineRss*(timeline: Timeline; profile: Profile; cfg: Config; multi=false): string =
|
||||
#let prefs = Prefs(replaceTwitter: cfg.hostname, replaceYouTube: "invidious.snopyta.org")
|
||||
#let urlPrefix = getUrlPrefix(cfg)
|
||||
#result = ""
|
||||
#let user = (if multi: "" else: "@") & profile.username
|
||||
#var title = profile.fullname
|
||||
@@ -73,29 +80,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
|
||||
<channel>
|
||||
<atom:link href="https://${hostname}/${profile.username}/rss" rel="self" type="application/rss+xml" />
|
||||
<atom:link href="${urlPrefix}/${profile.username}/rss" rel="self" type="application/rss+xml" />
|
||||
<title>${title}</title>
|
||||
<link>https://${hostname}/${profile.username}</link>
|
||||
<description>Twitter feed for: ${user}. Generated by ${hostname}</description>
|
||||
<link>${urlPrefix}/${profile.username}</link>
|
||||
<description>${getDescription(user, cfg)}</description>
|
||||
<language>en-us</language>
|
||||
<ttl>40</ttl>
|
||||
<image>
|
||||
<title>${title}</title>
|
||||
<link>https://${hostname}/${profile.username}</link>
|
||||
<url>https://${hostname}${getPicUrl(profile.getUserPic(style="_400x400"))}</url>
|
||||
<link>${urlPrefix}/${profile.username}</link>
|
||||
<url>${urlPrefix}${getPicUrl(profile.getUserPic(style="_400x400"))}</url>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</image>
|
||||
#if timeline.content.len > 0:
|
||||
${renderRssTweets(timeline.content, prefs, hostname)}
|
||||
#end if
|
||||
#if timeline.content.len > 0:
|
||||
${renderRssTweets(timeline.content, prefs, cfg)}
|
||||
#end if
|
||||
</channel>
|
||||
</rss>
|
||||
#end proc
|
||||
#
|
||||
#proc renderListRss*(tweets: seq[Tweet]; list: List; hostname: string): string =
|
||||
#let prefs = Prefs(replaceTwitter: hostname, replaceYouTube: "invidious.snopyta.org")
|
||||
#let link = &"https://{hostname}/{list.username}/lists/{list.name}"
|
||||
#proc renderListRss*(tweets: seq[Tweet]; list: List; cfg: Config): string =
|
||||
#let prefs = Prefs(replaceTwitter: cfg.hostname, replaceYouTube: "invidious.snopyta.org")
|
||||
#let link = &"{getUrlPrefix(cfg)}/{list.username}/lists/{list.name}"
|
||||
#result = ""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
|
||||
@@ -103,17 +110,17 @@
|
||||
<atom:link href="${link}" rel="self" type="application/rss+xml" />
|
||||
<title>${xmltree.escape(list.name)} / @${list.username}</title>
|
||||
<link>${link}</link>
|
||||
<description>Twitter feed for: ${list.name} by @${list.username}. Generated by ${hostname}</description>
|
||||
<description>${getDescription(list.name & " by @" & list.username, cfg)}</description>
|
||||
<language>en-us</language>
|
||||
<ttl>40</ttl>
|
||||
${renderRssTweets(tweets, prefs, hostname)}
|
||||
${renderRssTweets(tweets, prefs, cfg)}
|
||||
</channel>
|
||||
</rss>
|
||||
#end proc
|
||||
#
|
||||
#proc renderSearchRss*(tweets: seq[Tweet]; name, param, hostname: string): string =
|
||||
#let prefs = Prefs(replaceTwitter: hostname, replaceYouTube: "invidious.snopyta.org")
|
||||
#let link = &"https://{hostname}/search"
|
||||
#proc renderSearchRss*(tweets: seq[Tweet]; name, param: string; cfg: Config): string =
|
||||
#let prefs = Prefs(replaceTwitter: cfg.hostname, replaceYouTube: "invidious.snopyta.org")
|
||||
#let link = &"{getUrlPrefix(cfg)}/search"
|
||||
#let escName = xmltree.escape(name)
|
||||
#result = ""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -122,10 +129,10 @@
|
||||
<atom:link href="${link}" rel="self" type="application/rss+xml" />
|
||||
<title>Search results for "${escName}"</title>
|
||||
<link>${link}</link>
|
||||
<description>Twitter feed for search "${escName}". Generated by ${hostname}</description>
|
||||
<description>${getDescription("Search \"" & escName & "\"", cfg)}</description>
|
||||
<language>en-us</language>
|
||||
<ttl>40</ttl>
|
||||
${renderRssTweets(tweets, prefs, hostname)}
|
||||
${renderRssTweets(tweets, prefs, cfg)}
|
||||
</channel>
|
||||
</rss>
|
||||
#end proc
|
||||
|
||||
Reference in New Issue
Block a user