Mercurial > piecrust2
changeset 834:10c482d57c79
Allow an individual page to override pretty_urls in it config
author | Ben Artin <ben@artins.org> |
---|---|
date | Mon, 02 Jan 2017 20:33:57 -0500 |
parents | 82509bce94ca |
children | cc9593b9bcbf |
files | piecrust/baking/single.py piecrust/rendering.py |
diffstat | 2 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/baking/single.py Tue Dec 20 22:20:18 2016 -0800 +++ b/piecrust/baking/single.py Mon Jan 02 20:33:57 2017 -0500 @@ -56,12 +56,14 @@ self._writer_queue.put_nowait(None) self._writer.join() - def getOutputPath(self, uri): + def getOutputPath(self, uri, pretty_urls=None): uri_root, uri_path = split_uri(self.app, uri) bake_path = [self.out_dir] decoded_uri = urllib.parse.unquote(uri_path) - if self.pretty_urls: + if pretty_urls is None: + pretty_urls = self.pretty_urls + if pretty_urls: bake_path.append(decoded_uri) bake_path.append('index.html') elif decoded_uri == '': @@ -82,7 +84,7 @@ # Get the URL and path for this sub-page. sub_uri = qualified_page.getUri(cur_sub) logger.debug("Baking '%s' [%d]..." % (sub_uri, cur_sub)) - out_path = self.getOutputPath(sub_uri) + out_path = self.getOutputPath(sub_uri, qualified_page.pretty_urls) # Create the sub-entry for the bake record. sub_entry = SubPageBakeInfo(sub_uri, out_path) @@ -155,7 +157,7 @@ # Copy page assets. if (cur_sub == 1 and self.copy_assets and sub_entry.anyPass(lambda p: p.used_assets)): - if self.pretty_urls: + if qualified_page.pretty_urls: out_assets_dir = os.path.dirname(out_path) else: out_assets_dir, out_name = os.path.split(out_path)
--- a/piecrust/rendering.py Tue Dec 20 22:20:18 2016 -0800 +++ b/piecrust/rendering.py Mon Jan 02 20:33:57 2017 -0500 @@ -32,6 +32,7 @@ self.page = page self.route = route self.route_metadata = route_metadata + self.pretty_urls = page.config.get("pretty_urls") def getUri(self, sub_num=1): return self.route.getUri(self.route_metadata, sub_num=sub_num)