Load grid branding before connect
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
// Maintainer-controlled web client version metadata.
|
// Maintainer-controlled web client version metadata.
|
||||||
window.CHGRID_RELEASE_VERSION = "0.1.0";
|
window.CHGRID_RELEASE_VERSION = "0.1.0";
|
||||||
window.CHGRID_BUILD_REVISION = "R347";
|
window.CHGRID_BUILD_REVISION = "R348";
|
||||||
window.CHGRID_WEB_VERSION = `${window.CHGRID_RELEASE_VERSION} ${window.CHGRID_BUILD_REVISION}`;
|
window.CHGRID_WEB_VERSION = `${window.CHGRID_RELEASE_VERSION} ${window.CHGRID_BUILD_REVISION}`;
|
||||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ loadMasterVolume();
|
|||||||
void loadHelp();
|
void loadHelp();
|
||||||
void itemBehaviorRegistry.initialize();
|
void itemBehaviorRegistry.initialize();
|
||||||
void loadChangelog();
|
void loadChangelog();
|
||||||
|
void loadClientBranding();
|
||||||
|
|
||||||
function applyGridBranding(gridName: string | null | undefined, welcomeMessage: string | null | undefined): void {
|
function applyGridBranding(gridName: string | null | undefined, welcomeMessage: string | null | undefined): void {
|
||||||
const nextGridName = String(gridName ?? '').trim() || DEFAULT_GRID_NAME;
|
const nextGridName = String(gridName ?? '').trim() || DEFAULT_GRID_NAME;
|
||||||
@@ -378,6 +379,25 @@ function applyGridBranding(gridName: string | null | undefined, welcomeMessage:
|
|||||||
dom.canvas.setAttribute('aria-label', `${nextGridName}, press question mark for help.`);
|
dom.canvas.setAttribute('aria-label', `${nextGridName}, press question mark for help.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadClientBranding(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const response = await fetch(withBase('client_branding.json'), { cache: 'no-store' });
|
||||||
|
if (!response.ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = (await response.json()) as { gridName?: unknown; welcomeMessage?: unknown };
|
||||||
|
applyGridBranding(
|
||||||
|
typeof data.gridName === 'string' ? data.gridName : null,
|
||||||
|
typeof data.welcomeMessage === 'string' ? data.welcomeMessage : null,
|
||||||
|
);
|
||||||
|
if (!state.running && !isVersionReloadedSession()) {
|
||||||
|
setConnectionStatus(activeWelcomeMessage);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Branding falls back to built-in defaults when deploy-time branding is unavailable.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Fetches a required DOM element and casts it to the requested element type. */
|
/** Fetches a required DOM element and casts it to the requested element type. */
|
||||||
function requiredById<T extends HTMLElement>(id: string): T {
|
function requiredById<T extends HTMLElement>(id: string): T {
|
||||||
const found = document.getElementById(id);
|
const found = document.getElementById(id);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ cd "$REPO_ROOT"
|
|||||||
Optional 4th arg:
|
Optional 4th arg:
|
||||||
- server config path used when generating `media_proxy.config.php`
|
- server config path used when generating `media_proxy.config.php`
|
||||||
- use this for secondary grids that do not use `server/config.toml`
|
- use this for secondary grids that do not use `server/config.toml`
|
||||||
|
- the same config is also used to generate `client_branding.json` for pre-login client branding
|
||||||
|
|
||||||
## 4) Install/Reload Service Unit
|
## 4) Install/Reload Service Unit
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,32 @@ if [[ -n "${CHGRID_HOST_ORIGIN:-}" ]]; then
|
|||||||
if [[ -x "$SERVER_VENV_PYTHON" ]]; then
|
if [[ -x "$SERVER_VENV_PYTHON" ]]; then
|
||||||
config_python="$SERVER_VENV_PYTHON"
|
config_python="$SERVER_VENV_PYTHON"
|
||||||
fi
|
fi
|
||||||
|
branding_json="$(
|
||||||
|
"$config_python" - "$SERVER_CONFIG_PATH" <<'PY'
|
||||||
|
from pathlib import Path
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
import tomllib
|
||||||
|
except ModuleNotFoundError: # pragma: no cover - compatibility fallback
|
||||||
|
import tomli as tomllib
|
||||||
|
|
||||||
|
config_path = Path(sys.argv[1])
|
||||||
|
grid_name = "Chat Grid"
|
||||||
|
welcome_message = (
|
||||||
|
"Welcome to the Chat Grid, your immersive audio playground. "
|
||||||
|
"Configure your audio, then Log in or register to join the grid."
|
||||||
|
)
|
||||||
|
if config_path.exists():
|
||||||
|
with config_path.open("rb") as fp:
|
||||||
|
data = tomllib.load(fp)
|
||||||
|
server = data.get("server", {})
|
||||||
|
grid_name = str(server.get("grid_name", grid_name)).strip() or grid_name
|
||||||
|
welcome_message = str(server.get("welcome_message", welcome_message)).strip() or welcome_message
|
||||||
|
print(json.dumps({"gridName": grid_name, "welcomeMessage": welcome_message}))
|
||||||
|
PY
|
||||||
|
)"
|
||||||
session_check_url="$(
|
session_check_url="$(
|
||||||
"$config_python" - "$SERVER_CONFIG_PATH" <<'PY'
|
"$config_python" - "$SERVER_CONFIG_PATH" <<'PY'
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -83,6 +109,7 @@ PY
|
|||||||
escaped_host_origin=${escaped_host_origin//\'/\\\'}
|
escaped_host_origin=${escaped_host_origin//\'/\\\'}
|
||||||
escaped_session_check_url=${session_check_url//\\/\\\\}
|
escaped_session_check_url=${session_check_url//\\/\\\\}
|
||||||
escaped_session_check_url=${escaped_session_check_url//\'/\\\'}
|
escaped_session_check_url=${escaped_session_check_url//\'/\\\'}
|
||||||
|
printf '%s\n' "$branding_json" > "$PUBLISH_DIR/client_branding.json"
|
||||||
cat > "$PUBLISH_DIR/media_proxy.config.php" <<EOF
|
cat > "$PUBLISH_DIR/media_proxy.config.php" <<EOF
|
||||||
<?php
|
<?php
|
||||||
return array(
|
return array(
|
||||||
@@ -92,6 +119,7 @@ return array(
|
|||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
rm -f "$PUBLISH_DIR/media_proxy.config.php"
|
rm -f "$PUBLISH_DIR/media_proxy.config.php"
|
||||||
|
rm -f "$PUBLISH_DIR/client_branding.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$PUBLIC_HTACCESS_SRC" ]]; then
|
if [[ -f "$PUBLIC_HTACCESS_SRC" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user