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> </form>
</details> </details>
</nav> </nav>
<footer class="center">rev {{ .Rev }}</footer>
{{- end }} {{- end }}

View File

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

View File

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

View File

@ -2,6 +2,7 @@ package web
import ( import (
"net/http" "net/http"
"runtime/debug"
"sort" "sort"
"github.com/Jaculabilis/intake/core" "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]}) 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{ data := html.HomeData{
Channels: channelData, Channels: channelData,
Sources: sourceData, Sources: sourceData,
Rev: rev,
} }
html.Home(writer, data) html.Home(writer, data)
} }