Themes are now registered and can have their templates loaded properly
This commit is contained in:
parent
828fc6300a
commit
3b47da8eab
@ -76,10 +76,17 @@ class MediaGoblinApp(object):
|
|||||||
|
|
||||||
# Register themes
|
# Register themes
|
||||||
self.theme_registry = register_themes(app_config)
|
self.theme_registry = register_themes(app_config)
|
||||||
|
self.current_theme_name = app_config.get('theme')
|
||||||
|
if self.current_theme_name \
|
||||||
|
and self.theme_registry.has_key(self.current_theme_name):
|
||||||
|
self.current_theme = self.theme_registry[self.current_theme_name]
|
||||||
|
else:
|
||||||
|
self.current_theme = None
|
||||||
|
|
||||||
# Get the template environment
|
# Get the template environment
|
||||||
self.template_loader = get_jinja_loader(
|
self.template_loader = get_jinja_loader(
|
||||||
app_config.get('local_templates'))
|
app_config.get('local_templates'),
|
||||||
|
self.current_theme)
|
||||||
|
|
||||||
# Set up storage systems
|
# Set up storage systems
|
||||||
self.public_store, self.queue_store = setup_storage()
|
self.public_store, self.queue_store = setup_storage()
|
||||||
|
@ -60,6 +60,11 @@ push_urls = string_list(default=list())
|
|||||||
exif_visible = boolean(default=False)
|
exif_visible = boolean(default=False)
|
||||||
geolocation_map_visible = boolean(default=False)
|
geolocation_map_visible = boolean(default=False)
|
||||||
|
|
||||||
|
# Theming stuff
|
||||||
|
theme_install_dir = string(default="%(here)s/user_dev/themes/")
|
||||||
|
theme = string()
|
||||||
|
|
||||||
|
|
||||||
[storage:publicstore]
|
[storage:publicstore]
|
||||||
storage_class = string(default="mediagoblin.storage.filestorage:BasicFileStorage")
|
storage_class = string(default="mediagoblin.storage.filestorage:BasicFileStorage")
|
||||||
base_dir = string(default="%(here)s/user_dev/media/public")
|
base_dir = string(default="%(here)s/user_dev/media/public")
|
||||||
|
@ -71,7 +71,7 @@ def setup_database():
|
|||||||
return connection, db
|
return connection, db
|
||||||
|
|
||||||
|
|
||||||
def get_jinja_loader(user_template_path=None):
|
def get_jinja_loader(user_template_path=None, current_theme=None):
|
||||||
"""
|
"""
|
||||||
Set up the Jinja template loaders, possibly allowing for user
|
Set up the Jinja template loaders, possibly allowing for user
|
||||||
overridden templates.
|
overridden templates.
|
||||||
@ -79,10 +79,24 @@ def get_jinja_loader(user_template_path=None):
|
|||||||
(In the future we may have another system for providing theming;
|
(In the future we may have another system for providing theming;
|
||||||
for now this is good enough.)
|
for now this is good enough.)
|
||||||
"""
|
"""
|
||||||
if user_template_path:
|
if user_template_path or current_theme:
|
||||||
return jinja2.ChoiceLoader(
|
loader_choices = []
|
||||||
[jinja2.FileSystemLoader(user_template_path),
|
|
||||||
jinja2.PackageLoader('mediagoblin', 'templates')])
|
# user template overrides
|
||||||
|
if user_template_path:
|
||||||
|
loader_choices.append(jinja2.FileSystemLoader(user_template_path))
|
||||||
|
|
||||||
|
# Any theme directories in the registry
|
||||||
|
if current_theme and current_theme.get('templates_dir'):
|
||||||
|
loader_choices.append(
|
||||||
|
jinja2.FileSystemLoader(
|
||||||
|
current_theme['templates_dir']))
|
||||||
|
|
||||||
|
# Add the main mediagoblin templates
|
||||||
|
loader_choices.append(
|
||||||
|
jinja2.PackageLoader('mediagoblin', 'templates'))
|
||||||
|
|
||||||
|
return jinja2.ChoiceLoader(loader_choices)
|
||||||
else:
|
else:
|
||||||
return jinja2.PackageLoader('mediagoblin', 'templates')
|
return jinja2.PackageLoader('mediagoblin', 'templates')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user