Mercurial > piecrust2
changeset 836:dca51cd8147a
Merge pull request #42 from GitHub.
Also cleanup the code a bit.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 05 Feb 2017 22:50:12 -0800 |
parents | cb39c0dbe5f0 (current diff) cc9593b9bcbf (diff) |
children | ad8f48a31c62 |
files | piecrust/baking/single.py piecrust/rendering.py tests/test_baking_baker.py |
diffstat | 2 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/baking/single.py Sun Feb 05 22:42:18 2017 -0800 +++ b/piecrust/baking/single.py Sun Feb 05 22:50:12 2017 -0800 @@ -55,12 +55,12 @@ self._writer_queue.put_nowait(None) self._writer.join() - def getOutputPath(self, uri): + def getOutputPath(self, uri, pretty_urls): 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: bake_path.append(decoded_uri) bake_path.append('index.html') elif decoded_uri == '': @@ -81,7 +81,9 @@ # 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) + pretty_urls = qualified_page.config.get('pretty_urls', + self.pretty_urls) + out_path = self.getOutputPath(sub_uri, pretty_urls) # Create the sub-entry for the bake record. sub_entry = SubPageBakeInfo(sub_uri, out_path) @@ -154,7 +156,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 pretty_urls: out_assets_dir = os.path.dirname(out_path) else: out_assets_dir, out_name = os.path.split(out_path)
--- a/tests/test_baking_baker.py Sun Feb 05 22:42:18 2017 -0800 +++ b/tests/test_baking_baker.py Sun Feb 05 22:50:12 2017 -0800 @@ -46,7 +46,8 @@ app.config.set('site/root', urllib.parse.quote(site_root)) baker = PageBaker(app, '/destination') try: - path = baker.getOutputPath(urllib.parse.quote(site_root) + uri) + path = baker.getOutputPath(urllib.parse.quote(site_root) + uri, + pretty) expected = os.path.normpath( os.path.join('/destination', expected)) assert expected == path