4 # A plugin to XMLWriter to output XHTML
13 def __init__(self, planet):
18 def __write_item__(self, item):
20 blogTitle, blogName, itemTitle = map(unicode, [item.blogTitle, item.blogName, item.itemTitle])
21 except UnicodeDecodeError, e:
22 print >> sys.stderr, "Unicode error in %s" % item.itemURL
23 print >> sys.stderr, e
27 output += u'<div class="item">\n'
28 output += u'<h2><a href="%s" title="%s">%s</a>: <a href="%s">%s</a></h2>\n' % (item.blogURL, blogTitle, blogName, item.itemURL, itemTitle)
29 output += u'<p class="time">\n'
31 output += u'<a class="image" href="%s"><img class="image" src="%s" alt="%s" /></a>\n' % (item.imageLink, item.imageURL, item.blogName)
32 output += u'(<a href="%s">%s</a>)\n' % (item.itemURL ,time.strftime('posted on %A %B %d, %Y at %H:%M AWST', time.localtime(item.itemDate)))
34 output += u'<div class="itembody">\n'
35 output += item.contents
36 output += u'\n</div>\n'
38 output += u'<p class="comments"><a href="%s">Comments</a></p>' % item.commentsURL
45 output += '<?xml version="1.0" encoding="UTF-8"?>\n'
46 output += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n'
47 output += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >\n'
49 output += '<title>Planet UCC</title>\n'
50 output += '<link rel="stylesheet" href="planet.css" type="text/css" media="screen" />\n'
51 output += '<link rel="icon" type="image/png" href="icon.png" />\n'
52 output += '<link rel="SHORTCUT ICON" type="image/png" href="icon.png" />\n'
53 output += '<link rel="alternate" type="application/rss+xml" title="RSS 1.0" href="rss1.xml" />\n'
54 output += '<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss2.xml" />\n'
57 output += '<div class="header">\n'
59 output += open('header.html').read()
63 output += '<div class="items">\n'
64 for date in self.planet:
65 output += '<h1>%s</h1>\n' % time.strftime('%A %B %d, %Y', time.localtime(date.planetDate))
66 for item in date.items:
67 output += self.__write_item__(item)
68 # see how many items we've written
70 if itemcount >= self.maxitems:
72 # again, check to see if we've written the maximum number of items
73 if itemcount >= self.maxitems:
76 output += '<div class="sidebar">\n'
78 output += open('sidebar.html').read()
81 output += '<h2>Last Updated</h2>\n'
83 output += '%s\n' % time.strftime('%A %B %d, %Y %H:%M AWST', time.localtime())
86 output += '<h2>Feeds</h2>\n'
88 blogscopy = self.parent.blogs + []
89 blogscopy.sort(self.__blog_sort__)
90 for blog in blogscopy:
91 output += '<a href="%s">%s</a> (<a href="%s">feed</a>)<br />\n' % (blog.blogURL, blog.blogName, blog.feedURL)
94 output += '<div class="footer">\n'
96 output += open('footer.html').read()
100 output += '</body>\n'
104 def __blog_sort__(self, blog1, blog2):
105 # name1, name2 = blog1.blogName.split(' ')[-1], blog2.blogName.split(' ')[-1]
106 name1, name2 = blog1.blogName, blog2.blogName
107 if name1 < name2: return -1
108 if name1 == name2: return 0
109 if name1 > name2: return 1