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) != lastDate:
64 workingDate = PlanetDate(lastItem.itemDate)
65 self.dates.append(workingDate)
66 # append the item to the current date
67 workingDate.items.append(lastItem)
68 self.__tainted__ = False
73 def __init__(self, doctype, bloglist):
74 self.planet = Planet(bloglist)
75 self.items = self.planet.sort()
76 # doctype should be something like XMLWriter.XHTMLWriter
77 self.writer = doctype(self.items)
80 output = self.writer.write()
84 def __init__(self, planet):
88 def __write_item__(self, item):
90 output += '<div id="item">\n'
91 output += '<h2>%s: %s</h2>\n' % (item.blogTitle, item.itemTitle)
92 output += '<p class="time">\n'
93 output += '(%s)\n' % time.strftime('%A %B %d, %Y %H:%M %Z', time.localtime(item.itemDate))
95 output += '<p class="body">\n'
96 output += item.contents
103 output += '<?xml version="1.0" encoding="UTF-8"?>\n'
104 output += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n'
105 output += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >\n'
107 output += '<title>Planet UCC</title>\n'
108 # XXX: we'll want a style sheet in here
109 output += '</head>\n'
111 # XXX: we want some stuff in here, I'm sure
112 for date in self.planet:
113 output += '<h1>%s</h1>\n' % time.strftime('%A %B %d, %Y', time.localtime(date.planetDate))
114 for item in date.items:
115 output += self.__write_item__(item)
116 # see how many items we've written
118 if itemcount >= self.maxitems:
120 # again, check to see if we've written the maximum number of items
121 if itemcount >= self.maxitems:
123 # XXX: we want further stuff here