See ChangeLog some more... more output modules
authordavyd <davyd>
Sat, 6 Mar 2004 06:17:26 +0000 (06:17 +0000)
committerdavyd <davyd>
Sat, 6 Mar 2004 06:17:26 +0000 (06:17 +0000)
Changelog
RSS1Writer.py [new file with mode: 0644]
RSS2Writer.py
XHTMLWriter.py
XMLParse2.py
crontab
update-planet

index 7809779..a6894d0 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -8,8 +8,14 @@
    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
 ==========
diff --git a/RSS1Writer.py b/RSS1Writer.py
new file mode 100644 (file)
index 0000000..83460d3
--- /dev/null
@@ -0,0 +1,48 @@
+#
+# 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 <[email protected]>
+#
+
+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
index 86bfbb0..848f78e 100644 (file)
@@ -1,3 +1,11 @@
+#
+# RSS2Writer
+#
+# A plugin to XMLWriter to output RSS2.
+#
+# (c) 2004, Davyd Madeley <[email protected]>
+#
+
 import time
 
 class RSS2Writer:
index 0694064..3ef84c9 100644 (file)
@@ -1,3 +1,11 @@
+#
+# XHTMLWriter
+#
+# A plugin to XMLWriter to output XHTML
+#
+# (c) 2004, Davyd Madeley <[email protected]>
+#
+
 import time
 
 class XHTMLWriter:
index 563a0fa..3a14e2b 100644 (file)
@@ -13,6 +13,8 @@ import CacheHandler
 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
diff --git a/crontab b/crontab
index 9b00ed4..698ca49 100644 (file)
--- a/crontab
+++ b/crontab
@@ -1,2 +1,6 @@
-*/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
 
index c0634bb..91cd899 100755 (executable)
@@ -7,9 +7,12 @@
 # (c) 2004, Davyd Madeley <[email protected]>
 #
 
+# 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()
@@ -46,10 +49,14 @@ try:
        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

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