]> oss.titaniummirror.com Git - webber.git/blobdiff - plugins/rss_feed.py
rss_feed.py: add a bit of atom support
[webber.git] / plugins / rss_feed.py
index 0681b39dbd18b1f030dd7fbafd4457d9cc33e693..90627677b993e958a374d1007bbe71367c6e21ff 100644 (file)
@@ -67,8 +67,18 @@ def finish(params):
                lastBuildDate = datetime.datetime.now(),
                items = items,
        )
+       # Step one of self-reference
+       # (see http://feedvalidator.org/docs/warning/MissingAtomSelfLink.html)
+       rss.rss_attrs["xmlns:atom"] = "http://www.w3.org/2005/Atom"
+       
        try:
                os.makedirs(cfg.out_dir)
        except:
                pass
-       rss.write_xml( open(os.path.join(cfg.out_dir, cfg.rss_file), "w"))
+       f = open(os.path.join(cfg.out_dir, cfg.rss_file), "w")
+       # Ugly XML beautification
+       s = rss.to_xml().replace("<", "\n<").replace("\n\n", "\n")[1:]
+       # Step two of self-reference
+       s = s.replace('<channel>', '<channel>\n<atom:link href="http://%s/%s" rel="self" type="application/rss+xml" />' % (cfg.main_url, cfg.rss_file))
+       f.write(s)
+       f.write("\n")