Mercurial > piecrust2
diff piecrust/app.py @ 1005:2e5c5d33d62c
Merge changes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 21 Nov 2017 22:07:12 -0800 |
parents | 8adc27285d93 46025a1b5434 |
children | c4cf3cfe2726 |
line wrap: on
line diff
--- a/piecrust/app.py Tue Nov 21 21:30:37 2017 -0800 +++ b/piecrust/app.py Tue Nov 21 22:07:12 2017 -0800 @@ -15,6 +15,8 @@ from piecrust.page import Page from piecrust.plugins.base import PluginLoader from piecrust.routing import Route +from piecrust.sources.base import REALM_THEME +from piecrust.uriutil import multi_replace logger = logging.getLogger(__name__) @@ -118,8 +120,8 @@ return None # See if there's a theme we absolutely want. - td = self._get_dir(THEME_DIR) - if td is not None: + td = os.path.join(self.root_dir, THEME_DIR) + if os.path.isdir(td): return td # Try to load a theme specified in the configuration. @@ -133,8 +135,8 @@ return os.path.join(RESOURCES_DIR, 'theme') @cached_property - def plugins_dir(self): - return self._get_dir(PLUGINS_DIR) + def plugins_dirs(self): + return self._get_configurable_dirs(PLUGINS_DIR, 'site/plugins_dirs') @cached_property def cache_dir(self): @@ -229,11 +231,9 @@ cache_key, lambda: Page(source, content_item)) - def _get_dir(self, default_rel_dir): - abs_dir = os.path.join(self.root_dir, default_rel_dir) - if os.path.isdir(abs_dir): - return abs_dir - return None + def resolvePath(self, path): + path = multi_replace(path, {'%theme_dir%': self.theme_dir}) + return os.path.join(self.root_dir, path) def _get_configurable_dirs(self, default_rel_dir, conf_name): dirs = [] @@ -242,9 +242,9 @@ conf_dirs = self.config.get(conf_name) if conf_dirs is not None: if isinstance(conf_dirs, str): - dirs.append(os.path.join(self.root_dir, conf_dirs)) + dirs.append(self.resolvePath(conf_dirs)) else: - dirs += [os.path.join(self.root_dir, p) for p in conf_dirs] + dirs += [self.resolvePath(p) for p in conf_dirs] # Add the default directory if it exists. default_dir = os.path.join(self.root_dir, default_rel_dir)