why did I make user styles a config setting???
this moves it into the code, where it's sensible, and leaves the default to the config
This commit is contained in:
parent
3fcf916317
commit
d2c1c2e3ce
@ -34,11 +34,7 @@ class Config(object):
|
|||||||
|
|
||||||
MARKDOWN_EXTENSIONS = ['meta', 'tables']
|
MARKDOWN_EXTENSIONS = ['meta', 'tables']
|
||||||
|
|
||||||
PAGE_STYLES = {
|
DEFAULT_PAGE_STYLE = 'light'
|
||||||
'DEFAULT': 'css/light.css',
|
|
||||||
'dark': 'css/dark.css',
|
|
||||||
'light': 'css/light.css',
|
|
||||||
}
|
|
||||||
|
|
||||||
TITLE_SUFFIX = 'incorporeal.org'
|
TITLE_SUFFIX = 'incorporeal.org'
|
||||||
MEDIA_DIR = 'media'
|
MEDIA_DIR = 'media'
|
||||||
|
@ -44,13 +44,18 @@ def render(template_name_or_list, **context):
|
|||||||
|
|
||||||
* Determine the proper site theme to use in the template and provide it.
|
* Determine the proper site theme to use in the template and provide it.
|
||||||
"""
|
"""
|
||||||
|
PAGE_STYLES = {
|
||||||
|
'dark': 'css/dark.css',
|
||||||
|
'light': 'css/light.css',
|
||||||
|
}
|
||||||
|
|
||||||
selected_style = request.args.get('style', None)
|
selected_style = request.args.get('style', None)
|
||||||
if selected_style:
|
if selected_style:
|
||||||
user_style = selected_style
|
user_style = selected_style
|
||||||
else:
|
else:
|
||||||
user_style = request.cookies.get('user-style')
|
user_style = request.cookies.get('user-style')
|
||||||
logger.debug("user style cookie: %s", user_style)
|
logger.debug("user style cookie: %s", user_style)
|
||||||
context['user_style'] = app.config['PAGE_STYLES'].get(user_style, app.config['PAGE_STYLES']['DEFAULT'])
|
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))
|
resp = make_response(render_template(template_name_or_list, **context))
|
||||||
if selected_style:
|
if selected_style:
|
||||||
|
Loading…
Reference in New Issue
Block a user