mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 11:29:17 +02:00
Fix #879: Admins can now add custom CSS from their pod settings
This commit is contained in:
parent
78ab153734
commit
7897c8ac7f
5 changed files with 84 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
import html
|
||||
import requests
|
||||
import xml.sax.saxutils
|
||||
|
||||
from django import http
|
||||
from django.conf import settings
|
||||
|
@ -51,7 +52,13 @@ def serve_spa(request):
|
|||
|
||||
# let's inject our meta tags in the HTML
|
||||
head += "\n" + "\n".join(render_tags(final_tags)) + "\n</head>"
|
||||
|
||||
css = get_custom_css() or ""
|
||||
if css:
|
||||
# We add the style add the end of the body to ensure it has the highest
|
||||
# priority (since it will come after other stylesheets)
|
||||
body, tail = tail.split("</body>", 1)
|
||||
css = "<style>{}</style>".format(css)
|
||||
tail = body + "\n" + css + "\n</body>" + tail
|
||||
return http.HttpResponse(head + tail)
|
||||
|
||||
|
||||
|
@ -128,6 +135,14 @@ def get_request_head_tags(request):
|
|||
return match.func(request, *match.args, **match.kwargs)
|
||||
|
||||
|
||||
def get_custom_css():
|
||||
css = preferences.get("ui__custom_css").strip()
|
||||
if not css:
|
||||
return
|
||||
|
||||
return xml.sax.saxutils.escape(css)
|
||||
|
||||
|
||||
class SPAFallbackMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue