RSS: Change feed to Atom format
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Aug 2020 15:29:08 +0000 (15:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Aug 2020 15:29:08 +0000 (15:29 +0000)
RSS does not allow to not have an email address for authors
which we do not have for imported feeds.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/blog/base.html
src/templates/blog/feed.xml
src/templates/index.html
src/web/blog.py

index 723d702..14f7576 100644 (file)
@@ -1,7 +1,7 @@
 {% extends "../base.html" %}
 
 {% block head %}
-       <link rel="alternate" type="application/rss+xml" title="RSS" href="https://blog.ipfire.org/feed.xml" />
+       <link rel="alternate" type="application/atom+xml" title="RSS" href="https://blog.ipfire.org/feed.xml" />
        {% block meta %}{% end block %}
 {% end block %}
 
index 1796d3d..98fe72e 100644 (file)
@@ -2,43 +2,32 @@
 
 {% import ipfire.accounts as accounts %}
 
-<rss version="2.0"
-               xmlns:content="http://purl.org/rss/1.0/modules/content/"
-               xmlns:atom="http://www.w3.org/2005/Atom"
-               xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
-       <channel>
-               <title>IPFire Blog</title>
-               <atom:link href="https://blog.ipfire.org/feed.xml" rel="self" type="application/rss+xml" />
-               <link>https://blog.ipfire.org</link>
-               <description>The official blog of the IPFire Project</description>
-               <lastBuildDate>{{ now }}</lastBuildDate>
-               <language>en-GB</language>
-               <sy:updatePeriod>hourly</sy:updatePeriod>
-               <sy:updateFrequency>1</sy:updateFrequency>
+<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
+       <id>https://blog.ipfire.org/feed.xml</id>
 
-               <image>
-                       <url>https://www.ipfire.org{{ static_url("img/tux/ipfire_tux_32x32.png") }}</url>
-                       <title>IPFire Blog</title>
-                       <link>https://blog.ipfire.org</link>
-                       <width>32</width>
-                       <height>32</height>
-               </image>
+       <link href="https://blog.ipfire.org/feed.xml" rel="self" type="application/atom+xml" />
+       <link href="https://blog.ipfire.org" rel="alternate" type="text/html"/>
+       <link rel="payment" title="Donate!" href="https://www.ipfire.org/donate" type="text/html" />
 
-               <atom:link rel="payment" title="Donate!" href="https://www.ipfire.org/donate" type="text/html" />
+       <title>IPFire Blog</title>
+       <subtitle>The official blog of the IPFire Project</subtitle>
+       <logo>https://www.ipfire.org{{ static_url("img/tux/ipfire_tux_32x32.png") }}</logo>
+       <updated>{{ now.isoformat() }}Z</updated>
 
-               {% for post in posts %}
-                       <item>
-                               <title>{{ post.title }}</title>
-                               <link>https://blog.ipfire.org/post/{{ post.slug }}</link>
+       {% for post in posts %}
+               <entry>
+                       <id>https://blog.ipfire.org/post/{{ post.slug }}</id>
+                       <title type="html">{{ post.title }}</title>
+                       <link href="https://blog.ipfire.org/post/{{ post.slug }}" rel="alternate" type="text/html" title="{{ post.title }}" />
+                       <author>
+                               <name>{{ post.author }}</name>
                                {% if isinstance(post.author, accounts.Account) %}
-                                       <author>{{ post.author.email }} ({{ post.author.name }})</author>
-                               {% else %}
-                                       <author>{{ post.author }}</author>
+                                       <email>{{┬ápost.author.email }}</email>
                                {% end %}
-                               <pubDate>{{ post.published_at.strftime("%a, %d %b %Y %H:%M:%S +0200") }}</pubDate>
-                               <guid isPermaLink="true">https://blog.ipfire.org/post/{{ post.slug }}</guid>
-                               <description><![CDATA[{% raw post.html %}]]></description>
-                       </item>
-               {% end %}
-       </channel>
-</rss>
+                       </author>
+                       <published>{{ post.published_at.isoformat() }}Z</published>
+                       <updated>{{ post.updated_at.isoformat() }}Z</updated>
+                       <content type="html"><![CDATA[{% raw post.html %}]]></content>
+               </entry>
+       {% end %}
+</feed>
index f668b01..17520e3 100644 (file)
@@ -2,7 +2,7 @@
 
 {% block head %}
        <meta name="description" content="{{ _("IPFire is a hardened, versatile, state-of-the-art Open Source firewall based on Linux.") }}" />
-       <link rel="alternate" type="application/rss+xml" title="RSS" href="https://blog.ipfire.org/feed.xml" />
+       <link rel="alternate" type="application/atom+xml" title="RSS" href="https://blog.ipfire.org/feed.xml" />
 {% end block %}
 
 {% block title %}{{ _("Welcome to IPFire") }}{% end block %}
index 13d414e..ff90bdd 100644 (file)
@@ -48,11 +48,11 @@ class FeedHandler(base.BaseHandler):
                self.set_expires(600)
 
                # Set correct content type
-               self.set_header("Content-Type", "application/rss+xml")
+               self.set_header("Content-Type", "application/atom+xml")
 
                # Render the feed
                self.render("blog/feed.xml", posts=posts,
-                       now=email.utils.formatdate())
+                       now=datetime.datetime.now())
 
 
 class PostHandler(auth.CacheMixin, base.BaseHandler):