blob: 7b63c43a30efea9209a1f5a861ccd623eab99925 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
from datetime import date
from django.contrib.comments.models import Comment
from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed
from blog.models import Post
class BlogRss(Feed):
title = "toofishes.net Blog"
link = "/blog/"
description = "The latest and greatest from my blog."
year = date.today().year
feed_copyright = "Copyright (c) 2007-%d, Dan McGee" % year
title_template = 'feeds/blog_title.html'
description_template = 'feeds/blog_description.html'
def items(self):
return Post.objects.public().select_related('author')[:10]
def item_pubdate(self, item):
return item.pub_date
def item_categories(self, item):
return item.categories.all()
def item_author_name(self, item):
return item.author.get_full_name()
class BlogAtom(BlogRss):
feed_type = Atom1Feed
subtitle = BlogRss.description
class CommentsRss(Feed):
title = "toofishes.net Blog Comments"
link = "/blog/"
description = "The most recent post comments from my blog."
title_template = 'feeds/comments_title.html'
description_template = 'feeds/comments_description.html'
def items(self):
return Comment.objects.filter(is_public=True).order_by('-submit_date')[:20]
def item_pubdate(self, item):
return item.submit_date
def item_author_name(self, item):
return item.name
class CommentsAtom(CommentsRss):
feed_type = Atom1Feed
subtitle = CommentsRss.description
# vim: set ts=4 sw=4 et:
|