mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
- 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
49 lines
1.0 KiB
Go
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})
|
|
}
|