Mercurial > piecrust2
comparison piecrust/baking/single.py @ 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 | ab5c6a8ae90a |
children | cc9593b9bcbf |
comparison
equal
deleted
inserted
replaced
812:82509bce94ca | 834:10c482d57c79 |
---|---|
54 | 54 |
55 def shutdown(self): | 55 def shutdown(self): |
56 self._writer_queue.put_nowait(None) | 56 self._writer_queue.put_nowait(None) |
57 self._writer.join() | 57 self._writer.join() |
58 | 58 |
59 def getOutputPath(self, uri): | 59 def getOutputPath(self, uri, pretty_urls=None): |
60 uri_root, uri_path = split_uri(self.app, uri) | 60 uri_root, uri_path = split_uri(self.app, uri) |
61 | 61 |
62 bake_path = [self.out_dir] | 62 bake_path = [self.out_dir] |
63 decoded_uri = urllib.parse.unquote(uri_path) | 63 decoded_uri = urllib.parse.unquote(uri_path) |
64 if self.pretty_urls: | 64 if pretty_urls is None: |
65 pretty_urls = self.pretty_urls | |
66 if pretty_urls: | |
65 bake_path.append(decoded_uri) | 67 bake_path.append(decoded_uri) |
66 bake_path.append('index.html') | 68 bake_path.append('index.html') |
67 elif decoded_uri == '': | 69 elif decoded_uri == '': |
68 bake_path.append('index.html') | 70 bake_path.append('index.html') |
69 else: | 71 else: |
80 | 82 |
81 while has_more_subs: | 83 while has_more_subs: |
82 # Get the URL and path for this sub-page. | 84 # Get the URL and path for this sub-page. |
83 sub_uri = qualified_page.getUri(cur_sub) | 85 sub_uri = qualified_page.getUri(cur_sub) |
84 logger.debug("Baking '%s' [%d]..." % (sub_uri, cur_sub)) | 86 logger.debug("Baking '%s' [%d]..." % (sub_uri, cur_sub)) |
85 out_path = self.getOutputPath(sub_uri) | 87 out_path = self.getOutputPath(sub_uri, qualified_page.pretty_urls) |
86 | 88 |
87 # Create the sub-entry for the bake record. | 89 # Create the sub-entry for the bake record. |
88 sub_entry = SubPageBakeInfo(sub_uri, out_path) | 90 sub_entry = SubPageBakeInfo(sub_uri, out_path) |
89 sub_entries.append(sub_entry) | 91 sub_entries.append(sub_entry) |
90 | 92 |
153 sub_entry.render_info = rp.copyRenderInfo() | 155 sub_entry.render_info = rp.copyRenderInfo() |
154 | 156 |
155 # Copy page assets. | 157 # Copy page assets. |
156 if (cur_sub == 1 and self.copy_assets and | 158 if (cur_sub == 1 and self.copy_assets and |
157 sub_entry.anyPass(lambda p: p.used_assets)): | 159 sub_entry.anyPass(lambda p: p.used_assets)): |
158 if self.pretty_urls: | 160 if qualified_page.pretty_urls: |
159 out_assets_dir = os.path.dirname(out_path) | 161 out_assets_dir = os.path.dirname(out_path) |
160 else: | 162 else: |
161 out_assets_dir, out_name = os.path.split(out_path) | 163 out_assets_dir, out_name = os.path.split(out_path) |
162 if sub_uri != self.site_root: | 164 if sub_uri != self.site_root: |
163 out_name_noext, _ = os.path.splitext(out_name) | 165 out_name_noext, _ = os.path.splitext(out_name) |