Mercurial > piecrust2
diff piecrust/appconfig.py @ 787:f6f9a284a5f3
routing: Simplify how route functions are declared and handled.
* Site config now only has to declare the function name.
* Simply code for running route functions.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 01 Sep 2016 23:00:58 -0700 |
parents | 7dbddfed8129 |
children | 58ebf50235a5 |
line wrap: on
line diff
--- a/piecrust/appconfig.py Thu Sep 01 22:58:31 2016 -0700 +++ b/piecrust/appconfig.py Thu Sep 01 23:00:58 2016 -0700 @@ -287,7 +287,7 @@ { 'url': '/%path:slug%', 'source': 'theme_pages', - 'func': 'pcurl(slug)' + 'func': 'pcurl' } ], 'theme_tag_page': 'theme_pages:_tag.%ext%', @@ -339,7 +339,7 @@ 'default_post_layout': 'post', 'post_url': '/%int4:year%/%int2:month%/%int2:day%/%slug%', 'year_url': '/archives/%int4:year%', - 'tag_url': '/tag/%path:tag%', + 'tag_url': '/tag/%+tag%', 'category_url': '/%category%', 'posts_per_page': 5 }) @@ -365,7 +365,7 @@ { 'url': '/%path:slug%', 'source': 'pages', - 'func': 'pcurl(slug)' + 'func': 'pcurl' } ], 'taxonomies': collections.OrderedDict([ @@ -467,14 +467,12 @@ { 'url': post_url, 'source': blog_name, - 'func': ( - '%sposturl(int:year,int:month,int:day,slug)' % - tpl_func_prefix) + 'func': ('%sposturl' % tpl_func_prefix) }, { 'url': year_url, 'generator': ('%s_archives' % blog_name), - 'func': ('%syearurl(year)' % tpl_func_prefix) + 'func': ('%syearurl' % tpl_func_prefix) } ] }) @@ -510,19 +508,15 @@ (values, 'site/%s' % tax_url_cfg_name), default=('%s/%%%s%%' % (term, term))) tax_url = '/' + url_prefix + tax_url.lstrip('/') - term_arg = term - if tax_cfg.get('multiple') is True: - term_arg = '+' + term tax_func_name = try_get_dict_values( (user_overrides, 'site/taxonomies/%s/func_name' % tax_name), (values, 'site/taxonomies/%s/func_name' % tax_name), default=('%s%surl' % (tpl_func_prefix, term))) - tax_func = '%s(%s)' % (tax_func_name, term_arg) tax_route = collections.OrderedDict({ 'url': tax_url, 'generator': tax_gen_name, 'taxonomy': tax_name, - 'func': tax_func + 'func': tax_func_name }) cfg['site']['routes'].append(tax_route)