LibrePortal/scripts/webui/data/utils/webui_container_setup.sh
librelad 152d9c5d28 fix(webui): make all icon and data asset URLs absolute under path routing
Same class of bug as the topbar partial: icon and data-file references were
relative (icons/apps/x.svg, data/apps/...), so on deep path routes (/app/<name>,
/admin/config/x) the browser resolved them against the route dir and the SPA
catch-all served index.html with HTTP 200 instead of 404 — broken images and
silently-wrong JSON.

Make every reference absolute (anchored on the quote/backtick so already-absolute
/icons paths are untouched):
- JS: all icons/ and data/ literals + templates across components/utils/system
- html/topbar.html: logo <img>
- generators: webui_config.sh and webui_create_app_categories.sh now emit
  /icons/... into apps.json / apps-categories.json (regenerated on install)
- updated the two icon-path comments to match

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-24 23:20:42 +01:00

31 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
webuiContainerSetup()
{
local app_name=$1
local type=$2 # install or uninstall
if [[ "$app_name" == "libreportal" && "$type" == "uninstall" ]]; then
isNotice "Skipping WebUI config refresh — LibrePortal (the WebUI) is being removed."
return 0
fi
webuiUpdateAppStatus $app_name $type;
webuiUpdateAppLog $app_name $type;
webuiGenerateAppsServicesConfig;
# Targeted patch (~0.5s) instead of full regen (~3.5s) for the
# single app being installed/uninstalled.
if declare -F webuiPatchAppConfigJson >/dev/null 2>&1; then
webuiPatchAppConfigJson "$app_name" >/dev/null 2>&1 \
|| webuiGenerateLibrePortalConfig
else
webuiGenerateLibrePortalConfig
fi
# The patch path rewrites apps.json (which references
# /icons/apps/<app>.svg) but doesn't place the icon file — sync it here
# so the apps page never points at a missing icon. The full regen
# copies icons itself; this is cheap and idempotent regardless.
if declare -F webuiSyncAppIcon >/dev/null 2>&1; then
webuiSyncAppIcon "$app_name" >/dev/null 2>&1 || true
fi
}