mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Allow to use page URL in pagination pattern.
Currently it was only possible to use page "save as" name or part of it
for generating pagination links. That's not sufficient when page URLs
differ a lot from actual filenames. With this patch it's possible to use
the `{url}` placeholder in PAGINATION_PATTERNS setting. For example, the
paginated archives would be saved to:
blog/index.html
blog/2/index.html
blog/3/index.html
while the actual URLs would be like this (with the help of Apache's
mod_rewrite):
http://blog.my.site/
http://blog.my.site/2/
http://blog.my.site/3/
The configuration that corresponds to this is roughly the following:
ARCHIVES_SAVE_AS = 'blog/index.html'
ARCHIVES_URL = 'http://blog.my.site/'
PAGINATION_PATTERNS = [
(1, '/{url}', '{base_name}/index.html'),
(2, '/{url}{number}/', '{base_name}/{number}/index.html')
]
Also added YEAR_ARCHIVE_URL, MONTH_ARCHIVE_URL and DAY_ARCHIVE_URL
settings, as they were missing and now they make sense.
This commit is contained in:
parent
56a483475b
commit
182fb11c80
6 changed files with 74 additions and 25 deletions
|
|
@ -141,7 +141,7 @@ class Writer(object):
|
|||
return feed
|
||||
|
||||
def write_file(self, name, template, context, relative_urls=False,
|
||||
paginated=None, override_output=False, **kwargs):
|
||||
paginated=None, override_output=False, url=None, **kwargs):
|
||||
"""Render the template and write the file.
|
||||
|
||||
:param name: name of the file to output
|
||||
|
|
@ -153,6 +153,7 @@ class Writer(object):
|
|||
:param override_output: boolean telling if we can override previous
|
||||
output with the same name (and if next files written with the same
|
||||
name should be skipped to keep that one)
|
||||
:param url: url of the file (needed by the paginator)
|
||||
:param **kwargs: additional variables to pass to the templates
|
||||
"""
|
||||
|
||||
|
|
@ -202,7 +203,7 @@ class Writer(object):
|
|||
if paginated:
|
||||
|
||||
# pagination needed, init paginators
|
||||
paginators = {key: Paginator(name, val, self.settings)
|
||||
paginators = {key: Paginator(name, url, val, self.settings)
|
||||
for key, val in paginated.items()}
|
||||
|
||||
# generated pages, and write
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue