mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #418 from tbunnyman/WarnOnFeedGeneration#383
Update: De-appreciate FEED for FEED_RSS & FEED_ATOM
This commit is contained in:
commit
8007c20c79
10 changed files with 122 additions and 24 deletions
35
docs/faq.rst
35
docs/faq.rst
|
|
@ -59,4 +59,37 @@ want to have it's own template.
|
||||||
:template: template_name
|
:template: template_name
|
||||||
|
|
||||||
Then just make sure to have the template installed in to your theme as
|
Then just make sure to have the template installed in to your theme as
|
||||||
``template_name.html``.
|
``template_name.html``.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
I'm getting a warning about Feeds generated without SITEURL being set properly
|
||||||
|
==============================================================================
|
||||||
|
|
||||||
|
`RSS and atom feeds require all URLs and links in them to be absolute <http://validator.w3.org/feed/docs/rss2.html#comments>`_.
|
||||||
|
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.
|
||||||
|
If configured properly no other make commands should have this message.
|
||||||
|
|
||||||
|
Feeds still are generated when this error comes up, but may not validate.
|
||||||
|
|
||||||
|
My feeds are broken since I upgraded to 3.0
|
||||||
|
===========================================
|
||||||
|
|
||||||
|
Starting in 3.0 we changed the more confusing FEED options to say FEED_ATOM
|
||||||
|
like the RRS feed options. Here is an exact list of the changes::
|
||||||
|
|
||||||
|
FEED -> FEED_ATOM
|
||||||
|
TAG_FEED -> TAG_FEED_ATOM
|
||||||
|
CATEGORY_FEED -> CATEGORY_FEED_ATOM
|
||||||
|
|
||||||
|
Older 2.x themes that referenced these may not link properly. Please update
|
||||||
|
your themes for 3 on. For an example of complete RSS headers and usage please
|
||||||
|
check out the simple theme.
|
||||||
|
|
|
||||||
|
|
@ -52,19 +52,19 @@ détails au prochain chapitre.
|
||||||
Flux de syndication
|
Flux de syndication
|
||||||
===================
|
===================
|
||||||
|
|
||||||
CATEGORY_FEED :
|
CATEGORY_FEED_ATOM :
|
||||||
Chemin d’écriture des flux Atom liés aux catégories ;
|
Chemin d’écriture des flux Atom liés aux catégories ;
|
||||||
|
|
||||||
CATEGORY_FEED_RSS :
|
CATEGORY_FEED_RSS :
|
||||||
Idem pour les flux rss (Optionnel);
|
Idem pour les flux rss (Optionnel);
|
||||||
|
|
||||||
FEED :
|
FEED_ATOM :
|
||||||
Chemin du flux Atom global ;
|
Chemin du flux Atom global ;
|
||||||
|
|
||||||
FEED_RSS :
|
FEED_RSS :
|
||||||
Chemin du flux Rss global (Optionnel);
|
Chemin du flux Rss global (Optionnel);
|
||||||
|
|
||||||
TAG_FEED :
|
TAG_FEED_ATOM :
|
||||||
Chemin des flux Atom pour les tags (Optionnel);
|
Chemin des flux Atom pour les tags (Optionnel);
|
||||||
|
|
||||||
TAG_FEED_RSS :
|
TAG_FEED_RSS :
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ feeds if you prefer.
|
||||||
|
|
||||||
Pelican generates category feeds as well as feeds for all your articles. It does
|
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
|
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?
|
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
|
you have already explicitly defined SITEURL (see
|
||||||
above) and want to use the same domain for your
|
above) and want to use the same domain for your
|
||||||
feeds, you can just set: `FEED_DOMAIN = SITEURL`
|
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.
|
`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.
|
`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.
|
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
|
`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
|
`FEED_MAX_ITEMS` Maximum number of items allowed in a feed. Feed item
|
||||||
|
|
@ -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
|
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_ATOM``
|
||||||
|
and ``FEED_RSS`` to none.
|
||||||
|
|
||||||
.. [2] %s is the name of the category.
|
.. [2] %s is the name of the category.
|
||||||
|
|
||||||
|
|
@ -285,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
|
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
|
hosted on the www.example.com domain, you might use "thymefeeds" as your
|
||||||
unique identifier, which we'll use throughout this section for illustrative
|
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
|
"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
|
`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
|
to `http://feeds.feedburner.com`, or `http://feeds.example.com` if you are
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,22 @@ dates_page The current page of articles, ordered by date,
|
||||||
page_name 'tag/`tag_name`' -- useful for pagination links
|
page_name 'tag/`tag_name`' -- useful for pagination links
|
||||||
=================== ===================================================
|
=================== ===================================================
|
||||||
|
|
||||||
|
Feeds
|
||||||
|
=====
|
||||||
|
|
||||||
|
The feed variables changed in 3.0. Each variable now explicitly lists ATOM or
|
||||||
|
RSS in the name. ATOM is still the default. Old themes will need to be updated.
|
||||||
|
Here is a complete list of the feed variables::
|
||||||
|
|
||||||
|
FEED_ATOM
|
||||||
|
FEED_RSS
|
||||||
|
CATEGORY_FEED_ATOM
|
||||||
|
CATEGORY_FEED_RSS
|
||||||
|
TAG_FEED_ATOM
|
||||||
|
TAG_FEED_RSS
|
||||||
|
TRANSLATION_FEED
|
||||||
|
|
||||||
|
|
||||||
Inheritance
|
Inheritance
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,27 @@ class Pelican(object):
|
||||||
self.settings[setting])
|
self.settings[setting])
|
||||||
logger.warning("%s = '%s'" % (setting, self.settings[setting]))
|
logger.warning("%s = '%s'" % (setting, self.settings[setting]))
|
||||||
|
|
||||||
|
if self.settings.get('FEED', False):
|
||||||
|
logger.warning('Found deprecated `FEED` in settings. Modify FEED'
|
||||||
|
' to FEED_ATOM in your settings and theme for the same behavior.'
|
||||||
|
' Temporarily setting FEED_ATOM for backwards compatibility.')
|
||||||
|
self.settings['FEED_ATOM'] = self.settings['FEED']
|
||||||
|
|
||||||
|
if self.settings.get('TAG_FEED', False):
|
||||||
|
logger.warning('Found deprecated `TAG_FEED` in settings. Modify '
|
||||||
|
' TAG_FEED to TAG_FEED_ATOM in your settings and theme for the '
|
||||||
|
'same behavior. Temporarily setting TAG_FEED_ATOM for backwards '
|
||||||
|
'compatibility.')
|
||||||
|
self.settings['TAG_FEED_ATOM'] = self.settings['TAG_FEED']
|
||||||
|
|
||||||
|
if self.settings.get('CATEGORY_FEED', False):
|
||||||
|
logger.warning('Found deprecated `CATEGORY_FEED` in settings. '
|
||||||
|
'Modify CATEGORY_FEED to CATEGORY_FEED_ATOM in your settings and '
|
||||||
|
'theme for the same behavior. Temporarily setting '
|
||||||
|
'CATEGORY_FEED_ATOM for backwards compatibility.')
|
||||||
|
self.settings['CATEGORY_FEED_ATOM'] = self.settings['CATEGORY_FEED']
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Run the generators and return"""
|
"""Run the generators and return"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,10 +124,16 @@ class ArticlesGenerator(Generator):
|
||||||
|
|
||||||
def generate_feeds(self, writer):
|
def generate_feeds(self, writer):
|
||||||
"""Generate the feeds from the current context, and output files."""
|
"""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'):
|
if self.settings.get('FEED_ATOM'):
|
||||||
writer.write_feed(self.articles, self.context,
|
writer.write_feed(self.articles, self.context,
|
||||||
self.settings['FEED'])
|
self.settings['FEED_ATOM'])
|
||||||
|
|
||||||
if self.settings.get('FEED_RSS'):
|
if self.settings.get('FEED_RSS'):
|
||||||
writer.write_feed(self.articles, self.context,
|
writer.write_feed(self.articles, self.context,
|
||||||
|
|
@ -135,21 +141,21 @@ class ArticlesGenerator(Generator):
|
||||||
|
|
||||||
for cat, arts in self.categories:
|
for cat, arts in self.categories:
|
||||||
arts.sort(key=attrgetter('date'), reverse=True)
|
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,
|
writer.write_feed(arts, self.context,
|
||||||
self.settings['CATEGORY_FEED'] % cat)
|
self.settings['CATEGORY_FEED_ATOM'] % cat)
|
||||||
|
|
||||||
if self.settings.get('CATEGORY_FEED_RSS'):
|
if self.settings.get('CATEGORY_FEED_RSS'):
|
||||||
writer.write_feed(arts, self.context,
|
writer.write_feed(arts, self.context,
|
||||||
self.settings['CATEGORY_FEED_RSS'] % cat,
|
self.settings['CATEGORY_FEED_RSS'] % cat,
|
||||||
feed_type='rss')
|
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():
|
for tag, arts in self.tags.items():
|
||||||
arts.sort(key=attrgetter('date'), reverse=True)
|
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,
|
writer.write_feed(arts, self.context,
|
||||||
self.settings['TAG_FEED'] % tag)
|
self.settings['TAG_FEED_ATOM'] % tag)
|
||||||
|
|
||||||
if self.settings.get('TAG_FEED_RSS'):
|
if self.settings.get('TAG_FEED_RSS'):
|
||||||
writer.write_feed(arts, self.context,
|
writer.write_feed(arts, self.context,
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,11 @@ _DEFAULT_CONFIG = {'PATH': '.',
|
||||||
'MARKUP': ('rst', 'md'),
|
'MARKUP': ('rst', 'md'),
|
||||||
'STATIC_PATHS': ['images', ],
|
'STATIC_PATHS': ['images', ],
|
||||||
'THEME_STATIC_PATHS': ['static', ],
|
'THEME_STATIC_PATHS': ['static', ],
|
||||||
'FEED': 'feeds/all.atom.xml',
|
'FEED_ATOM': 'feeds/all.atom.xml',
|
||||||
'CATEGORY_FEED': 'feeds/%s.atom.xml',
|
'CATEGORY_FEED_ATOM': 'feeds/%s.atom.xml',
|
||||||
'TRANSLATION_FEED': 'feeds/all-%s.atom.xml',
|
'TRANSLATION_FEED': 'feeds/all-%s.atom.xml',
|
||||||
'FEED_MAX_ITEMS': '',
|
'FEED_MAX_ITEMS': '',
|
||||||
|
'SITEURL': '',
|
||||||
'SITENAME': 'A Pelican Blog',
|
'SITENAME': 'A Pelican Blog',
|
||||||
'DISPLAY_PAGES_ON_MENU': True,
|
'DISPLAY_PAGES_ON_MENU': True,
|
||||||
'PDF_GENERATOR': False,
|
'PDF_GENERATOR': False,
|
||||||
|
|
@ -142,7 +143,7 @@ def configure_settings(settings, default_settings=None, filename=None):
|
||||||
settings['FEED_DOMAIN'] = settings['SITEURL']
|
settings['FEED_DOMAIN'] = settings['SITEURL']
|
||||||
|
|
||||||
# Warn if feeds are generated with both SITEURL & FEED_DOMAIN undefined
|
# 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 "
|
logger.warn("Since feed URLs should always be absolute, you should specify "
|
||||||
"FEED_DOMAIN in your settings. (e.g., 'FEED_DOMAIN = "
|
"FEED_DOMAIN in your settings. (e.g., 'FEED_DOMAIN = "
|
||||||
"http://www.example.com')")
|
"http://www.example.com')")
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
<title>{% block title %}{{ SITENAME }}{%endblock%}</title>
|
<title>{% block title %}{{ SITENAME }}{%endblock%}</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/{{ CSS_FILE }}" type="text/css" />
|
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/{{ CSS_FILE }}" type="text/css" />
|
||||||
<link href="{{ FEED_DOMAIN }}/{{ FEED }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Atom Feed" />
|
{% if FEED_ATOM %}
|
||||||
|
<link href="{{ FEED_DOMAIN }}/{{ FEED_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Atom Feed" />
|
||||||
|
{% endif %}
|
||||||
{% if FEED_RSS %}
|
{% if FEED_RSS %}
|
||||||
<link href="{{ FEED_DOMAIN }}/{{ FEED_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} RSS Feed" />
|
<link href="{{ FEED_DOMAIN }}/{{ FEED_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} RSS Feed" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -56,7 +58,7 @@
|
||||||
<div class="social">
|
<div class="social">
|
||||||
<h2>social</h2>
|
<h2>social</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{{ FEED_DOMAIN }}/{{ FEED }}" type="application/atom+xml" rel="alternate">atom feed</a></li>
|
<li><a href="{{ FEED_DOMAIN }}/{{ FEED_ATOM }}" type="application/atom+xml" rel="alternate">atom feed</a></li>
|
||||||
{% if FEED_RSS %}
|
{% if FEED_RSS %}
|
||||||
<li><a href="{{ FEED_DOMAIN }}/{{ FEED_RSS }}" type="application/rss+xml" rel="alternate">rss feed</a></li>
|
<li><a href="{{ FEED_DOMAIN }}/{{ FEED_RSS }}" type="application/rss+xml" rel="alternate">rss feed</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,24 @@
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<title>{% block title %}{{ SITENAME }}{% endblock title %}</title>
|
<title>{% block title %}{{ SITENAME }}{% endblock title %}</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
{% if FEED_ATOM %}
|
||||||
|
<link href="{{ FEED_DOMAIN }}/{{ FEED_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Atom Feed" />
|
||||||
|
{% endif %}
|
||||||
|
{% if FEED_RSS %}
|
||||||
|
<link href="{{ FEED_DOMAIN }}/{{ FEED_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} RSS Feed" />
|
||||||
|
{% endif %}
|
||||||
|
{% if CATEGORY_FEED_ATOM %}
|
||||||
|
<link href="{{ FEED_DOMAIN }}/{{ CATEGORY_FEED_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Categories Atom Feed" />
|
||||||
|
{% endif %}
|
||||||
|
{% if CATEGORY_FEED_RSS %}
|
||||||
|
<link href="{{ FEED_DOMAIN }}/{{ CATEGORY_FEED_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Categories RSS Feed" />
|
||||||
|
{% endif %}
|
||||||
|
{% if TAG_FEED_ATOM %}
|
||||||
|
<link href="{{ FEED_DOMAIN }}/{{ TAG_FEED_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Tags Atom Feed" />
|
||||||
|
{% endif %}
|
||||||
|
{% if TAG_FEED_RSS %}
|
||||||
|
<link href="{{ FEED_DOMAIN }}/{{ TAG_FEED_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Tags RSS Feed" />
|
||||||
|
{% endif %}
|
||||||
{% endblock head %}
|
{% endblock head %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,14 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
|
|
||||||
def test_generate_feeds(self):
|
def test_generate_feeds(self):
|
||||||
|
|
||||||
generator = ArticlesGenerator(None, {'FEED': _DEFAULT_CONFIG['FEED']},
|
generator = ArticlesGenerator(None, {'FEED_ATOM': _DEFAULT_CONFIG['FEED_ATOM']},
|
||||||
None, _DEFAULT_CONFIG['THEME'], None,
|
None, _DEFAULT_CONFIG['THEME'], None,
|
||||||
_DEFAULT_CONFIG['MARKUP'])
|
_DEFAULT_CONFIG['MARKUP'])
|
||||||
writer = MagicMock()
|
writer = MagicMock()
|
||||||
generator.generate_feeds(writer)
|
generator.generate_feeds(writer)
|
||||||
writer.write_feed.assert_called_with([], None, 'feeds/all.atom.xml')
|
writer.write_feed.assert_called_with([], None, 'feeds/all.atom.xml')
|
||||||
|
|
||||||
generator = ArticlesGenerator(None, {'FEED': None}, None,
|
generator = ArticlesGenerator(None, {'FEED_ATOM': None}, None,
|
||||||
_DEFAULT_CONFIG['THEME'], None, None)
|
_DEFAULT_CONFIG['THEME'], None, None)
|
||||||
writer = MagicMock()
|
writer = MagicMock()
|
||||||
generator.generate_feeds(writer)
|
generator.generate_feeds(writer)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue