From d2c1c2e3ce52246127d95bf0ec62fb13b35e4c6e Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Tue, 8 Dec 2020 16:43:20 -0600 Subject: [PATCH] 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 --- incorporealcms/config.py | 6 +----- incorporealcms/pages.py | 7 ++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/incorporealcms/config.py b/incorporealcms/config.py index af0ee7a..5b405c3 100644 --- a/incorporealcms/config.py +++ b/incorporealcms/config.py @@ -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' diff --git a/incorporealcms/pages.py b/incorporealcms/pages.py index a60df46..a850240 100644 --- a/incorporealcms/pages.py +++ b/incorporealcms/pages.py @@ -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: