Mercurial > piecrust2
comparison piecrust/app.py @ 663:3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 01 Mar 2016 22:27:28 -0800 |
parents | 59268b4d8c71 |
children | 81d9c3a3a0b5 |
comparison
equal
deleted
inserted
replaced
662:cbd5cdec0695 | 663:3ceeca7bb71c |
---|---|
52 def config(self): | 52 def config(self): |
53 logger.debug("Creating site configuration...") | 53 logger.debug("Creating site configuration...") |
54 start_time = time.perf_counter() | 54 start_time = time.perf_counter() |
55 | 55 |
56 paths = [] | 56 paths = [] |
57 if self.theme_dir: | 57 if not self.theme_site: |
58 paths.append(os.path.join(self.theme_dir, THEME_CONFIG_PATH)) | 58 if self.theme_dir: |
59 paths.append(os.path.join(self.root_dir, CONFIG_PATH)) | 59 paths.append(os.path.join(self.theme_dir, THEME_CONFIG_PATH)) |
60 paths.append(os.path.join(self.root_dir, CONFIG_PATH)) | |
61 else: | |
62 paths.append(os.path.join(self.root_dir, THEME_CONFIG_PATH)) | |
63 preview_path = os.path.join( | |
64 self.root_dir, 'configs', 'theme_preview.yml') | |
65 if os.path.isfile(preview_path): | |
66 paths.append(preview_path) | |
60 | 67 |
61 config_cache = self.cache.getCache('app') | 68 config_cache = self.cache.getCache('app') |
62 config = PieCrustConfiguration(paths, config_cache) | 69 config = PieCrustConfiguration(paths, config_cache, |
70 theme_config=self.theme_site) | |
63 if self.theme_dir: | 71 if self.theme_dir: |
64 # We'll need to flag all page sources as coming from | 72 # We'll need to flag all page sources as coming from |
65 # the theme. | 73 # the theme. |
66 def _fixupThemeSources(index, config): | 74 def _fixupThemeSources(index, config): |
67 if index != 0: | 75 if index != 0: |
105 | 113 |
106 return templates_dirs | 114 return templates_dirs |
107 | 115 |
108 @cached_property | 116 @cached_property |
109 def theme_dir(self): | 117 def theme_dir(self): |
118 if self.theme_site: | |
119 return None | |
110 td = self._get_dir(THEME_DIR) | 120 td = self._get_dir(THEME_DIR) |
111 if td is not None: | 121 if td is not None: |
112 return td | 122 return td |
113 return os.path.join(RESOURCES_DIR, 'theme') | 123 return os.path.join(RESOURCES_DIR, 'theme') |
114 | 124 |