diff --git a/docs/plugins.rst b/docs/plugins.rst index 4e0ec6d1..18c18364 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -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) diff --git a/docs/settings.rst b/docs/settings.rst index a4fc0ba5..ceb94e57 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -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 ` section for -more information. +Pelican offers a way to translate articles. See the :doc:`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 `. +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 `. 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 diff --git a/pelican/generators.py b/pelican/generators.py index d176e4ee..9e2925cb 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -315,80 +315,114 @@ class ArticlesGenerator(CachingGenerator): order_by=self.settings['ARTICLE_ORDER_BY']) if self.settings.get('FEED_ALL_ATOM'): - writer.write_feed(all_articles, self.context, + writer.write_feed(all_articles, + self.context, self.settings['FEED_ALL_ATOM'], self.settings.get( 'FEED_ALL_ATOM_URL', - self.settings['FEED_ALL_ATOM'])) + self.settings['FEED_ALL_ATOM']) + ) if self.settings.get('FEED_ALL_RSS'): - writer.write_feed(all_articles, self.context, + writer.write_feed(all_articles, + self.context, self.settings['FEED_ALL_RSS'], self.settings.get( 'FEED_ALL_RSS_URL', self.settings['FEED_ALL_RSS']), - feed_type='rss') + feed_type='rss' + ) for cat, arts in self.categories: if self.settings.get('CATEGORY_FEED_ATOM'): - writer.write_feed(arts, self.context, - self.settings['CATEGORY_FEED_ATOM'] - % cat.slug, + writer.write_feed(arts, + self.context, + self.settings['CATEGORY_FEED_ATOM'].format( + slug=cat.slug + ), self.settings.get( 'CATEGORY_FEED_ATOM_URL', - self.settings['CATEGORY_FEED_ATOM']) - % cat.slug, feed_title=cat.name) + self.settings['CATEGORY_FEED_ATOM']).format( + slug=cat.slug + ), + feed_title=cat.name + ) if self.settings.get('CATEGORY_FEED_RSS'): - writer.write_feed(arts, self.context, - self.settings['CATEGORY_FEED_RSS'] - % cat.slug, + writer.write_feed(arts, + self.context, + self.settings['CATEGORY_FEED_RSS'].format( + slug=cat.slug + ), self.settings.get( 'CATEGORY_FEED_RSS_URL', - self.settings['CATEGORY_FEED_RSS']) - % cat.slug, feed_title=cat.name, - feed_type='rss') + self.settings['CATEGORY_FEED_RSS']).format( + slug=cat.slug + ), + feed_title=cat.name, + feed_type='rss' + ) for auth, arts in self.authors: if self.settings.get('AUTHOR_FEED_ATOM'): - writer.write_feed(arts, self.context, - self.settings['AUTHOR_FEED_ATOM'] - % auth.slug, + writer.write_feed(arts, + self.context, + self.settings['AUTHOR_FEED_ATOM'].format( + slug=auth.slug + ), self.settings.get( 'AUTHOR_FEED_ATOM_URL', - self.settings['AUTHOR_FEED_ATOM']) - % auth.slug, feed_title=auth.name) + self.settings['AUTHOR_FEED_ATOM']).format( + slug=auth.slug + ), + feed_title=auth.name + ) if self.settings.get('AUTHOR_FEED_RSS'): - writer.write_feed(arts, self.context, - self.settings['AUTHOR_FEED_RSS'] - % auth.slug, + writer.write_feed(arts, + self.context, + self.settings['AUTHOR_FEED_RSS'].format( + slug=auth.slug + ), self.settings.get( 'AUTHOR_FEED_RSS_URL', - self.settings['AUTHOR_FEED_RSS']) - % auth.slug, feed_title=auth.name, - feed_type='rss') + self.settings['AUTHOR_FEED_RSS']).format( + slug=auth.slug + ), + feed_title=auth.name, + feed_type='rss' + ) if (self.settings.get('TAG_FEED_ATOM') or self.settings.get('TAG_FEED_RSS')): for tag, arts in self.tags.items(): if self.settings.get('TAG_FEED_ATOM'): - writer.write_feed(arts, self.context, - self.settings['TAG_FEED_ATOM'] - % tag.slug, + writer.write_feed(arts, + self.context, + self.settings['TAG_FEED_ATOM'].format( + tag.slug + ), self.settings.get( 'TAG_FEED_ATOM_URL', - self.settings['TAG_FEED_ATOM']) - % tag.slug, feed_title=tag.name) + self.settings['TAG_FEED_ATOM']).format( + tag.slug + ), + feed_title=tag.name + ) if self.settings.get('TAG_FEED_RSS'): writer.write_feed(arts, self.context, - self.settings['TAG_FEED_RSS'] % tag.slug, + self.settings['TAG_FEED_RSS'].format( + tag.slug + ), self.settings.get( 'TAG_FEED_RSS_URL', - self.settings['TAG_FEED_RSS']) - % tag.slug, feed_title=tag.name, - feed_type='rss') + self.settings['TAG_FEED_RSS']).format( + tag.slug + ), + feed_title=tag.name, + feed_type='rss' + ) if (self.settings.get('TRANSLATION_FEED_ATOM') or self.settings.get('TRANSLATION_FEED_RSS')): @@ -401,19 +435,27 @@ class ArticlesGenerator(CachingGenerator): items, order_by=self.settings['ARTICLE_ORDER_BY']) if self.settings.get('TRANSLATION_FEED_ATOM'): writer.write_feed( - items, self.context, - self.settings['TRANSLATION_FEED_ATOM'] % lang, + items, + self.context, + self.settings['TRANSLATION_FEED_ATOM'].format( + lang=lang), self.settings.get( 'TRANSLATION_FEED_ATOM_URL', - self.settings['TRANSLATION_FEED_ATOM']) % lang) + self.settings['TRANSLATION_FEED_ATOM']).format( + lang=lang) + ) if self.settings.get('TRANSLATION_FEED_RSS'): writer.write_feed( - items, self.context, - self.settings['TRANSLATION_FEED_RSS'] % lang, + items, + self.context, + self.settings['TRANSLATION_FEED_RSS'].format( + lang=lang), self.settings.get( 'TRANSLATION_FEED_RSS_URL', - self.settings['TRANSLATION_FEED_RSS']) % lang, - feed_type='rss') + self.settings['TRANSLATION_FEED_RSS']).format( + lang=lang), + feed_type='rss' + ) def generate_articles(self, write): """Generate the articles.""" diff --git a/pelican/settings.py b/pelican/settings.py index b6f481d2..0c1ef14d 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -44,10 +44,10 @@ DEFAULT_CONFIG = { 'THEME_STATIC_DIR': 'theme', 'THEME_STATIC_PATHS': ['static', ], 'FEED_ALL_ATOM': posix_join('feeds', 'all.atom.xml'), - 'CATEGORY_FEED_ATOM': posix_join('feeds', '%s.atom.xml'), - 'AUTHOR_FEED_ATOM': posix_join('feeds', '%s.atom.xml'), - 'AUTHOR_FEED_RSS': posix_join('feeds', '%s.rss.xml'), - 'TRANSLATION_FEED_ATOM': posix_join('feeds', 'all-%s.atom.xml'), + 'CATEGORY_FEED_ATOM': posix_join('feeds', '{slug}.atom.xml'), + 'AUTHOR_FEED_ATOM': posix_join('feeds', '{slug}.atom.xml'), + 'AUTHOR_FEED_RSS': posix_join('feeds', '{slug}.rss.xml'), + 'TRANSLATION_FEED_ATOM': posix_join('feeds', 'all-{lang}.atom.xml'), 'FEED_MAX_ITEMS': '', 'RSS_FEED_SUMMARY_ONLY': True, 'SITEURL': '', diff --git a/pelican/tests/default_conf.py b/pelican/tests/default_conf.py index 77c2b947..a567dc10 100644 --- a/pelican/tests/default_conf.py +++ b/pelican/tests/default_conf.py @@ -12,7 +12,7 @@ REVERSE_CATEGORY_ORDER = True DEFAULT_PAGINATION = 2 FEED_RSS = 'feeds/all.rss.xml' -CATEGORY_FEED_RSS = 'feeds/%s.rss.xml' +CATEGORY_FEED_RSS = 'feeds/{slug}.rss.xml' LINKS = (('Biologeek', 'http://biologeek.org'), ('Filyb', "http://filyb.info/"), diff --git a/pelican/tools/templates/publishconf.py.jinja2 b/pelican/tools/templates/publishconf.py.jinja2 index 4b9a7cba..913de7f1 100755 --- a/pelican/tools/templates/publishconf.py.jinja2 +++ b/pelican/tools/templates/publishconf.py.jinja2 @@ -15,7 +15,7 @@ SITEURL = '{{siteurl}}' RELATIVE_URLS = False FEED_ALL_ATOM = 'feeds/all.atom.xml' -CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml' +CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml' DELETE_OUTPUT_DIRECTORY = True diff --git a/samples/pelican.conf.py b/samples/pelican.conf.py index da5c5dc5..41d251a0 100755 --- a/samples/pelican.conf.py +++ b/samples/pelican.conf.py @@ -18,7 +18,7 @@ DEFAULT_PAGINATION = 4 DEFAULT_DATE = (2012, 3, 2, 14, 1, 1) FEED_ALL_RSS = 'feeds/all.rss.xml' -CATEGORY_FEED_RSS = 'feeds/%s.rss.xml' +CATEGORY_FEED_RSS = 'feeds{slug}.rss.xml' LINKS = (('Biologeek', 'http://biologeek.org'), ('Filyb', "http://filyb.info/"), diff --git a/samples/pelican.conf_FR.py b/samples/pelican.conf_FR.py index 54b348c4..b1571e8a 100644 --- a/samples/pelican.conf_FR.py +++ b/samples/pelican.conf_FR.py @@ -22,7 +22,7 @@ ARTICLE_URL = 'posts/{date:%Y}/{date:%B}/{date:%d}/{slug}/' ARTICLE_SAVE_AS = ARTICLE_URL + 'index.html' FEED_ALL_RSS = 'feeds/all.rss.xml' -CATEGORY_FEED_RSS = 'feeds/%s.rss.xml' +CATEGORY_FEED_RSS = 'feeds/{slug}.rss.xml' LINKS = (('Biologeek', 'http://biologeek.org'), ('Filyb', "http://filyb.info/"),