feedlist: update blog URL
[planet-ucc.git] / XMLWriter.py
index 8a443ba..27f4738 100644 (file)
@@ -14,10 +14,12 @@ class PlanetItem:
                self.itemURL    = item.itemURL
                self.itemDate   = item.itemDate
                self.blogTitle  = blog.blogTitle
+               self.blogName   = blog.blogName
                self.blogURL    = blog.blogURL
                self.imageURL   = blog.imageURL
                self.imageLink  = blog.imageLink
                self.contents   = item.contents
+               self.commentsURL = item.commentsURL
 
 class PlanetDate:
        def __init__(self, date):
@@ -71,82 +73,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 id="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 %Z', time.localtime(item.itemDate)))
-               output  +=      '</p>\n'
-               output  +=      '<p class="body">\n'
-               output  +=      item.contents
-               output  +=      '\n</p>\n'
-               output  +=      '</div>'
-               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  +=      '</head>\n'
-               output  +=      '<body>\n'
-               output  +=      '<div id="header">\n'
-               output  +=      '</div>\n'
-               output  +=      '<div id="sidebar">\n'
-               try:
-                       output  +=      open('sidebar.html').read()
-               except:
-                       pass
-               if self.parent:
-                       output  +=      '<h2>Feeds</h2>\n'
-                       output  +=      '<p>\n'
-                       for blog in self.parent.blogs:
-                               output  += '<a href="%s">%s</a><br />\n' % (blog.blogURL, blog.blogTitle)
-                       output  +=      '</p>\n'
-               output  +=      '</div>\n'
-               output  +=      '<div id="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 id="footer">\n'
-               try:
-                       output  +=      open('footer.html').read()
-               except:
-                       pass
-               output  +=      '</body>\n'
-               output  +=      '</html>'
-               return output

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