See ChangeLog some more... more output modules
[planet-ucc.git] / RSS1Writer.py
1 #
2 # RSS1Writer
3 #
4 # A plugin to XMLWriter to output RSS version 1.0.
5 # This plugin has been developed with no regard for the RSS1.0 spec.
6 #
7 # (c) 2004, Davyd Madeley <[email protected]>
8 #
9
10 import time
11
12 class RSS1Writer:
13         def __init__(self, planet):
14                 self.planet     = planet
15                 self.maxitems   = 50
16                 self.parent     = None
17         
18         def __write_item__(self, item):
19                 output  =       ''
20                 output  +=      '<item rdfAbout="%s">\n' % item.itemURL
21                 output  +=      ' <title>%s: %s</title>\n' % (item.blogTitle, item.itemTitle)
22                 output  +=      ' <link>%s</link>\n' % item.itemURL
23                 output  +=      ' <content:encoded>\n'
24                 output  +=      item.contents
25                 output  +=      '\n </content:encoded>\n'
26                 output  +=      ' <dc:date>%s</dc:date>\n' % time.strftime('%Y-%m-%dT%H:%M:%S+00:00', time.gmtime(item.itemDate))
27                 output  +=      '</item>\n'
28                 return output
29         
30         def write(self):
31                 itemcount       = 0
32                 output  =       ''
33                 output  +=      '<rdf:RDF>\n'
34                 output  +=      ' <channel>\n'
35                 output  +=      '  <title>Planet UCC</title>\n'
36                 output  +=      '  <link>http://planet.ucc.asn.au/</link>\n'
37                 # XXX: we need to output the blogroll here
38                 output  +=      ' </channel>\n'
39                 for date in self.planet:
40                         for item in date.items:
41                                 output  += self.__write_item__(item)
42                                 itemcount += 1
43                                 if itemcount >= self.maxitems:
44                                         break
45                         if itemcount >= self.maxitems:
46                                 break
47                 output  +=      '</rdf:RDF>\n'
48                 return output

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