compliancy fixes
authordavyd <davyd>
Sat, 6 Mar 2004 09:13:58 +0000 (09:13 +0000)
committerdavyd <davyd>
Sat, 6 Mar 2004 09:13:58 +0000 (09:13 +0000)
RSS1Writer.py
RSS2Writer.py
update-planet

index 571998c..678f98d 100644 (file)
@@ -2,12 +2,11 @@
 # RSS1Writer
 #
 # A plugin to XMLWriter to output RSS version 1.0.
-# This plugin has been developed with no regard for the RSS1.0 spec.
 #
 # (c) 2004, Davyd Madeley <davyd@ucc.asn.au>
 #
 
-import time
+import time, cgi
 
 class RSS1Writer:
        def __init__(self, planet):
@@ -20,20 +19,20 @@ class RSS1Writer:
                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'
@@ -42,7 +41,7 @@ class RSS1Writer:
                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:
@@ -52,6 +51,5 @@ class RSS1Writer:
                                        break
                        if itemcount >= self.maxitems:
                                break
-               output  +=      '</rdf:RDF>\n'
-               output  +=      '</rss>'
+               output  +=      '</rdf:RDF>'
                return output
index 848f78e..07a7f35 100644 (file)
@@ -6,7 +6,7 @@
 # (c) 2004, Davyd Madeley <davyd@ucc.asn.au>
 #
 
-import time
+import time, cgi
 
 class RSS2Writer:
        def __init__(self, planet):
@@ -18,10 +18,10 @@ class RSS2Writer:
                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'
index 91cd899..86fc4a8 100755 (executable)
@@ -59,4 +59,3 @@ try:
        codecs.open('rss1.xml', 'wb', 'utf-8').write(xmlwriter.write(RSS1Writer.RSS1Writer))
 except:
        sys.stderr.write('DEBUG: update-planet: could not write rss1.xml, aborting\n')
-       raise

UCC git Repository :: git.ucc.asn.au