comparison piecrust/appconfig.py @ 743:7705b3d981ca

templating: Make the 'categories' taxonomy use a 'pccaturl' function again.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 03 Jun 2016 20:21:58 -0700
parents 8c3c2b949b82
children 7dbddfed8129
comparison
equal deleted inserted replaced
742:9231172e3d81 743:7705b3d981ca
12 DEFAULT_FORMAT, DEFAULT_TEMPLATE_ENGINE, DEFAULT_POSTS_FS, 12 DEFAULT_FORMAT, DEFAULT_TEMPLATE_ENGINE, DEFAULT_POSTS_FS,
13 DEFAULT_DATE_FORMAT, DEFAULT_THEME_SOURCE) 13 DEFAULT_DATE_FORMAT, DEFAULT_THEME_SOURCE)
14 from piecrust.cache import NullCache 14 from piecrust.cache import NullCache
15 from piecrust.configuration import ( 15 from piecrust.configuration import (
16 Configuration, ConfigurationError, ConfigurationLoader, 16 Configuration, ConfigurationError, ConfigurationLoader,
17 try_get_dict_value, set_dict_value, merge_dicts, visit_dict) 17 try_get_dict_value, try_get_dict_values,
18 set_dict_value, merge_dicts, visit_dict)
18 from piecrust.sources.base import REALM_USER, REALM_THEME 19 from piecrust.sources.base import REALM_USER, REALM_THEME
19 20
20 21
21 logger = logging.getLogger(__name__) 22 logger = logging.getLogger(__name__)
22 23
371 ('tags', { 372 ('tags', {
372 'multiple': True, 373 'multiple': True,
373 'term': 'tag' 374 'term': 'tag'
374 }), 375 }),
375 ('categories', { 376 ('categories', {
376 'term': 'category' 377 'term': 'category',
378 'func_name': 'pccaturl'
377 }) 379 })
378 ]) 380 ])
379 }) 381 })
380 }) 382 })
381 383
500 }) 502 })
501 cfg['site']['generators'][tax_gen_name] = tax_gen 503 cfg['site']['generators'][tax_gen_name] = tax_gen
502 504
503 # Route. 505 # Route.
504 tax_url_cfg_name = '%s_url' % term 506 tax_url_cfg_name = '%s_url' % term
505 tax_url = blog_cfg.get(tax_url_cfg_name, 507 tax_url = try_get_dict_values(
506 try_get_dict_value( 508 (blog_cfg, tax_url_cfg_name),
507 user_overrides, 509 (user_overrides, 'site/%s' % tax_url_cfg_name),
508 'site/%s' % tax_url_cfg_name, 510 (values, 'site/%s' % tax_url_cfg_name),
509 values['site'].get( 511 default=('%s/%%%s%%' % (term, term)))
510 tax_url_cfg_name,
511 '%s/%%%s%%' % (term, term))))
512 tax_url = '/' + url_prefix + tax_url.lstrip('/') 512 tax_url = '/' + url_prefix + tax_url.lstrip('/')
513 term_arg = term 513 term_arg = term
514 if tax_cfg.get('multiple') is True: 514 if tax_cfg.get('multiple') is True:
515 term_arg = '+' + term 515 term_arg = '+' + term
516 tax_func = '%s%surl(%s)' % (tpl_func_prefix, term, term_arg) 516 tax_func_name = try_get_dict_values(
517 (user_overrides, 'site/taxonomies/%s/func_name' % tax_name),
518 (values, 'site/taxonomies/%s/func_name' % tax_name),
519 default=('%s%surl' % (tpl_func_prefix, term)))
520 tax_func = '%s(%s)' % (tax_func_name, term_arg)
517 tax_route = collections.OrderedDict({ 521 tax_route = collections.OrderedDict({
518 'url': tax_url, 522 'url': tax_url,
519 'generator': tax_gen_name, 523 'generator': tax_gen_name,
520 'taxonomy': tax_name, 524 'taxonomy': tax_name,
521 'func': tax_func 525 'func': tax_func