allow for overriding PAGE_STYLES
moving this allows for per-instance customizations later, but that won't be practical until serving styles from the instance dir is also allowed. but, this sets the ground work and does allow for removing some styles (e.g. if someone wanted to only allow 'plain'). also I still need to add the ability to present the themes list dynamically
This commit is contained in:
@@ -50,6 +50,12 @@ class Config(object):
|
||||
MEDIA_DIR = 'media'
|
||||
|
||||
# customizations
|
||||
PAGE_STYLES = {
|
||||
'dark': 'css/dark.css',
|
||||
'light': 'css/light.css',
|
||||
'plain': 'css/plain.css',
|
||||
}
|
||||
|
||||
DEFAULT_PAGE_STYLE = 'light'
|
||||
TITLE_SUFFIX = 'example.com'
|
||||
CONTACT_EMAIL = 'admin@example.com'
|
||||
|
||||
@@ -31,19 +31,14 @@ def render(template_name_or_list, **context):
|
||||
|
||||
* Determine the proper site theme to use in the template and provide it.
|
||||
"""
|
||||
PAGE_STYLES = {
|
||||
'dark': 'css/dark.css',
|
||||
'light': 'css/light.css',
|
||||
'plain': 'css/plain.css',
|
||||
}
|
||||
|
||||
page_styles = app.config['PAGE_STYLES']
|
||||
selected_style = request.args.get('style', None)
|
||||
if selected_style:
|
||||
user_style = selected_style
|
||||
else:
|
||||
user_style = request.cookies.get('user-style')
|
||||
logger.debug("user style cookie: %s", user_style)
|
||||
context['user_style'] = PAGE_STYLES.get(user_style, PAGE_STYLES.get(app.config['DEFAULT_PAGE_STYLE']))
|
||||
context['user_style'] = page_styles.get(user_style, page_styles.get(app.config['DEFAULT_PAGE_STYLE']))
|
||||
|
||||
resp = make_response(render_template(template_name_or_list, **context))
|
||||
if selected_style:
|
||||
|
||||
Reference in New Issue
Block a user