Mercurial > piecrust2
comparison piecrust/app.py @ 87:2fb6501ed668
Merge changes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 03 Sep 2014 18:49:10 -0700 |
parents | b3ce11b2cf36 f9f67086415c |
children | 28ea3e69d67e |
comparison
equal
deleted
inserted
replaced
86:1cd67680c38c | 87:2fb6501ed668 |
---|---|
120 'pagination_suffix': '/%num%', | 120 'pagination_suffix': '/%num%', |
121 'plugins_sources': [DEFAULT_PLUGIN_SOURCE], | 121 'plugins_sources': [DEFAULT_PLUGIN_SOURCE], |
122 'themes_sources': [DEFAULT_THEME_SOURCE], | 122 'themes_sources': [DEFAULT_THEME_SOURCE], |
123 'cache_time': 28800, | 123 'cache_time': 28800, |
124 'display_errors': True, | 124 'display_errors': True, |
125 'enable_debug_info': True | 125 'enable_debug_info': True, |
126 'use_default_content': True | |
126 } | 127 } |
127 sitec = values.get('site') | 128 sitec = values.get('site') |
128 if sitec is None: | 129 if sitec is None: |
129 sitec = {} | 130 sitec = {} |
130 for key, val in default_sitec.items(): | 131 for key, val in default_sitec.items(): |
166 if pf is not None: | 167 if pf is not None: |
167 sitec.setdefault('items_filters', pf) | 168 sitec.setdefault('items_filters', pf) |
168 | 169 |
169 # Figure out if we need to validate sources/routes, or auto-generate | 170 # Figure out if we need to validate sources/routes, or auto-generate |
170 # them from simple blog settings. | 171 # them from simple blog settings. |
171 if 'sources' not in sitec: | 172 orig_sources = sitec.get('sources') |
173 orig_routes = sitec.get('routes') | |
174 orig_taxonomies = sitec.get('taxonomies') | |
175 use_default_content = sitec.get('use_default_content') | |
176 if (orig_sources is None or orig_routes is None or | |
177 orig_taxonomies is None or use_default_content): | |
178 | |
179 # Setup defaults for various settings. | |
172 posts_fs = sitec.setdefault('posts_fs', DEFAULT_POSTS_FS) | 180 posts_fs = sitec.setdefault('posts_fs', DEFAULT_POSTS_FS) |
173 blogsc = sitec.setdefault('blogs', ['posts']) | 181 blogsc = sitec.setdefault('blogs', ['posts']) |
174 | 182 |
175 g_post_url = sitec.get('post_url', '%year%/%month%/%day%/%slug%') | 183 g_post_url = sitec.get('post_url', '%year%/%month%/%day%/%slug%') |
176 g_tag_url = sitec.get('tag_url', 'tag/%tag%') | 184 g_tag_url = sitec.get('tag_url', 'tag/%tag%') |
177 g_category_url = sitec.get('category_url', '%category%') | 185 g_category_url = sitec.get('category_url', '%category%') |
178 g_posts_per_page = sitec.get('items_per_page', 5) | 186 g_posts_per_page = sitec.get('items_per_page', 5) |
179 g_posts_filters = sitec.get('items_filters') | 187 g_posts_filters = sitec.get('items_filters') |
180 g_date_format = sitec.get('date_format', DEFAULT_DATE_FORMAT) | 188 g_date_format = sitec.get('date_format', DEFAULT_DATE_FORMAT) |
181 | 189 |
190 # The normal pages and tags/categories. | |
182 sourcesc = {} | 191 sourcesc = {} |
183 sourcesc['pages'] = { | 192 sourcesc['pages'] = { |
184 'type': 'default', | 193 'type': 'default', |
185 'ignore_missing_dir': True, | 194 'ignore_missing_dir': True, |
186 'data_endpoint': 'site.pages', | 195 'data_endpoint': 'site.pages', |
200 'term': 'tag'} | 209 'term': 'tag'} |
201 taxonomiesc['categories'] = { | 210 taxonomiesc['categories'] = { |
202 'term': 'category'} | 211 'term': 'category'} |
203 sitec['taxonomies'] = taxonomiesc | 212 sitec['taxonomies'] = taxonomiesc |
204 | 213 |
214 # Setup sources/routes/taxonomies for each blog. | |
205 for blog_name in blogsc: | 215 for blog_name in blogsc: |
206 blogc = values.get(blog_name, {}) | 216 blogc = values.get(blog_name, {}) |
207 url_prefix = blog_name + '/' | 217 url_prefix = blog_name + '/' |
208 endpoint = 'posts/%s' % blog_name | 218 endpoint = 'posts/%s' % blog_name |
209 item_name = '%s-post' % blog_name | 219 item_name = '%s-post' % blog_name |
248 'func': 'pctagurl(tag)'}) | 258 'func': 'pctagurl(tag)'}) |
249 routesc.append({'url': category_url, 'source': blog_name, | 259 routesc.append({'url': category_url, 'source': blog_name, |
250 'taxonomy': 'categories', | 260 'taxonomy': 'categories', |
251 'func': 'pccaturl(category)'}) | 261 'func': 'pccaturl(category)'}) |
252 | 262 |
263 # If the user defined some additional sources/routes/taxonomies, | |
264 # append them to the default ones. | |
265 if orig_sources: | |
266 sourcesc += orig_sources | |
267 if orig_routes: | |
268 routesc + orig_routes | |
269 if orig_taxonomies: | |
270 taxonomiesc += orig_taxonomies | |
271 | |
253 # Validate sources/routes. | 272 # Validate sources/routes. |
254 sourcesc = sitec.get('sources') | 273 sourcesc = sitec.get('sources') |
255 routesc = sitec.get('routes') | 274 routesc = sitec.get('routes') |
256 if not sourcesc: | 275 if not sourcesc: |
257 raise ConfigurationError("There are no sources defined.") | 276 raise ConfigurationError("There are no sources defined.") |