1
0
Fork 0
forked from github/pelican

Add Multi-theme support

Adds multi-theme support using the new THEMES setting.
You can specify all the themes that you will be using in python
dicionary form. You can then inherit from the themes specified
in THEMES using the corresponding key in the dictionary.
This commit is contained in:
th3aftermath 2014-04-23 23:39:12 -04:00 committed by Ondrej Grover
commit b00d9ef6d1
8 changed files with 119 additions and 41 deletions

View file

@ -34,6 +34,7 @@ DEFAULT_CONFIG = {
'PAGE_PATHS': ['pages'],
'PAGE_EXCLUDES': [],
'THEME': DEFAULT_THEME,
'THEMES': {},
'OUTPUT_PATH': 'output',
'READERS': {},
'STATIC_PATHS': ['images'],
@ -164,6 +165,13 @@ def read_settings(path=None, override=None):
elif local_settings['PLUGIN_PATHS'] is not None:
local_settings['PLUGIN_PATHS'] = [os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(path), pluginpath)))
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])))
if os.path.exists(absp):
local_settings['THEMES'][p] = absp
else:
local_settings = copy.deepcopy(DEFAULT_CONFIG)
@ -223,6 +231,18 @@ 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]):
theme_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'themes',
settings['THEMES'][theme])
if os.path.exists(theme_path):
settings['THEMES'][theme] = theme_path
else:
raise Exception("Could not find the theme %s"
% theme)
# make paths selected for writing absolute if necessary
settings['WRITE_SELECTED'] = [
os.path.abspath(path) for path in