Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added sub-feeds for community feed types.

  • Loading branch information...
commit 5483763700cdb82873f1d66764d1376a8d2bb25a 1 parent 257b3bd
Jacob Kaplan-Moss authored January 28, 2011
1  TODO
... ...
@@ -1,4 +1,3 @@
1 1
 * Pagination for aggregator feed item details
2  
-* Individual RSS feeds - firehose, blogs, q&a, etc.
3 2
 * allow users to "own" feeds and self-edit
4 3
 * allow users to "claim" legacy feeds (might do this by hand.)
53  django_website/aggregator/feeds.py
... ...
@@ -1,12 +1,55 @@
1 1
 from __future__ import absolute_import
2 2
 
  3
+from django.core import urlresolvers
3 4
 from django.contrib.syndication.views import Feed
4  
-from .models import FeedItem
  5
+from django.shortcuts import get_object_or_404
  6
+from .models import FeedType, FeedItem
5 7
 
6 8
 class CommunityAggregatorFeed(Feed):
7  
-    title = "The Django community aggregator"
8  
-    link = "http://www.djangoproject.com/community/"
9 9
     description = "Aggregated feeds from the Django community."
10 10
 
11  
-    def items(self):
12  
-        return FeedItem.objects.all()[:10]
  11
+    def get_object(self, request, slug=None):
  12
+        if slug:
  13
+            return get_object_or_404(FeedType, slug=slug)
  14
+        return None
  15
+
  16
+    def title(self, obj):
  17
+        title = obj.name if obj else "firehose"
  18
+        return "Django community aggregator: %s" % title
  19
+
  20
+    def link(self, obj):
  21
+        if obj:
  22
+            return urlresolvers.reverse('aggregator-feed', args=[obj.slug])
  23
+        else:
  24
+            return urlresolvers.reverse('aggregator-feed-firehose')
  25
+
  26
+    def description(self, obj):
  27
+        return self.title(obj)
  28
+
  29
+    def items(self, obj):
  30
+        qs = FeedItem.objects.order_by('-date_modified')
  31
+        qs = qs.select_related('feed', 'feed__feed_type')
  32
+        if obj:
  33
+            qs = qs.filter(feed__feed_type=obj)
  34
+        return qs[:25]
  35
+
  36
+    def item_title(self, item):
  37
+        return item.title
  38
+
  39
+    def item_description(self, item):
  40
+        return item.summary
  41
+
  42
+    def item_guid(self, item):
  43
+        return item.guid
  44
+
  45
+    def item_link(self, item):
  46
+        return item.link
  47
+
  48
+    def item_author_name(self, item):
  49
+        return item.feed.title
  50
+
  51
+    def item_author_link(self, item):
  52
+        return item.feed.public_url
  53
+
  54
+    def item_pubdate(self, item):
  55
+        return item.date_modified
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
6 6
 
7 7
 {% for feedtype in feedtype_list %}
8 8
 <div id="{{ feedtype.slug }}" class="module {% cycle "first" "last" %}">
9  
-  <h3 class="header">{{ feedtype.name }}</h3>
  9
+  <h3 class="header">
  10
+    {{ feedtype.name }}
  11
+    <a class="rss" href="{% url aggregator-feed slug=feedtype.slug %}">RSS</a>
  12
+  </h3>
10 13
   {% for item in feedtype.items|slice:":5" %}
11 14
     <h5><a href="{{ item.link }}">{{ item.title }}</a></h5>
12 15
     <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>
1  django_website/templates/feeds/weblog_description.html
... ...
@@ -1 +0,0 @@
1  
-{{ obj.body|safe }}
1  django_website/templates/feeds/weblog_title.html
... ...
@@ -1 +0,0 @@
1  
-{{ obj.headline }}
25  django_website/urls/www.py
@@ -17,12 +17,6 @@
17 17
     'paginate_by': 15,
18 18
 }
19 19
 
20  
-feeds = {
21  
-    'weblog': WeblogEntryFeed,
22  
-    'comments': LatestCommentFeed,
23  
-    'community': CommunityAggregatorFeed,
24  
-}
25  
-
26 20
 sitemaps = {
27 21
     'weblog': WeblogSitemap,
28 22
     'flatpages': FlatPageSitemap,
@@ -41,14 +35,19 @@
41 35
          'django_website.aggregator.views.feed_list',
42 36
           name="community-feed-list"),
43 37
     url(r'^community/', 'django_website.aggregator.views.index', name='community-index'),
44  
-    (r'^contact/', include('django_website.contact.urls')),
45  
-    (r'^r/', include('django.conf.urls.shortcut')),
46  
-    (r'^rss/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
47  
-    (r'^sitemap\.xml$', cache_page(sitemap_views.sitemap, 60 * 60 * 6), {'sitemaps': sitemaps}),
48  
-    (r'^weblog/', include('django_website.blog.urls')),
49  
-    (r'^freenode\.9xJY7YIUWtwn\.html$', 'django.views.generic.simple.direct_to_template', {'template': 'freenode_tmp.html'}),
  38
+    url(r'^contact/', include('django_website.contact.urls')),
  39
+    url(r'^r/', include('django.conf.urls.shortcut')),
  40
+
  41
+    url(r'^rss/weblog/$', WeblogEntryFeed(), name='weblog-feed'),
  42
+    url(r'^rss/comments/$', LatestCommentFeed(), name='comments-feed'),
  43
+    url(r'^rss/community/$', CommunityAggregatorFeed(), name='aggregator-firehose-feed'),
  44
+    url(r'^rss/community/(?P<slug>[\w-]+)/$', CommunityAggregatorFeed(), name='aggregator-feed'),
  45
+
  46
+    url(r'^sitemap\.xml$', cache_page(sitemap_views.sitemap, 60 * 60 * 6), {'sitemaps': sitemaps}),
  47
+    url(r'^weblog/', include('django_website.blog.urls')),
  48
+    url(r'^freenode\.9xJY7YIUWtwn\.html$', 'django.views.generic.simple.direct_to_template', {'template': 'freenode_tmp.html'}),
50 49
     url(r'^download$', 'django.contrib.flatpages.views.flatpage', {'url': 'download'}, name="download"),
51  
-    (r'', include('django_website.legacy.urls')),
  50
+    url(r'', include('django_website.legacy.urls')),
52 51
 )
53 52
 
54 53
 if not settings.PRODUCTION:

0 notes on commit 5483763

Please sign in to comment.
Something went wrong with that request. Please try again.