Add a setting to limit feeds to a max number of items.

This adds FEED_MAX_ITEMS, which dictates the maximum number of items allowed in a feed.
This commit is contained in:
Borgar 2011-08-02 23:29:34 +00:00
commit cd277672d0
3 changed files with 8 additions and 2 deletions

View file

@ -15,6 +15,7 @@ _DEFAULT_CONFIG = {'PATH': None,
'FEED': 'feeds/all.atom.xml',
'CATEGORY_FEED': 'feeds/%s.atom.xml',
'TRANSLATION_FEED': 'feeds/all-%s.atom.xml',
'FEED_MAX_ITEMS': '',
'SITENAME': 'A Pelican Blog',
'DISPLAY_PAGES_ON_MENU': True,
'PDF_GENERATOR': False,

View file

@ -58,8 +58,11 @@ class Writer(object):
feed = self._create_new_feed(feed_type, context)
for item in elements:
self._add_item_to_the_feed(feed, item)
max_items = len(elements)
if self.settings['FEED_MAX_ITEMS']:
max_items = min(self.settings['FEED_MAX_ITEMS'], max_items)
for i in xrange(max_items):
self._add_item_to_the_feed(feed, elements[i])
if filename:
complete_path = os.path.join(self.output_path, filename)