From e9af2de21eb8768276865edd8f694761a27b1b14 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sat, 31 Dec 2022 10:16:35 -0600 Subject: [PATCH] don't assume all styles are in the static directory this is to make room for a second, instance-configured spot for them --- incorporealcms/config.py | 6 +++--- incorporealcms/templates/base.html | 2 +- tests/test_pages.py | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/incorporealcms/config.py b/incorporealcms/config.py index f5bd28a..7641984 100644 --- a/incorporealcms/config.py +++ b/incorporealcms/config.py @@ -51,9 +51,9 @@ class Config(object): # customizations PAGE_STYLES = { - 'dark': 'css/dark.css', - 'light': 'css/light.css', - 'plain': 'css/plain.css', + 'dark': '/static/css/dark.css', + 'light': '/static/css/light.css', + 'plain': '/static/css/plain.css', } DEFAULT_PAGE_STYLE = 'light' diff --git a/incorporealcms/templates/base.html b/incorporealcms/templates/base.html index 6ba53ba..a1b4cb8 100644 --- a/incorporealcms/templates/base.html +++ b/incorporealcms/templates/base.html @@ -7,7 +7,7 @@ - +
diff --git a/tests/test_pages.py b/tests/test_pages.py index 6ce09e9..9c83f98 100644 --- a/tests/test_pages.py +++ b/tests/test_pages.py @@ -85,7 +85,7 @@ def test_render_with_theme_overrides_affects_html(app): """Test that the overridden themes are presented in the HTML.""" # test we can remove stuff from the default restyled_app = create_app(instance_path=os.path.join(HERE, 'instance'), - test_config={'PAGE_STYLES': {'light': 'css/light.css'}}) + test_config={'PAGE_STYLES': {'light': '/static/css/light.css'}}) with restyled_app.test_request_context(): assert b'?style=light' in render('base.html').data assert b'?style=dark' not in render('base.html').data @@ -93,8 +93,8 @@ def test_render_with_theme_overrides_affects_html(app): # test that we can add new stuff too/instead restyled_app = create_app(instance_path=os.path.join(HERE, 'instance'), - test_config={'PAGE_STYLES': {'cool': 'css/cool.css', - 'warm': 'css/warm.css'}, + test_config={'PAGE_STYLES': {'cool': '/static/css/cool.css', + 'warm': '/static/css/warm.css'}, 'DEFAULT_PAGE_STYLE': 'warm'}) with restyled_app.test_request_context(): assert b'?style=cool' in render('base.html').data @@ -105,8 +105,8 @@ def test_render_with_theme_overrides(app): """Test that the loaded themes can be overridden from the default.""" cookie = dump_cookie("user-style", 'cool') restyled_app = create_app(instance_path=os.path.join(HERE, 'instance'), - test_config={'PAGE_STYLES': {'cool': 'css/cool.css', - 'warm': 'css/warm.css'}}) + test_config={'PAGE_STYLES': {'cool': '/static/css/cool.css', + 'warm': '/static/css/warm.css'}}) with restyled_app.test_request_context(headers={'COOKIE': cookie}): assert b'/static/css/cool.css' in render('base.html').data assert b'/static/css/warm.css' not in render('base.html').data @@ -116,8 +116,8 @@ def test_render_with_theme_overrides_not_found_is_default(app): """Test that theme overrides work, and if a requested theme doesn't exist, the default is loaded.""" cookie = dump_cookie("user-style", 'nonexistent') restyled_app = create_app(instance_path=os.path.join(HERE, 'instance'), - test_config={'PAGE_STYLES': {'cool': 'css/cool.css', - 'warm': 'css/warm.css'}, + test_config={'PAGE_STYLES': {'cool': '/static/css/cool.css', + 'warm': '/static/css/warm.css'}, 'DEFAULT_PAGE_STYLE': 'warm'}) with restyled_app.test_request_context(headers={'COOKIE': cookie}): assert b'/static/css/warm.css' in render('base.html').data