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