diff --git a/docs/changelog.rst b/docs/changelog.rst index b7c64190..c225a499 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -11,6 +11,9 @@ Release history * Improved appearance of LinkedIn icon in default theme * Add GitHub and Google+ social icons support in default theme * Optimize social icons +* Add ``FEED_ALL_ATOM`` and ``FEED_ALL_RSS`` to generate feeds containing all posts regardless of their language +* Split ``TRANSLATION_FEED`` into ``TRANSLATION_FEED_ATOM`` and ``TRANSLATION_FEED_RSS`` +* The different feeds can now be enabled/disabled individually 3.0 (2012-08-08) ================== diff --git a/docs/faq.rst b/docs/faq.rst index 4225ab5f..735fe9d0 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -93,9 +93,15 @@ 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_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. +To disable all feed generation, all feed settings should be set to ``None``. +Since other feed settings already defaults to ``None``, you only need to set +the following settings:: + + FEED_ALL_ATOM = None + CATEGORY_FEED_ATOM = None + +Please note that ``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 ============================================================================== @@ -111,7 +117,7 @@ should result in this warning. Feeds are still generated when this warning is displayed but may not validate. -My feeds are broken since I upgraded to Pelican 3.0 +My feeds are broken since I upgraded to Pelican 3.x =================================================== Starting in 3.0, some of the FEED setting names were changed to more explicitly @@ -122,6 +128,13 @@ setting names). Here is an exact list of the renamed setting names:: TAG_FEED -> TAG_FEED_ATOM CATEGORY_FEED -> CATEGORY_FEED_ATOM +Starting in 3.1, the new feed ``FEED_ALL_ATOM`` has been introduced: this +feed will aggregate all posts regardless of their language. It is generated to +``'feeds/all.atom.xml'`` by default and ``FEED_ATOM`` now defaults to ``None``. +The following FEED setting has also been renamed:: + + TRANSLATION_FEED -> TRANSLATION_FEED_ATOM + Older 2.x themes that referenced the old setting names may not link properly. In order to rectify this, please update your theme for compatibility with 3.0+ by changing the relevant values in your template files. For an example of diff --git a/docs/fr/configuration.rst b/docs/fr/configuration.rst index 76f03a61..e3fb8542 100644 --- a/docs/fr/configuration.rst +++ b/docs/fr/configuration.rst @@ -59,11 +59,17 @@ CATEGORY_FEED_RSS : Idem pour les flux rss (Optionnel); FEED_ATOM : - Chemin du flux Atom global ; + Chemin du flux Atom global; FEED_RSS : Chemin du flux Rss global (Optionnel); +FEED_ALL_ATOM : + Chemin du flux Atom global qui inclut la totalité des posts, indépendamment de la langue; + +FEED_ALL_RSS : + Chemin du flux Rss global qui inclut la totalité des posts, indépendamment de la langue (Optionnel); + TAG_FEED_ATOM : Chemin des flux Atom pour les tags (Optionnel); diff --git a/docs/settings.rst b/docs/settings.rst index 6bcc7292..94ce65a0 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -303,9 +303,15 @@ Setting name (default value) What does it do? to define this (e.g., "http://feeds.example.com"). If 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_ATOM` (``'feeds/all.atom.xml'``) Relative URL to output the Atom feed. + feeds, you can just set: ``FEED_DOMAIN = SITEURL``. +`FEED_ATOM` (``None``, i.e. no Atom feed) Relative URL to output the Atom feed. `FEED_RSS` (``None``, i.e. no RSS) Relative URL to output the RSS feed. +`FEED_ALL_ATOM` (``'feeds/all.atom.xml'``) Relative URL to output the all posts Atom feed: + this feed will contain all posts regardless of their + language. +`FEED_ALL_RSS` (``None``, i.e. no all RSS) Relative URL to output the all posts RSS feed: + this feed will contain all posts regardless of their + language. `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_ATOM` (``None``, i.e. no tag feed) Relative URL to output the tag Atom feed. It should @@ -315,9 +321,8 @@ Setting name (default value) What does it do? quantity is unrestricted by default. ================================================ ===================================================== -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_ATOM`` -and ``FEED_RSS`` to none. +If you don't want to generate some or any of these feeds, set ``None`` to the +variables above. .. [2] %s is the name of the category. diff --git a/docs/themes.rst b/docs/themes.rst index e482bc9b..664b4466 100644 --- a/docs/themes.rst +++ b/docs/themes.rst @@ -200,6 +200,8 @@ Here is a complete list of the feed variables:: FEED_ATOM FEED_RSS + FEED_ALL_ATOM + FEED_ALL_RSS CATEGORY_FEED_ATOM CATEGORY_FEED_RSS TAG_FEED_ATOM diff --git a/pelican/generators.py b/pelican/generators.py index 01f4701c..77989df9 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -156,13 +156,6 @@ class ArticlesGenerator(Generator): def generate_feeds(self, writer): """Generate the feeds from the current context, and output files.""" - 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_ATOM'): writer.write_feed(self.articles, self.context, @@ -172,6 +165,21 @@ class ArticlesGenerator(Generator): writer.write_feed(self.articles, self.context, self.settings['FEED_RSS'], feed_type='rss') + if self.settings.get('FEED_ALL_ATOM') or \ + self.settings.get('FEED_ALL_RSS'): + all_articles = list(self.articles) + for article in self.articles: + all_articles.extend(article.translations) + all_articles.sort(key=attrgetter('date'), reverse=True) + + if self.settings.get('FEED_ALL_ATOM'): + writer.write_feed(all_articles, self.context, + self.settings['FEED_ALL_ATOM']) + + if self.settings.get('FEED_ALL_RSS'): + writer.write_feed(all_articles, self.context, + self.settings['FEED_ALL_RSS'], feed_type='rss') + for cat, arts in self.categories: arts.sort(key=attrgetter('date'), reverse=True) if self.settings.get('CATEGORY_FEED_ATOM'): diff --git a/pelican/settings.py b/pelican/settings.py index 35752fee..d1532bc7 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -24,7 +24,7 @@ _DEFAULT_CONFIG = {'PATH': '.', 'MARKUP': ('rst', 'md'), 'STATIC_PATHS': ['images', ], 'THEME_STATIC_PATHS': ['static', ], - 'FEED_ATOM': 'feeds/all.atom.xml', + 'FEED_ALL_ATOM': 'feeds/all.atom.xml', 'CATEGORY_FEED_ATOM': 'feeds/%s.atom.xml', 'TRANSLATION_FEED_ATOM': 'feeds/all-%s.atom.xml', 'FEED_MAX_ITEMS': '', @@ -175,10 +175,21 @@ def configure_settings(settings): settings['FEED_DOMAIN'] = settings['SITEURL'] # Warn if feeds are generated with both SITEURL & FEED_DOMAIN undefined - 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')") + feed_keys = ['FEED_ATOM', 'FEED_RSS', + 'FEED_ALL_ATOM', 'FEED_ALL_RSS', + 'CATEGORY_FEED_ATOM', 'CATEGORY_FEED_RSS', + 'TAG_FEED_ATOM', 'TAG_FEED_RSS', + 'TRANSLATION_FEED_ATOM', 'TRANSLATION_FEED_RSS', + ] + + if any(settings.get(k) for k in feed_keys): + if not settings.get('FEED_DOMAIN'): + 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')") + + if not settings.get('SITEURL'): + logger.warn("Feeds generated without SITEURL set properly may not be valid") if not 'TIMEZONE' in settings: logger.warn("No timezone information specified in the settings. Assuming" diff --git a/pelican/themes/notmyidea/templates/base.html b/pelican/themes/notmyidea/templates/base.html index 6ab87c5a..45c2c3a2 100644 --- a/pelican/themes/notmyidea/templates/base.html +++ b/pelican/themes/notmyidea/templates/base.html @@ -4,11 +4,11 @@ {% block title %}{{ SITENAME }}{%endblock%} - {% if FEED_ATOM %} - + {% if FEED_ALL_ATOM %} + {% endif %} - {% if FEED_RSS %} - + {% if FEED_ALL_RSS %} + {% endif %}