瀏覽代碼

Improve RSS validity

Zed 7 年之前
父節點
當前提交
8912c53f23
共有 2 個文件被更改,包括 15 次插入8 次删除
  1. 4 1
      src/formatters.nim
  2. 11 7
      src/views/rss.nimf

+ 4 - 1
src/formatters.nim

@@ -114,7 +114,10 @@ proc getJoinDateFull*(profile: Profile): string =
   profile.joinDate.format("h:mm tt - d MMM YYYY")
 
 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 =
   &"/{tweet.profile.username}/status/{tweet.id}"

+ 11 - 7
src/views/rss.nimf

@@ -43,23 +43,27 @@
 #let prefs = Prefs(replaceTwitter: hostname)
 #result = ""
 <?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>
-    <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>
-    <link>https://${hostname}${profile.username}</link>
-    <description>Twitter feed for: ${profile.username}. Generated by ${hostname}</description>
+    <link>https://${hostname}/${profile.username}</link>
+    <description>Twitter feed for: @${profile.username}. Generated by ${hostname}</description>
     <language>en-us</language>
     <ttl>40</ttl>
     <image>
-        <url>https://${hostname}${getPicUrl(profile.getUserPic(style="_400x400"))}</url>
+      <title>${profile.fullname} / @${profile.username}</title>
+      <link>https://${hostname}/${profile.username}</link>
+      <url>https://${hostname}${getPicUrl(profile.getUserPic(style="_400x400"))}</url>
+      <width>128</width>
+      <height>128</height>
     </image>
     #for tweet in tweets:
     <item>
       <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>
-      <pubDate>${getTime(tweet)}</pubDate>
+      <pubDate>${getRfc822Time(tweet)}</pubDate>
       <guid>https://${hostname}${getLink(tweet)}</guid>
       <link>https://${hostname}${getLink(tweet)}</link>
     </item>