mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 10:29:20 +02:00
Fix #1107: Fix HTML <title> not including instance name in some situations
This commit is contained in:
parent
90427331e6
commit
0ee0db7ea5
4 changed files with 20 additions and 6 deletions
|
@ -39,6 +39,9 @@ def serve_spa(request):
|
|||
settings.FUNKWHALE_SPA_REWRITE_MANIFEST_URL
|
||||
or federation_utils.full_url(urls.reverse("api:v1:instance:spa-manifest"))
|
||||
)
|
||||
title = preferences.get("instance__name")
|
||||
if title:
|
||||
head = replace_title(head, title)
|
||||
head = replace_manifest_url(head, new_url)
|
||||
|
||||
if not preferences.get("common__api_authentication_required"):
|
||||
|
@ -82,6 +85,7 @@ def serve_spa(request):
|
|||
|
||||
|
||||
MANIFEST_LINK_REGEX = re.compile(r"<link [^>]*rel=(?:'|\")?manifest(?:'|\")?[^>]*>")
|
||||
TITLE_REGEX = re.compile(r"<title>.*</title>")
|
||||
|
||||
|
||||
def replace_manifest_url(head, new_url):
|
||||
|
@ -90,6 +94,12 @@ def replace_manifest_url(head, new_url):
|
|||
return head
|
||||
|
||||
|
||||
def replace_title(head, new_title):
|
||||
replacement = "<title>{}</title>".format(html.escape(new_title))
|
||||
head = TITLE_REGEX.sub(replacement, head)
|
||||
return head
|
||||
|
||||
|
||||
def get_spa_html(spa_url):
|
||||
return get_spa_file(spa_url, "index.html")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue