From: Holger Schurig Date: Wed, 23 Jun 2010 09:14:30 +0000 (+0200) Subject: rss_feed.py: sort items by modification time X-Git-Url: https://oss.titaniummirror.com/gitweb?p=webber.git;a=commitdiff_plain;h=7e006074808e3c233ae4cbe8abfa6d4fe228d085 rss_feed.py: sort items by modification time --- diff --git a/plugins/rss_feed.py b/plugins/rss_feed.py index a8adbec..1dbc11e 100644 --- a/plugins/rss_feed.py +++ b/plugins/rss_feed.py @@ -52,13 +52,20 @@ def sitemap_scan(params): link = full_url, guid = PyRSS2Gen.Guid("%s %s" % (full_url, file["mtime"]), isPermaLink=0), description = change, - pubDate = datetime.datetime.fromtimestamp(file["mtime"], utc), + pubDate = file["mtime"] ) items.append(item) @set_hook("finish") def finish(params): + # Sort items by pubDate, which still holds the mtime + items.sort(key=lambda i: i.pubDate, reverse=True) + + # convert mtime to real pupDate + for i in items: + i.pubDate = datetime.datetime.fromtimestamp(i.pubDate, utc) + rss = PyRSS2Gen.RSS2( title = cfg.subtitle, link = "http://%s" % cfg.main_url,