equal
deleted
inserted
replaced
|
1 """ |
|
2 Uses PyRSS2Gen to generate XML RSS documents |
|
3 """ |
|
4 |
|
5 import PyRSS2Gen as RSS2Gen |
|
6 import datetime, pytz |
|
7 |
|
8 class RSSFormatter (object) : |
|
9 """ |
|
10 Mixin for LogFormatter that implements the basic RSS-rendering stuff on top of format_html |
|
11 """ |
|
12 |
|
13 def format_rss (self, lines, **kwargs) : |
|
14 """ |
|
15 Process using format_html |
|
16 """ |
|
17 |
|
18 # build the RSS2 object and return the XML |
|
19 return RSS2Gen.RSS2( |
|
20 title = "IRC RSS feed", |
|
21 link = "http://irclogs.qmsk.net/", |
|
22 description = "A stupid RSS feed that nobody sane would ever use", |
|
23 |
|
24 # XXX: GMT |
|
25 lastBuildDate = datetime.datetime.utcnow(), |
|
26 |
|
27 items = [ |
|
28 RSS2Gen.RSSItem( |
|
29 # use the formatted HTML data as the title |
|
30 title = html_data, |
|
31 |
|
32 # timestamp |
|
33 pubDate = line.timestamp.astimezone(pytz.utc), |
|
34 |
|
35 # link |
|
36 link = "http://xxx/", |
|
37 |
|
38 ) for line, html_data in self.format_html(lines, **kwargs) |
|
39 ] |
|
40 ).to_xml('utf8') |
|
41 |