Mercurial > piecrust2
comparison piecrust/baking/single.py @ 262:61145dcd56e0
routing: Better generate URLs according to the site configuration.
This fixes problems now that even the chef server generates URLs that are
appropriate given the `pretty_urls` and `trailing_slash` settings.
Add some tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 24 Feb 2015 08:06:25 -0800 |
parents | da5e6e00fb41 |
children | 74bea91c9630 |
comparison
equal
deleted
inserted
replaced
261:b51ddb0c260b | 262:61145dcd56e0 |
---|---|
37 bake_path = [self.out_dir] | 37 bake_path = [self.out_dir] |
38 decoded_uri = urllib.parse.unquote(uri.lstrip('/')) | 38 decoded_uri = urllib.parse.unquote(uri.lstrip('/')) |
39 if self.pretty_urls: | 39 if self.pretty_urls: |
40 bake_path.append(decoded_uri) | 40 bake_path.append(decoded_uri) |
41 bake_path.append('index.html') | 41 bake_path.append('index.html') |
42 elif decoded_uri == '': | |
43 bake_path.append('index.html') | |
42 else: | 44 else: |
43 name, ext = os.path.splitext(decoded_uri) | 45 bake_path.append(decoded_uri) |
44 if decoded_uri == '': | |
45 bake_path.append('index.html') | |
46 elif ext: | |
47 bake_path.append(decoded_uri) | |
48 else: | |
49 bake_path.append(decoded_uri + '.html') | |
50 | 46 |
51 return os.path.normpath(os.path.join(*bake_path)) | 47 return os.path.normpath(os.path.join(*bake_path)) |
52 | 48 |
53 def bake(self, factory, route, record_entry, | 49 def bake(self, factory, route, record_entry, |
54 taxonomy_name=None, taxonomy_term=None): | 50 taxonomy_name=None, taxonomy_term=None): |