From a6b44e78d606c5789997525674f0ade578c1c8e8 Mon Sep 17 00:00:00 2001 From: bbassie <17990055+bbassie@users.noreply.github.com> Date: Sat, 21 Nov 2026 22:03:02 +0000 Subject: [PATCH 1/3] Tidy up web interface buttons and labels Rename save Copy to Duplicate, shorten the save buttons, move Load scenario into the instance control button and Create template into More, square off the online players table, show the bind address and public URL on the controller page, restyle the user settings like the role page, add a favicon with a controller.favicon_url override, and put the page name in the tab title. Closes #1260 Co-Authored-By: Claude Opus 5.5 --- docs/configuration.md | 8 + packages/controller/src/Controller.ts | 15 +- packages/controller/web/index.html | 2 + packages/lib/src/config/definitions.ts | 7 + packages/web_ui/src/bootstrap.tsx | 8 + .../web_ui/src/components/ControllerPage.tsx | 45 ++- .../web_ui/src/components/CreateSaveModal.tsx | 2 +- packages/web_ui/src/components/FieldRow.tsx | 9 + .../src/components/InstanceControlButton.tsx | 15 +- .../src/components/InstanceViewPage.tsx | 41 ++- .../web_ui/src/components/InstancesPage.tsx | 177 +++++------ .../src/components/LoadScenarioModal.tsx | 98 +++--- .../src/components/OnlinePlayersList.tsx | 17 +- packages/web_ui/src/components/PageLayout.tsx | 14 +- .../web_ui/src/components/RoleViewPage.tsx | 43 +-- packages/web_ui/src/components/SavesList.tsx | 18 +- .../src/components/UnsavedChangesBar.tsx | 40 +++ .../web_ui/src/components/UploadButton.tsx | 4 +- .../web_ui/src/components/UserViewPage.tsx | 283 +++++++----------- 19 files changed, 455 insertions(+), 391 deletions(-) create mode 100644 packages/web_ui/src/components/FieldRow.tsx create mode 100644 packages/web_ui/src/components/UnsavedChangesBar.tsx diff --git a/docs/configuration.md b/docs/configuration.md index 90465063..e8ed4579 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -126,6 +126,14 @@ This should be a full URL ending with a /. Defaults to null meaning assume localhost. +### controller.favicon_url + +URL of the icon shown in the browser tab. +A relative URL is relative to the web interface root, so `static/icon.png` loads `icon.png` from the `static` folder in the controller's working directory. + +Defaults to null meaning use the Clusterio logo. + + ### controller.static_url Used to override where static assets such as the web bundle is loaded from. diff --git a/packages/controller/src/Controller.ts b/packages/controller/src/Controller.ts index 11618c0d..304255a5 100644 --- a/packages/controller/src/Controller.ts +++ b/packages/controller/src/Controller.ts @@ -48,6 +48,11 @@ const logSizeGauge = new Gauge( type InstanceId = { instanceId: number }; +const htmlEscapes: Record = { "&": "&", "<": "<", ">": ">", "\"": """, "'": "'" }; +function escapeHtml(text: string) { + return text.replace(/[&<>"']/g, char => htmlEscapes[char]); +} + type ControllerDebugEvents = { "message": [ { direction: "in" | "out", content: string } ], }; @@ -1720,8 +1725,16 @@ export default class Controller { path.join(import.meta.dirname, "..", "..", "..", "web", "index.html"), "utf8", ).then(async (content) => { + const config: lib.ControllerConfig = res.app.locals.controller.config; + let faviconUrl = config.get("controller.favicon_url"); + // Relative to the web root rather than the page + if (faviconUrl && !/^([a-z][a-z0-9+.-]*:|\/)/i.test(faviconUrl)) { + faviconUrl = webRoot + faviconUrl; + } + const favicon = faviconUrl ? `` : ""; content = content - .replace(/__CLUSTER_NAME__/g, res.app.locals.controller.config.get("controller.name")) + .replace(/__CLUSTER_NAME__/g, () => escapeHtml(config.get("controller.name"))) + .replace(/__FAVICON__/g, () => favicon) .replace(/__WEB_ROOT__/g, webRoot) .replace(/__STATIC_ROOT__/g, staticRoot) .replace(/__IMPORT_MAP__/g, () => importMap) diff --git a/packages/controller/web/index.html b/packages/controller/web/index.html index a153d69e..272702f5 100644 --- a/packages/controller/web/index.html +++ b/packages/controller/web/index.html @@ -4,7 +4,9 @@ + __CLUSTER_NAME__ + __FAVICON__