Improve RSS validity

This commit is contained in:
Zed 2019-09-15 11:14:03 +02:00
parent a87e278a68
commit 8912c53f23
2 changed files with 15 additions and 8 deletions

View File

@ -114,7 +114,10 @@ proc getJoinDateFull*(profile: Profile): string =
profile.joinDate.format("h:mm tt - d MMM YYYY") profile.joinDate.format("h:mm tt - d MMM YYYY")
proc getTime*(tweet: Tweet): string = proc getTime*(tweet: Tweet): string =
tweet.time.format("d/M/yyyy', ' HH:mm:ss") tweet.time.format("d/M/yyyy', 'HH:mm:ss")
proc getRfc822Time*(tweet: Tweet): string =
tweet.time.format("ddd', 'd MMM yyyy HH:mm:ss 'GMT'")
proc getLink*(tweet: Tweet | Quote): string = proc getLink*(tweet: Tweet | Quote): string =
&"/{tweet.profile.username}/status/{tweet.id}" &"/{tweet.profile.username}/status/{tweet.id}"

View File

@ -43,23 +43,27 @@
#let prefs = Prefs(replaceTwitter: hostname) #let prefs = Prefs(replaceTwitter: hostname)
#result = "" #result = ""
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:nitter="http://${hostname}" version="2.0"> <rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel> <channel>
<atom:link href="http://${hostname}${profile.username}/rss" rel="self" type="application/rss+xml" /> <atom:link href="https://${hostname}/${profile.username}/rss" rel="self" type="application/rss+xml" />
<title>${profile.fullname} / @${profile.username}</title> <title>${profile.fullname} / @${profile.username}</title>
<link>https://${hostname}${profile.username}</link> <link>https://${hostname}/${profile.username}</link>
<description>Twitter feed for: ${profile.username}. Generated by ${hostname}</description> <description>Twitter feed for: @${profile.username}. Generated by ${hostname}</description>
<language>en-us</language> <language>en-us</language>
<ttl>40</ttl> <ttl>40</ttl>
<image> <image>
<title>${profile.fullname} / @${profile.username}</title>
<link>https://${hostname}/${profile.username}</link>
<url>https://${hostname}${getPicUrl(profile.getUserPic(style="_400x400"))}</url> <url>https://${hostname}${getPicUrl(profile.getUserPic(style="_400x400"))}</url>
<width>128</width>
<height>128</height>
</image> </image>
#for tweet in tweets: #for tweet in tweets:
<item> <item>
<title>${getTitle(tweet, prefs)}</title> <title>${getTitle(tweet, prefs)}</title>
<creator> (@${tweet.profile.username})</creator> <dc:creator>@${tweet.profile.username}</dc:creator>
<description><![CDATA[${renderRssTweet(tweet, prefs).strip(chars={'\n'})}]]></description> <description><![CDATA[${renderRssTweet(tweet, prefs).strip(chars={'\n'})}]]></description>
<pubDate>${getTime(tweet)}</pubDate> <pubDate>${getRfc822Time(tweet)}</pubDate>
<guid>https://${hostname}${getLink(tweet)}</guid> <guid>https://${hostname}${getLink(tweet)}</guid>
<link>https://${hostname}${getLink(tweet)}</link> <link>https://${hostname}${getLink(tweet)}</link>
</item> </item>