Mercurial > piecrust2
comparison piecrust/appconfig.py @ 730:8c3c2b949b82
routing: Fix problems with route functions.
Instead of using merged functions with multiblog sites, use different
functions. Add some options to customize the function names.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 01 Jun 2016 22:10:47 -0700 |
parents | 606f6d57b5df |
children | 7705b3d981ca |
comparison
equal
deleted
inserted
replaced
729:e35407c60e00 | 730:8c3c2b949b82 |
---|---|
396 url_prefix = '' | 396 url_prefix = '' |
397 page_prefix = '' | 397 page_prefix = '' |
398 fs_endpoint = 'posts' | 398 fs_endpoint = 'posts' |
399 data_endpoint = 'blog' | 399 data_endpoint = 'blog' |
400 item_name = 'post' | 400 item_name = 'post' |
401 tpl_func_prefix = 'pc' | |
401 | 402 |
402 if theme_site: | 403 if theme_site: |
403 # If this is a theme site, show posts from a `sample` directory | 404 # If this is a theme site, show posts from a `sample` directory |
404 # so it's clearer that those won't show up when the theme is | 405 # so it's clearer that those won't show up when the theme is |
405 # actually applied to a normal site. | 406 # actually applied to a normal site. |
406 fs_endpoint = 'sample/posts' | 407 fs_endpoint = 'sample/posts' |
407 else: | 408 else: |
408 url_prefix = blog_name + '/' | 409 url_prefix = blog_name + '/' |
409 page_prefix = blog_name + '/' | 410 page_prefix = blog_name + '/' |
411 data_endpoint = blog_name | |
410 fs_endpoint = 'posts/%s' % blog_name | 412 fs_endpoint = 'posts/%s' % blog_name |
411 data_endpoint = blog_name | 413 item_name = try_get_dict_value(user_overrides, |
412 item_name = '%s-post' % blog_name | 414 '%s/item_name' % blog_name, |
415 '%spost' % blog_name) | |
416 tpl_func_prefix = try_get_dict_value(user_overrides, | |
417 '%s/func_prefix' % blog_name, | |
418 'pc%s' % blog_name) | |
413 | 419 |
414 # Figure out the settings values for this blog, specifically. | 420 # Figure out the settings values for this blog, specifically. |
415 # The value could be set on the blog config itself, globally, or left at | 421 # The value could be set on the blog config itself, globally, or left at |
416 # its default. We already handle the "globally vs. default" with the | 422 # its default. We already handle the "globally vs. default" with the |
417 # `defs` map that we computed above. | 423 # `defs` map that we computed above. |
457 }), | 463 }), |
458 'routes': [ | 464 'routes': [ |
459 { | 465 { |
460 'url': post_url, | 466 'url': post_url, |
461 'source': blog_name, | 467 'source': blog_name, |
462 'func': 'pcposturl(int:year,int:month,int:day,slug)' | 468 'func': ( |
469 '%sposturl(int:year,int:month,int:day,slug)' % | |
470 tpl_func_prefix) | |
463 }, | 471 }, |
464 { | 472 { |
465 'url': year_url, | 473 'url': year_url, |
466 'generator': ('%s_archives' % blog_name), | 474 'generator': ('%s_archives' % blog_name), |
467 'func': 'pcyearurl(archive_year)' | 475 'func': ('%syearurl(year)' % tpl_func_prefix) |
468 } | 476 } |
469 ] | 477 ] |
470 }) | 478 }) |
471 }) | 479 }) |
472 | 480 |
503 '%s/%%%s%%' % (term, term)))) | 511 '%s/%%%s%%' % (term, term)))) |
504 tax_url = '/' + url_prefix + tax_url.lstrip('/') | 512 tax_url = '/' + url_prefix + tax_url.lstrip('/') |
505 term_arg = term | 513 term_arg = term |
506 if tax_cfg.get('multiple') is True: | 514 if tax_cfg.get('multiple') is True: |
507 term_arg = '+' + term | 515 term_arg = '+' + term |
508 tax_func = 'pc%surl(%s)' % (term, term_arg) | 516 tax_func = '%s%surl(%s)' % (tpl_func_prefix, term, term_arg) |
509 tax_route = collections.OrderedDict({ | 517 tax_route = collections.OrderedDict({ |
510 'url': tax_url, | 518 'url': tax_url, |
511 'generator': tax_gen_name, | 519 'generator': tax_gen_name, |
512 'taxonomy': tax_name, | 520 'taxonomy': tax_name, |
513 'func': tax_func | 521 'func': tax_func |