From ac075747dfc38f010dc5c92f13e3ff67c1fa90db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kr=C3=BChlmann?= Date: Wed, 10 Dec 2025 23:58:08 +0100 Subject: [PATCH] Add version --- .../app/controller/ViewController.java | 6 ++- .../app/service/GitVersionService.java | 52 +++++++++++++++++++ src/main/resources/static/css/styles.css | 39 ++++++++++++++ src/main/resources/templates/index.html | 9 +++- 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/imgfloat/app/service/GitVersionService.java diff --git a/src/main/java/com/imgfloat/app/controller/ViewController.java b/src/main/java/com/imgfloat/app/controller/ViewController.java index ac6c6da..4c27139 100644 --- a/src/main/java/com/imgfloat/app/controller/ViewController.java +++ b/src/main/java/com/imgfloat/app/controller/ViewController.java @@ -1,6 +1,7 @@ package com.imgfloat.app.controller; import com.imgfloat.app.service.ChannelDirectoryService; +import com.imgfloat.app.service.GitVersionService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken; @@ -14,9 +15,11 @@ import static org.springframework.http.HttpStatus.FORBIDDEN; public class ViewController { private static final Logger LOG = LoggerFactory.getLogger(ViewController.class); private final ChannelDirectoryService channelDirectoryService; + private final GitVersionService gitVersionService; - public ViewController(ChannelDirectoryService channelDirectoryService) { + public ViewController(ChannelDirectoryService channelDirectoryService, GitVersionService gitVersionService) { this.channelDirectoryService = channelDirectoryService; + this.gitVersionService = gitVersionService; } @org.springframework.web.bind.annotation.GetMapping("/") @@ -29,6 +32,7 @@ public class ViewController { model.addAttribute("adminChannels", channelDirectoryService.adminChannelsFor(login)); return "dashboard"; } + model.addAttribute("gitVersion", gitVersionService.getVersion()); return "index"; } diff --git a/src/main/java/com/imgfloat/app/service/GitVersionService.java b/src/main/java/com/imgfloat/app/service/GitVersionService.java new file mode 100644 index 0000000..4c73372 --- /dev/null +++ b/src/main/java/com/imgfloat/app/service/GitVersionService.java @@ -0,0 +1,52 @@ +package com.imgfloat.app.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +@Component +public class GitVersionService { + private static final Logger LOG = LoggerFactory.getLogger(GitVersionService.class); + private final String version; + + public GitVersionService() { + this.version = resolveVersion(); + } + + public String getVersion() { + return version; + } + + private String resolveVersion() { + Process process = null; + try { + process = new ProcessBuilder("git", "describe", "--tags", "--always") + .redirectErrorStream(true) + .start(); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + String result = reader.readLine(); + int exitCode = process.waitFor(); + if (exitCode == 0 && result != null && !result.isBlank()) { + return result.trim(); + } + LOG.warn("git describe returned exit code {} with output: {}", exitCode, result); + } + } catch (IOException e) { + LOG.warn("Unable to determine git version", e); + if (process != null) { + process.destroyForcibly(); + } + } catch (InterruptedException e) { + LOG.warn("Interrupted while determining git version", e); + if (process != null) { + process.destroyForcibly(); + } + Thread.currentThread().interrupt(); + } + return "unknown"; + } +} diff --git a/src/main/resources/static/css/styles.css b/src/main/resources/static/css/styles.css index 1452acd..209010a 100644 --- a/src/main/resources/static/css/styles.css +++ b/src/main/resources/static/css/styles.css @@ -31,6 +31,34 @@ body { padding: 40px 20px 64px; } +.landing-meta { + display: flex; + justify-content: flex-end; + margin-top: 18px; +} + +.build-chip { + display: inline-flex; + align-items: center; + gap: 10px; + padding: 6px 10px; + background: rgba(15, 23, 42, 0.7); + border: 1px solid rgba(148, 163, 184, 0.24); + border-radius: 12px; + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24); +} + +.version-badge { + padding: 4px 10px; + border-radius: 999px; + background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(59, 130, 246, 0.12)); + border: 1px solid rgba(124, 58, 237, 0.35); + color: #cbd5e1; + font-weight: 700; + letter-spacing: 0.2px; + font-size: 13px; +} + .channels-body { min-height: 100vh; background: radial-gradient(circle at 10% 20%, rgba(124, 58, 237, 0.16), transparent 30%), @@ -228,6 +256,17 @@ body { width: 100%; } +.broadcaster-button { + background: linear-gradient(115deg, #7c3aed, #2563eb); + border: 1px solid rgba(124, 58, 237, 0.35); + box-shadow: 0 14px 35px rgba(37, 99, 235, 0.3); +} + +.broadcaster-button:hover { + filter: brightness(1.05); + box-shadow: 0 16px 38px rgba(37, 99, 235, 0.38); +} + .block { width: 100%; display: flex; diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 3b66e19..7c09467 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -1,5 +1,5 @@ - + Imgfloat - Twitch overlay @@ -29,6 +29,13 @@ + +