feedlist: added committee minutes feed
[planet-ucc.git] / RSS2Writer.py
1 #
2 # RSS2Writer
3 #
4 # A plugin to XMLWriter to output RSS2.
5 #
6 # (c) 2004, Davyd Madeley <[email protected]>
7 #
8
9 import time, cgi
10
11 class RSS2Writer:
12         def __init__(self, planet):
13                 self.planet     = planet
14                 self.maxitems   = 50
15                 self.parent     = None
16         
17         def __write_item__(self, item):
18                 output  =       ''
19                 output  +=      '<item>\n'
20                 output  +=      ' <title>%s: %s</title>\n' % (item.blogName, item.itemTitle)
21                 output  +=      ' <link>%s</link>\n' % item.itemURL
22                 output  +=      ' <description>\n'
23                 output  +=      cgi.escape(item.contents)
24                 output  +=      '\n </description>\n'
25                 output  +=      '<pubDate>%s</pubDate>\n' % time.strftime('%a, %d %b %Y %H:%M:%S +0800', time.gmtime(item.itemDate))
26                 output  +=      '<comments>%s</comments>\n' % item.commentsURL
27                 output  +=      '</item>\n'
28                 return output
29         
30         def write(self):
31                 itemcount       = 0
32                 output  =       ''
33                 output  +=      '<rss version="2.0">\n'
34                 output  +=      ' <channel>\n'
35                 output  +=      '  <title>Planet UCC</title>\n'
36                 output  +=      '  <link>http://planet.ucc.asn.au/</link>\n'
37                 output  +=      '  <language>en</language>\n'
38                 output  +=      '  <description>Planet UCC</description>\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  +=      ' </channel>\n'
48                 output  +=      '</rss>\n'
49                 return output

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