Moved XHTMLWriter to it's own file, made some API changes.
* update-planet
Reflected API changes to XMLWriter, added generator for RSS2 feed.
+ Added generator for RSS1 feed.
* crontab
Added line to scp rss2.xml to mussel.
+ Added line to scp rss1.xml to mussel.
+ * XMLParse2
+ Added line to give personalised USER_AGENT.
+ * Added RSS1Writer.py
+ Output plugin for RSS1 files.
2004-02-28
==========
--- /dev/null
+#
+# 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
+
+class RSS1Writer:
+ def __init__(self, planet):
+ self.planet = planet
+ self.maxitems = 50
+ self.parent = None
+
+ def __write_item__(self, item):
+ output = ''
+ 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 += ' <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 = ''
+ output += '<rdf:RDF>\n'
+ output += ' <channel>\n'
+ output += ' <title>Planet UCC</title>\n'
+ output += ' <link>http://planet.ucc.asn.au/</link>\n'
+ # XXX: we need to output the blogroll here
+ output += ' </channel>\n'
+ for date in self.planet:
+ for item in date.items:
+ output += self.__write_item__(item)
+ itemcount += 1
+ if itemcount >= self.maxitems:
+ break
+ if itemcount >= self.maxitems:
+ break
+ output += '</rdf:RDF>\n'
+ return output
+#
+# RSS2Writer
+#
+# A plugin to XMLWriter to output RSS2.
+#
+#
+
import time
class RSS2Writer:
+#
+# XHTMLWriter
+#
+# A plugin to XMLWriter to output XHTML
+#
+#
+
import time
class XHTMLWriter:
sys.path.insert(0, 'extra')
import feedparser
+feedparser.USER_AGENT = "PlanetUCC/1.0b +http://planet.ucc.asn.au/ %s" % feedparser.USER_AGENT
+
class Blog:
def __init__(self):
self.blogTitle = None
-*/5 * * * * cd $HOME/projects/planetucc/ && ./update-planet > /dev/null && scp $HOME/projects/planetucc/planet.html
[email protected]:public-html/index.html 2>/dev/null && scp $HOME/projects/planetucc/rss2.xml
[email protected]:public-html/rss2.xml 2>/dev/null
+*/5 * * * * cd $HOME/projects/planetucc/ && \
+ ./update-planet > /dev/null && \
+ scp $HOME/projects/planetucc/planet.html
[email protected]:public-html/index.html 2>/dev/null && \
+ scp $HOME/projects/planetucc/rss2.xml
[email protected]:public-html/rss2.xml 2>/dev/null && \
+ scp $HOME/projects/planetucc/rss1.xml
[email protected]:public-html/rss1.xml 2>/dev/null
#
+# standard python modules
import sys, codecs
+# planetUCC modules
import XMLParse2 as XMLParse, XMLWriter, CacheHandler
-import XHTMLWriter, RSS2Writer
+# planetUCC output plugins
+import XHTMLWriter, RSS2Writer, RSS1Writer
# step 1: read in the config and check each object from cache
cache = CacheHandler.CacheHandler()
codecs.open('planet.html', 'wb', 'utf-8').write(xmlwriter.write(XHTMLWriter.XHTMLWriter))
except:
sys.stderr.write('DEBUG: update-planet: could not write planet.html, aborting\n')
- raise
try:
codecs.open('rss2.xml', 'wb', 'utf-8').write(xmlwriter.write(RSS2Writer.RSS2Writer))
except:
sys.stderr.write('DEBUG: update-planet: could not write rss2.xml, aborting\n')
+
+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