return entries, context
- def get_obj_description(self, obj):
- return obj.excerpt
+ def add_item(self, feed, obj, kwargs=None):
+ defaults = {
+ 'title': obj.title,
+ 'description': obj.excerpt or obj.content,
+ 'author_name': obj.author.get_full_name(),
+ 'pubdate': obj.date
+ }
+ defaults.update(kwargs or {})
+ super(BlogView, self).add_item(feed, obj, defaults)
def entry_view(self, request, slug, year=None, month=None, day=None, node=None, extra_context=None):
entries = self.blog.entries.all()
context.update({'newsletter': self.newsletter})
return self.issue_archive_page.render_to_response(node, request, extra_context=context)
- def get_obj_description(self, obj):
- return obj.lede or obj.full_text
\ No newline at end of file
+ def add_item(self, feed, obj, kwargs=None):
+ defaults = {
+ 'title': obj.title,
+ 'author_name': ', '.join(obj.authors),
+ 'pubdate': obj.date,
+ 'description': obj.lede or obj.full_text,
+ 'categories': [tag.name for tag in obj.tags.all()]
+ }
+ defaults.update(kwargs or {})
+ super(NewsletterView, self).add_item(feed, obj, defaults)
\ No newline at end of file
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
from django.conf.urls.defaults import url, patterns
+from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from philo.utils import paginate
feed_type = 'atom'
feed = self.get_feed(feed_type, request, node, kwargs, reverse_name)
+ current_site = Site.objects.get_current()
for obj in objects:
- feed.add_item(obj.title, '/%s/%s/' % (node.get_absolute_url().strip('/'), self.get_subpath(obj).strip('/')), description=self.get_obj_description(obj))
+ kwargs = {
+ 'link': 'http://%s/%s/%s/' % (current_site.domain, node.get_absolute_url().strip('/'), self.get_subpath(obj).strip('/'))
+ }
+ self.add_item(feed, obj, kwargs=kwargs)
response = HttpResponse(mimetype=feed.mime_type)
feed.write(response, 'utf-8')
def get_feed(self, feed_type, request, node, kwargs, reverse_name):
title = self.feed_title
- link = '/%s/%s/' % (node.get_absolute_url().strip('/'), reverse(reverse_name, urlconf=self, kwargs=kwargs).strip('/'))
+ current_site = Site.objects.get_current()
+ link = 'http://%s/%s/%s/' % (current_site.domain, node.get_absolute_url().strip('/'), reverse(reverse_name, urlconf=self, kwargs=kwargs).strip('/'))
description = self.feed_description
if feed_type == 'rss':
return self.rss_feed(title, link, description)
)
return urlpatterns
- def get_obj_description(self, obj):
- raise NotImplementedError
\ No newline at end of file
+ def add_item(self, feed, obj, kwargs=None):
+ defaults = kwargs or {}
+ feed.add_item(**defaults)
\ No newline at end of file