Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added sub-feeds for community feed types.

  • Loading branch information...
commit 5483763700cdb82873f1d66764d1376a8d2bb25a 1 parent 257b3bd
@jacobian jacobian authored
View
1  TODO
@@ -1,4 +1,3 @@
* Pagination for aggregator feed item details
-* Individual RSS feeds - firehose, blogs, q&a, etc.
* allow users to "own" feeds and self-edit
* allow users to "claim" legacy feeds (might do this by hand.)
View
53 django_website/aggregator/feeds.py
@@ -1,12 +1,55 @@
from __future__ import absolute_import
+from django.core import urlresolvers
from django.contrib.syndication.views import Feed
-from .models import FeedItem
+from django.shortcuts import get_object_or_404
+from .models import FeedType, FeedItem
class CommunityAggregatorFeed(Feed):
- title = "The Django community aggregator"
- link = "http://www.djangoproject.com/community/"
description = "Aggregated feeds from the Django community."
- def items(self):
- return FeedItem.objects.all()[:10]
+ def get_object(self, request, slug=None):
+ if slug:
+ return get_object_or_404(FeedType, slug=slug)
+ return None
+
+ def title(self, obj):
+ title = obj.name if obj else "firehose"
+ return "Django community aggregator: %s" % title
+
+ def link(self, obj):
+ if obj:
+ return urlresolvers.reverse('aggregator-feed', args=[obj.slug])
+ else:
+ return urlresolvers.reverse('aggregator-feed-firehose')
+
+ def description(self, obj):
+ return self.title(obj)
+
+ def items(self, obj):
+ qs = FeedItem.objects.order_by('-date_modified')
+ qs = qs.select_related('feed', 'feed__feed_type')
+ if obj:
+ qs = qs.filter(feed__feed_type=obj)
+ return qs[:25]
+
+ def item_title(self, item):
+ return item.title
+
+ def item_description(self, item):
+ return item.summary
+
+ def item_guid(self, item):
+ return item.guid
+
+ def item_link(self, item):
+ return item.link
+
+ def item_author_name(self, item):
+ return item.feed.title
+
+ def item_author_link(self, item):
+ return item.feed.public_url
+
+ def item_pubdate(self, item):
+ return item.date_modified
View
5 django_website/templates/aggregator/index.html
@@ -6,7 +6,10 @@ <h2 class="deck">This page, updated regularly, aggregates what's going on in the
{% for feedtype in feedtype_list %}
<div id="{{ feedtype.slug }}" class="module {% cycle "first" "last" %}">
- <h3 class="header">{{ feedtype.name }}</h3>
+ <h3 class="header">
+ {{ feedtype.name }}
+ <a class="rss" href="{% url aggregator-feed slug=feedtype.slug %}">RSS</a>
+ </h3>
{% for item in feedtype.items|slice:":5" %}
<h5><a href="{{ item.link }}">{{ item.title }}</a></h5>
<p class="date">{{ item.date_modified|date:"N jS, Y \a\t P" }} by <a href="{{ item.feed.public_url }}">{{ item.feed.title }}</a></p>
View
1  django_website/templates/feeds/weblog_description.html
@@ -1 +0,0 @@
-{{ obj.body|safe }}
View
1  django_website/templates/feeds/weblog_title.html
@@ -1 +0,0 @@
-{{ obj.headline }}
View
25 django_website/urls/www.py
@@ -17,12 +17,6 @@
'paginate_by': 15,
}
-feeds = {
- 'weblog': WeblogEntryFeed,
- 'comments': LatestCommentFeed,
- 'community': CommunityAggregatorFeed,
-}
-
sitemaps = {
'weblog': WeblogSitemap,
'flatpages': FlatPageSitemap,
@@ -41,14 +35,19 @@
'django_website.aggregator.views.feed_list',
name="community-feed-list"),
url(r'^community/', 'django_website.aggregator.views.index', name='community-index'),
- (r'^contact/', include('django_website.contact.urls')),
- (r'^r/', include('django.conf.urls.shortcut')),
- (r'^rss/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
- (r'^sitemap\.xml$', cache_page(sitemap_views.sitemap, 60 * 60 * 6), {'sitemaps': sitemaps}),
- (r'^weblog/', include('django_website.blog.urls')),
- (r'^freenode\.9xJY7YIUWtwn\.html$', 'django.views.generic.simple.direct_to_template', {'template': 'freenode_tmp.html'}),
+ url(r'^contact/', include('django_website.contact.urls')),
+ url(r'^r/', include('django.conf.urls.shortcut')),
+
+ url(r'^rss/weblog/$', WeblogEntryFeed(), name='weblog-feed'),
+ url(r'^rss/comments/$', LatestCommentFeed(), name='comments-feed'),
+ url(r'^rss/community/$', CommunityAggregatorFeed(), name='aggregator-firehose-feed'),
+ url(r'^rss/community/(?P<slug>[\w-]+)/$', CommunityAggregatorFeed(), name='aggregator-feed'),
+
+ url(r'^sitemap\.xml$', cache_page(sitemap_views.sitemap, 60 * 60 * 6), {'sitemaps': sitemaps}),
+ url(r'^weblog/', include('django_website.blog.urls')),
+ url(r'^freenode\.9xJY7YIUWtwn\.html$', 'django.views.generic.simple.direct_to_template', {'template': 'freenode_tmp.html'}),
url(r'^download$', 'django.contrib.flatpages.views.flatpage', {'url': 'download'}, name="download"),
- (r'', include('django_website.legacy.urls')),
+ url(r'', include('django_website.legacy.urls')),
)
if not settings.PRODUCTION:
Please sign in to comment.
Something went wrong with that request. Please try again.