From e533b3b82e254e2c22ed40a570b5e8b31a1f126b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sat, 29 Oct 2011 01:37:55 +0200 Subject: [PATCH] First try at an ATOM feed --- blog/urls.py | 1 + blog/views.py | 8 ++++++++ templates/blog/base.html | 14 ++++++++++++++ templates/blog/rss.xml | 25 +++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 templates/blog/rss.xml diff --git a/blog/urls.py b/blog/urls.py index c4137ed..a21c56a 100644 --- a/blog/urls.py +++ b/blog/urls.py @@ -6,4 +6,5 @@ urlpatterns = patterns('blog.views', (r'^post/(?P\d+)/$', 'post'), (r'^tags/$', 'tags'), (r'^tag/(?P[\w_]+)/$', 'tag'), + (r'^atom/$', 'atom'), ) diff --git a/blog/views.py b/blog/views.py index 06a4aba..92ac55e 100644 --- a/blog/views.py +++ b/blog/views.py @@ -27,6 +27,14 @@ def index(request, page=0): return direct_to_template(request, "blog/posts.html", c) +def atom(request): + post_list = Post.objects.all().order_by("-postdate")[0:15] + c = { + 'postlist': post_list, + } + + return direct_to_template(request, "blog/rss.xml", c) + def post(request, post_id): post = Post.objects.filter(pk=post_id) t = loader.get_template("blog/posts.html") diff --git a/templates/blog/base.html b/templates/blog/base.html index 2eadc88..e5caf88 100644 --- a/templates/blog/base.html +++ b/templates/blog/base.html @@ -3,3 +3,17 @@ {% block subtitle %} blog {% endblock %} + +{% block extrastyle %} + +{% endblock %} + +{% block submenu %} +
+
+ blog +
+ feed +
+{% endblock %} diff --git a/templates/blog/rss.xml b/templates/blog/rss.xml new file mode 100644 index 0000000..9cc6df3 --- /dev/null +++ b/templates/blog/rss.xml @@ -0,0 +1,25 @@ + + + ryuslash.org + + + http://ryuslash.org/blog/ + + Tom Willemsen + + 2011-10-29T23:16:00+01:00 + + {% for post in postlist %} + + {{ post.subject }} + + http://ryuslash.org/blog/post/{{ post.pk }}/ + {{ post.postdate|date:"c" }} + +
+ {{ post.body|linebreaksbr }} +
+
+
+ {% endfor %} +