Add footer with git revision

This commit is contained in:
Tim Van Baak 2025-02-20 21:31:51 -08:00
parent 30ead637e2
commit 9aa95aba13
4 changed files with 20 additions and 0 deletions

View File

@ -86,4 +86,6 @@
</form>
</details>
</nav>
<footer class="center">rev {{ .Rev }}</footer>
{{- end }}

View File

@ -106,6 +106,7 @@ type SourceData struct {
type HomeData struct {
Channels []ChannelData
Sources []SourceData
Rev string
}
func Home(writer io.Writer, data HomeData) {

View File

@ -101,3 +101,6 @@ span.error-message {
#envvars input {
font-family: monospace;
}
footer {
opacity: 0.5
}

View File

@ -2,6 +2,7 @@ package web
import (
"net/http"
"runtime/debug"
"sort"
"github.com/Jaculabilis/intake/core"
@ -37,9 +38,22 @@ func (env *Env) getRoot(writer http.ResponseWriter, req *http.Request) {
channelData = append(channelData, html.ChannelData{Name: name, Active: channels[name]})
}
rev := ""
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
rev = setting.Value + rev
}
if setting.Key == "vcs.modified" {
rev = rev + "-dirty"
}
}
}
data := html.HomeData{
Channels: channelData,
Sources: sourceData,
Rev: rev,
}
html.Home(writer, data)
}