From d9817f9a96390d04bec9070007d9ceaf890f0456 Mon Sep 17 00:00:00 2001 From: tBunnyMan Date: Sat, 14 Jul 2012 17:05:04 -0700 Subject: [PATCH] Test for FEED & FEED_RSS before generation. Then we bypass all feed generation of both are set to None or throw a warning if SITEURL is unset. Updated all documentation, to make sure the usage and warning is clear. --- docs/faq.rst | 21 ++++++++++++++++++++- docs/settings.rst | 3 ++- pelican/generators.py | 6 ++++++ pelican/settings.py | 1 + 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 3eec6e84..1241c5ab 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -59,4 +59,23 @@ want to have it's own template. :template: template_name Then just make sure to have the template installed in to your theme as -``template_name.html``. \ No newline at end of file +``template_name.html``. + +What if I want to disable feed generation? +========================================== + +To disable all feed generation set ``FEED`` and ``FEED_RSS`` to ``None`` in +your settings. Please note ``None`` and ``''`` are not the same thing. The +word None should not be surrounded by quotes. + +I'm getting a warning about Feeds generated without SITEURL being set properly +============================================================================== + +RSS and arom3 feeds require all URLs and links in them to be absolute. In order +to properly generate all URLs properly in perlican you will need to set +``SITEURL`` to the full path of your blog. By default, when using the ``make html`` +to test build your site ``SITEURL`` is disabled so you should receive this +warning. +If configured properly no other make commands should have this message. + +Feeds still are generated when this error comes up, but may not validate. diff --git a/docs/settings.rst b/docs/settings.rst index 0a1af584..6c7b112e 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -274,7 +274,8 @@ Setting name (default value) What does it do? ================================================ ===================================================== If you don't want to generate some of these feeds, set ``None`` to the -variables above. +variables above. If you don't want to generate any feeds set both ``FEED`` +and ``FEED_RSS`` to none. .. [2] %s is the name of the category. diff --git a/pelican/generators.py b/pelican/generators.py index 14616949..dba3b1d8 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -124,6 +124,12 @@ class ArticlesGenerator(Generator): def generate_feeds(self, writer): """Generate the feeds from the current context, and output files.""" + if self.settings.get('FEED') is None and self.settings.get('FEED_RSS') is None: + return + elif self.settings.get('SITEURL') is '': + logger.warning( + 'Feeds generated without SITEURL set properly may not be vaild' + ) if self.settings.get('FEED'): writer.write_feed(self.articles, self.context, diff --git a/pelican/settings.py b/pelican/settings.py index 41b8baa9..fc042841 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -25,6 +25,7 @@ _DEFAULT_CONFIG = {'PATH': '.', 'CATEGORY_FEED': 'feeds/%s.atom.xml', 'TRANSLATION_FEED': 'feeds/all-%s.atom.xml', 'FEED_MAX_ITEMS': '', + 'SITEURL': '', 'SITENAME': 'A Pelican Blog', 'DISPLAY_PAGES_ON_MENU': True, 'PDF_GENERATOR': False,