diff options
author | Dan McGee <dan@archlinux.org> | 2011-04-07 14:39:14 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-04-07 17:01:16 -0500 |
commit | 9f4902f9c921b82f924fe0af106fa5480ca10ca9 (patch) | |
tree | 489df7db006f43f6ab74bb191fe220012073c539 /feeds.py | |
parent | 0504fbeb92e83e92e1f1bc6e003bdb3f93c4318f (diff) |
Ensure feed GUIDs are unchanging and unique
Implement 'tag:' style URIs for the GUID field on our RSS feeds. This
ensures new package updates show up as new, and we aren't jumping back
and forth between generated GUIDs having 'http://' and 'https://'
prefixes.
Much of the work here is to attempt to keep old news GUIDs constant so
we don't once again make everything show up as new in newsreaders.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'feeds.py')
-rw-r--r-- | feeds.py | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1,6 +1,7 @@ import datetime from decimal import Decimal, ROUND_HALF_DOWN +from django.contrib.sites.models import Site from django.contrib.syndication.views import Feed from django.core.cache import cache from django.db.models import Q @@ -97,9 +98,18 @@ class PackageFeed(Feed): s += '.' return s + subtitle = description + def items(self, obj): return obj['qs'] + def item_guid(self, item): + # http://diveintomark.org/archives/2004/05/28/howto-atom-id + date = item.last_update + return 'tag:%s,%s:%s%s' % (Site.objects.get_current().domain, + date.strftime('%Y-%m-%d'), item.get_absolute_url(), + date.strftime('%Y%m%d%H%M')) + def item_pubdate(self, item): return item.last_update @@ -135,6 +145,7 @@ class NewsFeed(Feed): title = 'Arch Linux: Recent news updates' link = '/news/' description = 'The latest and greatest news from the Arch Linux distribution.' + subtitle = description title_template = 'feeds/news_title.html' description_template = 'feeds/news_description.html' @@ -146,6 +157,9 @@ class NewsFeed(Feed): return News.objects.select_related('author').order_by( '-postdate', '-id')[:10] + def item_guid(self, item): + return item.guid + def item_pubdate(self, item): return item.postdate |