1
0
Fork 0
forked from github/pelican

more robust PAGINATION_(URL|SAVE_AS) support

- add base_name and number_seperator to context to give more flexibility
  when naming things
This commit is contained in:
Ross McFarland 2012-12-29 17:44:35 -08:00 committed by Nathan Yergler
commit e07b39dfcb
2 changed files with 9 additions and 2 deletions

View file

@ -4,6 +4,7 @@ from __future__ import unicode_literals, print_function
# From django.core.paginator
import functools
import logging
import os
from math import ceil
@ -114,10 +115,16 @@ class Page(object):
return value
else:
context = self.__dict__
context['base_name'] = os.path.dirname(self.name)
context['number_sep'] = '/'
if self.number == 1:
# no page numbers on the first page
context['number'] = ''
return unicode(value).format(**context)
context['number_sep'] = ''
ret = unicode(value).format(**context)
if ret[0] == '/':
ret = ret[1:]
return ret
url = property(functools.partial(_from_settings, key='URL'))
save_as = property(functools.partial(_from_settings, key='SAVE_AS'))

View file

@ -150,7 +150,7 @@ class Writer(object):
# check paginated
paginated = paginated or {}
if paginated:
name_root, ext = os.path.splitext(name)
name_root = os.path.splitext(name)[0]
# pagination needed, init paginators
paginators = {}