Inline logo SVG and hide login/logout buttons

- Embed logo SVG directly in PHP output instead of fetching via JS
  to eliminate the flash of missing logo on page load
- Hide login/logout nav items since auth is handled by reverse proxy
This commit is contained in:
2026-03-14 19:34:09 +01:00
parent 744daeefec
commit 94f4e97f46
3 changed files with 12 additions and 16 deletions
+7 -13
View File
@@ -81,7 +81,11 @@ class BockenTheme extends AbstractModule implements ModuleCustomInterface, Modul
public function bodyContent(): string
{
$logoUrl = $this->assetUrl('img/logo.svg');
$logoSvg = file_get_contents(self::MODULE_RESOURCE_PATH . 'img/logo.svg');
// Strip XML declaration, collapse to single line for safe JS string embedding
$logoSvg = preg_replace('/<\?xml[^?]*\?>/', '', $logoSvg);
$logoSvg = preg_replace('/\s+/', ' ', trim($logoSvg));
$logoSvgJs = addcslashes($logoSvg, "'\\");
return <<<HTML
<script src="https://unpkg.com/lucide@latest"></script>
@@ -155,20 +159,10 @@ class BockenTheme extends AbstractModule implements ModuleCustomInterface, Modul
var logoContainer = document.createElement('div');
logoContainer.className = 'bocken-logo-container';
logoContainer.innerHTML = '<a href="https://bocken.org" class="bocken-logo-link" aria-label="Bocken.org"></a>';
// Fetch and inline the SVG so parent CSS variables work
fetch('{$logoUrl}')
.then(function(r) { return r.text(); })
.then(function(svgText) {
var wrapper = document.createElement('div');
wrapper.className = 'bocken-logo';
wrapper.innerHTML = svgText;
logoContainer.querySelector('a').appendChild(wrapper);
updateLogoFill();
});
logoContainer.innerHTML = '<a href="https://bocken.org" class="bocken-logo-link" aria-label="Bocken.org"><div class="bocken-logo">{$logoSvgJs}</div></a>';
titleEl.parentNode.insertBefore(logoContainer, titleEl);
updateLogoFill();
}
// --- Theme toggle button injection ---