mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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:
parent
73ba522508
commit
cd277672d0
3 changed files with 8 additions and 2 deletions
|
|
@ -115,6 +115,8 @@ Setting name (default value) what does it do?
|
||||||
`TAG_FEED` (``None``, ie no tag feed) relative url to output the tags atom feed. It should
|
`TAG_FEED` (``None``, ie no tag feed) relative url to output the tags atom feed. It should
|
||||||
be defined using a "%s" matchin the tag name
|
be defined using a "%s" matchin the tag name
|
||||||
`TAG_FEED_RSS` (``None``, ie no RSS tag feed) relative url to output the tag RSS feed
|
`TAG_FEED_RSS` (``None``, ie no RSS tag feed) relative url to output the tag RSS feed
|
||||||
|
`FEED_MAX_ITEMS` Maximum number of items allowed in a feed. Feeds are
|
||||||
|
unrestricted by default.
|
||||||
================================================ =====================================================
|
================================================ =====================================================
|
||||||
|
|
||||||
.. [2] %s is the name of the category.
|
.. [2] %s is the name of the category.
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ _DEFAULT_CONFIG = {'PATH': None,
|
||||||
'FEED': 'feeds/all.atom.xml',
|
'FEED': 'feeds/all.atom.xml',
|
||||||
'CATEGORY_FEED': 'feeds/%s.atom.xml',
|
'CATEGORY_FEED': 'feeds/%s.atom.xml',
|
||||||
'TRANSLATION_FEED': 'feeds/all-%s.atom.xml',
|
'TRANSLATION_FEED': 'feeds/all-%s.atom.xml',
|
||||||
|
'FEED_MAX_ITEMS': '',
|
||||||
'SITENAME': 'A Pelican Blog',
|
'SITENAME': 'A Pelican Blog',
|
||||||
'DISPLAY_PAGES_ON_MENU': True,
|
'DISPLAY_PAGES_ON_MENU': True,
|
||||||
'PDF_GENERATOR': False,
|
'PDF_GENERATOR': False,
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,11 @@ class Writer(object):
|
||||||
|
|
||||||
feed = self._create_new_feed(feed_type, context)
|
feed = self._create_new_feed(feed_type, context)
|
||||||
|
|
||||||
for item in elements:
|
max_items = len(elements)
|
||||||
self._add_item_to_the_feed(feed, item)
|
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:
|
if filename:
|
||||||
complete_path = os.path.join(self.output_path, filename)
|
complete_path = os.path.join(self.output_path, filename)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue