comparison piecrust/app.py @ 152:8d956bd94ad2

Better combine user sources/routes with the default ones.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 04 Dec 2014 12:49:35 -0800
parents 5b12c1d96523
children 0a86a7a6b284
comparison
equal deleted inserted replaced
151:fd146f54bdaa 152:8d956bd94ad2
259 routesc.append({'url': category_url, 'source': blog_name, 259 routesc.append({'url': category_url, 'source': blog_name,
260 'taxonomy': 'categories', 260 'taxonomy': 'categories',
261 'func': 'pccaturl(category)'}) 261 'func': 'pccaturl(category)'})
262 262
263 # If the user defined some additional sources/routes/taxonomies, 263 # If the user defined some additional sources/routes/taxonomies,
264 # append them to the default ones. 264 # add them to the default ones. For routes, the order matters,
265 # though, so we make sure to add the user routes at the front
266 # of the list so they're evaluated first.
265 if orig_sources: 267 if orig_sources:
266 sourcesc.update(orig_sources) 268 sourcesc.update(orig_sources)
269 sitec['sources'] = sourcesc
267 if orig_routes: 270 if orig_routes:
268 routesc + orig_routes 271 routesc = orig_routes + routesc
272 sitec['routes'] = routesc
269 if orig_taxonomies: 273 if orig_taxonomies:
270 taxonomiesc.update(orig_taxonomies) 274 taxonomiesc.update(orig_taxonomies)
275 sitec['taxonomies'] = taxonomiesc
271 276
272 # Validate sources/routes. 277 # Validate sources/routes.
273 sourcesc = sitec.get('sources') 278 sourcesc = sitec.get('sources')
274 routesc = sitec.get('routes') 279 routesc = sitec.get('routes')
275 if not sourcesc: 280 if not sourcesc:
305 for sn, sc in sourcesc.items(): 310 for sn, sc in sourcesc.items():
306 if not isinstance(sc, dict): 311 if not isinstance(sc, dict):
307 raise ConfigurationError("All sources in 'site/sources' must be dictionaries.") 312 raise ConfigurationError("All sources in 'site/sources' must be dictionaries.")
308 sc.setdefault('type', 'default') 313 sc.setdefault('type', 'default')
309 sc.setdefault('fs_endpoint', sn) 314 sc.setdefault('fs_endpoint', sn)
315 sc.setdefault('ignore_missing_dir', False)
310 sc.setdefault('data_endpoint', sn) 316 sc.setdefault('data_endpoint', sn)
311 sc.setdefault('data_type', 'iterator') 317 sc.setdefault('data_type', 'iterator')
312 sc.setdefault('item_name', sn) 318 sc.setdefault('item_name', sn)
313 sc.setdefault('items_per_page', 5) 319 sc.setdefault('items_per_page', 5)
314 sc.setdefault('date_format', DEFAULT_DATE_FORMAT) 320 sc.setdefault('date_format', DEFAULT_DATE_FORMAT)