comparison piecrust/app.py @ 486:aae241804096

themes: Don't fixup template directories, it's actually better as-is. Prepending `theme/` is not too much trouble, and directories without that are useful for handling possible user overrides.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 22 Jul 2015 20:00:14 -0700
parents 3b6cbadd0c64
children 39175c48a4ae
comparison
equal deleted inserted replaced
485:c40b7923c474 486:aae241804096
27 27
28 28
29 logger = logging.getLogger(__name__) 29 logger = logging.getLogger(__name__)
30 30
31 31
32 CACHE_VERSION = 20 32 CACHE_VERSION = 21
33 33
34 34
35 class VariantNotFoundError(Exception): 35 class VariantNotFoundError(Exception):
36 def __init__(self, variant_path, message=None): 36 def __init__(self, variant_path, message=None):
37 super(VariantNotFoundError, self).__init__( 37 super(VariantNotFoundError, self).__init__(
431 paths.append(os.path.join(self.root_dir, CONFIG_PATH)) 431 paths.append(os.path.join(self.root_dir, CONFIG_PATH))
432 432
433 config_cache = self.cache.getCache('app') 433 config_cache = self.cache.getCache('app')
434 config = PieCrustConfiguration(paths, config_cache) 434 config = PieCrustConfiguration(paths, config_cache)
435 if self.theme_dir: 435 if self.theme_dir:
436 # We'll need to patch the templates directories to be relative 436 # We'll need to flag all page sources as coming from
437 # to the site's root, and not the theme root.
438 def _fixupThemeTemplatesDir(index, config):
439 if index != 0:
440 return
441 sitec = config.get('site')
442 if sitec is None:
443 return
444 tplc = sitec.get('templates_dirs')
445 if tplc is None:
446 return
447 if isinstance(tplc, str):
448 tplc = [tplc]
449 sitec['templates_dirs'] = list(
450 map(
451 lambda p: os.path.join(self.theme_dir, p),
452 tplc))
453
454 config.fixups.append(_fixupThemeTemplatesDir)
455
456 # We'll also need to flag all page sources as coming from
457 # the theme. 437 # the theme.
458 def _fixupThemeSources(index, config): 438 def _fixupThemeSources(index, config):
459 if index != 0: 439 if index != 0:
460 return 440 return
461 sitec = config.get('site') 441 sitec = config.get('site')