Fix #1291: Feeds have ambiguous titles on sites with multiple categories.

This commit is contained in:
davidlesieur 2014-09-15 19:58:31 -04:00 committed by Chris Krycho
commit 3b6d059eac
2 changed files with 17 additions and 11 deletions

View file

@ -31,11 +31,14 @@ class Writer(object):
self._written_files = set()
self._overridden_files = set()
def _create_new_feed(self, feed_type, context):
def _create_new_feed(self, feed_type, feed_title, context):
feed_class = Rss201rev2Feed if feed_type == 'rss' else Atom1Feed
sitename = Markup(context['SITENAME']).striptags()
if feed_title:
feed_title = context['SITENAME'] + ' - ' + feed_title
else:
feed_title = context['SITENAME']
feed = feed_class(
title=sitename,
title=Markup(feed_title).striptags(),
link=(self.site_url + '/'),
feed_url=self.feed_url,
description=context.get('SITESUBTITLE', ''))
@ -84,7 +87,7 @@ class Writer(object):
return open(filename, 'w', encoding=encoding)
def write_feed(self, elements, context, path=None, feed_type='atom',
override_output=False):
override_output=False, feed_title=None):
"""Generate a feed with the list of articles provided
Return the feed. If no path or output_path is specified, just
@ -97,6 +100,7 @@ class Writer(object):
:param override_output: boolean telling if we can override previous
output with the same name (and if next files written with the same
name should be skipped to keep that one)
:param feed_title: the title of the feed.o
"""
if not is_selected_for_writing(self.settings, path):
return
@ -107,7 +111,7 @@ class Writer(object):
self.feed_domain = context.get('FEED_DOMAIN')
self.feed_url = '{}/{}'.format(self.feed_domain, path)
feed = self._create_new_feed(feed_type, context)
feed = self._create_new_feed(feed_type, feed_title, context)
max_items = len(elements)
if self.settings['FEED_MAX_ITEMS']: