Provides Custom URLs for FEEDS

Provides an optional FEED URL. Feed variables have been split into two, _SAVE_AS and _URL.

 _SAVE_AS variables are used to define the RSS/ATOM Files.
 _URL variables are the feed slugs (aligns to post/page variables)

 Using rewrite rules (nginx/apache) it is now possible to have _pretty_ feed URLS like /feed or /feed/tag/pelican
This commit is contained in:
Nick 2015-01-05 10:14:59 +00:00
commit 7f8df5bb8e
12 changed files with 223 additions and 131 deletions

View file

@ -154,11 +154,11 @@ To disable feed generation, all feed settings should be set to ``None``.
All but three feed settings already default to ``None``, so if you want to
disable all feed generation, you only need to specify the following settings::
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
FEED_ALL_ATOM_SAVE_AS = None
CATEGORY_FEED_ATOM_SAVE_AS = None
TRANSLATION_FEED_ATOM_SAVE_AS = None
AUTHOR_FEED_ATOM_SAVE_AS = None
AUTHOR_FEED_RSS_SAVE_AS = None
The word ``None`` should not be surrounded by quotes. Please note that ``None``
and ``''`` are not the same thing.
@ -192,6 +192,24 @@ generates ``'feeds/all.atom.xml'`` by default and ``FEED_ATOM`` now defaults to
TRANSLATION_FEED -> TRANSLATION_FEED_ATOM
Starting in 3.5, the feed variables have been split into two. FEED_ATOM
has now become FEED_ATOM_SAVE_AS allowing FEED_ATOM_URL to be introduced; FEED_ATOM_URL
allows you to assign URL Slugs to feeds such as /feed/atom. (URL rewriting will still
be required on the web server). Here is an exact list of the renamed settings::
FEED_ATOM -> FEED_ATOM_SAVE_AS
FEED_RSS -> FEED_RSS_SAVE_AS
FEED_ALL_ATOM -> FEED_ALL_ATOM_SAVE_AS
FEED_ALL_RSS -> FEED_ALL_RSS_SAVE_AS
CATEGORY_FEED_ATOM -> CATEGORY_FEED_ATOM_SAVE_AS
CATEGORY_FEED_RSS -> CATEGORY_FEED_RSS_SAVE_AS
AUTHOR_FEED_ATOM -> AUTHOR_FEED_ATOM_SAVE_AS
AUTHOR_FEED_RSS -> AUTHOR_FEED_RSS_SAVE_AS
TAG_FEED_ATOM -> TAG_FEED_ATOM_SAVE_AS
TAG_FEED_RSS -> TAG_FEED_RSS_SAVE_AS
To use the new URLs see :doc:`feed settings <settings>`.
Older themes that referenced the old setting names may not link properly.
In order to rectify this, please update your theme for compatibility by changing
the relevant values in your template files. For an example of complete feed

View file

