Source

django-blog / feeds.py

Full commit
# -*- coding: utf-8 -*-
from django.utils.feedgenerator import Atom1Feed
from django.contrib.syndication.views import Feed

from cedricbonhomme.blog.models import Post
from cedricbonhomme.blog.models import Comment

class RssSiteNewsFeed(Feed):
    """
    """
    title = "~/blog"
    link = "/"
    description = "Latest news from the blog of Cédric Bonhomme."

    def items(self):
        return Post.objects.order_by('-created')[:15]

    def item_description(self, item):
        return item.content_html

    def item_link(self, item):
        return self.link + str(item.id)

class AtomSiteNewsFeed(RssSiteNewsFeed):
    """
    """
    feed_type = Atom1Feed
    subtitle = RssSiteNewsFeed.description



class RssCommentsFeed(Feed):
    """
    """
    title = "~/blog"
    link = "/"
    description = "Latest comments from the blog of Cédric Bonhomme."

    def items(self):
        return Comment.objects.order_by('-created')[:15]

    def item_description(self, item):
        return item.content

    def item_link(self, item):
        return self.link + str(item.post.id)

class AtomCommentsFeed(RssCommentsFeed):
    """
    """
    feed_type = Atom1Feed
    subtitle = RssCommentsFeed.description