mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 11:49:25 +00:00
Add version
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Imgfloat - Twitch overlay</title>
|
||||
@@ -29,6 +29,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="landing-meta">
|
||||
<div class="build-chip">
|
||||
<span class="muted">Build</span>
|
||||
<span class="version-badge" th:text="${gitVersion}">unknown</span>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user