comparison piecrust/app.py @ 36:485682a6de50

New site layout support.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 20 Aug 2014 23:16:51 -0700
parents 8c15fc45d712
children 2f717f961996
comparison
equal deleted inserted replaced
35:e4c345dcf33c 36:485682a6de50
5 import hashlib 5 import hashlib
6 import logging 6 import logging
7 import yaml 7 import yaml
8 from werkzeug.utils import cached_property 8 from werkzeug.utils import cached_property
9 from piecrust import (APP_VERSION, 9 from piecrust import (APP_VERSION,
10 CACHE_DIR, TEMPLATES_DIR, 10 CACHE_DIR, TEMPLATES_DIR, ASSETS_DIR,
11 PLUGINS_DIR, THEME_DIR, 11 PLUGINS_DIR, THEME_DIR,
12 CONFIG_PATH, THEME_CONFIG_PATH, 12 CONFIG_PATH, THEME_CONFIG_PATH,
13 DEFAULT_FORMAT, DEFAULT_TEMPLATE_ENGINE, DEFAULT_POSTS_FS, 13 DEFAULT_FORMAT, DEFAULT_TEMPLATE_ENGINE, DEFAULT_POSTS_FS,
14 DEFAULT_DATE_FORMAT, DEFAULT_PLUGIN_SOURCE, DEFAULT_THEME_SOURCE) 14 DEFAULT_DATE_FORMAT, DEFAULT_PLUGIN_SOURCE, DEFAULT_THEME_SOURCE)
15 from piecrust.cache import ExtensibleCache, NullCache, NullExtensibleCache 15 from piecrust.cache import ExtensibleCache, NullCache, NullExtensibleCache
22 22
23 23
24 logger = logging.getLogger(__name__) 24 logger = logging.getLogger(__name__)
25 25
26 26
27 CACHE_VERSION = 11 27 CACHE_VERSION = 12
28 28
29 29
30 class VariantNotFoundError(Exception): 30 class VariantNotFoundError(Exception):
31 def __init__(self, variant_path, message=None): 31 def __init__(self, variant_path, message=None):
32 super(VariantNotFoundError, self).__init__( 32 super(VariantNotFoundError, self).__init__(
390 config.fixups.append(_fixupThemeSources) 390 config.fixups.append(_fixupThemeSources)
391 391
392 return config 392 return config
393 393
394 @cached_property 394 @cached_property
395 def assets_dirs(self):
396 assets_dirs = self._get_configurable_dirs(ASSETS_DIR,
397 'site/assets_dirs')
398
399 # Also add the theme directory, if any.
400 if self.theme_dir:
401 default_theme_dir = os.path.join(self.theme_dir, ASSETS_DIR)
402 if os.path.isdir(default_theme_dir):
403 assets_dirs.append(default_theme_dir)
404
405 return assets_dirs
406
407 @cached_property
395 def templates_dirs(self): 408 def templates_dirs(self):
396 templates_dirs = self._get_configurable_dirs(TEMPLATES_DIR, 409 templates_dirs = self._get_configurable_dirs(TEMPLATES_DIR,
397 'site/templates_dirs') 410 'site/templates_dirs')
398 411
399 # Also, add the theme directory, if nay. 412 # Also, add the theme directory, if any.
400 if self.theme_dir: 413 if self.theme_dir:
401 default_theme_dir = os.path.join(self.theme_dir, TEMPLATES_DIR) 414 default_theme_dir = os.path.join(self.theme_dir, TEMPLATES_DIR)
402 if os.path.isdir(default_theme_dir): 415 if os.path.isdir(default_theme_dir):
403 templates_dirs.append(default_theme_dir) 416 templates_dirs.append(default_theme_dir)
404 417