4 # Generate arbitrary XML files
12 def __init__(self, blog, item):
13 self.itemTitle = item.itemTitle
14 self.itemURL = item.itemURL
15 self.itemDate = item.itemDate
16 self.blogTitle = blog.blogTitle
17 self.blogURL = blog.blogURL
18 self.imageURL = blog.imageURL
19 self.imageLink = blog.imageLink
20 self.contents = item.contents
23 def __init__(self, date):
24 self.planetDate = date
28 def __init__(self, bloglist):
29 self.__bloglist__ = bloglist
30 self.__tainted__ = True
33 def append(self, blog):
34 self.__bloglist__.append(blog)
35 self.__tainted__ = True
37 def __getNext__(self, bloglist):
38 "Returns a PlanetItem reaped from a bloglist"
42 if len(blog.items) > 0 and blog.items[0].itemDate > latestTime:
43 latestTime = blog.items[0].itemDate
45 if holdingBlog == None:
47 item = holdingBlog.items.pop(0)
48 return PlanetItem(holdingBlog, item)
52 # we need to sort the blogs into a single news feed
53 # copy the bloglist to a working symbol
54 bloglist = self.__bloglist__ + []
59 lastItem = self.__getNext__(bloglist)
62 # this checks to see if it's a new day
63 if time.localtime(lastItem.itemDate)[6] != lastDate:
64 lastDate = time.localtime(lastItem.itemDate)[6]
65 workingDate = PlanetDate(lastItem.itemDate)
66 self.dates.append(workingDate)
67 # append the item to the current date
68 workingDate.items.append(lastItem)
69 self.__tainted__ = False
74 def __init__(self, doctype, bloglist):
75 self.planet = Planet(bloglist)
76 self.items = self.planet.sort()
77 # doctype should be something like XMLWriter.XHTMLWriter
78 self.writer = doctype(self.items)
81 output = self.writer.write()
85 def __init__(self, planet):
89 def __write_item__(self, item):
91 output += '<div id="item">\n'
92 output += '<h2>%s: %s</h2>\n' % (item.blogTitle, item.itemTitle)
93 output += '<p class="time">\n'
94 output += '(%s)\n' % time.strftime('%A %B %d, %Y %H:%M %Z', time.localtime(item.itemDate))
96 output += '<p class="body">\n'
97 output += item.contents
104 output += '<?xml version="1.0" encoding="UTF-8"?>\n'
105 output += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n'
106 output += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >\n'
108 output += '<title>Planet UCC</title>\n'
109 # XXX: we'll want a style sheet in here
110 output += '</head>\n'
112 # XXX: we want some stuff in here, I'm sure
113 for date in self.planet:
114 output += '<h1>%s</h1>\n' % time.strftime('%A %B %d, %Y', time.localtime(date.planetDate))
115 for item in date.items:
116 output += self.__write_item__(item)
117 # see how many items we've written
119 if itemcount >= self.maxitems:
121 # again, check to see if we've written the maximum number of items
122 if itemcount >= self.maxitems:
124 # XXX: we want further stuff here