Redesign the UI on brain's look: sidebar with search, Overview, modules, grouped Settings

- Left sidebar as in brain: search at the top (press /), Overview,
  Inventory, the modules (Content with Inbox, Sources, Scheduled and
  Published; later phases greyed out), Settings at the bottom; a top bar
  with breadcrumbs, and a menu that slides in on narrow screens.
- brain's colour tokens, type, radius and shadows, with a dark theme that
  follows the system setting.
- Settings as grouped tabs: Profile; Social accounts (was Credentials, now
  keys and sign-in together per network); Core & Hermes; AI, which now
  holds the API keys too. Old addresses redirect.
- /search matches every word across posts, fetched items, the inventory,
  products and settings pages.
- Overview: a card per module, then the setup checklist, folded once done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 07:50:24 -07:00
co-authored by Claude Opus 5.5
parent 81a7d0596c
commit a89121f1ec
29 changed files with 1141 additions and 364 deletions
+78 -13
View File
@@ -76,9 +76,7 @@ func (s *Server) Handler() (http.Handler, error) {
mux.HandleFunc("GET /{$}", s.dashboard)
mux.HandleFunc("GET /profile", s.profilePage)
mux.HandleFunc("POST /profile", s.profileSave)
mux.HandleFunc("POST /profile/draft", s.profileDraft)
mux.HandleFunc("GET /search", s.searchPage)
mux.HandleFunc("GET /inventory", s.inventoryList)
mux.HandleFunc("GET /inventory/new", s.inventoryEdit)
@@ -89,13 +87,21 @@ func (s *Server) Handler() (http.Handler, error) {
mux.HandleFunc("POST /inventory/import", s.inventoryImport)
mux.HandleFunc("GET /inventory/export", s.inventoryExport)
// Settings: the profile, social accounts, AI, and the Core & Hermes.
mux.HandleFunc("GET /settings", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/settings/profile", http.StatusSeeOther)
})
mux.HandleFunc("GET /settings/profile", s.profilePage)
mux.HandleFunc("POST /settings/profile", s.profileSave)
mux.HandleFunc("POST /settings/profile/draft", s.profileDraft)
mux.HandleFunc("GET /settings/ai", s.aiPage)
mux.HandleFunc("POST /settings/ai", s.aiSave)
mux.HandleFunc("POST /settings/ai/test", s.aiTest)
mux.HandleFunc("GET /settings/ai/models", s.aiModels)
mux.HandleFunc("GET /settings/credentials", s.credentialsPage)
mux.HandleFunc("POST /settings/credentials", s.credentialsSave)
mux.HandleFunc("GET /settings/accounts", s.accountsPage)
mux.HandleFunc("POST /settings/accounts", s.accountsSave)
mux.HandleFunc("POST /auth/{provider}/start", s.oauthStart)
mux.HandleFunc("GET /auth/{provider}/callback", s.oauthCallback)
@@ -112,8 +118,17 @@ func (s *Server) Handler() (http.Handler, error) {
mux.HandleFunc("POST /drafts/{id}/{action}", s.draftAction)
mux.HandleFunc("POST /reddit/rules/{name}", s.refreshRules)
mux.HandleFunc("GET /core", s.corePage)
mux.HandleFunc("GET /core/checks", s.coreChecks)
mux.HandleFunc("GET /settings/core", s.corePage)
mux.HandleFunc("GET /settings/core/checks", s.coreChecks)
// Where these pages used to be, for bookmarks.
for old, now := range map[string]string{
"/profile": "/settings/profile", "/core": "/settings/core", "/settings/credentials": "/settings/accounts",
} {
mux.HandleFunc("GET "+old, func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, now, http.StatusMovedPermanently)
})
}
return s.guard(mux), nil
}
@@ -175,10 +190,27 @@ func sameOrigin(r *http.Request) bool {
func (s *Server) loadTemplates() error {
funcs := template.FuncMap{
"lines": func(v []string) string { return strings.Join(v, "\n") },
"join": strings.Join,
"ago": ago,
"add": func(a, b int) int { return a + b },
"lines": func(v []string) string { return strings.Join(v, "\n") },
"join": strings.Join,
"ago": ago,
"add": func(a, b int) int { return a + b },
"hasPrefix": strings.HasPrefix,
// dict builds a map from key, value pairs, to pass several values
// to a template.
"dict": func(kv ...any) (map[string]any, error) {
if len(kv)%2 != 0 {
return nil, fmt.Errorf("dict: odd number of arguments")
}
m := make(map[string]any, len(kv)/2)
for i := 0; i < len(kv); i += 2 {
k, ok := kv[i].(string)
if !ok {
return nil, fmt.Errorf("dict: key %v isn't a string", kv[i])
}
m[k] = kv[i+1]
}
return m, nil
},
"xreserve": twitter.URLReserve,
"truncate": func(n int, s string) string {
r := []rune(s)
@@ -210,14 +242,47 @@ func (s *Server) loadTemplates() error {
// page is what every template gets.
type page struct {
Title string
Nav string // which nav item is current
Nav string // which menu item is current: "home", "content/inbox", "settings/ai"…
Version string
Flash string
Error string
Data any
Inbox int // drafts waiting for review, shown in the menu
Inbox int // drafts waiting for review, shown in the menu
Query string // the search box's text
}
// Section is the top bar's first breadcrumb, from Nav.
func (p page) Section() string {
switch {
case p.Nav == "home":
return ""
case strings.HasPrefix(p.Nav, "content"):
return "Content"
case strings.HasPrefix(p.Nav, "settings"):
return "Settings"
case p.Nav == "inventory":
return "Inventory"
}
return ""
}
// Modules are the app's modules, in the menu and on the Overview. One
// without a Link isn't built yet.
type module struct {
ID, Name, Phase, Body, Link string
}
var modules = []module{
{"content", "Content", "Phase 1", "Draft posts from partner and competitor news and your own products; review and publish to X, LinkedIn and Reddit.", "/content"},
{"prospects", "Prospects", "Phase 2", "Find companies and people who fit your targets, and add the ones you approve to EspoCRM through Hermes.", ""},
{"seo", "SEO", "Phase 3", "Audit your websites and open fixes as pull requests on your Hugo repositories.", ""},
{"metrics", "Metrics", "Phase 4", "Pipeline influence, CAC, CLV and NRR from Stripe, EspoCRM and Plausible.", ""},
{"sites", "Sites", "Phase 5", "Build pages and sites from a component library and publish them through Gitea.", ""},
}
// Modules is for the menu.
func (p page) Modules() []module { return modules }
// render writes a full page, or only its "content" block for htmx requests
// that ask for a fragment.
func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, p page) {