Files
skillshare/internal/server/handler_search.go
T
Willie 0c49860d63 feat: add project mode labels, privacy-first messaging, and UI polish
- Add (project) labels to status, sync, collect, target, and uninstall
  headers for clear mode distinction (matching list/target list pattern)
- Add ui.WithModeLabel() helper for shared functions that run in both modes
- Update uninstall confirmation prompt: "from the project?" in project mode
- Add "Privacy-first" to README Why section and website homepage
- Replace "Unified Source" card with "Privacy-First" card on website
- Unify Quick Actions card heights with h-full in DashboardPage
- Add frontend rebuild note to Docker sandbox docs
2026-02-09 21:08:03 +08:00

49 lines
1.0 KiB
Go

package server
import (
"net/http"
"strconv"
"skillshare/internal/search"
)
func (s *Server) handleSearch(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query().Get("q")
limit := 20
if l := r.URL.Query().Get("limit"); l != "" {
if parsed, err := strconv.Atoi(l); err == nil {
limit = parsed
}
}
results, err := search.Search(query, limit)
if err != nil {
writeError(w, http.StatusInternalServerError, err.Error())
return
}
type resultItem struct {
Name string `json:"name"`
Description string `json:"description"`
Source string `json:"source"`
Stars int `json:"stars"`
Owner string `json:"owner"`
Repo string `json:"repo"`
}
items := make([]resultItem, 0, len(results))
for _, r := range results {
items = append(items, resultItem{
Name: r.Name,
Description: r.Description,
Source: r.Source,
Stars: r.Stars,
Owner: r.Owner,
Repo: r.Repo,
})
}
writeJSON(w, map[string]any{"results": items})
}