Skip to content

Commit

Permalink
Enhance detection of a theme directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
saimn committed Sep 1, 2015
1 parent 9f0cf68 commit ccea99e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sigal/settings.py
Expand Up @@ -132,7 +132,9 @@ def read_settings(filename=None):
# Make the paths relative to the settings file
paths = ['source', 'destination', 'watermark']

if os.path.isdir(join(settings_path, settings['theme'])):
if os.path.isdir(join(settings_path, settings['theme'])) and \
os.path.isdir(join(settings_path, settings['theme'],
'templates')):
paths.append('theme')

enc = locale.getpreferredencoding() if PY2 else None
Expand Down
3 changes: 2 additions & 1 deletion sigal/writer.py
Expand Up @@ -53,7 +53,8 @@ def __init__(self, settings, index_title=''):
self.logger = logging.getLogger(__name__)

# search the theme in sigal/theme if the given one does not exists
if not os.path.exists(self.theme):
if not os.path.exists(self.theme) or \
not os.path.exists(os.path.join(self.theme, 'templates')):
self.theme = os.path.join(THEMES_PATH, self.theme)
if not os.path.exists(self.theme):
raise Exception("Impossible to find the theme %s" % self.theme)
Expand Down
1 change: 1 addition & 0 deletions tests/test_settings.py
Expand Up @@ -48,6 +48,7 @@ def test_theme_path(tmpdir):
"""Test that image size is swaped if needed."""

tmpdir.join('theme').mkdir()
tmpdir.join('theme').join('templates').mkdir()
conf = tmpdir.join('sigal.conf.py')
conf.write("""# -*- coding: utf-8 -*-
Expand Down

0 comments on commit ccea99e

Please sign in to comment.