1
0
Fork 0
forked from github/pelican
pelican-theme/pelican
W. Trevor King 2c434ebac1 contents: Add rich comparisons to URLWrapper for easy sorting
There have been earlier attempts to sort categories and authors
[1,2,3], but they either sorted based on the object id [3], or only
sorted the main author and categories list.

This patch uses rich comparisons (keyed off URLWrapper.name, but
easily adjustable in subclasses) to make the objects sortable without
specifying a key for each sort.  For example, now

  {% for tag, articles in tags|sort %}

works as expected in a Jinja template.

The functools.total_ordering decorator fills in the missing rich
comparisons [4,5].

[1]: 877d454c8f
[2]: 7f36e0ed20
[3]: d0ec18f4db
[4]: http://docs.python.org/2/library/functools.html#functools.total_ordering
[5]: http://docs.python.org/3/library/functools.html#functools.total_ordering
2013-01-15 22:51:53 -05:00
..
plugins Annotate py3k code when needed. 2013-01-11 18:55:04 +01:00
themes Strip tags from title in simple index. Fixes #612 2012-12-02 16:10:11 -08:00
tools Annotate py3k code when needed. 2013-01-11 18:55:04 +01:00
__init__.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00
contents.py contents: Add rich comparisons to URLWrapper for easy sorting 2013-01-15 22:51:53 -05:00
generators.py contents: Add rich comparisons to URLWrapper for easy sorting 2013-01-15 22:51:53 -05:00
log.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00
paginator.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00
readers.py Annotate py3k code when needed. 2013-01-11 18:55:04 +01:00
rstdirectives.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00
server.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00
settings.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00
signals.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00
utils.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00
writers.py Port pelican to python 3. 2013-01-11 03:20:09 +01:00