Mercurial > piecrust2
comparison piecrust/app.py @ 307:869a206facd5
internal: Remove mentions of plugins directories and sources.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 22 Mar 2015 22:29:06 -0700 |
parents | 12657039c436 |
children | 47ffac7ab25d |
comparison
equal
deleted
inserted
replaced
306:7122976bc751 | 307:869a206facd5 |
---|---|
8 import yaml | 8 import yaml |
9 from werkzeug.utils import cached_property | 9 from werkzeug.utils import cached_property |
10 from piecrust import ( | 10 from piecrust import ( |
11 APP_VERSION, RESOURCES_DIR, | 11 APP_VERSION, RESOURCES_DIR, |
12 CACHE_DIR, TEMPLATES_DIR, ASSETS_DIR, | 12 CACHE_DIR, TEMPLATES_DIR, ASSETS_DIR, |
13 PLUGINS_DIR, THEME_DIR, | 13 THEME_DIR, |
14 CONFIG_PATH, THEME_CONFIG_PATH, | 14 CONFIG_PATH, THEME_CONFIG_PATH, |
15 DEFAULT_FORMAT, DEFAULT_TEMPLATE_ENGINE, DEFAULT_POSTS_FS, | 15 DEFAULT_FORMAT, DEFAULT_TEMPLATE_ENGINE, DEFAULT_POSTS_FS, |
16 DEFAULT_DATE_FORMAT, DEFAULT_PLUGIN_SOURCE, DEFAULT_THEME_SOURCE) | 16 DEFAULT_DATE_FORMAT, DEFAULT_THEME_SOURCE) |
17 from piecrust.cache import ExtensibleCache, NullCache, NullExtensibleCache | 17 from piecrust.cache import ExtensibleCache, NullCache, NullExtensibleCache |
18 from piecrust.plugins.base import PluginLoader | 18 from piecrust.plugins.base import PluginLoader |
19 from piecrust.environment import StandardEnvironment | 19 from piecrust.environment import StandardEnvironment |
20 from piecrust.configuration import (Configuration, ConfigurationError, | 20 from piecrust.configuration import ( |
21 ConfigurationLoader, merge_dicts) | 21 Configuration, ConfigurationError, ConfigurationLoader, |
22 merge_dicts) | |
22 from piecrust.routing import Route | 23 from piecrust.routing import Route |
23 from piecrust.sources.base import REALM_USER, REALM_THEME | 24 from piecrust.sources.base import REALM_USER, REALM_THEME |
24 from piecrust.taxonomies import Taxonomy | 25 from piecrust.taxonomies import Taxonomy |
25 | 26 |
26 | 27 |
27 logger = logging.getLogger(__name__) | 28 logger = logging.getLogger(__name__) |
28 | 29 |
29 | 30 |
30 CACHE_VERSION = 15 | 31 CACHE_VERSION = 16 |
31 | 32 |
32 | 33 |
33 class VariantNotFoundError(Exception): | 34 class VariantNotFoundError(Exception): |
34 def __init__(self, variant_path, message=None): | 35 def __init__(self, variant_path, message=None): |
35 super(VariantNotFoundError, self).__init__( | 36 super(VariantNotFoundError, self).__init__( |
115 ('html', ''), | 116 ('html', ''), |
116 ('md', 'markdown'), | 117 ('md', 'markdown'), |
117 ('textile', 'textile')]), | 118 ('textile', 'textile')]), |
118 'default_auto_format': 'md', | 119 'default_auto_format': 'md', |
119 'pagination_suffix': '/%num%', | 120 'pagination_suffix': '/%num%', |
120 'plugins_sources': [DEFAULT_PLUGIN_SOURCE], | 121 'plugins': None, |
121 'themes_sources': [DEFAULT_THEME_SOURCE], | 122 'themes_sources': [DEFAULT_THEME_SOURCE], |
122 'cache_time': 28800, | 123 'cache_time': 28800, |
123 'enable_debug_info': True, | 124 'enable_debug_info': True, |
124 'show_debug_info': False, | 125 'show_debug_info': False, |
125 'use_default_content': True | 126 'use_default_content': True |
166 pgn_suffix_re = re.escape(pgn_suffix) | 167 pgn_suffix_re = re.escape(pgn_suffix) |
167 pgn_suffix_re = (pgn_suffix_re.replace("\\%num\\%", "(?P<num>\\d+)") + | 168 pgn_suffix_re = (pgn_suffix_re.replace("\\%num\\%", "(?P<num>\\d+)") + |
168 '$') | 169 '$') |
169 cachec['pagination_suffix_re'] = pgn_suffix_re | 170 cachec['pagination_suffix_re'] = pgn_suffix_re |
170 | 171 |
171 # Make sure plugins and theme sources are lists. | 172 # Make sure theme sources is a list. |
172 if not isinstance(sitec['plugins_sources'], list): | |
173 sitec['plugins_sources'] = [sitec['plugins_sources']] | |
174 if not isinstance(sitec['themes_sources'], list): | 173 if not isinstance(sitec['themes_sources'], list): |
175 sitec['themes_sources'] = [sitec['themes_sources']] | 174 sitec['themes_sources'] = [sitec['themes_sources']] |
176 | 175 |
177 # Figure out if we need to validate sources/routes, or auto-generate | 176 # Figure out if we need to validate sources/routes, or auto-generate |
178 # them from simple blog settings. | 177 # them from simple blog settings. |
461 templates_dirs.append(default_theme_dir) | 460 templates_dirs.append(default_theme_dir) |
462 | 461 |
463 return templates_dirs | 462 return templates_dirs |
464 | 463 |
465 @cached_property | 464 @cached_property |
466 def plugins_dirs(self): | |
467 return self._get_configurable_dirs(PLUGINS_DIR, | |
468 'site/plugins_dirs') | |
469 | |
470 @cached_property | |
471 def theme_dir(self): | 465 def theme_dir(self): |
472 td = self._get_dir(THEME_DIR) | 466 td = self._get_dir(THEME_DIR) |
473 if td is not None: | 467 if td is not None: |
474 return td | 468 return td |
475 return os.path.join(RESOURCES_DIR, 'theme') | 469 return os.path.join(RESOURCES_DIR, 'theme') |