From b0a57f9c679e8c483d1a81cb3c749cf8555785f6 Mon Sep 17 00:00:00 2001
From: E44 <129310925+programmer-44@users.noreply.github.com>
Date: Sat, 10 Jan 2026 14:06:10 -0500
Subject: [PATCH] chore: singe source of truth for version & show it on splash
screen (#7)
Co-authored-by: 2mal3 <56305732+2mal3@users.noreply.github.com>
---
control/frontend/src/routes/+layout.svelte | 5 ++++-
display/main.go | 4 +---
display/web/main.go | 5 ++++-
shared/embed.go | 5 +++++
shared/splash_screen.html | 16 ++++++++++++++++
shared/version.txt | 1 +
6 files changed, 31 insertions(+), 5 deletions(-)
create mode 100644 shared/version.txt
diff --git a/control/frontend/src/routes/+layout.svelte b/control/frontend/src/routes/+layout.svelte
index efc07c4..73ca926 100644
--- a/control/frontend/src/routes/+layout.svelte
+++ b/control/frontend/src/routes/+layout.svelte
@@ -2,9 +2,12 @@
import '../app.css';
import Notification from './Notification.svelte';
import SplashScreen from './../../../../shared/splash_screen.html?raw';
+ import version from './../../../../shared/version.txt?raw';
import { dev } from '$app/environment';
let { children } = $props();
+
+ let versionSplashScreen = SplashScreen.replaceAll('%%APP-VERSION%%', version.trim());
@@ -12,7 +15,7 @@
{#if !dev}
- {@html SplashScreen}
+ {@html versionSplashScreen}
{/if}
{@render children()}
diff --git a/display/main.go b/display/main.go
index e37983d..43013ef 100644
--- a/display/main.go
+++ b/display/main.go
@@ -9,8 +9,6 @@ import (
"plg-mudics/shared"
)
-const VERSION = "0.1.0"
-
//go:generate go tool templ generate
func main() {
@@ -27,7 +25,7 @@ func main() {
// the order is important, the open browser command exitsts as soon as the winodw is closed
// and since its the last action in the main go func all other goroutines (e.g. the webserver) are killed
- go web.StartWebServer(VERSION, port)
+ go web.StartWebServer(shared.Version, port)
err = shared.OpenBrowserWindow("http://localhost:"+port, true, true)
if err != nil {
slog.Error("Failed to open browser window", "error", err)
diff --git a/display/web/main.go b/display/web/main.go
index 89c15a1..c7e4fb9 100644
--- a/display/web/main.go
+++ b/display/web/main.go
@@ -15,6 +15,7 @@ import (
"os/exec"
"path/filepath"
shared "plg-mudics/shared"
+ "strings"
"github.com/gabriel-vasile/mimetype"
"github.com/labstack/echo/v4"
@@ -35,7 +36,9 @@ func StartWebServer(v string, port string) {
e.GET("/", indexRoute)
e.GET("/sse", sseRoute)
e.GET("/splash", func(ctx echo.Context) error {
- return ctx.HTML(http.StatusOK, shared.SplashScreenTemplate)
+ html := shared.SplashScreenTemplate
+ html = strings.ReplaceAll(html, "%%APP-VERSION%%", version)
+ return ctx.HTML(http.StatusOK, html)
})
e.GET("/qr", qrRoute)
diff --git a/shared/embed.go b/shared/embed.go
index 23e0f9a..f569902 100644
--- a/shared/embed.go
+++ b/shared/embed.go
@@ -2,7 +2,12 @@ package shared
import (
_ "embed"
+ "strings"
)
//go:embed splash_screen.html
var SplashScreenTemplate string
+
+//go:embed version.txt
+var versionNotTrimmed string
+var Version = strings.TrimSpace(versionNotTrimmed)
diff --git a/shared/splash_screen.html b/shared/splash_screen.html
index 5caf70e..bb713d8 100644
--- a/shared/splash_screen.html
+++ b/shared/splash_screen.html
@@ -167,6 +167,7 @@
/>
+
+
+ %%APP-VERSION%%