Skip to content

Commit ee8ec9a

Browse files
authored
Merge pull request #1975 from UlrichB22/custom_css
Add custom.css feature
2 parents 457f61e + e4c600b commit ee8ec9a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

docs/admin/configure.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ If desired, the name of this directory may be changed or a separate subdirectory
158158
for template files may be created by editing
159159
the wikiconfig file and changing the line that defines `template_dirs`::
160160

161-
template_dirs = [os.path.join(wikiconfig_dir, 'wiki_local'), ]
161+
template_dirs = [os.path.join(wikiconfig_dir, "wiki_local")]
162+
163+
Simple customizations using CSS can be made by providing a file named `custom.css`
164+
in the `wiki_local` subdirectory.
162165

163166
Using a custom snippets.html template
164167
-------------------------------------

src/moin/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class ItemNameConverter(PathConverter):
193193
if app.cfg.template_dirs:
194194
app.jinja_env.loader = ChoiceLoader([FileSystemLoader(app.cfg.template_dirs), app.jinja_env.loader])
195195
app.register_error_handler(403, themed_error)
196+
app.cfg.custom_css_path = os.path.isfile("wiki_local/custom.css")
196197
clock.stop("create_app flask-theme")
197198
# create global counter to limit content security policy reports, prevent spam
198199
app.csp_count = 0

src/moin/templates/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
{%- if user.valid and user.css_url -%}
6767
<link media="all" rel="stylesheet" title="{{ user.name }}'s stylesheet" href="{{ user.css_url }}">
6868
{%- endif -%}
69+
{%- if cfg.custom_css_path -%}
70+
<link media="all" rel="stylesheet" href="{{ url_for('serve.files', name='wiki_local', filename='custom.css') }}">
71+
{%- endif -%}
6972
{%- endblock -%}
7073
{%- endblock %}
7174
</head>

0 commit comments

Comments
 (0)