# -*- coding: iso-8859-1 -*-
from webber import *
-import os, datetime, PyRSS2Gen
+import os, datetime
+try:
+ import PyRSS2Gen
+except ImportError:
+ print "rss_feed needs the python module PyRSS2Gen"
+ raise
items = []
file = params.file
if not file.has_key("linktitle"):
return
- if not file.has_key("change"):
- return
+ if file.has_key("change"):
+ change = file["change"]
+ else:
+ change = ""
fname_out = os.path.join(cfg.out_dir, file.out_path)
full_url = "http://%s/%s" % (cfg.main_url, fname_out)
item = PyRSS2Gen.RSSItem(
title = file["title"],
link = full_url,
- guid = PyRSS2Gen.Guid("%s %s" % (full_url, file["mtime"])),
- description = file["change"],
+ guid = PyRSS2Gen.Guid("%s %s" % (full_url, file["mtime"]), isPermaLink=0),
+ description = change,
pubDate = datetime.datetime.fromtimestamp(file["mtime"], utc),
)
items.append(item)
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:]
+ f.write(s)
+ f.write("\n")