Code

Ticket #3958: feedgenerator.3.diff

File feedgenerator.3.diff, 1.7 KB (added by Baptiste <baptiste.goupil@…>, 7 years ago)

And a bonus patch that sets the <subtitle> to the given argument subtitle if it exists or the description if not, since the <subtitle> is almost the description. Nothing is broken, and that allows to use the same code for ATOM & RSS feeds.

Line 
1Index: utils/feedgenerator.py
2===================================================================
3--- utils/feedgenerator.py      (revision 4953)
4+++ utils/feedgenerator.py      (copie de travail)
5@@ -132,6 +132,7 @@
6             handler.addQuickElement(u"category", cat)
7         if self.feed['feed_copyright'] is not None:
8             handler.addQuickElement(u"copyright", self.feed['feed_copyright'])
9+        handler.addQuickElement(u"lastBuildDate", rfc2822_date(self.latest_post_date()).decode('ascii'))
10         self.write_items(handler)
11         self.endChannelElement(handler)
12         handler.endElement(u"rss")
13@@ -199,6 +200,8 @@
14         else:
15             handler.startElement(u"feed", {u"xmlns": self.ns})
16         handler.addQuickElement(u"title", self.feed['title'])
17+        if self.feed['subtitle'] is not None or self.feed['description'] is not None:
18+            handler.addQuickElement(u"subtitle", self.feed['subtitle'] or self.feed['description'])
19         handler.addQuickElement(u"link", "", {u"rel": u"alternate", u"href": self.feed['link']})
20         if self.feed['feed_url'] is not None:
21             handler.addQuickElement(u"link", "", {u"rel": u"self", u"href": self.feed['feed_url']})
22@@ -212,8 +215,6 @@
23             if self.feed['author_link'] is not None:
24                 handler.addQuickElement(u"uri", self.feed['author_link'])
25             handler.endElement(u"author")
26-        if self.feed['subtitle'] is not None:
27-            handler.addQuickElement(u"subtitle", self.feed['subtitle'])
28         for cat in self.feed['categories']:
29             handler.addQuickElement(u"category", "", {u"term": cat})
30         if self.feed['feed_copyright'] is not None: