Add /api/info endpoint for build time, title.js, UI tweaks

This commit is contained in:
Meleki committed 2026-02-27 14:29:43 +01:00
1 parent bdd3173e5f
commit 6556d62f17
10 files changed
+77 -20

No files matched your search

+1
View File
@@ -3,3 +3,4 @@
/obj/
/publish/
/appsettings.Production.json
/DEVY.md
+42
View File
@@ -0,0 +1,42 @@
using System;
using System.IO;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Gott.Endpoints;
public static class InfoEndpoint
{
public static void MapInfoEndpoint(this IEndpointRouteBuilder app)
{
app.MapGet("/api/info", HandleInfo);
}
private static IResult HandleInfo()
{
var assembly = Assembly.GetExecutingAssembly();
var location = assembly.Location;
long buildTime = 0;
if (!string.IsNullOrEmpty(location) && File.Exists(location))
{
var lastWrite = File.GetLastWriteTimeUtc(location);
buildTime = new DateTimeOffset(lastWrite).ToUnixTimeSeconds();
}
else
{
var dir = AppContext.BaseDirectory;
var exePath = Path.Combine(dir, "gott");
if (File.Exists(exePath))
{
var lastWrite = File.GetLastWriteTimeUtc(exePath);
buildTime = new DateTimeOffset(lastWrite).ToUnixTimeSeconds();
}
}
return Results.Json(new { buildTime });
}
}
+1
View File
@@ -22,5 +22,6 @@ app.MapHistoryEndpoint();
app.MapSessionEndpoints();
app.MapAgentEndpoints();
app.MapWorkspaceEndpoint();
app.MapInfoEndpoint();
app.Run("http://0.0.0.0:19000");
-1
View File
@@ -17,7 +17,6 @@ fi
export PATH="$HOME/.dotnet:$PATH"
dotnet publish -c Release -o publish
cp wwwroot/index.html publish/wwwroot/index.html
if [ "$_hostname" = "stein2" ]; then
systemctl start gott
+1 -1
View File
@@ -51,7 +51,7 @@ button:not(:disabled):hover, select:hover, input:hover, textarea:hover {
}
button:disabled {
opacity: .5;
opacity: var(--semi-transparent);
}
textarea {
+6 -6
View File
@@ -23,7 +23,7 @@
}
.custom-cmd-btn.running {
opacity: 0.5;
opacity: var(--semi-transparent);
cursor: wait;
}
@@ -84,6 +84,7 @@
border-bottom: var(--border-width) solid var(--f1-border);
flex-shrink: 0;
min-height: 2.5em;
opacity: var(--semi-transparent);
}
.msg {
@@ -130,7 +131,7 @@
padding: var(--s2);
background: var(--f1-bg);
border: var(--border-width) solid var(--f1-border);
opacity: 0.5;
opacity: var(--semi-transparent);
}
.input-area {
@@ -150,7 +151,6 @@
}
.input-area button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
@@ -161,7 +161,7 @@
}
.archived {
opacity: 0.6;
opacity: var(--semi-transparent);
}
.archive-load-btn {
@@ -244,7 +244,7 @@
cursor: pointer;
padding: var(--s1);
color: var(--text);
opacity: 0.6;
opacity: var(--semi-transparent);
}
.file-remove:hover {
@@ -255,7 +255,7 @@
.attachment-indicator {
margin-top: var(--s2);
opacity: 0.7;
opacity: var(--semi-transparent);
}
.attachment-indicator:hover {
+4 -10
View File
@@ -39,7 +39,7 @@
}
.fe-path {
opacity: 0.6;
opacity: var(--semi-transparent);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -49,11 +49,6 @@
padding: var(--s1) var(--s2);
}
.fe-btn:disabled {
opacity: 0.4;
cursor: default;
}
.fe-body {
display: flex;
flex: 1;
@@ -102,13 +97,12 @@
.fe-file {
color: var(--text);
opacity: 0.85;
}
.fe-loading, .fe-error, .fe-empty, .fe-placeholder {
padding: var(--s4);
text-align: center;
opacity: 0.5;
opacity: var(--semi-transparent);
align-self: center;
margin: auto;
}
@@ -128,7 +122,7 @@
padding-right: var(--s3);
background: var(--f1-bg);
color: var(--text);
opacity: 0.35;
opacity: var(--semi-transparent);
text-align: right;
overflow: hidden;
user-select: none;
@@ -184,7 +178,7 @@
}
.fe-info {
opacity: 0.6;
opacity: var(--semi-transparent);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
+1
View File
@@ -13,4 +13,5 @@
--s3: .75em;
--s4: 1em;
--border-width: 1px;
--semi-transparent: 0.6;
}
+3 -2
View File
@@ -3,7 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Gott</title>
<title>// gott</title>
<script src="js/title.js"></script>
<link rel="stylesheet" href="css/theme.css">
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/main.css">
@@ -133,8 +134,8 @@
</div>
</div>
</header>
<div class="meta-bar" id="meta"></div>
<div id="chat"></div>
<div class="meta-bar" id="meta"></div>
<div id="filePreview" class="file-preview" hidden></div>
<div id="refPreview" class="ref-preview" hidden></div>
<div class="input-area">
+18
View File
@@ -0,0 +1,18 @@
let buildTime = 0;
fetch('/api/info').then(r => r.json()).then(data => {
buildTime = data.buildTime || 0;
updateTitle();
setInterval(updateTitle, 1000);
});
function updateTitle() {
if (!buildTime) { document.title = '// gott'; return; }
const s = Math.floor(Date.now() / 1000) - buildTime;
let ago;
if (s < 60) ago = `${s} Sekunde${s !== 1 ? 'n' : ''}`;
else if (s < 3600) { const m = Math.floor(s / 60); ago = `${m} Minute${m !== 1 ? 'n' : ''}`; }
else if (s < 86400) { const h = Math.floor(s / 3600); ago = `${h} Stunde${h !== 1 ? 'n' : ''}`; }
else { const d = Math.floor(s / 86400); ago = `${d} Tag${d !== 1 ? 'en' : ''}`; }
document.title = `// gott :: Build vor ${ago}`;
}