Improve uniqueness of feed entry ID

The ID of a feed entry should never change, but the previous method of
generating the ID -- i.e., using the entry URL -- results in an ID that
is not permanent and can change. Switching to the tag URI method from
RFC 4151 should help improve the long-term uniqueness and permanence of
entry IDs, as espoused here:
<http://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id>

Also added a trailing slash to the site URL inside the feed; the lack
thereof was causing a feed validation warning.
This commit is contained in:
Justin Mayer 2012-03-31 10:08:16 -07:00
commit 56b8a88b1f

View file

@ -27,7 +27,7 @@ class Writer(object):
feed_class = Rss201rev2Feed if feed_type == 'rss' else Atom1Feed
feed = feed_class(
title=context['SITENAME'],
link=self.site_url,
link=(self.site_url + '/'),
feed_url=self.feed_url,
description=context.get('SITESUBTITLE', ''))
return feed
@ -36,8 +36,9 @@ class Writer(object):
feed.add_item(
title=item.title,
link='%s/%s' % (self.site_url, item.url),
unique_id='%s/%s' % (self.site_url, item.url),
link='%s%s' % (self.site_url, item.url),
unique_id='tag:%s,%s:%s' % (self.site_url.replace('http://', ''),
item.date.date(), item.url),
description=item.content,
categories=item.tags if hasattr(item, 'tags') else None,
author_name=getattr(item, 'author', 'John Doe'),