Fix #1647: Fix ARTICLE_ORDER_BY and add the ability to reverse order

ARTICLE_ORDER_BY wasn't doing anything because the ArticlesGenerator
was sorting articles after ARTICLE_ORDER_BY was applied. This fixes
that by adding the ability to reverse metadata order by adding the
option prefix 'reversed-' to metadata and changing the default value
to 'reversed-date'.

Relevant documentation is also updated and moved into a more appropriate
place ('Ordering Content' instead of 'URL settings').
This commit is contained in:
Deniz Turgut 2015-06-12 17:15:19 -04:00
commit da8b469ab8
5 changed files with 115 additions and 35 deletions

View file

@ -277,14 +277,6 @@ Setting name (followed by default value, if any) What does it do?
====================================================== ==============================================================
``ARTICLE_URL = '{slug}.html'`` The URL to refer to an article.
``ARTICLE_SAVE_AS = '{slug}.html'`` The place where we will save an article.
``ARTICLE_ORDER_BY = 'slug'`` The metadata attribute used to sort articles. By default,
the ``articles_page.object_list`` template variable is
ordered by slug. If you modify this, make sure all
articles contain the attribute you specify. You can also
specify a "sorting" function of one argument that is used
to extract a comparison key from each article. For example,
sorting by title without using the built-in functionality
would use the function ``operator.attrgetter('title')``.
``ARTICLE_LANG_URL = '{slug}-{lang}.html'`` The URL to refer to an article which doesn't use the
default language.
``ARTICLE_LANG_SAVE_AS = '{slug}-{lang}.html'`` The place where we will save an article which
@ -299,17 +291,6 @@ Setting name (followed by default value, if any) What does it do?
``PAGE_SAVE_AS = 'pages/{slug}.html'`` The location we will save the page. This value has to be
the same as PAGE_URL or you need to use a rewrite in
your server config.
``PAGE_ORDER_BY = 'basename'`` The metadata attribute used to sort pages. By default
the ``PAGES`` template variable is ordered by basename
(i.e., path not included). Note that the option ``'basename'``
is a special option supported in the source code. If
you modify this setting, make sure all pages contain
the attribute you specify. You can also specify a "sorting"
function of one argument that is used to extract a comparison
key from each page. For example, the basename function looks
similar to
``lambda x: os.path.basename(getattr(x, 'source_path', ''))``.
``PAGE_LANG_URL = 'pages/{slug}-{lang}.html'`` The URL we will use to link to a page which doesn't
use the default language.
``PAGE_LANG_SAVE_AS = 'pages/{slug}-{lang}.html'`` The location we will save the page which doesn't
@ -644,14 +625,26 @@ Setting name (followed by default value, if any) What does it do?
Ordering content
================
================================================ =====================================================
================================================ ==============================================================
Setting name (followed by default value) What does it do?
================================================ =====================================================
================================================ ==============================================================
``NEWEST_FIRST_ARCHIVES = True`` Order archives by newest first by date. (False:
orders by date with older articles first.)
``REVERSE_CATEGORY_ORDER = False`` Reverse the category order. (True: lists by reverse
alphabetical order; default lists alphabetically.)
================================================ =====================================================
``ARTICLE_ORDER_BY = 'reversed-date'`` Defines how the articles (``articles_page.object_list`` in
the template) are sorted. Valid options are: metadata as a
string (use ``reversed-`` prefix the reverse the sort order),
special option ``'basename'`` which will use the basename of
the file (without path) or a custom function to extract the
sorting key from articles. The default value,
``'reversed-date'``, will sort articles by date in reverse
order (i.e. newest article comes first).
``PAGE_ORDER_BY = 'basename'`` Defines how the pages (``PAGES`` variable in the template)
are sorted. Options are same as ``ARTICLE_ORDER_BY``.
The default value, ``'basename'`` will sort pages by their
basename.
================================================ ==============================================================
Themes