X-Git-Url: https://git.ucc.asn.au/?p=planet-ucc.git;a=blobdiff_plain;f=XMLWriter.py;h=27f4738363fbc9d224b6f24cb52c5823537121b2;hp=1311fb68631723a1ab03defcde68c5f3fffaa6d2;hb=38a726acb570f023a3e4ea859d5dc9d80465b70b;hpb=b2d7ed4b39a5a03fb8f264e26b0d04a502928ddf diff --git a/XMLWriter.py b/XMLWriter.py index 1311fb6..27f4738 100644 --- a/XMLWriter.py +++ b/XMLWriter.py @@ -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): @@ -60,7 +62,8 @@ class Planet: if lastItem == None: break # this checks to see if it's a new day - if time.localtime(lastItem.itemDate) != lastDate: + if time.localtime(lastItem.itemDate)[6] != lastDate: + lastDate = time.localtime(lastItem.itemDate)[6] workingDate = PlanetDate(lastItem.itemDate) self.dates.append(workingDate) # append the item to the current date @@ -70,57 +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) - 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 = 100 - - def __write_item__(self, item): - output = '' - output += '
\n' - output += '

%s: %s

\n' % (item.blogTitle, item.itemTitle) - output += '

\n' - output += '(%s)\n' % time.strftime('%A %B %d, %Y %H:%M %Z', time.localtime(item.itemDate)) - output += '

\n' - output += '

\n' - output += item.contents - output += '\n

\n' - return output - - def write(self): - itemcount = 0 - output = '' - output += '\n' - output += '\n' - output += '\n' - output += '\n' - output += 'Planet UCC\n' - # XXX: we'll want a style sheet in here - output += '\n' - output += '\n' - # XXX: we want some stuff in here, I'm sure - for date in self.planet: - output += '

%s

\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 - # XXX: we want further stuff here - output += '' - output += '' - return output