Skip to content

Commit

Permalink
Don't spcify unlimited feed size by default
Browse files Browse the repository at this point in the history
Having a feed with hundreds of articles, making a very large file, is
rarely expected.

Set a high fallback value of 100 so it does not change for small sites.

Still allow to have infinite feed by setting FEED_MAX_ITEM = None
  • Loading branch information
mart-e committed May 13, 2023
1 parent 86f62d0 commit 953b661
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/settings.rst
Expand Up @@ -998,10 +998,10 @@ the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
placeholder. If not set, ``TAG_FEED_RSS`` is used both for save location and
URL.

.. data:: FEED_MAX_ITEMS
.. data:: FEED_MAX_ITEMS = 100

Maximum number of items allowed in a feed. Feed item quantity is
unrestricted by default.
Maximum number of items allowed in a feed. Setting to ``None`` will cause the
feed to contains every article. 100 if not specified.

.. data:: RSS_FEED_SUMMARY_ONLY = True

Expand Down
2 changes: 1 addition & 1 deletion pelican/settings.py
Expand Up @@ -40,7 +40,7 @@ def load_source(name, path):
'AUTHOR_FEED_ATOM': 'feeds/{slug}.atom.xml',
'AUTHOR_FEED_RSS': 'feeds/{slug}.rss.xml',
'TRANSLATION_FEED_ATOM': 'feeds/all-{lang}.atom.xml',
'FEED_MAX_ITEMS': '',
'FEED_MAX_ITEMS': 100,
'RSS_FEED_SUMMARY_ONLY': True,
'SITEURL': '',
'SITENAME': 'A Pelican Blog',
Expand Down
8 changes: 3 additions & 5 deletions pelican/writers.py
Expand Up @@ -143,11 +143,9 @@ def write_feed(self, elements, context, path=None, url=None,

feed = self._create_new_feed(feed_type, feed_title, context)

max_items = len(elements)
if self.settings['FEED_MAX_ITEMS']:
max_items = min(self.settings['FEED_MAX_ITEMS'], max_items)
for i in range(max_items):
self._add_item_to_the_feed(feed, elements[i])
# FEED_MAX_ITEMS = None means [:None] to get every element
for element in elements[:self.settings['FEED_MAX_ITEMS']]:
self._add_item_to_the_feed(feed, element)

signals.feed_generated.send(context, feed=feed)
if path:
Expand Down

0 comments on commit 953b661

Please sign in to comment.