summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--feeds.py22
-rw-r--r--urls.py14
2 files changed, 17 insertions, 19 deletions
diff --git a/feeds.py b/feeds.py
index 32190a7b..0bb0e352 100644
--- a/feeds.py
+++ b/feeds.py
@@ -1,28 +1,27 @@
import datetime
-from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
+from django.contrib.syndication.feeds import FeedDoesNotExist
+from django.contrib.syndication.views import Feed
from django.db.models import Q
from main.models import Arch, Repo, Package, News
class PackageFeed(Feed):
link = '/packages/'
+ title_template = 'feeds/packages_title.html'
+ description_template = 'feeds/packages_description.html'
- def get_object(self, bits):
- # just cut the BS early
- if len(bits) > 2:
- raise FeedDoesNotExist
-
+ def get_object(self, request, arch='', repo=''):
obj = dict()
qs = Package.objects.select_related('arch', 'repo').order_by('-last_update')
- if len(bits) > 0:
+ if arch != '':
# feed for a single arch, also include 'any' packages everywhere
- a = Arch.objects.get(name=bits[0])
+ a = Arch.objects.get(name=arch)
qs = qs.filter(Q(arch=a) | Q(arch__name__iexact='any'))
obj['arch'] = a
- if len(bits) > 1:
+ if repo != '':
# feed for a single arch AND repo
- r = Repo.objects.get(name=bits[1])
+ r = Repo.objects.get(name=repo)
qs = qs.filter(repo=r)
obj['repo'] = r
obj['qs'] = qs[:50]
@@ -61,6 +60,8 @@ class NewsFeed(Feed):
title = 'Arch Linux: Recent news updates'
link = '/news/'
description = 'The latest and greatest news from the Arch Linux distribution.'
+ title_template = 'feeds/news_title.html'
+ description_template = 'feeds/news_description.html'
def items(self):
return News.objects.select_related('author').order_by('-postdate', '-id')[:10]
@@ -73,4 +74,3 @@ class NewsFeed(Feed):
return item.author.get_full_name()
# vim: set ts=4 sw=4 et:
-
diff --git a/urls.py b/urls.py
index 8fe7d7d9..64e60ccb 100644
--- a/urls.py
+++ b/urls.py
@@ -10,12 +10,6 @@ from main.models import Todolist
from feeds import PackageFeed, NewsFeed
from sitemaps import NewsSitemap, PackagesSitemap, PackageFilesSitemap
-
-feeds = {
- 'news': NewsFeed,
- 'packages': PackageFeed,
-}
-
sitemaps = {
'news': NewsSitemap,
'packages': PackagesSitemap,
@@ -85,8 +79,12 @@ urlpatterns = patterns('',
# Feeds and sitemaps
(r'^feeds/$', 'public.views.feeds', {}, 'feeds-list'),
- (r'^feeds/(?P<url>.*)/$',
- 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
+ (r'^feeds/news/$', NewsFeed()),
+ (r'^feeds/packages/$', PackageFeed()),
+ (r'^feeds/packages/(?P<arch>[A-z0-9]+)/$',
+ PackageFeed()),
+ (r'^feeds/packages/(?P<arch>[A-z0-9]+)/(?P<repo>[A-z0-9\-]+)/$',
+ PackageFeed()),
(r'^sitemap.xml$', 'django.contrib.sitemaps.views.index',
{'sitemaps': sitemaps}),
(r'^sitemap-(?P<section>.+)\.xml$', 'django.contrib.sitemaps.views.sitemap',