See ChangeLog
authordavyd <davyd>
Sat, 6 Mar 2004 05:44:48 +0000 (05:44 +0000)
committerdavyd <davyd>
Sat, 6 Mar 2004 05:44:48 +0000 (05:44 +0000)
Changelog
RSS2Writer.py [new file with mode: 0644]
XHTMLWriter.py [new file with mode: 0644]
XMLWriter.py
crontab
update-planet

index 6279c4a..7809779 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,25 @@
+2004-03-06
+==========
+ * Added RSS2Writer.py
+   XMLWriter plugin for handling RSS2 output.
+ * Added XHTMLWriter.py
+   Moved XHTMLWriter plugin out of XMLWriter.
+ * XMLWriter.py
+   Moved XHTMLWriter to it's own file, made some API changes.
+ * update-planet
+   Reflected API changes to XMLWriter, added generator for RSS2 feed.
+ * crontab
+   Added line to scp rss2.xml to mussel.
+
+2004-02-28
+==========
+ * crontab
+   Reduced update time to 5 minutes
+ * planet.css
+   Tweaked CSS to make sidebar background non-transparent.
+ * feedlist
+   Added people.
+
 2004-02-15
 ==========
  * update-planet
diff --git a/RSS2Writer.py b/RSS2Writer.py
new file mode 100644 (file)
index 0000000..86bfbb0
--- /dev/null
@@ -0,0 +1,41 @@
+import time
+
+class RSS2Writer:
+       def __init__(self, planet):
+               self.planet     = planet
+               self.maxitems   = 50
+               self.parent     = None
+       
+       def __write_item__(self, item):
+               output  =       ''
+               output  +=      '<item>\n'
+               output  +=      ' <title>%s: %s</title>\n' % (item.blogTitle, item.itemTitle)
+               output  +=      ' <guid>%s</guid>\n' % item.itemURL
+               output  +=      ' <link>%s</link>\n' % item.itemURL
+               output  +=      ' <description>\n'
+               output  +=      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'
+               return output
+       
+       def write(self):
+               itemcount       = 0
+               output  =       ''
+               output  +=      '<rss version="2.0">\n'
+               output  +=      ' <channel>\n'
+               output  +=      '  <title>Planet UCC</title>\n'
+               output  +=      '  <link>http://planet.ucc.asn.au/</link>\n'
+               output  +=      '  <language>en</language>\n'
+               output  +=      '  <description>Planet UCC</description>\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  +=      ' </channel>\n'
+               output  +=      '</rss>\n'
+               return output
diff --git a/XHTMLWriter.py b/XHTMLWriter.py
new file mode 100644 (file)
index 0000000..0694064
--- /dev/null
@@ -0,0 +1,87 @@
+import time
+
+class XHTMLWriter:
+       def __init__(self, planet):
+               self.planet     = planet
+               self.maxitems   = 50
+               self.parent     = None
+       
+       def __write_item__(self, item):
+               output  =       ''
+               output  +=      '<div class="item">\n'
+               output  +=      '<h2>%s: %s</h2>\n' % (item.blogTitle, item.itemTitle)
+               output  +=      '<p class="time">\n'
+               if item.imageURL:
+                       output += '<a class="image" href="%s"><img class="image" src="%s" alt="%s" /></a>\n' % (item.imageLink, item.imageURL, item.blogTitle)
+               output  +=      '(<a href="%s">%s</a>)\n' % (item.itemURL ,time.strftime('%A %B %d, %Y %H:%M AWST', time.localtime(item.itemDate)))
+               output  +=      '</p>\n'
+               output  +=      '<p class="body">\n'
+               output  +=      item.contents
+               output  +=      '\n</p>\n'
+               output  +=      '</div>\n'
+               return output
+       
+       def write(self):
+               itemcount       = 0
+               output  =       ''
+               output  +=      '<?xml version="1.0" encoding="UTF-8"?>\n'
+               output  +=      '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n'
+               output  +=      '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >\n'
+               output  +=      '<head>\n'
+               output  +=      '<title>Planet UCC</title>\n'
+               output  +=      '<link rel="stylesheet" href="planet.css" type="text/css" media="screen" />\n'
+               output  +=      '<link rel="icon" type="image/png" href="icon.png" />\n'
+               output  +=      '</head>\n'
+               output  +=      '<body>\n'
+               output  +=      '<div class="header">\n'
+               try:
+                       output  +=      open('header.html').read()
+               except:
+                       pass
+               output  +=      '</div>\n'
+               output  +=      '<div class="sidebar">\n'
+               try:
+                       output  +=      open('sidebar.html').read()
+               except:
+                       pass
+               output  +=      '<h2>Last Updated</h2>\n'
+               output  +=      '<p>\n'
+               output  +=      '%s\n' % time.strftime('%A %B %d, %Y %H:%M AWST', time.localtime())
+               output  +=      '</p>\n'
+               if self.parent:
+                       output  +=      '<h2>Feeds</h2>\n'
+                       output  +=      '<p>\n'
+                       blogscopy       = self.parent.blogs + []
+                       blogscopy.sort(self.__blog_sort__)
+                       for blog in blogscopy:
+                               output  += '<a href="%s">%s</a> (<a href="%s">feed</a>)<br />\n' % (blog.blogURL, blog.blogTitle, blog.feedURL)
+                       output  +=      '</p>\n'
+               output  +=      '</div>\n'
+               output  +=      '<div class="items">\n'
+               for date in self.planet:
+                       output  += '<h1>%s</h1>\n' % time.strftime('%A %B %d, %Y', time.localtime(date.planetDate))
+                       for item in date.items:
+                               output  += self.__write_item__(item)
+                               # see how many items we've written
+                               itemcount += 1
+                               if itemcount >= self.maxitems:
+                                       break
+                       # again, check to see if we've written the maximum number of items
+                       if itemcount >= self.maxitems:
+                               break
+               output  +=      '</div>\n'
+               output  +=      '<div class="footer">\n'
+               try:
+                       output  +=      open('footer.html').read()
+               except:
+                       pass
+               output  +=      '</div>\n'
+               output  +=      '</body>\n'
+               output  +=      '</html>'
+               return output
+       
+       def __blog_sort__(self, blog1, blog2):
+               name1, name2    = blog1.blogTitle.split(' ')[-1], blog2.blogTitle.split(' ')[-1]
+               if name1 < name2: return -1
+               if name1 == name2: return 0
+               if name1 > name2: return 1
index 38904dc..7f60c4e 100644 (file)
@@ -71,100 +71,15 @@ class Planet:
                        
 
 class XMLWriter:
