1
0
Fork 0
forked from github/pelican

Merge pull request #1926 from MrSenko/tag_slugs

More granular control of tags and categories slugs. Fixes #1873
This commit is contained in:
Justin Mayer 2016-05-02 09:12:07 -07:00
commit 515f2fb5b2
8 changed files with 167 additions and 9 deletions

View file

@ -4,7 +4,17 @@ Release history
Next release
============
- Nothing yet
* ``SLUG_SUBSTITUTIONS`` now accepts 3-tuple elements, allowing to keep
non-alphanum characters. Existing 2-tuple configurations will continue to work
without change in behavior. The new 3rd parameter has side effects when there
are multiple substitutions defined. Plese see the docs.
* Tag and category slugs can be controlled with greater precision using the
``TAG_SUBSTITUTIONS`` and ``CATEGORY_SUBSTITUTIONS`` settings. These also
allow for keeping non-alphanum characters for backward compatibility with
existing URLs.
* Author slugs can be controlled with greater precision using the
``AUTHOR_SUBSTITUTIONS`` setting. Keeping non-alphanum characters is supported
as well but discouraged.
3.6.3 (2015-08-14)
==================

View file

@ -306,8 +306,14 @@ Setting name (followed by default value, if any) What does it do?
``DAY_ARCHIVE_SAVE_AS = ''`` The location to save per-day archives of your posts.
``SLUG_SUBSTITUTIONS = ()`` Substitutions to make prior to stripping out
non-alphanumerics when generating slugs. Specified
as a list of 2-tuples of ``(from, to)`` which are
applied in order.
as a list of 3-tuples of ``(from, to, skip)`` which are
applied in order. ``skip`` is a boolean indicating whether
or not to skip replacement of non-alphanumeric characters.
Useful for backward compatibility with existing URLs.
``AUTHOR_SUBSTITUTIONS = ()`` Substitutions for authors. ``SLUG_SUBSTITUTIONS`` is not
taken into account here!
``CATEGORY_SUBSTITUTIONS = ()`` Added to ``SLUG_SUBSTITUTIONS`` for categories.
``TAG_SUBSTITUTIONS = ()`` Added to ``SLUG_SUBSTITUTIONS`` for tags.
====================================================== ==============================================================
.. note::
@ -317,6 +323,20 @@ Setting name (followed by default value, if any) What does it do?
set the corresponding ``*_SAVE_AS`` setting to ``''`` to prevent the
relevant page from being generated.
.. note::
Substitutions are applied in order with the side effect that keeping
non-alphanum characters applies to the whole string when a replacement
is made. For example if you have the following setting
``SLUG_SUBSTITUTIONS = (('C++', 'cpp'), ('keep dot', 'keep.dot', True))``
the string ``Keep Dot`` will be converted to ``keep.dot``, however
``C++ will keep dot`` will be converted to ``cpp will keep.dot`` instead
of ``cpp-will-keep.dot``!
If you want to keep non-alphanum characters only for tags or categories
but not other slugs then configure ``TAG_SUBSTITUTIONS`` and
``CATEGORY_SUBSTITUTIONS`` respectively!
Pelican can optionally create per-year, per-month, and per-day archives of your
posts. These secondary archives are disabled by default but are automatically
enabled if you supply format strings for their respective ``_SAVE_AS`` settings.