Mercurial > piecrust2
comparison piecrust/routing.py @ 235:55087da9a72e
bake: Don't include the site root when building output paths.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 14 Feb 2015 08:49:09 -0800 |
parents | a75d024ee839 |
children | da5e6e00fb41 |
comparison
equal
deleted
inserted
replaced
234:1c4078ec3011 | 235:55087da9a72e |
---|---|
83 m = self.uri_re_no_path.match(uri) | 83 m = self.uri_re_no_path.match(uri) |
84 if m: | 84 if m: |
85 return m.groupdict() | 85 return m.groupdict() |
86 return None | 86 return None |
87 | 87 |
88 def getUri(self, source_metadata, provider=None): | 88 def getUri(self, source_metadata, provider=None, include_site_root=True): |
89 if provider: | 89 if provider: |
90 source_metadata = dict(source_metadata) | 90 source_metadata = dict(source_metadata) |
91 source_metadata.update(provider.getRouteMetadata()) | 91 source_metadata.update(provider.getRouteMetadata()) |
92 #TODO: fix this hard-coded shit | 92 #TODO: fix this hard-coded shit |
93 for key in ['year', 'month', 'day']: | 93 for key in ['year', 'month', 'day']: |
94 if key in source_metadata and isinstance(source_metadata[key], str): | 94 if key in source_metadata and isinstance(source_metadata[key], str): |
95 source_metadata[key] = int(source_metadata[key]) | 95 source_metadata[key] = int(source_metadata[key]) |
96 return self.uri_root + (self.uri_format % source_metadata) | 96 uri = self.uri_format % source_metadata |
97 if include_site_root: | |
98 uri = self.uri_root + uri | |
99 return uri | |
97 | 100 |
98 def _uriFormatRepl(self, m): | 101 def _uriFormatRepl(self, m): |
99 name = m.group('name') | 102 name = m.group('name') |
100 #TODO: fix this hard-coded shit | 103 #TODO: fix this hard-coded shit |
101 if name == 'year': | 104 if name == 'year': |