Merge pull request #979 from nyergler/pagination_conf

Support flexible pagination configuration
This commit is contained in:
Justin Mayer 2013-08-03 14:58:47 -07:00
commit bea03bb4bb
9 changed files with 140 additions and 33 deletions

View file

@ -74,6 +74,9 @@ DEFAULT_CONFIG = {
'TAG_SAVE_AS': os.path.join('tag', '{slug}.html'),
'AUTHOR_URL': 'author/{slug}.html',
'AUTHOR_SAVE_AS': os.path.join('author', '{slug}.html'),
'PAGINATION_PATTERNS': [
(0, '{name}{number}.html', '{name}{number}.html'),
],
'YEAR_ARCHIVE_SAVE_AS': False,
'MONTH_ARCHIVE_SAVE_AS': False,
'DAY_ARCHIVE_SAVE_AS': False,
@ -237,6 +240,19 @@ def configure_settings(settings):
'http://docs.getpelican.com/en/latest/settings.html#timezone '
'for more information')
# fix up pagination rules
from pelican.paginator import PaginationRule
pagination_rules = [
PaginationRule(*r) for r in settings.get(
'PAGINATION_PATTERNS',
DEFAULT_CONFIG['PAGINATION_PATTERNS'],
)
]
settings['PAGINATION_PATTERNS'] = sorted(
pagination_rules,
key=lambda r: r[0],
)
# Save people from accidentally setting a string rather than a list
path_keys = (
'ARTICLE_EXCLUDES',