diff --git a/requirements.txt b/requirements.txt
index d26342d..c128aea 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1,2 @@
-Flask-Markdown==0.3
\ No newline at end of file
+Flask-Markdown==0.3
+rfeed==1.1.1
\ No newline at end of file
diff --git a/webapp/app.py b/webapp/app.py
index 7bee328..5b4b911 100644
--- a/webapp/app.py
+++ b/webapp/app.py
@@ -1,6 +1,8 @@
+import datetime
import html
-from flask import render_template, request, flash, redirect, url_for
+import rfeed
+from flask import render_template, request, flash, redirect, url_for, Response
from webapp.routes import *
from oshipka.webapp import app
@@ -53,3 +55,28 @@ def blog_post_filename(filename):
flash("Blog post doesn't exist")
return redirect(url_for('index'))
return render_template("blog_post/get.html", instance=blog_post)
+
+
+@app.route('/rss.xml')
+def rss():
+ feed_items = []
+ for blog_post in BlogPost.query.order_by(BlogPost.created_dt.desc()).all():
+ d = blog_post.created_dt
+ pub_date = datetime.datetime(int(d[0:4]), int(d[4:6]), int(d[6:8]))
+ item = rfeed.Item(
+ title=blog_post.title,
+ link="https://blog.pi2.dev/blog_post/{}".format(blog_post.filename),
+ description="{}...".format(blog_post.body[:300]),
+ author="Daniel",
+ guid=rfeed.Guid("https://blog.pi2.dev/blog_post/{}".format(blog_post.filename)),
+ pubDate=pub_date)
+ feed_items.append(item)
+
+ feed = rfeed.Feed(
+ title="Pi2-Blog posts",
+ link="https://blog.pi2.dev/rss.xml",
+ description="Pisquared Blog - Recently updated posts",
+ language="en-US",
+ lastBuildDate=datetime.datetime.now(),
+ items=feed_items)
+ return Response(feed.rss(), mimetype='text/xml')
diff --git a/webapp/templates/layout.html b/webapp/templates/layout.html
index fe1883c..86d7978 100644
--- a/webapp/templates/layout.html
+++ b/webapp/templates/layout.html
@@ -11,6 +11,7 @@
href="{{ url_for('static', filename='favicons/favicon-96x96.png') }}">
+