mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-05 16:37:09 +00:00
chore: singe source of truth for version & show it on splash screen (#7)
Co-authored-by: 2mal3 <56305732+2mal3@users.noreply.github.com>
This commit is contained in:
@@ -2,9 +2,12 @@
|
|||||||
import '../app.css';
|
import '../app.css';
|
||||||
import Notification from './Notification.svelte';
|
import Notification from './Notification.svelte';
|
||||||
import SplashScreen from './../../../../shared/splash_screen.html?raw';
|
import SplashScreen from './../../../../shared/splash_screen.html?raw';
|
||||||
|
import version from './../../../../shared/version.txt?raw';
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
|
|
||||||
|
let versionSplashScreen = SplashScreen.replaceAll('%%APP-VERSION%%', version.trim());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -12,7 +15,7 @@
|
|||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#if !dev}
|
{#if !dev}
|
||||||
{@html SplashScreen}
|
{@html versionSplashScreen}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{@render children()}
|
{@render children()}
|
||||||
|
|||||||
+1
-3
@@ -9,8 +9,6 @@ import (
|
|||||||
"plg-mudics/shared"
|
"plg-mudics/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "0.1.0"
|
|
||||||
|
|
||||||
//go:generate go tool templ generate
|
//go:generate go tool templ generate
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -27,7 +25,7 @@ func main() {
|
|||||||
|
|
||||||
// the order is important, the open browser command exitsts as soon as the winodw is closed
|
// 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
|
// 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)
|
err = shared.OpenBrowserWindow("http://localhost:"+port, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to open browser window", "error", err)
|
slog.Error("Failed to open browser window", "error", err)
|
||||||
|
|||||||
+4
-1
@@ -15,6 +15,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
shared "plg-mudics/shared"
|
shared "plg-mudics/shared"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gabriel-vasile/mimetype"
|
"github.com/gabriel-vasile/mimetype"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
@@ -35,7 +36,9 @@ func StartWebServer(v string, port string) {
|
|||||||
e.GET("/", indexRoute)
|
e.GET("/", indexRoute)
|
||||||
e.GET("/sse", sseRoute)
|
e.GET("/sse", sseRoute)
|
||||||
e.GET("/splash", func(ctx echo.Context) error {
|
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)
|
e.GET("/qr", qrRoute)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ package shared
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed splash_screen.html
|
//go:embed splash_screen.html
|
||||||
var SplashScreenTemplate string
|
var SplashScreenTemplate string
|
||||||
|
|
||||||
|
//go:embed version.txt
|
||||||
|
var versionNotTrimmed string
|
||||||
|
var Version = strings.TrimSpace(versionNotTrimmed)
|
||||||
|
|||||||
@@ -167,6 +167,7 @@
|
|||||||
/>
|
/>
|
||||||
<path class="window-controls" d="M 550 375 h 15" />
|
<path class="window-controls" d="M 550 375 h 15" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<div class="fade-in">
|
<div class="fade-in">
|
||||||
<div
|
<div
|
||||||
class="cursor-x"
|
class="cursor-x"
|
||||||
@@ -196,6 +197,8 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<span id="version-label" aria-label="Version">%%APP-VERSION%%</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -216,6 +219,8 @@
|
|||||||
--other-button: oklch(55.3% 0.013 58.071);
|
--other-button: oklch(55.3% 0.013 58.071);
|
||||||
--splash-control-monitor: oklch(44.4% 0.011 73.639);
|
--splash-control-monitor: oklch(44.4% 0.011 73.639);
|
||||||
|
|
||||||
|
--version-color: oklch(55.3% 0.013 58.071);
|
||||||
|
|
||||||
--mouse-size: 50px;
|
--mouse-size: 50px;
|
||||||
--mouse-bounce-delay: 5s;
|
--mouse-bounce-delay: 5s;
|
||||||
--mouse-start-x: calc((35 * 100vw) / 1920);
|
--mouse-start-x: calc((35 * 100vw) / 1920);
|
||||||
@@ -229,6 +234,17 @@
|
|||||||
--gap: 20;
|
--gap: 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#version-label {
|
||||||
|
position: absolute;
|
||||||
|
right: 1rem;
|
||||||
|
top: 1rem;
|
||||||
|
display: block;
|
||||||
|
color: var(--version-color);
|
||||||
|
padding: 0.4rem 0.8rem;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
#splash {
|
#splash {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
v0.0.10
|
||||||
Reference in New Issue
Block a user