From 8909654c8fa69805072dfd994d7f441e84cbd872 Mon Sep 17 00:00:00 2001 From: ashisgreat22 Date: Sun, 22 Mar 2026 13:21:31 +0100 Subject: [PATCH] docs: fix implementation plan issues from review - Move template registration from Phase 2 to Phase 4 (was causing build failure) - Add filter params (activeCategory, activeTime, activeType) to FromResponse - Add DisabledCategories to PageData for backend-unsupported categories - Add disabled class to sidebar for future categories - Clarify POST handler is a no-op for localStorage-only preferences - Note CSS must be tested manually in browser Co-Authored-By: Claude Opus 4.6 --- ...26-03-22-brave-search-frontend-redesign.md | 99 +++++++++---------- 1 file changed, 44 insertions(+), 55 deletions(-) diff --git a/docs/superpowers/plans/2026-03-22-brave-search-frontend-redesign.md b/docs/superpowers/plans/2026-03-22-brave-search-frontend-redesign.md index 486cee4..a7f1b62 100644 --- a/docs/superpowers/plans/2026-03-22-brave-search-frontend-redesign.md +++ b/docs/superpowers/plans/2026-03-22-brave-search-frontend-redesign.md @@ -354,11 +354,13 @@ Append to end of `kafka.css`, before the `@media print` block: } ``` -- [ ] **Step 6: Verify CSS changes compile** +- [ ] **Step 6: Verify Go compilation** Run: `go build ./...` Expected: No errors +Note: CSS is embedded as static files and not processed by the Go compiler. CSS changes must be tested manually in a browser. + - [ ] **Step 7: Commit** ```bash @@ -501,17 +503,28 @@ type FilterOption struct { } ``` -- [ ] **Step 4: Update FromResponse to populate new fields** +- [ ] **Step 4: Update FromResponse to accept filter params** -In `views.go`, update `FromResponse` to populate the new fields: +Update `FromResponse` signature to accept `activeCategory`, `activeTime`, and `activeType` from the request. First update the `Search` handler in `handlers.go` to pass these params: ```go -func FromResponse(resp contracts.SearchResponse, query string, pageno int) PageData { +// In handlers.go, update Search handler: +pd := views.FromResponse(resp, req.Query, req.Pageno) +pd.ActiveCategory = r.FormValue("category") +pd.ActiveTime = r.FormValue("time") +pd.ActiveType = r.FormValue("type") +``` + +Then update `FromResponse` in `views.go` to accept these params: + +```go +func FromResponse(resp contracts.SearchResponse, query string, pageno int, activeCategory, activeTime, activeType string) PageData { pd := PageData{ // ... existing initialization ... // New: categories with icons - Categories: []string{"all", "news", "images", "videos", "maps", "shopping", "music", "weather"}, + Categories: []string{"all", "news", "images", "videos", "maps"}, + DisabledCategories: []string{"shopping", "music", "weather"}, CategoryIcons: map[string]string{ "all": "🌐", "news": "📰", @@ -522,7 +535,8 @@ func FromResponse(resp contracts.SearchResponse, query string, pageno int) PageD "music": "🎵", "weather": "🌤️", }, - ActiveCategory: "all", + ActiveCategory: activeCategory, + if activeCategory == "" { activeCategory = "all" } // Time filters TimeFilters: []FilterOption{ @@ -533,7 +547,7 @@ func FromResponse(resp contracts.SearchResponse, query string, pageno int) PageD {Label: "Past month", Value: "m"}, {Label: "Past year", Value: "y"}, }, - ActiveTime: "", + ActiveTime: activeTime, // Type filters TypeFilters: []FilterOption{ @@ -542,64 +556,40 @@ func FromResponse(resp contracts.SearchResponse, query string, pageno int) PageD {Label: "Videos", Value: "video"}, {Label: "Images", Value: "image"}, }, - ActiveType: "", + ActiveType: activeType, } // ... rest of function ... } ``` -- [ ] **Step 5: Register new preferences template** +Add `DisabledCategories []string` field to `PageData`. -In `views.go`, add to the `init()` function and add `tmplPreferences`: +- [ ] **Step 5: Update results.html sidebar to show disabled state** -```go -var ( - tmplFull *template.Template - tmplIndex *template.Template - tmplFragment *template.Template - tmplPreferences *template.Template -) +Update the sidebar category loop to conditionally apply `disabled` class: -func init() { - tmplFS, _ := fs.Sub(templatesFS, "templates") - - funcMap := template.FuncMap{ - "urlquery": template.URLQueryEscaper, - } - - tmplFull = template.Must(template.New("").Funcs(funcMap).ParseFS(tmplFS, - "base.html", "results.html", "results_inner.html", "result_item.html", "video_item.html", - )) - tmplIndex = template.Must(template.New("").Funcs(funcMap).ParseFS(tmplFS, - "base.html", "index.html", - )) - tmplFragment = template.Must(template.New("").Funcs(funcMap).ParseFS(tmplFS, - "results_inner.html", "result_item.html", "video_item.html", - )) - tmplPreferences = template.Must(template.New("").Funcs(funcMap).ParseFS(tmplFS, - "base.html", "preferences.html", - )) -} +```html +{{range .Categories}} + + {{index $.CategoryIcons .}} + {{.}} + +{{end}} + +{{range .DisabledCategories}} + + {{index $.CategoryIcons .}} + {{.}} + +{{end}} ``` -- [ ] **Step 6: Add RenderPreferences function** - -Add to `views.go`: - -```go -// RenderPreferences renders the full preferences page. -func RenderPreferences(w http.ResponseWriter, sourceURL string) error { - w.Header().Set("Content-Type", "text/html; charset=utf-8") - return tmplPreferences.ExecuteTemplate(w, "base", PageData{ShowHeader: true, SourceURL: sourceURL}) -} -``` - -- [ ] **Step 7: Test compilation** +- [ ] **Step 6: Test compilation** Run: `go build ./...` Expected: No errors -- [ ] **Step 8: Commit** +- [ ] **Step 7: Commit** ```bash git add internal/views/views.go internal/views/templates/results.html @@ -1020,15 +1010,14 @@ func (h *Handler) Preferences(w http.ResponseWriter, r *http.Request) { } // PreferencesPOST handles form submission from the preferences page. +// NOTE: This is a no-op. All preferences are stored in localStorage on the client +// via JavaScript. This handler exists only for form submission completeness (e.g., +// if a form POSTs without JS). The JavaScript in settings.js handles all saves. func (h *Handler) PreferencesPOST(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/preferences" { http.NotFound(w, r) return } - // Preferences are stored in localStorage on the client. - // This handler exists for form submission completeness but - // the actual save happens via JavaScript. - // Redirect back to preferences page. http.Redirect(w, r, "/preferences", http.StatusFound) } ```