Permalink
Browse files

Clean up the blog feeds.

  • Loading branch information...
1 parent f07df08 commit d7e50bec9f601b73bc1e36731c217587c7629c73 @stephenmcd committed Apr 14, 2012
Showing with 22 additions and 16 deletions.
  1. +2 −2 mezzanine/blog/feeds.py
  2. +2 −2 mezzanine/blog/urls.py
  3. +18 −12 mezzanine/blog/views.py
View
@@ -44,7 +44,7 @@ def __init__(self, *args, **kwargs):
self.description = settings.SITE_TAGLINE
def link(self):
- return reverse("blog_post_feed", kwargs={"url": "rss"})
+ return reverse("blog_post_feed", kwargs={"format": "rss"})
def items(self):
if not self._public:
@@ -81,4 +81,4 @@ def subtitle(self):
return self.description
def link(self):
- return reverse("blog_post_feed", kwargs={"url": "atom"})
+ return reverse("blog_post_feed", kwargs={"format": "atom"})
View
@@ -1,10 +1,10 @@
from django.conf.urls.defaults import patterns, url
+
# Blog patterns.
urlpatterns = patterns("mezzanine.blog.views",
- url("^feeds/(?P<url>.*)/$", "blog_post_feed", name="blog_post_feed"),
-
+ url("^feeds/(?P<format>.*)/$", "blog_post_feed", name="blog_post_feed"),
url("^tag/(?P<tag>.*)/$", "blog_post_list", name="blog_post_list_tag"),
url("^category/(?P<category>.*)/$", "blog_post_list",
name="blog_post_list_category"),
View
@@ -108,15 +108,21 @@ def blog_post_detail(request, slug, year=None, month=None,
templates = [u"blog/blog_post_detail_%s.html" % unicode(slug), template]
return render(request, templates, context)
-blog_feed_dict = {"rss": PostsRSS, "atom": PostsAtom}
-try:
- # Django <= 1.3
- from django.contrib.syndication.views import feed
- def blog_post_feed(request, url):
- return feed(request, url, feed_dict=blog_feed_dict)
-except ImportError:
- # Django >= 1.4
- def blog_post_feed(request, url):
- if url not in blog_feed_dict:
- raise Http404()
- return blog_feed_dict[url]()(request)
+
+def blog_post_feed(request, format):
+ """
+ Blog posts feeds - handle difference between Django 1.3 and 1.4
+ """
+ blog_feed_dict = {"rss": PostsRSS, "atom": PostsAtom}
+ try:
+ blog_feed_dict[format]
+ except KeyError:
+ raise Http404()
+ try:
+ # Django <= 1.3
+ from django.contrib.syndication.views import feed
+ except ImportError:
+ # Django >= 1.4
+ return blog_feed_dict[format]()(request)
+ else:
+ return feed(request, format, feed_dict=blog_feed_dict)

0 comments on commit d7e50be

Please sign in to comment.