From 94823b52168b44894fb5e9c960358ed02ebb122b Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sun, 5 Jul 2026 22:35:21 -0400 Subject: feat: courses gui overhaul, add course tab to map, add hidden exits to give courses structure --- internal/admin/api_search.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'internal/admin/api_search.go') diff --git a/internal/admin/api_search.go b/internal/admin/api_search.go index 32ef292..d54e7f1 100644 --- a/internal/admin/api_search.go +++ b/internal/admin/api_search.go @@ -2,8 +2,12 @@ package admin import ( "net/http" + "os" + "path/filepath" "strconv" "strings" + + "gopkg.in/yaml.v3" ) func (s *AdminServer) handleSearch(w http.ResponseWriter, r *http.Request) { @@ -30,6 +34,7 @@ func (s *AdminServer) handleSearch(w http.ResponseWriter, r *http.Request) { Objects []searchResult `json:"objects"` Hazards []searchResult `json:"hazards"` Drops []searchResult `json:"drops"` + Courses []searchResult `json:"courses"` } var resp searchResponse @@ -98,5 +103,21 @@ func (s *AdminServer) handleSearch(w http.ResponseWriter, r *http.Request) { } } + courseIDs, _ := listYAMLFiles(s.dataDir, "courses") + for _, id := range courseIDs { + raw, err := os.ReadFile(filepath.Join(s.dataDir, "courses", id+".yaml")) + if err != nil { + continue + } + var c map[string]any + if err := yaml.Unmarshal(raw, &c); err != nil { + continue + } + name, _ := c["name"].(string) + if strings.Contains(strings.ToLower(id), q) || strings.Contains(strings.ToLower(name), q) { + resp.Courses = append(resp.Courses, searchResult{ID: id, Name: name}) + } + } + writeJSON(w, resp) } -- cgit v1.2.3