Convert RSS setting from %s to {slug}-style strings

This commit is contained in:
MinchinWeb 2018-07-11 23:32:57 -06:00
commit 06f637a23b
8 changed files with 184 additions and 142 deletions

View file

@ -60,7 +60,7 @@ which you map the signals to your plugin logic. Let's take a simple example::
from pelican import signals
def test(sender):
print "%s initialized !!" % sender
print("{} initialized !!".format(sender))
def register():
signals.initialized.connect(test)

View file

@ -890,59 +890,61 @@ the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
Relative URL of the all-posts RSS feed. If not set, ``FEED_ALL_RSS`` is used
both for save location and URL.
.. data:: CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
.. data:: CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
The location to save the category Atom feeds. [2]_
.. data:: CATEGORY_FEED_ATOM_URL = None
Relative URL of the category Atom feeds, including the ``%s`` placeholder.
[2]_ If not set, ``CATEGORY_FEED_ATOM`` is used both for save location and
URL.
Relative URL of the category Atom feeds, including the ``{slug}``
placeholder. [2]_ If not set, ``CATEGORY_FEED_ATOM`` is used both for save
location and URL.
.. data:: CATEGORY_FEED_RSS = None, i.e. no RSS
The location to save the category RSS feeds, including the ``%s``
The location to save the category RSS feeds, including the ``{slug}``
placeholder. [2]_
.. data:: CATEGORY_FEED_RSS_URL = None
Relative URL of the category RSS feeds, including the ``%s`` placeholder.
[2]_ If not set, ``CATEGORY_FEED_RSS`` is used both for save location and
URL.
Relative URL of the category RSS feeds, including the ``{slug}``
placeholder. [2]_ If not set, ``CATEGORY_FEED_RSS`` is used both for save
location and URL.
.. data:: AUTHOR_FEED_ATOM = 'feeds/%s.atom.xml'
.. data:: AUTHOR_FEED_ATOM = 'feeds/{slug}.atom.xml'
The location to save the author Atom feeds. [2]_
.. data:: AUTHOR_FEED_ATOM_URL = None
Relative URL of the author Atom feeds, including the ``%s`` placeholder.
Relative URL of the author Atom feeds, including the ``{slug}`` placeholder.
[2]_ If not set, ``AUTHOR_FEED_ATOM`` is used both for save location and
URL.
.. data:: AUTHOR_FEED_RSS = 'feeds/%s.rss.xml'
.. data:: AUTHOR_FEED_RSS = 'feeds/{slug}.rss.xml'
The location to save the author RSS feeds. [2]_
.. data:: AUTHOR_FEED_RSS_URL = None
Relative URL of the author RSS feeds, including the ``%s`` placeholder. [2]_
If not set, ``AUTHOR_FEED_RSS`` is used both for save location and URL.
Relative URL of the author RSS feeds, including the ``{slug}`` placeholder.
[2]_ If not set, ``AUTHOR_FEED_RSS`` is used both for save location and URL.
.. data:: TAG_FEED_ATOM = None, i.e. no tag feed
The location to save the tag Atom feed, including the ``%s`` placeholder.
[2]_
The location to save the tag Atom feed, including the ``{slug}``
placeholder. [2]_
.. data:: TAG_FEED_ATOM_URL = None
Relative URL of the tag Atom feed, including the ``%s`` placeholder. [2]_
Relative URL of the tag Atom feed, including the ``{slug}`` placeholder.
[2]_
.. data:: TAG_FEED_RSS = None, i.e. no RSS tag feed
Relative URL to output the tag RSS feed, including the ``%s`` placeholder.
If not set, ``TAG_FEED_RSS`` is used both for save location and URL.
Relative URL to output the tag RSS feed, including the ``{slug}``
placeholder. If not set, ``TAG_FEED_RSS`` is used both for save location and
URL.
.. data:: FEED_MAX_ITEMS
@ -955,9 +957,10 @@ the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
to ``False``, the full content will be included instead. This setting
doesn't affect Atom feeds, only RSS ones.
If you don't want to generate some or any of these feeds, set the above variables to ``None``.
If you don't want to generate some or any of these feeds, set the above
variables to ``None``.
.. [2] ``%s`` is replaced by name of the category / author / tag.
.. [2] ``{slug}`` is replaced by name of the category / author / tag.
FeedBurner
@ -1031,20 +1034,20 @@ This would cause the first page to be written to
Translations
============
Pelican offers a way to translate articles. See the :doc:`Content <content>` section for
more information.
Pelican offers a way to translate articles. See the :doc:`Content <content>`
section for more information.
.. data:: DEFAULT_LANG = 'en'
The default language to use.
.. data:: TRANSLATION_FEED_ATOM = 'feeds/all-%s.atom.xml'
.. data:: TRANSLATION_FEED_ATOM = 'feeds/all-{lang}.atom.xml'
The location to save the Atom feed for translations. [3]_
.. data:: TRANSLATION_FEED_ATOM_URL = None
Relative URL of the Atom feed for translations, including the ``%s``
Relative URL of the Atom feed for translations, including the ``{lang}``
placeholder. [3]_ If not set, ``TRANSLATION_FEED_ATOM`` is used both for
save location and URL.
@ -1054,11 +1057,11 @@ more information.
.. data:: TRANSLATION_FEED_RSS_URL = None
Relative URL of the RSS feed for translations, including the ``%s``
Relative URL of the RSS feed for translations, including the ``{lang}``
placeholder. [3]_ If not set, ``TRANSLATION_FEED_RSS`` is used both for save
location and URL.
.. [3] %s is the language
.. [3] {lang} is the language
Ordering content
@ -1094,8 +1097,9 @@ Ordering content
Themes
======
Creating Pelican themes is addressed in a dedicated section (see :ref:`theming-pelican`).
However, here are the settings that are related to themes.
Creating Pelican themes is addressed in a dedicated section (see
:ref:`theming-pelican`). However, here are the settings that are related to
themes.
.. data:: THEME
@ -1140,11 +1144,13 @@ setting or by passing the ``-t`` option to the ``pelican`` command:
* notmyidea
* simple (a synonym for "plain text" :)
There are a number of other themes available at https://github.com/getpelican/pelican-themes.
Pelican comes with :doc:`pelican-themes`, a small script for managing themes.
There are a number of other themes available at
https://github.com/getpelican/pelican-themes. Pelican comes with
:doc:`pelican-themes`, a small script for managing themes.
You can define your own theme, either by starting from scratch or by duplicating
and modifying a pre-existing theme. Here is :doc:`a guide on how to create your theme <themes>`.
You can define your own theme, either by starting from scratch or by
duplicating and modifying a pre-existing theme. Here is :doc:`a guide on how to
create your theme <themes>`.
Following are example ways to specify your preferred theme::
@ -1157,8 +1163,8 @@ Following are example ways to specify your preferred theme::
# Specify a customized theme, via absolute path
THEME = "/home/myuser/projects/mysite/themes/mycustomtheme"
The built-in ``notmyidea`` theme can make good use of the following settings. Feel
free to use them in your themes as well.
The built-in ``notmyidea`` theme can make good use of the following settings.
Feel free to use them in your themes as well.
.. data:: SITESUBTITLE
@ -1282,58 +1288,54 @@ and pages with modified content.
When Pelican is about to read some content source file:
1. The hash or modification time information for the file from a
previous build are loaded from a cache file if ``LOAD_CONTENT_CACHE``
is ``True``. These files are stored in the ``CACHE_PATH``
directory. If the file has no record in the cache file, it is read
as usual.
previous build are loaded from a cache file if ``LOAD_CONTENT_CACHE`` is
``True``. These files are stored in the ``CACHE_PATH`` directory. If the
file has no record in the cache file, it is read as usual.
2. The file is checked according to ``CHECK_MODIFIED_METHOD``:
- If set to ``'mtime'``, the modification time of the file is
checked.
- If set to a name of a function provided by the ``hashlib``
module, e.g. ``'md5'``, the file hash is checked.
- If set to anything else or the necessary information about the
file cannot be found in the cache file, the content is read as
usual.
- If set to ``'mtime'``, the modification time of the file is checked.
- If set to a name of a function provided by the ``hashlib`` module, e.g.
``'md5'``, the file hash is checked.
- If set to anything else or the necessary information about the file
cannot be found in the cache file, the content is read as usual.
3. If the file is considered unchanged, the content data saved in a
previous build corresponding to the file is loaded from the cache,
and the file is not read.
previous build corresponding to the file is loaded from the cache, and the
file is not read.
4. If the file is considered changed, the file is read and the new
modification information and the content data are saved to the
cache if ``CACHE_CONTENT`` is ``True``.
modification information and the content data are saved to the cache if
``CACHE_CONTENT`` is ``True``.
If ``CONTENT_CACHING_LAYER`` is set to ``'reader'`` (the default),
the raw content and metadata returned by a reader are cached. If this
setting is instead set to ``'generator'``, the processed content
object is cached. Caching the processed content object may conflict
with plugins (as some reading related signals may be skipped) and the
``WITH_FUTURE_DATES`` functionality (as the ``draft`` status of the
cached content objects would not change automatically over time).
If ``CONTENT_CACHING_LAYER`` is set to ``'reader'`` (the default), the raw
content and metadata returned by a reader are cached. If this setting is
instead set to ``'generator'``, the processed content object is cached. Caching
the processed content object may conflict with plugins (as some reading related
signals may be skipped) and the ``WITH_FUTURE_DATES`` functionality (as the
``draft`` status of the cached content objects would not change automatically
over time).
Checking modification times is faster than comparing file hashes,
but it is not as reliable because ``mtime`` information can be lost,
e.g., when copying content source files using the ``cp`` or ``rsync``
commands without the ``mtime`` preservation mode (which for ``rsync``
can be invoked by passing the ``--archive`` flag).
Checking modification times is faster than comparing file hashes, but it is not
as reliable because ``mtime`` information can be lost, e.g., when copying
content source files using the ``cp`` or ``rsync`` commands without the
``mtime`` preservation mode (which for ``rsync`` can be invoked by passing the
``--archive`` flag).
The cache files are Python pickles, so they may not be readable by
different versions of Python as the pickle format often changes. If
such an error is encountered, it is caught and the cache file is
rebuilt automatically in the new format. The cache files will also be
rebuilt after the ``GZIP_CACHE`` setting has been changed.
The cache files are Python pickles, so they may not be readable by different
versions of Python as the pickle format often changes. If such an error is
encountered, it is caught and the cache file is rebuilt automatically in the
new format. The cache files will also be rebuilt after the ``GZIP_CACHE``
setting has been changed.
The ``--ignore-cache`` command-line option is useful when the
whole cache needs to be regenerated, such as when making modifications
to the settings file that will affect the cached content, or just for
debugging purposes. When Pelican runs in autoreload mode, modification
of the settings file will make it ignore the cache automatically if
``AUTORELOAD_IGNORE_CACHE`` is ``True``.
The ``--ignore-cache`` command-line option is useful when the whole cache needs
to be regenerated, such as when making modifications to the settings file that
will affect the cached content, or just for debugging purposes. When Pelican
runs in autoreload mode, modification of the settings file will make it ignore
the cache automatically if ``AUTORELOAD_IGNORE_CACHE`` is ``True``.
Note that even when using cached content, all output is always
written, so the modification times of the generated ``*.html`` files
will always change. Therefore, ``rsync``-based uploading may benefit
from the ``--checksum`` option.
Note that even when using cached content, all output is always written, so the
modification times of the generated ``*.html`` files will always change.
Therefore, ``rsync``-based uploading may benefit from the ``--checksum``
option.
.. _writing_only_selected_content:
@ -1341,16 +1343,14 @@ from the ``--checksum`` option.
Writing only selected content
=============================
When only working on a single article or page, or making tweaks to
your theme, it is often desirable to generate and review your work
as quickly as possible. In such cases, generating and writing the
entire site output is often unnecessary. By specifying only the
desired files as output paths in the ``WRITE_SELECTED`` list,
**only** those files will be written. This list can be also specified
on the command line using the ``--write-selected`` option, which
accepts a comma-separated list of output file paths. By default this
list is empty, so all output is written. See :ref:`site_generation` for
more details.
When only working on a single article or page, or making tweaks to your theme,
it is often desirable to generate and review your work as quickly as possible.
In such cases, generating and writing the entire site output is often
unnecessary. By specifying only the desired files as output paths in the
``WRITE_SELECTED`` list, **only** those files will be written. This list can be
also specified on the command line using the ``--write-selected`` option, which
accepts a comma-separated list of output file paths. By default this list is
empty, so all output is written. See :ref:`site_generation` for more details.
Example settings