Mercurial > piecrust2
diff piecrust/data/builder.py @ 329:422052d2e978
internal: Try handling URLs in a consistent way.
* Now URLs passed to, and returned from, routes will always be absolute URLs,
i.e. URLs including the site root.
* Validate the site root at config loading time to make sure it starts and ends
with a slash.
* Get rid of unused stuff.
* Add tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 31 Mar 2015 23:03:28 -0700 |
parents | 412537e91e45 |
children | 498a917cd2d4 |
line wrap: on
line diff
--- a/piecrust/data/builder.py Tue Mar 31 22:38:56 2015 -0700 +++ b/piecrust/data/builder.py Tue Mar 31 23:03:28 2015 -0700 @@ -7,7 +7,7 @@ from piecrust.data.debug import build_debug_info from piecrust.data.linker import PageLinkerData from piecrust.data.paginator import Paginator -from piecrust.uriutil import get_slug, split_sub_uri +from piecrust.uriutil import split_uri, split_sub_uri logger = logging.getLogger(__name__) @@ -22,14 +22,15 @@ self.pagination_filter = None @property - def slug(self): - return get_slug(self.page.app, self.uri) + def app(self): + return self.page.app def build_page_data(ctx): page = ctx.page app = page.app first_uri, _ = split_sub_uri(app, ctx.uri) + _, slug = split_uri(app, ctx.uri) pc_data = PieCrustData() pgn_source = ctx.pagination_source or get_default_pagination_source(page) @@ -46,7 +47,7 @@ } page_data = data['page'] page_data['url'] = ctx.uri - page_data['slug'] = ctx.slug + page_data['slug'] = slug page_data['timestamp'] = time.mktime(page.datetime.timetuple()) date_format = app.config.get('site/date_format') if date_format: