# RSS1Writer
#
# A plugin to XMLWriter to output RSS version 1.0.
-# This plugin has been developed with no regard for the RSS1.0 spec.
#
#
-import time
+import time, cgi
class RSS1Writer:
def __init__(self, planet):
output += '<item rdfAbout="%s">\n' % item.itemURL
output += ' <title>%s: %s</title>\n' % (item.blogTitle, item.itemTitle)
output += ' <link>%s</link>\n' % item.itemURL
- output += ' <content:encoded>\n'
- output += item.contents
- output += '\n </content:encoded>\n'
+ output += ' <description>\n'
+ output += cgi.escape(item.contents)
+ output += '\n </description>\n'
output += ' <dc:date>%s</dc:date>\n' % time.strftime('%Y-%m-%dT%H:%M:%S+00:00', time.gmtime(item.itemDate))
output += '</item>\n'
return output
def write(self):
itemcount = 0
- output = '<rss version="1.0\n'
+ output = ''
+ output += '<rdf:RDF>\n'
+ output += ' xmlns="http://purl.org/rss/1.0/"\n'
output += ' xmlns:dc="http://purl.org/dc/elements/1.1/"\n'
- output += ' xmlns:content="http://purl.org/rss/1.0/modules/content/">\n'
output += ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\n'
- output += '<rdf:RDF>\n'
output += ' <channel>\n'
output += ' <title>Planet UCC</title>\n'
output += ' <link>http://planet.ucc.asn.au/</link>\n'
for blog in self.parent.blogs:
output += ' <rdf:li rdf:resource="%s" />\n' % blog.feedURL
output += ' </rdf:Seq>\n'
- output += ' <items>\n'
+ output += ' </items>\n'
output += ' </channel>\n'
for date in self.planet:
for item in date.items:
break
if itemcount >= self.maxitems:
break
- output += '</rdf:RDF>\n'
- output += '</rss>'
+ output += '</rdf:RDF>'
return output
#
-import time
+import time, cgi
class RSS2Writer:
def __init__(self, planet):
output = ''
output += '<item>\n'
output += ' <title>%s: %s</title>\n' % (item.blogTitle, item.itemTitle)
- output += ' <guid>%s</guid>\n' % item.itemURL
+# output += ' <guid>%s</guid>\n' % item.itemURL
output += ' <link>%s</link>\n' % item.itemURL
output += ' <description>\n'
- output += item.contents
+ output += cgi.escape(item.contents)
output += '\n </description>\n'
output += '<pubDate>%s</pubDate>\n' % time.strftime('%a, %d %b %Y %H:%M:%S +0000', time.gmtime(item.itemDate))
output += '</item>\n'