diff --git a/api/funkwhale_api/common/middleware.py b/api/funkwhale_api/common/middleware.py
index 1143255e3..de06fd1d4 100644
--- a/api/funkwhale_api/common/middleware.py
+++ b/api/funkwhale_api/common/middleware.py
@@ -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"]*rel=(?:'|\")?manifest(?:'|\")?[^>]*>")
+TITLE_REGEX = re.compile(r"
.*")
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 = "{}".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")
diff --git a/api/tests/common/test_middleware.py b/api/tests/common/test_middleware.py
index 40ff279cb..8f04ba318 100644
--- a/api/tests/common/test_middleware.py
+++ b/api/tests/common/test_middleware.py
@@ -1,6 +1,6 @@
+import html
import time
import pytest
-
from django.http import HttpResponse
from django.urls import reverse
@@ -55,10 +55,12 @@ def test_should_fallback(path, expected, mocker):
def test_serve_spa_from_cache(mocker, settings, preferences, no_api_auth):
-
+ preferences["instance__name"] = 'Best Funkwhale "pod"'
request = mocker.Mock(path="/")
get_spa_html = mocker.patch.object(
- middleware, "get_spa_html", return_value=""
+ middleware,
+ "get_spa_html",
+ return_value="Funkwhale",
)
mocker.patch.object(
middleware,
@@ -84,7 +86,8 @@ def test_serve_spa_from_cache(mocker, settings, preferences, no_api_auth):
assert response.status_code == 200
expected = [
- "",
+ ""
+ "{}".format(html.escape(preferences["instance__name"])),
'',
'',
'',
diff --git a/changes/changelog.d/1091.bugfix b/changes/changelog.d/1091.bugfix
new file mode 100644
index 000000000..d51cd00df
--- /dev/null
+++ b/changes/changelog.d/1091.bugfix
@@ -0,0 +1 @@
+Fixed page not refreshing when switching between My Library and Explore sections (#1091)
diff --git a/changes/changelog.d/1107.enhancement b/changes/changelog.d/1107.enhancement
new file mode 100644
index 000000000..2b4ff8863
--- /dev/null
+++ b/changes/changelog.d/1107.enhancement
@@ -0,0 +1 @@
+Fix HTML not including instance name in some situations (#1107)
diff --git a/front/src/App.vue b/front/src/App.vue
index f85d8e920..0cfbb5bdc 100644
--- a/front/src/App.vue
+++ b/front/src/App.vue
@@ -66,6 +66,7 @@ export default {
instanceUrl: null,
showShortcutsModal: false,
showSetInstanceModal: false,
+ initialTitle: document.title,
}
},
async created () {
@@ -147,7 +148,6 @@ export default {
},
mounted () {
let self = this
-
// slight hack to allow use to have internal links in tags
// while preserving router behaviour
document.documentElement.addEventListener('click', function (event) {
@@ -281,7 +281,7 @@ export default {
if (this.$store.state.ui.pageTitle) {
parts.push(this.$store.state.ui.pageTitle)
}
- parts.push(this.$store.state.instance.settings.instance.name.value || 'Funkwhale')
+ parts.push(this.initialTitle || 'Funkwhale')
document.title = parts.join(' – ')
},
diff --git a/front/src/components/Footer.vue b/front/src/components/Footer.vue
index 3b2442831..6e9f76167 100644
--- a/front/src/components/Footer.vue
+++ b/front/src/components/Footer.vue
@@ -4,10 +4,10 @@
diff --git a/front/src/components/library/Library.vue b/front/src/components/library/Library.vue
index 2b22a4ca6..c9b162be0 100644
--- a/front/src/components/library/Library.vue
+++ b/front/src/components/library/Library.vue
@@ -1,6 +1,6 @@
-
+