Commits

Cédric Bonhomme  committed 474b7ab

Added RSS and ATOM feeds.

  • Participants
  • Parent commits 86714cf

Comments (0)

Files changed (2)

+# -*- coding: utf-8 -*-
+from django.utils.feedgenerator import Atom1Feed
+from django.contrib.syndication.views import Feed
+
+from cedricbonhomme.blog.models import Post
+
+class RssSiteNewsFeed(Feed):
+    """
+    """
+    title = "~/blog"
+    link = "http://127.0.0.1:8000/"
+    description = "Updates on changes and additions to chicagocrime.org."
+
+    def items(self):
+        return Post.objects.order_by('-created')[:5]
+
+    def item_link(self, item):
+        return self.link + str(item.id)
+
+class AtomSiteNewsFeed(RssSiteNewsFeed):
+    """
+    """
+    feed_type = Atom1Feed
+    subtitle = RssSiteNewsFeed.description
 # -*- coding: utf-8 -*-
 from django.conf.urls.defaults import patterns, include, url
 
+from cedricbonhomme.feeds import RssSiteNewsFeed, AtomSiteNewsFeed
+
 # Uncomment the next two lines to enable the admin:
 from django.contrib import admin
 admin.autodiscover()
 
     (r"^categories/$", "cedricbonhomme.blog.views.categories"),
     (r"^category/(\w+)$", "cedricbonhomme.blog.views.category"),
-    
+
+
+    (r'^rss/$', RssSiteNewsFeed()),
+    (r'^atom/$', AtomSiteNewsFeed()),
+
     # Uncomment the admin/doc line below to enable admin documentation:
     # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),