From 9f4902f9c921b82f924fe0af106fa5480ca10ca9 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 7 Apr 2011 14:39:14 -0500 Subject: 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 --- feeds.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'feeds.py') diff --git a/feeds.py b/feeds.py index cdba991..d204327 100644 --- a/feeds.py +++ b/feeds.py @@ -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 -- cgit v1.2.3-24-g4f1b