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:
parent
c5eecd23eb
commit
e07b39dfcb
2 changed files with 9 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ from __future__ import unicode_literals, print_function
|
||||||
# From django.core.paginator
|
# From django.core.paginator
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from math import ceil
|
from math import ceil
|
||||||
|
|
||||||
|
|
@ -114,10 +115,16 @@ class Page(object):
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
context = self.__dict__
|
context = self.__dict__
|
||||||
|
context['base_name'] = os.path.dirname(self.name)
|
||||||
|
context['number_sep'] = '/'
|
||||||
if self.number == 1:
|
if self.number == 1:
|
||||||
# no page numbers on the first page
|
# no page numbers on the first page
|
||||||
context['number'] = ''
|
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'))
|
url = property(functools.partial(_from_settings, key='URL'))
|
||||||
save_as = property(functools.partial(_from_settings, key='SAVE_AS'))
|
save_as = property(functools.partial(_from_settings, key='SAVE_AS'))
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ class Writer(object):
|
||||||
# check paginated
|
# check paginated
|
||||||
paginated = paginated or {}
|
paginated = paginated or {}
|
||||||
if paginated:
|
if paginated:
|
||||||
name_root, ext = os.path.splitext(name)
|
name_root = os.path.splitext(name)[0]
|
||||||
|
|
||||||
# pagination needed, init paginators
|
# pagination needed, init paginators
|
||||||
paginators = {}
|
paginators = {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue