Mercurial > piecrust2
diff piecrust/uriutil.py @ 298:b7ab1b503510
data: Fix incorrect next/previous page URLs in pagination data.
Consolidate splitting an URL between its first URL and its sub page number.
Be careful about the index page's URL not losing its slash.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 11 Mar 2015 23:46:42 -0700 |
parents | 62c7a97c8340 |
children | 422052d2e978 |
line wrap: on
line diff
--- a/piecrust/uriutil.py Tue Mar 10 08:34:45 2015 -0700 +++ b/piecrust/uriutil.py Wed Mar 11 23:46:42 2015 -0700 @@ -80,18 +80,22 @@ return uri.lstrip('/') -def get_first_sub_uri(app, uri): +def split_sub_uri(app, uri): pretty_urls = app.config.get('site/pretty_urls') if not pretty_urls: uri, ext = os.path.splitext(uri) + page_num = 1 pgn_suffix_re = app.config.get('__cache/pagination_suffix_re') m = re.search(pgn_suffix_re, uri) if m: uri = uri[:m.start()] + if uri == '': + uri = '/' + page_num = int(m.group('num')) if not pretty_urls: uri += ext - return uri + return (uri, page_num)