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%%