diff --git a/docs/settings.rst b/docs/settings.rst index e8743238..7d20a962 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -720,7 +720,7 @@ Setting name (followed by default value, if any) What does it do? the paths defined in this settings, they will be progressively overwritten. ``CSS_FILE = 'main.css'`` Specify the CSS file you want to load. -``THEMES = ('simple', ('!simple', 'simple'))`` Extra themes that can be inherited from, either +``THEMES = ['simple', ('!simple', 'simple')]`` Extra themes that can be inherited from, either implicitly (just a path to the theme) or explicitly using a prefix marker (tuple of prefix and path to theme). They can also inherit from each other, diff --git a/docs/themes.rst b/docs/themes.rst index 81854382..72923ff4 100644 --- a/docs/themes.rst +++ b/docs/themes.rst @@ -377,7 +377,7 @@ extra explicitly inherited theme .. code-block:: python - THEMES = ('simple', ('!simple', 'simple'), ('!foo', 'foo')) + THEMES = ['simple', ('!simple', 'simple'), ('!foo', 'foo')] You can extend parent (inherited) or sibling (your own theme) templates diff --git a/pelican/__init__.py b/pelican/__init__.py index 4570dc08..db92acca 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -367,7 +367,8 @@ def main(): watchers[static_path] = folder_watcher(static_path, [''], pelican.ignore_files) for theme in pelican.themes: - watchers[theme] = folder_watcher(pelican.themes[theme], [''], pelican.ignore_files) + theme = theme[1] if isinstance(theme, tuple) else theme + watchers[theme] = folder_watcher(theme, [''], pelican.ignore_files) try: if args.autoreload: diff --git a/pelican/generators.py b/pelican/generators.py index d9d463ad..a523663b 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -71,8 +71,11 @@ class Generator(object): explicit_themes[prefix] = FileSystemLoader(templates_path) else: # implicit inheritance if theme == 'simple': - theme = simple_theme_path - themes.append(FileSystemLoader(theme)) + templates_path = simple_theme_path + else: + templates_path = os.path.join(theme, "templates") + logger.debug('Implicit template path: %s', templates_path) + themes.append(FileSystemLoader(templates_path)) themes.append(PrefixLoader(explicit_themes)) loader=ChoiceLoader(themes) diff --git a/pelican/settings.py b/pelican/settings.py index 70ad3f82..464883dd 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -34,7 +34,7 @@ DEFAULT_CONFIG = { 'PAGE_PATHS': ['pages'], 'PAGE_EXCLUDES': [], 'THEME': DEFAULT_THEME, - 'THEMES': ('simple', ('!simple', 'simple')), + 'THEMES': ['simple', ('!simple', 'simple')], 'OUTPUT_PATH': 'output', 'READERS': {}, 'STATIC_PATHS': ['images'], @@ -167,11 +167,16 @@ def read_settings(path=None, override=None): if not isabs(pluginpath) else pluginpath for pluginpath in local_settings['PLUGIN_PATHS']] if 'THEMES' in local_settings and local_settings['THEMES']: - for p in local_settings['THEMES']: - if not isabs(local_settings['THEMES'][p]): - absp = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(path), local_settings['THEMES'][p]))) + for i, p in enumerate(local_settings['THEMES']): + explicit = isinstance(p, tuple) + p = p[1] if explicit else p + if not isabs(p): + absp = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(path), p))) if os.path.exists(absp): - local_settings['THEMES'][p] = absp + if explicit: + local_settings['THEMES'][i][1] = absp + else: + local_settings['THEMES'][i] = absp else: local_settings = copy.deepcopy(DEFAULT_CONFIG) @@ -231,14 +236,14 @@ def configure_settings(settings): raise Exception("Could not find the theme %s" % settings['THEME']) - for theme in settings['THEMES']: - if not os.path.isdir(settings['THEMES'][theme]): + for i, theme in enumerate(settings['THEMES']): + theme = theme[1] if isinstance(theme, tuple) else theme + if not os.path.isdir(theme): theme_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), - 'themes', - settings['THEMES'][theme]) + 'themes', theme) if os.path.exists(theme_path): - settings['THEMES'][theme] = theme_path + settings['THEMES'][i] = theme_path else: raise Exception("Could not find the theme %s" % theme)