aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/api_colors.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/api_colors.go')
-rw-r--r--internal/admin/api_colors.go34
1 files changed, 8 insertions, 26 deletions
diff --git a/internal/admin/api_colors.go b/internal/admin/api_colors.go
index 876656d..b57ad82 100644
--- a/internal/admin/api_colors.go
+++ b/internal/admin/api_colors.go
@@ -3,7 +3,6 @@ package admin
import (
"net/http"
"os"
- "sort"
"strings"
"gopkg.in/yaml.v3"
@@ -185,11 +184,6 @@ func knownConstantColor(name string) bool {
return false
}
-// knownColor returns true if name is editable in either section.
-func knownColor(name string) bool {
- return knownPlayerColor(name) || knownConstantColor(name)
-}
-
// seg is a small constructor helper for the inline preview builder.
func seg(t, cat string) colorSegment {
return colorSegment{T: t, C: cat}
@@ -280,7 +274,6 @@ func buildPreview() []colorSection {
ln(seg("Oh dear, you are dead!", "death")),
txt(""),
txt(""),
-
},
})
@@ -479,20 +472,20 @@ func (s *AdminServer) getColors(w http.ResponseWriter, _ *http.Request) {
}
writeJSON(w, map[string]any{
- "colors": live,
- "default_colors": def,
- "categories": colorCategories,
- "constant_colors": liveConst,
+ "colors": live,
+ "default_colors": def,
+ "categories": colorCategories,
+ "constant_colors": liveConst,
"default_constant_colors": defConst,
- "constant_categories": constantCategories,
- "preview": buildPreview(),
+ "constant_categories": constantCategories,
+ "preview": buildPreview(),
})
}
func (s *AdminServer) saveColors(w http.ResponseWriter, r *http.Request) {
var body struct {
- Colors map[string]string `json:"colors"`
- ConstantColors map[string]string `json:"constant_colors"`
+ Colors map[string]string `json:"colors"`
+ ConstantColors map[string]string `json:"constant_colors"`
}
if err := readJSON(r, &body); err != nil {
writeJSONError(w, "invalid request body", http.StatusBadRequest)
@@ -593,14 +586,3 @@ func (s *AdminServer) writeConfigFile() error {
}
return os.WriteFile(s.configPath, out, 0644)
}
-
-// sortedKeys is a small helper retained in case future code wants a stable
-// iteration order over the category names.
-func sortedKeys(m map[string]string) []string {
- keys := make([]string, 0, len(m))
- for k := range m {
- keys = append(keys, k)
- }
- sort.Strings(keys)
- return keys
-}