@ -518,39 +518,50 @@ 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_ATOM`` and ``TAG_FEED_RSS`` settings:
the ``TAG_FEED_ATOM_SAVE_AS`` and ``TAG_FEED_RSS_SAVE_AS`` settings:
================================================= =====================================================
Setting name (followed by default value, if any) What does it do?
================================================= =====================================================
``FEED_DOMAIN = None``, i.e. base URL is "/" The domain prepended to feed URLs. Since feed URLs
should always be absolute, it is highly recommended
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 = 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-posts 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.
``AUTHOR_FEED_ATOM = 'feeds/%s.atom.xml'`` [2]_ Where to put the author Atom feeds.
``AUTHOR_FEED_RSS = 'feeds/%s.rss.xml'`` [2]_ Where to put the author RSS feeds.
``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``, i.e. 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
quantity is unrestricted by default.
================================================= =====================================================
========================================================= =====================================================
Setting name (followed by default value, if any) What does it do?
========================================================= =====================================================
``FEED_DOMAIN = None``, i.e. base URL is "/" The domain prepended to feed URLs. Since feed URLs
should always be absolute, it is highly recommended
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_SAVE_AS = None``, i.e. no Atom feed Path to output the Atom feed.
``FEED_ATOM_URL = None``, i.e. no Atom Slug Relative URL (Slug) for the Atom feed.
``FEED_RSS_SAVE_AS = None``, i.e. no RSS Path to output the RSS feed.
``FEED_RSS_URL = None``, i.e. no RSS Slug Relative URL (Slug) for the RSS feed.
``FEED_ALL_ATOM_SAVE_AS = 'feeds/all.atom.xml'`` Path to output the all-posts Atom feed:
this feed will contain all posts regardless of their
language.
``FEED_ALL_ATOM_URL = None``, i.e. no all Atom Slug Relative URL to the all-posts Atom feed.
``FEED_ALL_RSS_SAVE_AS = None``, i.e. no all-posts RSS Relative URL to output the all-posts RSS feed:
this feed will contain all posts regardless of their
language.
``FEED_ALL_RSS_URL = None``, i.e. no all RSS Slug Relative URL to the all-posts RSS feed.
``CATEGORY_FEED_ATOM_SAVE_AS = 'feeds/%s.atom.xml'`` [2]_ Path to put the category Atom feeds.
``CATEGORY_FEED_ATOM_URL = None`` Relative URL to the category Atom feed. [4]_
``CATEGORY_FEED_RSS_SAVE_AS = None``, i.e. no RSS Path to put the category RSS feeds.
``CATEGORY_FEED_RSS_URL = None`` Relative URL for the category RSS feeds. [4]_
``AUTHOR_FEED_ATOM_SAVE_AS = 'feeds/%s.atom.xml'`` [2]_ Path to put the author Atom feeds.
``AUTHOR_FEED_ATOM_URL = None`` Relative URL for the authoor atom feeds. [4]_
``AUTHOR_FEED_RSS_SAVE_AS = 'feeds/%s.rss.xml'`` [2]_ Path to put the author RSS feeds.
``AUTHOR_FEED_RSS_URL = None`` Relative URL for the author RSS feeds. [4]_
``TAG_FEED_ATOM_SAVE_AS = None``, i.e. no tag feed Path to output the tag Atom feed. It should
be defined using a "%s" match in the tag name.
``TAG_FEED_ATOM_URL = None`` Relative URL for the tag atom feeds. [4]_
``TAG_FEED_RSS_SAVE_AS = None``, i.e. no RSS tag feed Path to output the tag RSS feed
``TAG_FEED_RSS_URL = None`` Relative URL for the tag RSS feeds. [4]_
``FEED_MAX_ITEMS`` Maximum number of items allowed in a feed. Feed item
quantity is unrestricted by default.
========================================================= =====================================================
If you don't want to generate some or any of these feeds, set the above variables to ``None``.
.. [2] %s is the name of the category.
.. [4] %s should be used for substitution, e.g. "feeds/atom/category/%s"
FeedBurner

View file

@ -334,20 +334,34 @@ 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.
If you use URL rewriting on your webserver slugs can be setup for feeds.
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
AUTHOR_FEED_ATOM
AUTHOR_FEED_RSS
TAG_FEED_ATOM
TAG_FEED_RSS
TRANSLATION_FEED_ATOM
TRANSLATION_FEED_RSS
FEED_ATOM_SAVE_AS
FEED_RSS_SAVE_AS
FEED_ALL_ATOM_SAVE_AS
FEED_ALL_RSS_SAVE_AS
CATEGORY_FEED_ATOM_SAVE_AS
CATEGORY_FEED_RSS_SAVE_AS
AUTHOR_FEED_ATOM_SAVE_AS
AUTHOR_FEED_RSS_SAVE_AS
TAG_FEED_ATOM_SAVE_AS
TAG_FEED_RSS_SAVE_AS
TRANSLATION_FEED_ATOM_SAVE_AS
TRANSLATION_FEED_RSS_SAVE_AS
FEED_ATOM_URL
FEED_RSS_URL
FEED_ALL_ATOM_URL
FEED_ALL_RSS_URL
CATEGORY_FEED_ATOM_URL
CATEGORY_FEED_RSS_URL
AUTHOR_FEED_ATOM_URL
AUTHOR_FEED_RSS_URL
TAG_FEED_ATOM_URL
TAG_FEED_RSS_URL
TRANSLATION_FEED_ATOM_URL
TRANSLATION_FEED_RSS_URL
Inheritance