-       def __init__(self, doctype, bloglist):
+       def __init__(self, bloglist):
                self.blogs      = bloglist
                self.planet     = Planet(bloglist)
                self.items      = self.planet.sort()
-               # doctype should be something like XMLWriter.XHTMLWriter
-               self.writer             = doctype(self.items)
-               self.writer.parent      = self
        
-       def write(self):
-               output          = self.writer.write()
+       def write(self, doctype):
+               # doctype should be something like XHTMLWriter.XHTMLWriter
+               writer          = doctype(self.items)
+               writer.parent   = self
+               output          = writer.write()
                return output
 
-class XHTMLWriter:
-       def __init__(self, planet):
-               self.planet     = planet
-               self.maxitems   = 50
-               self.parent     = None
-       
-       def __write_item__(self, item):
-               output  =       ''
-               output  +=      '<div class="item">\n'
-               output  +=      '<h2>%s: %s</h2>\n' % (item.blogTitle, item.itemTitle)
-               output  +=      '<p class="time">\n'
-               if item.imageURL:
-                       output += '<a class="image" href="%s"><img class="image" src="%s" alt="%s" /></a>\n' % (item.imageLink, item.imageURL, item.blogTitle)
-               output  +=      '(<a href="%s">%s</a>)\n' % (item.itemURL ,time.strftime('%A %B %d, %Y %H:%M AWST', time.localtime(item.itemDate)))
-               output  +=      '</p>\n'
-               output  +=      '<p class="body">\n'
-               output  +=      item.contents
-               output  +=      '\n</p>\n'
-               output  +=      '</div>\n'
-               return output
-       
-       def write(self):
-               itemcount       = 0
-               output  =       ''
-               output  +=      '<?xml version="1.0" encoding="UTF-8"?>\n'
-               output  +=      '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n'
-               output  +=      '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >\n'
-               output  +=      '<head>\n'
-               output  +=      '<title>Planet UCC</title>\n'
-               output  +=      '<link rel="stylesheet" href="planet.css" type="text/css" media="screen" />\n'
-               output  +=      '<link rel="icon" type="image/png" href="icon.png" />\n'
-               output  +=      '</head>\n'
-               output  +=      '<body>\n'
-               output  +=      '<div class="header">\n'
-               try:
-                       output  +=      open('header.html').read()
-               except:
-                       pass
-               output  +=      '</div>\n'
-               output  +=      '<div class="sidebar">\n'
-               try:
-                       output  +=      open('sidebar.html').read()
-               except:
-                       pass
-               output  +=      '<h2>Last Updated</h2>\n'
-               output  +=      '<p>\n'
-               output  +=      '%s\n' % time.strftime('%A %B %d, %Y %H:%M AWST', time.localtime())
-               output  +=      '</p>\n'
-               if self.parent:
-                       output  +=      '<h2>Feeds</h2>\n'
-                       output  +=      '<p>\n'
-                       blogscopy       = self.parent.blogs + []
-                       blogscopy.sort(self.__blog_sort__)
-                       for blog in blogscopy:
-                               output  += '<a href="%s">%s</a> (<a href="%s">feed</a>)<br />\n' % (blog.blogURL, blog.blogTitle, blog.feedURL)
-                       output  +=      '</p>\n'
-               output  +=      '</div>\n'
-               output  +=      '<div class="items">\n'
-               for date in self.planet:
-                       output  += '<h1>%s</h1>\n' % time.strftime('%A %B %d, %Y', time.localtime(date.planetDate))
-                       for item in date.items:
-                               output  += self.__write_item__(item)
-                               # see how many items we've written
-                               itemcount += 1
-                               if itemcount >= self.maxitems:
-                                       break
-                       # again, check to see if we've written the maximum number of items
-                       if itemcount >= self.maxitems:
-                               break
-               output  +=      '</div>\n'
-               output  +=      '<div class="footer">\n'
-               try:
-                       output  +=      open('footer.html').read()
-               except:
-                       pass
-               output  +=      '</div>\n'
-               output  +=      '</body>\n'
-               output  +=      '</html>'
-               return output
-       
-       def __blog_sort__(self, blog1, blog2):
-               name1, name2    = blog1.blogTitle.split(' ')[-1], blog2.blogTitle.split(' ')[-1]
-               if name1 < name2: return -1
-               if name1 == name2: return 0
-               if name1 > name2: return 1
diff --git a/crontab b/crontab
index c05976a..9b00ed4 100644 (file)
--- a/crontab
+++ b/crontab
@@ -1,2 +1,2 @@
-*/5 *  * * *   cd $HOME/projects/planetucc/ && ./update-planet > /dev/null && scp $HOME/projects/planetucc/planet.html [email protected]:public-html/index.html 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
 
index b532165..c0634bb 100755 (executable)
@@ -9,6 +9,7 @@
 
 import sys, codecs
 import XMLParse2 as XMLParse, XMLWriter, CacheHandler
+import XHTMLWriter, RSS2Writer
 
 # step 1: read in the config and check each object from cache
 cache  = CacheHandler.CacheHandler()
@@ -37,8 +38,18 @@ for feed in feeds:
        else:
                pass
 
-# step 3: write feed to disk
+# step 3: sift the feeds
+xmlwriter      = XMLWriter.XMLWriter(blogs)
+
+# step 4: write feed to disk
 try:
-       codecs.open('planet.html', 'wb', 'utf-8').write(XMLWriter.XMLWriter(XMLWriter.XHTMLWriter, blogs).write())
+       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')
+       raise

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