Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
atom.xml: don't assume <updated> to be last updated post
Browse files Browse the repository at this point in the history
The user may have triggered an manual regeneration, so it may not be
accurate to assume that the feed's last-modified date is the same as
that of the last updated post.

We change <updated> and <id>, but leave <rights> alone, since the
copyright year should rely on the post's update date.
  • Loading branch information
rctay authored and Arachnid committed Jun 4, 2010
1 parent 924bbd7 commit eba2eb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,15 @@ def generate_resource(cls, post, resource):
q = models.BlogPost.all().order('-updated')
# Fetch the 10 most recently updated non-draft posts
posts = list(itertools.islice((x for x in q if x.path), 10))
now = datetime.datetime.now().replace(second=0, microsecond=0)
template_vals = {
'posts': posts,
'updated': now,
}
rendered = utils.render_template("atom.xml", template_vals)
static.set('/feeds/atom.xml', rendered,
'application/atom+xml; charset=utf-8', indexed=False)
'application/atom+xml; charset=utf-8', indexed=False,
last_modified=now)
if config.hubbub_hub_url:
cls.send_hubbub_ping(config.hubbub_hub_url)

Expand Down
4 changes: 2 additions & 2 deletions themes/default/atom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">{{config.blog_name}}</title>
<subtitle type="html">{{config.slogan}}</subtitle>
<updated>{{posts.0.updated|date:"Y-m-d\TH:i:s\Z"}}</updated>
<id>tag:{{config.host}},{{posts.0.updated|date:"Y-m-d"}}:atom.xml</id>
<updated>{{updated|date:"Y-m-d\TH:i:s\Z"}}</updated>
<id>tag:{{config.host}},{{updated|date:"Y-m-d"}}:atom.xml</id>
<link rel="alternate" type="text/html" hreflang="en" href="http://{{config.host}}{{config.url_prefix}}/" />
<link rel="self" type="application/atom+xml" href="http://{{config.host}}{{config.url_prefix}}/feeds/atom.xml" />
<link rel="hub" href="{{config.hubbub_hub_url}}" />
Expand Down

0 comments on commit eba2eb9

Please sign in to comment.