big w labels

This commit is contained in:
Bel LaPointe
2026-01-31 16:31:44 -07:00
parent 7d3da593ca
commit c283999b1a
2 changed files with 31 additions and 7 deletions

View File

@@ -13,7 +13,6 @@ import (
"net/http"
"net/url"
"regexp"
"slices"
"strconv"
"strings"
"text/template"
@@ -293,14 +292,28 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (s *Server) Home(w http.ResponseWriter, r *http.Request) {
keys := s.db.Keys(nsRouting)
routePrefixes := []string{}
routePrefixes := map[string]string{}
for _, key := range keys {
u, _ := s.lookup(key)
if u != nil && u.String() != "" {
routePrefixes = append(routePrefixes, strings.Split(key, "/")[0])
routePrefixes[strings.Split(key, "/")[0]] = ""
}
}
priority := map[string]string{
"wyze0": "Home Camera 0",
"wyze1": "Home Camera 1",
"wyze2": "Home Camera 2",
"wyze3": "Home Camera 3",
"whereis": "Map of Belling",
"moolah": "Money",
"autobookshelf": "Ebooks",
"jackett": "The 7 Seas",
}
for k, v := range priority {
if _, ok := routePrefixes[k]; ok {
routePrefixes[k] = v
}
}
slices.Sort(routePrefixes)
t := strings.ReplaceAll(`
<DOCTYPE! html>
<html>
@@ -309,9 +322,17 @@ func (s *Server) Home(w http.ResponseWriter, r *http.Request) {
<body>
{{- $baseDomain := .baseDomain }}
{{- $scheme := .scheme }}
{{- range .routePrefixes }}
{{- $url := printf "%s://%s.%s" $scheme . $baseDomain }}
<a href="{{ $url }}">{{ . }}</a><br>
{{- range $k, $v := .routePrefixes }}
{{- $url := printf "%s://%s.%s" $scheme $k $baseDomain }}
{{ if ne $v "" }}
<a style="size: 2em" href="{{ $url }}">{{ $k }} ({{ $v }})</a><br>
{{ end }}
{{- end }}
{{- range $k, $v := .routePrefixes }}
{{- $url := printf "%s://%s.%s" $scheme $k $baseDomain }}
{{ if eq $v "" }}
<a href="{{ $url }}">{{ $k }}</a><br>
{{ end }}
{{- end }}
</body>
<footer>