Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #20. Made feeds in DjogSite more robust.

git-svn-id: file:///Users/brian/Backups/S3/backups/Wednesday/brian/svn/djog/trunk@59 95ab7de8-677b-4562-a266-b8acc9dd993c
  • Loading branch information...
commit 872b7b8e70d95f3c70e2d66d33811dd483a8e7a6 1 parent 2231157
@brosner authored
Showing with 15 additions and 13 deletions.
  1. +4 −4 djog/feeds.py
  2. +4 −9 djog/sites.py
  3. +7 −0 djog/urls.py
View
8 djog/feeds.py
@@ -7,7 +7,7 @@
from djog.models import Entry, Tag
-class LatestEntries(Feed):
+class EntryFeed(Feed):
title = "Alex's Blog: Latest Entries"
link = "/blog/latest/"
description = "The latest entries on Alex's Blog"
@@ -15,7 +15,7 @@ class LatestEntries(Feed):
def items(self):
return Entry.objects.order_by('-pub_date')[:10]
-class LatestCommentsByEntry(Feed):
+class CommentsByEntryFeed(Feed):
def get_object(self, bits):
if len(bits) != 4:
raise ObjectDoesNotExist
@@ -33,7 +33,7 @@ def description(self, obj):
def items(self, obj):
return FreeComment.objects.filter(content_type__model='entry').filter(object_id=obj.pk).order_by('-submit_date')[:10]
-class LatestEntriesByTag(Feed):
+class EntriesByTagFeed(Feed):
def get_object(self, bits):
if len(bits) != 1:
raise ObjectDoesNotExist
@@ -51,7 +51,7 @@ def description(self, obj):
def items(self, obj):
return Entry.objects.filter(tags__tag=obj.tag)[:10]
-class EntriesBySearch(Feed):
+class SearchFeed(Feed):
def get_object(self, bits):
if len(bits) != 1:
raise ObjectDoesNotExist
View
13 djog/sites.py
@@ -7,24 +7,19 @@
from django.utils.encoding import smart_str
from django.contrib.syndication.views import feed
-from djog.feeds import *
from djog.models import Blog
class DjogSite(object):
def __init__(self):
- self.feeds = {
- 'latest': LatestEntries,
- 'comments': LatestCommentsByEntry,
- 'tags': LatestEntriesByTag,
- 'search': EntriesBySearch,
- }
+ self.feeds = {}
def get_blog(self):
- # TODO: look at this a bit more and find a good way to ensure it has
- # an object.
return Blog.on_site.all()[0]
+ def add_feed(self, url, feed_class):
+ self.feeds.update({url: feed_class})
+
def archive_index(self, request, **kwargs):
defaults = dict(
queryset = self.get_blog().entry_set.all(),
View
7 djog/urls.py
@@ -1,6 +1,13 @@
from django.conf.urls.defaults import *
+
from djog import site
+from djog.feeds import *
+
+site.add_feed('latest', EntryFeed)
+site.add_feed('comments', CommentsByEntryFeed)
+site.add_feed('tags', EntriesByTagFeed)
+site.add_feed('search', SearchFeed)
urlpatterns = patterns('',
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$',
Please sign in to comment.
Something went wrong with that request. Please try again.