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:
Brian S. Stephan 2020-12-08 16:43:20 -06:00
parent 3fcf916317
commit d2c1c2e3ce
2 changed files with 7 additions and 6 deletions

View File

@ -34,11 +34,7 @@ class Config(object):
MARKDOWN_EXTENSIONS = ['meta', 'tables']
PAGE_STYLES = {
'DEFAULT': 'css/light.css',
'dark': 'css/dark.css',
'light': 'css/light.css',
}
DEFAULT_PAGE_STYLE = 'light'
TITLE_SUFFIX = 'incorporeal.org'
MEDIA_DIR = 'media'

View File

@ -44,13 +44,18 @@ 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',
}
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'] = 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))
if selected_style: