added side context panel and repo only search bar

This commit is contained in:
2026-05-17 21:13:45 +02:00
parent 5147c6bddb
commit ec9a286d33
7 changed files with 362 additions and 1 deletions
+30
View File
@@ -650,3 +650,33 @@ func (h *RepoHandler) lookupRepo(w http.ResponseWriter, r *http.Request) (*model
jsonError(w, "repository not found", http.StatusNotFound)
return nil, false
}
// SearchFiles handles GET /repos/{owner}/{repo}/files?q=...&ref=...
// Returns up to 20 matching file paths (case-insensitive substring match).
func (h *RepoHandler) SearchFiles(w http.ResponseWriter, r *http.Request) {
repo, ok := h.lookupRepo(w, r)
if !ok {
return
}
query := strings.TrimSpace(r.URL.Query().Get("q"))
if query == "" {
jsonOK(w, []string{})
return
}
ref := r.URL.Query().Get("ref")
if ref == "" {
ref = repo.DefaultBranch
}
files, err := gitdomain.SearchFiles(repo.DiskPath, ref, query, 20)
if err != nil {
jsonError(w, "search failed", http.StatusInternalServerError)
return
}
if files == nil {
files = []string{}
}
jsonOK(w, files)
}