From e4c600ba1fea4e51980e9a4047247c2ca205f4b5 Mon Sep 17 00:00:00 2001 From: UlrichB22 <97119703+UlrichB22@users.noreply.github.com> Date: Mon, 11 Aug 2025 22:08:14 +0200 Subject: [PATCH] Add custom.css feature --- docs/admin/configure.rst | 5 ++++- src/moin/app.py | 1 + src/moin/templates/base.html | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/admin/configure.rst b/docs/admin/configure.rst index 706fe7a58..e8838da49 100644 --- a/docs/admin/configure.rst +++ b/docs/admin/configure.rst @@ -158,7 +158,10 @@ If desired, the name of this directory may be changed or a separate subdirectory for template files may be created by editing the wikiconfig file and changing the line that defines `template_dirs`:: - template_dirs = [os.path.join(wikiconfig_dir, 'wiki_local'), ] + template_dirs = [os.path.join(wikiconfig_dir, "wiki_local")] + +Simple customizations using CSS can be made by providing a file named `custom.css` +in the `wiki_local` subdirectory. Using a custom snippets.html template ------------------------------------- diff --git a/src/moin/app.py b/src/moin/app.py index b7615ed46..7c5577588 100644 --- a/src/moin/app.py +++ b/src/moin/app.py @@ -193,6 +193,7 @@ class ItemNameConverter(PathConverter): if app.cfg.template_dirs: app.jinja_env.loader = ChoiceLoader([FileSystemLoader(app.cfg.template_dirs), app.jinja_env.loader]) app.register_error_handler(403, themed_error) + app.cfg.custom_css_path = os.path.isfile("wiki_local/custom.css") clock.stop("create_app flask-theme") # create global counter to limit content security policy reports, prevent spam app.csp_count = 0 diff --git a/src/moin/templates/base.html b/src/moin/templates/base.html index f819a2c0f..6aa80cefb 100644 --- a/src/moin/templates/base.html +++ b/src/moin/templates/base.html @@ -66,6 +66,9 @@ {%- if user.valid and user.css_url -%} {%- endif -%} + {%- if cfg.custom_css_path -%} + + {%- endif -%} {%- endblock -%} {%- endblock %}