From d9817f9a96390d04bec9070007d9ceaf890f0456 Mon Sep 17 00:00:00 2001 From: tBunnyMan Date: Sat, 14 Jul 2012 17:05:04 -0700 Subject: [PATCH 1/7] 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, From 6393df3bfea06d2a9aabd83e5ac0caf955ea0781 Mon Sep 17 00:00:00 2001 From: tBunnyMan Date: Sat, 14 Jul 2012 18:08:11 -0700 Subject: [PATCH 2/7] Fix Spelling --- docs/faq.rst | 4 ++-- pelican/generators.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 1241c5ab..f754986e 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -71,8 +71,8 @@ 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 +RSS and atom3 feeds require all URLs and links in them to be absolute. In order +to properly generate all URLs properly in pelican 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. diff --git a/pelican/generators.py b/pelican/generators.py index dba3b1d8..081c9ead 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -128,7 +128,7 @@ class ArticlesGenerator(Generator): return elif self.settings.get('SITEURL') is '': logger.warning( - 'Feeds generated without SITEURL set properly may not be vaild' + 'Feeds generated without SITEURL set properly may not be valid' ) if self.settings.get('FEED'): From 1e8b05984a9664df8ac48fa8eafde1a7083e5e47 Mon Sep 17 00:00:00 2001 From: tBunnyMan Date: Sat, 14 Jul 2012 18:26:33 -0700 Subject: [PATCH 3/7] Add reference to FAQ statement about feeds --- docs/faq.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index f754986e..caa40eff 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -71,8 +71,8 @@ word None should not be surrounded by quotes. I'm getting a warning about Feeds generated without SITEURL being set properly ============================================================================== -RSS and atom3 feeds require all URLs and links in them to be absolute. In order -to properly generate all URLs properly in pelican you will need to set +`RSS and atom3 feeds require all URLs and links in them to be absolute `_. +In order to properly generate all URLs properly in pelican 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. From 5f958ae84d8aa77ab66d1fedc169b1c66ebdb099 Mon Sep 17 00:00:00 2001 From: tBunnyMan Date: Mon, 16 Jul 2012 09:35:05 -0700 Subject: [PATCH 4/7] Refactor atom feed names for clarity FEED -> FEED_ATOM TAG_FEED -> TAG_FEED_ATOM CATEGORY_FEED -> CATEGORY_FEED_ATOM --- docs/faq.rst | 2 +- docs/fr/configuration.rst | 6 +++--- docs/settings.rst | 12 ++++++------ pelican/generators.py | 16 ++++++++-------- pelican/settings.py | 6 +++--- pelican/themes/notmyidea/templates/base.html | 4 ++-- tests/test_generators.py | 4 ++-- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index caa40eff..71acb78e 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -64,7 +64,7 @@ Then just make sure to have the template installed in to your theme as What if I want to disable feed generation? ========================================== -To disable all feed generation set ``FEED`` and ``FEED_RSS`` to ``None`` in +To disable all feed generation set ``FEED_ATOM`` 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. diff --git a/docs/fr/configuration.rst b/docs/fr/configuration.rst index 895802d6..e0ae083b 100644 --- a/docs/fr/configuration.rst +++ b/docs/fr/configuration.rst @@ -52,19 +52,19 @@ détails au prochain chapitre. Flux de syndication =================== -CATEGORY_FEED : +CATEGORY_FEED_ATOM : Chemin d’écriture des flux Atom liés aux catégories ; CATEGORY_FEED_RSS : Idem pour les flux rss (Optionnel); -FEED : +FEED_ATOM : Chemin du flux Atom global ; FEED_RSS : Chemin du flux Rss global (Optionnel); -TAG_FEED : +TAG_FEED_ATOM : Chemin des flux Atom pour les tags (Optionnel); TAG_FEED_RSS : diff --git a/docs/settings.rst b/docs/settings.rst index 6c7b112e..48196e4b 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -251,7 +251,7 @@ feeds if you prefer. Pelican generates category feeds as well as feeds for all your articles. It does not generate feeds for tags by default, but it is possible to do so using -the ``TAG_FEED`` and ``TAG_FEED_RSS`` settings: +the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings: ================================================ ===================================================== Setting name (default value) What does it do? @@ -262,11 +262,11 @@ Setting name (default value) What does it do? you have already explicitly defined SITEURL (see above) and want to use the same domain for your feeds, you can just set: `FEED_DOMAIN = SITEURL` -`FEED` (``'feeds/all.atom.xml'``) Relative URL to output the Atom feed. +`FEED_ATOM` (``'feeds/all.atom.xml'``) Relative URL to output the Atom feed. `FEED_RSS` (``None``, i.e. no RSS) Relative URL to output the RSS feed. -`CATEGORY_FEED` ('feeds/%s.atom.xml'[2]_) Where to put the category Atom feeds. +`CATEGORY_FEED_ATOM` ('feeds/%s.atom.xml'[2]_) Where to put the category Atom feeds. `CATEGORY_FEED_RSS` (``None``, i.e. no RSS) Where to put the category RSS feeds. -`TAG_FEED` (``None``, i.e. no tag feed) Relative URL to output the tag Atom feed. It should +`TAG_FEED_ATOM` (``None``, i.e. no tag feed) Relative URL to output the tag Atom feed. It should be defined using a "%s" match in the tag name. `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. Feed item @@ -274,7 +274,7 @@ 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. If you don't want to generate any feeds set both ``FEED`` +variables above. If you don't want to generate any feeds set both ``FEED_ATOM`` and ``FEED_RSS`` to none. .. [2] %s is the name of the category. @@ -286,7 +286,7 @@ If you want to use FeedBurner for your feed, you will likely need to decide upon a unique identifier. For example, if your site were called "Thyme" and hosted on the www.example.com domain, you might use "thymefeeds" as your unique identifier, which we'll use throughout this section for illustrative -purposes. In your Pelican settings, set the `FEED` attribute to +purposes. In your Pelican settings, set the `FEED_ATOM` attribute to "thymefeeds/main.xml" to create an Atom feed with an original address of `http://www.example.com/thymefeeds/main.xml`. Set the `FEED_DOMAIN` attribute to `http://feeds.feedburner.com`, or `http://feeds.example.com` if you are diff --git a/pelican/generators.py b/pelican/generators.py index 081c9ead..3cf770eb 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -124,16 +124,16 @@ 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: + if self.settings.get('FEED_ATOM') 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 valid' ) - if self.settings.get('FEED'): + if self.settings.get('FEED_ATOM'): writer.write_feed(self.articles, self.context, - self.settings['FEED']) + self.settings['FEED_ATOM']) if self.settings.get('FEED_RSS'): writer.write_feed(self.articles, self.context, @@ -141,21 +141,21 @@ class ArticlesGenerator(Generator): for cat, arts in self.categories: arts.sort(key=attrgetter('date'), reverse=True) - if self.settings.get('CATEGORY_FEED'): + if self.settings.get('CATEGORY_FEED_ATOM'): writer.write_feed(arts, self.context, - self.settings['CATEGORY_FEED'] % cat) + self.settings['CATEGORY_FEED_ATOM'] % cat) if self.settings.get('CATEGORY_FEED_RSS'): writer.write_feed(arts, self.context, self.settings['CATEGORY_FEED_RSS'] % cat, feed_type='rss') - if self.settings.get('TAG_FEED') or self.settings.get('TAG_FEED_RSS'): + if self.settings.get('TAG_FEED_ATOM') or self.settings.get('TAG_FEED_RSS'): for tag, arts in self.tags.items(): arts.sort(key=attrgetter('date'), reverse=True) - if self.settings.get('TAG_FEED'): + if self.settings.get('TAG_FEED_ATOM'): writer.write_feed(arts, self.context, - self.settings['TAG_FEED'] % tag) + self.settings['TAG_FEED_ATOM'] % tag) if self.settings.get('TAG_FEED_RSS'): writer.write_feed(arts, self.context, diff --git a/pelican/settings.py b/pelican/settings.py index fc042841..f98551cf 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -21,8 +21,8 @@ _DEFAULT_CONFIG = {'PATH': '.', 'MARKUP': ('rst', 'md'), 'STATIC_PATHS': ['images', ], 'THEME_STATIC_PATHS': ['static', ], - 'FEED': 'feeds/all.atom.xml', - 'CATEGORY_FEED': 'feeds/%s.atom.xml', + 'FEED_ATOM': 'feeds/all.atom.xml', + 'CATEGORY_FEED_ATOM': 'feeds/%s.atom.xml', 'TRANSLATION_FEED': 'feeds/all-%s.atom.xml', 'FEED_MAX_ITEMS': '', 'SITEURL': '', @@ -143,7 +143,7 @@ def configure_settings(settings, default_settings=None, filename=None): settings['FEED_DOMAIN'] = settings['SITEURL'] # Warn if feeds are generated with both SITEURL & FEED_DOMAIN undefined - if (('FEED' in settings) or ('FEED_RSS' in settings)) and (not 'FEED_DOMAIN' in settings): + if (('FEED_ATOM' in settings) or ('FEED_RSS' in settings)) and (not 'FEED_DOMAIN' in settings): logger.warn("Since feed URLs should always be absolute, you should specify " "FEED_DOMAIN in your settings. (e.g., 'FEED_DOMAIN = " "http://www.example.com')") diff --git a/pelican/themes/notmyidea/templates/base.html b/pelican/themes/notmyidea/templates/base.html index c9f2c0c8..0994aac9 100644 --- a/pelican/themes/notmyidea/templates/base.html +++ b/pelican/themes/notmyidea/templates/base.html @@ -4,7 +4,7 @@ {% block title %}{{ SITENAME }}{%endblock%} - + {% if FEED_RSS %} {% endif %} @@ -56,7 +56,7 @@