diff --git a/PLAN.md b/PLAN.md index 126085b..e5529d0 100644 --- a/PLAN.md +++ b/PLAN.md @@ -406,7 +406,7 @@ Part 4, promoting our own products: invites feedback, and the Inbox warns that self-promotion is often restricted. -**Not yet tried for real.** Parts 1–4 are covered by tests with fake AI +**Not yet tried for real (deferred on 2026-11-21 for the UI redesign below; run this checklist next).** Parts 1–4 are covered by tests with fake AI and channel clients, and the rebuilt app runs (schema 3). But the installed app has no profile, AI key, inventory or social sign-ins yet, so no real fetch, generation or post has been made. Before relying on it: @@ -429,6 +429,25 @@ so `git push` can't prompt from Claude Code). The branch stays off `main` until the user decides to merge; posting works again now, which was the condition for merging. +**UI redesign (2026-11-21).** The user asked for brain +(gitea.federated.computer/Federated_Computer/brain, a Next.js + Tailwind +app) to be the UI basis from now on. Supermarket stays Go templates + htmx; +it takes brain's look rather than its stack: brain's colour tokens, type, +radius and shadows (and its dark theme, following the system setting), a +left sidebar with search at the top and Settings at the bottom, a top bar +with breadcrumbs, and Settings as grouped tabs on the left. The menu: +Search, Overview (module cards and setup), Inventory, then the modules +(Content with Inbox, Sources, Scheduled and Published; the later phases +shown greyed out). Settings holds Profile, Social accounts (was +Credentials; keys and sign-in together per network), Core & Hermes, and AI +(provider, model, and the API keys, which moved there from Credentials). +Old addresses (`/profile`, `/core`, `/settings/credentials`) redirect. +Search (`/search`) matches every word across posts, fetched items, the +inventory, products and settings pages. New modules add a `modules` entry +in `internal/web/server.go` and an icon in `layout.html`. brain's fonts +(DM Sans, Plus Jakarta Sans) are named but not bundled, so the system font +is used unless they're installed. + **To pick this up:** try Phase 1 for real (the checklist above), fix what that turns up, then decide whether to merge `phase0-foundation` into `main` and tag `v0.1.0`. Then Phase 2, Prospects → EspoCRM, which depends on the diff --git a/README.md b/README.md index f582ec5..edee81c 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,12 @@ After that, CoreDesktop's `update` keeps it current: it pulls this repository an Then open Supermarket and: -1. **Profile**: enter your website and press *Draft*. Correct the draft and save it. -2. **Settings > AI provider**: Anthropic (add your API key under *Credentials*) or an LLM server on your network, such as Ollama. Servers found by CoreDesktop's `configure ai-servers` are offered. +1. **Settings → AI**: Anthropic, with Hermes' key (shared by `supermarket hermes`) or your own, or an LLM server on your network, such as Ollama. Servers found by CoreDesktop's `configure ai-servers` are offered. +2. **Settings → Profile**: enter your website and press *Draft*. Correct the draft and save it. 3. **Inventory**: add your partners and competitors, or import a list. -4. **Settings > Credentials**: connect X and LinkedIn. +4. **Settings → Social accounts**: connect X, LinkedIn and Reddit. + +The menu on the left has a search box at the top (press `/` to jump to it), then the **Overview** with a card per module, the **Inventory**, and the modules: **Content** (Inbox, Sources, Scheduled, Published), and the ones still to come. **Settings**, at the bottom, holds the Profile, Social accounts, Core & Hermes, and AI. Search finds posts, fetched items, inventory entries, your products and settings pages. The look follows brain (Federated's superbrain), including a dark theme that follows your system's setting. ## The `supermarket` command @@ -88,7 +90,7 @@ MCPHUB_AUTH= Hermes' sandbox can only reach the hub once it's in `network.allowedDomains` in `~/.config/coredesktop/sandbox/hermes.json`. The script asks before adding it, then restarts Hermes' gateway. To enter a different hub token: `supermarket hermes --reconfigure`. -**AI for Supermarket itself.** If Hermes uses an Anthropic key, `supermarket hermes` offers to let Supermarket use the same key and model, so AI is set up once. Only the key and model are copied, to `hermes-ai.json` in the data folder (readable only by you), and `update.sh` keeps them in step. Supermarket still calls the model directly, not through Hermes: writing posts means reading text from the web, and that text shouldn't reach an agent that has tools and your CRM. A key saved under Settings → Credentials takes the place of Hermes'. +**AI for Supermarket itself.** If Hermes uses an Anthropic key, `supermarket hermes` offers to let Supermarket use the same key and model, so AI is set up once. Only the key and model are copied, to `hermes-ai.json` in the data folder (readable only by you), and `update.sh` keeps them in step. Supermarket still calls the model directly, not through Hermes: writing posts means reading text from the web, and that text shouldn't reach an agent that has tools and your CRM. A key saved under Settings → AI takes the place of Hermes'. To check the connection, open **Core & Hermes** in Supermarket and ask Hermes the question shown there. Hermes lists the hub's tools and reports them back to Supermarket, which shows when it last heard from Hermes. @@ -125,7 +127,7 @@ Sign-ins come back to Supermarket at `http://localhost:8470/auth//call - X developer portal, your app's *User authentication settings*: `http://localhost:8470/auth/x/callback` - LinkedIn developer portal, your app's *Auth* tab: `http://localhost:8470/auth/linkedin/callback` -- Reddit, [reddit.com/prefs/apps](https://www.reddit.com/prefs/apps): create a **web app** with the redirect URI `http://localhost:8470/auth/reddit/callback`, and put its client ID and secret under Settings → Credentials +- Reddit, [reddit.com/prefs/apps](https://www.reddit.com/prefs/apps): create a **web app** with the redirect URI `http://localhost:8470/auth/reddit/callback`, and put its client ID and secret under Settings → Social accounts The old terminal app used `http://localhost:8080/callback`; you can remove that one. diff --git a/internal/api/reddit/client.go b/internal/api/reddit/client.go index 9fdb1a0..5757f97 100644 --- a/internal/api/reddit/client.go +++ b/internal/api/reddit/client.go @@ -52,7 +52,7 @@ func UserAgent(version, username string) string { } // ErrUnauthorized means the token was refused even after a refresh. -var ErrUnauthorized = errors.New("Reddit refused the sign-in: connect Reddit again under Settings → Credentials") +var ErrUnauthorized = errors.New("Reddit refused the sign-in: connect Reddit again under Settings → Social accounts") func (c *Client) do(ctx context.Context, method, path string, form url.Values, out any) error { for attempt := 0; ; attempt++ { diff --git a/internal/content/search.go b/internal/content/search.go new file mode 100644 index 0000000..c022a32 --- /dev/null +++ b/internal/content/search.go @@ -0,0 +1,53 @@ +package content + +import ( + "strings" + + "supermarket/internal/db" +) + +// matchAll builds a condition that every word appears in one of the columns +// (case-insensitively for ASCII, as SQLite's lower() is), and its arguments. +// Words are expected in lower case. +func matchAll(words []string, columns ...string) (string, []any) { + hay := "lower(" + strings.Join(columns, " || ' ' || ") + ")" + conds := make([]string, 0, len(words)) + args := make([]any, 0, len(words)) + for _, w := range words { + conds = append(conds, "instr("+hay+", ?) > 0") + args = append(args, w) + } + return strings.Join(conds, " AND "), args +} + +// SearchItems returns fetched items (dismissed ones too) containing every +// word, newest first. Products, which are in the profile, are left out. +func SearchItems(d *db.DB, words []string, limit int) ([]Item, error) { + if len(words) == 0 { + return nil, nil + } + cond, args := matchAll(words, "c.title", "c.body", "c.author", "c.author_handle", "c.url") + rows, err := d.Query(`SELECT `+itemColumns+itemFrom+` + WHERE c.source != 'Product' AND `+cond+` + ORDER BY c.published_at DESC LIMIT ?`, append(args, limit)...) + if err != nil { + return nil, err + } + return scanItems(rows) +} + +// SearchDrafts returns posts (not discarded ones) containing every word, +// most recently changed first. +func SearchDrafts(d *db.DB, words []string, limit int) ([]Draft, error) { + if len(words) == 0 { + return nil, nil + } + cond, args := matchAll(words, "content", "title", "target", "inventory_name", "source_url") + rows, err := d.Query(`SELECT `+draftColumns+` FROM drafts + WHERE status != ? AND `+cond+` + ORDER BY updated_at DESC, id DESC LIMIT ?`, append(append([]any{StatusDiscarded}, args...), limit)...) + if err != nil { + return nil, err + } + return scanDrafts(rows) +} diff --git a/internal/web/channels.go b/internal/web/channels.go index a376a7d..7e9963d 100644 --- a/internal/web/channels.go +++ b/internal/web/channels.go @@ -149,7 +149,7 @@ func (s *Server) redditReader(ctx context.Context) (*reddit.Client, error) { } id, secret := s.Secrets.Get(secrets.RedditClientID), s.Secrets.Get(secrets.RedditClientSecret) if id == "" || secret == "" { - return nil, errors.New("add Reddit's client ID and secret under Settings → Credentials to read subreddits") + return nil, errors.New("add Reddit's client ID and secret under Settings → Social accounts to read subreddits") } s.mu.Lock() tok, exp := s.redditAppToken, s.redditAppTokenExp diff --git a/internal/web/content.go b/internal/web/content.go index 09be315..dfe41cd 100644 --- a/internal/web/content.go +++ b/internal/web/content.go @@ -63,7 +63,7 @@ func (s *Server) contentIndex(w http.ResponseWriter, r *http.Request) { rows = append(rows, contentRow{Entry: e, Name: e.Name, Sources: fetcher.Sources(&e), Waiting: counts[strings.ToLower(e.Name)], LastChecked: last}) } - s.render(w, r, "content", page{Title: "Content", Nav: "content", Data: map[string]any{"Rows": rows}}) + s.render(w, r, "content", page{Title: "Sources", Nav: "content/sources", Data: map[string]any{"Rows": rows}}) } type channelChoice struct { @@ -181,7 +181,7 @@ func (s *Server) contentEntry(w http.ResponseWriter, r *http.Request) { s.serverError(w, err) return } - s.render(w, r, "content-entry", page{Title: d.Name, Nav: "content", Data: d}) + s.render(w, r, "content-entry", page{Title: d.Name, Nav: "content/sources", Data: d}) } func (s *Server) contentFetch(w http.ResponseWriter, r *http.Request) { @@ -221,7 +221,7 @@ func (s *Server) contentFetch(w http.ResponseWriter, r *http.Request) { return } d.Fetched, d.NewItems, d.Errors, d.Skipped = true, n, res.Errors, res.Skipped - s.render(w, r, "content-entry", page{Title: d.Name, Nav: "content", Data: d}) + s.render(w, r, "content-entry", page{Title: d.Name, Nav: "content/sources", Data: d}) } // contentItems handles the item list's buttons: dismiss, restore, write. @@ -245,7 +245,7 @@ func (s *Server) contentItems(w http.ResponseWriter, r *http.Request) { s.serverError(w, err) return } - s.render(w, r, "content-entry", page{Title: d.Name, Nav: "content", Error: msg, Data: d}) + s.render(w, r, "content-entry", page{Title: d.Name, Nav: "content/sources", Error: msg, Data: d}) } if len(ids) == 0 { showErr("Select at least one item first.") diff --git a/internal/web/content_test.go b/internal/web/content_test.go index a750f63..7edca1d 100644 --- a/internal/web/content_test.go +++ b/internal/web/content_test.go @@ -101,7 +101,7 @@ func TestDraftsPage(t *testing.T) { body := rec.Body.String() if rec.Code != 200 || strings.Index(body, "X text") > strings.Index(body, "LinkedIn text") || !strings.Contains(body, "31 / 280 including the link") || !strings.Contains(body, `data-reserve="25"`) || - !strings.Contains(body, `class="count-badge">2<`) { + !strings.Contains(body, `class="count-badge" title="2 waiting for review">2<`) { t.Errorf("inbox (X should come first, menu count 2):\n%s", body) } @@ -301,7 +301,7 @@ func TestOwnContentPage(t *testing.T) { } body = do(h, http.MethodGet, "/content/own", nil, nil).Body.String() for _, want := range []string{"

Acme ", `value="product:acme-mail"`, `action="/content/own/fetch"`, - `href="/profile">Edit profile`, `action="/content/own/items"`} { + `href="/settings/profile">Edit profile`, `action="/content/own/items"`} { if !strings.Contains(body, want) { t.Errorf("own page lacks %q", want) } diff --git a/internal/web/inbox.go b/internal/web/inbox.go index 3f230e5..ce890da 100644 --- a/internal/web/inbox.go +++ b/internal/web/inbox.go @@ -92,7 +92,7 @@ func (s *Server) renderInbox(w http.ResponseWriter, r *http.Request, errMsg stri if len(pending) > 0 { sections = append(sections, inboxSection{Module: "Content", Batches: groupBatches(pending)}) } - s.render(w, r, "inbox", page{Title: "Inbox", Nav: "inbox", Error: errMsg, Data: map[string]any{ + s.render(w, r, "inbox", page{Title: "Inbox", Nav: "content/inbox", Error: errMsg, Data: map[string]any{ "Sections": sections, "Reddit": s.redditViews(r.Context(), pending), "Connected": s.connected(), @@ -160,7 +160,7 @@ func (s *Server) renderScheduled(w http.ResponseWriter, r *http.Request, errMsg s.serverError(w, err) return } - s.render(w, r, "content-scheduled", page{Title: "Scheduled", Nav: "content", Error: errMsg, Data: map[string]any{ + s.render(w, r, "content-scheduled", page{Title: "Scheduled", Nav: "content/scheduled", Error: errMsg, Data: map[string]any{ "Drafts": drafts, "Connected": s.connected(), "Zone": time.Now().Format("MST"), }}) } @@ -171,7 +171,7 @@ func (s *Server) publishedPage(w http.ResponseWriter, r *http.Request) { s.serverError(w, err) return } - s.render(w, r, "content-published", page{Title: "Published", Nav: "content", Data: map[string]any{"Drafts": drafts}}) + s.render(w, r, "content-published", page{Title: "Published", Nav: "content/published", Data: map[string]any{"Drafts": drafts}}) } // dateTimeLocal is the format of , read in the diff --git a/internal/web/pages.go b/internal/web/pages.go index 4430434..a75cf06 100644 --- a/internal/web/pages.go +++ b/internal/web/pages.go @@ -50,11 +50,6 @@ type step struct { Link string } -type module struct { - Name, Phase, Body string - Link string // set once the module is usable -} - func (s *Server) dashboard(w http.ResponseWriter, r *http.Request) { p, err := profile.Load(s.DB) if err != nil { @@ -86,27 +81,24 @@ func (s *Server) dashboard(w http.ResponseWriter, r *http.Request) { steps := []step{ {Label: "AI provider", Done: aiErr == nil, Link: "/settings/ai", Detail: ifElse(aiErr == nil, aiCfg.Provider+" · "+aiCfg.Model, "Choose Anthropic or a server on your network; the profile draft and posts need it")}, - {Label: "Company profile", Done: p.IsSet(), Link: "/profile", + {Label: "Company profile", Done: p.IsSet(), Link: "/settings/profile", Detail: ifElse(p.IsSet(), p.Name, "Describe the company, its products and its customers (the AI can draft it from your website)")}, {Label: "Inventory", Done: len(entries) > 0, Link: "/inventory", Detail: inventorySummary(counts)}, {Label: "Social accounts", Done: s.Secrets.Has(secrets.XAccessToken) || s.Secrets.Has(secrets.LinkedInAccessToken) || s.Secrets.Has(secrets.RedditAccessToken), - Link: "/settings/credentials", Detail: s.connectionSummary(conns)}, - {Label: "Federated Core", Done: s.Core != nil, Link: "/core", + Link: "/settings/accounts", Detail: s.connectionSummary(conns)}, + {Label: "Federated Core", Done: s.Core != nil, Link: "/settings/core", Detail: ifElse(s.Core != nil, coreDomain(s.Core), "No Core found; run `configure core` in CoreDesktop")}, - {Label: "Hermes bridge", Done: last != nil, Link: "/core", + {Label: "Hermes bridge", Done: last != nil, Link: "/settings/core", Detail: ifElse(last != nil, "Last check-in "+ago(atOf(last)), "Hermes hasn't checked in yet")}, } - modules := []module{ - {"Content", "Phase 1", "Draft posts from partner and competitor news and your own products; review and publish to X, LinkedIn and Reddit.", "/content"}, - {"Prospects", "Phase 2", "Find companies and people who fit your targets, and add the ones you approve to EspoCRM through Hermes.", ""}, - {"SEO", "Phase 3", "Audit your websites and open fixes as pull requests on your Hugo repositories.", ""}, - {"Metrics", "Phase 4", "Pipeline influence, CAC, CLV and NRR from Stripe, EspoCRM and Plausible.", ""}, - {"Sites", "Phase 5", "Build pages and sites from a component library and publish them through Gitea.", ""}, - } - queued, _ := content.CountDrafts(s.DB) + scheduled, _ := content.ListDrafts(s.DB, 1000, content.StatusScheduled) + pending := false + for _, st := range steps { + pending = pending || !st.Done + } s.render(w, r, "dashboard", page{Title: "Overview", Nav: "home", Data: map[string]any{ "Steps": steps, @@ -114,6 +106,8 @@ func (s *Server) dashboard(w http.ResponseWriter, r *http.Request) { "ImportStatus": s.ImportStatus, "ImportErr": errString(s.ImportErr), "QueuedPosts": queued, + "Scheduled": len(scheduled), + "Pending": pending, }}) } @@ -226,7 +220,7 @@ func (s *Server) corePage(w http.ResponseWriter, r *http.Request) { command: socat args: ["STDIO", "UNIX-CONNECT:` + d.MCPSocket + `"]` d.HermesEnv = `MCPHUB_AUTH=` - s.render(w, r, "core", page{Title: "Core & Hermes", Nav: "core", Data: d}) + s.render(w, r, "core", page{Title: "Core & Hermes", Nav: "settings/core", Data: d}) } func publicPort(u string) string { diff --git a/internal/web/profile.go b/internal/web/profile.go index 25f7497..5d3cb1f 100644 --- a/internal/web/profile.go +++ b/internal/web/profile.go @@ -36,7 +36,7 @@ func (s *Server) profilePage(w http.ResponseWriter, r *http.Request) { d.DraftURL = p.Websites[0].URL } d.NoAI = !s.aiReady() - s.render(w, r, "profile", page{Title: "Company profile", Nav: "profile", Data: d}) + s.render(w, r, "profile", page{Title: "Company profile", Nav: "settings/profile", Data: d}) } // profileFromForm reads the profile form. Repeated rows (products, websites) @@ -103,7 +103,7 @@ func (s *Server) profileSave(w http.ResponseWriter, r *http.Request) { p := profileFromForm(r) p.Clean() if !p.IsSet() { - s.render(w, r, "profile", page{Title: "Company profile", Nav: "profile", + s.render(w, r, "profile", page{Title: "Company profile", Nav: "settings/profile", Error: "The company's name and description are required.", Data: withBlankRows(p)}) return } @@ -111,7 +111,7 @@ func (s *Server) profileSave(w http.ResponseWriter, r *http.Request) { s.serverError(w, err) return } - redirect(w, r, "/profile", "saved") + redirect(w, r, "/settings/profile", "saved") } // profileDraft drafts the profile from a website and shows it in the form, @@ -132,7 +132,7 @@ func (s *Server) profileDraft(w http.ResponseWriter, r *http.Request) { d.Drafted = drafted d.DraftURL = siteURL d.NoAI = !s.aiReady() - s.render(w, r, "profile", page{Title: "Company profile", Nav: "profile", Error: errMsg, Data: d}) + s.render(w, r, "profile", page{Title: "Company profile", Nav: "settings/profile", Error: errMsg, Data: d}) } cfg, err := ai.LoadConfig(s.DB) diff --git a/internal/web/search.go b/internal/web/search.go new file mode 100644 index 0000000..c20d531 --- /dev/null +++ b/internal/web/search.go @@ -0,0 +1,167 @@ +package web + +import ( + "net/http" + "strconv" + "strings" + + "supermarket/internal/content" + "supermarket/internal/inventory" + "supermarket/internal/profile" +) + +// hit is one search result. +type hit struct { + Title, Detail, Link string + Badge string // e.g. a relationship or a draft's status +} + +// hitGroup is a kind of result, in the order shown. +type hitGroup struct { + Name string + Hits []hit +} + +const searchLimit = 25 + +// settingsPages are searched by name and by what they hold, so "anthropic +// key" or "reddit" find the right tab. +var settingsPages = []struct { + hit + Words string +}{ + {hit{"Company profile", "Settings · your company, products, websites, voice and targets", "/settings/profile", ""}, + "profile company products websites voice tone audience keywords feeds subreddits accounts"}, + {hit{"Social accounts", "Settings · X, LinkedIn, Reddit and YouTube keys and sign-ins", "/settings/accounts", ""}, + "social accounts credentials keys x twitter linkedin reddit youtube sign in connect oauth bearer token"}, + {hit{"AI", "Settings · provider, model, API keys and the Hermes key", "/settings/ai", ""}, + "ai provider model anthropic claude openai ollama lm studio api key hermes effort"}, + {hit{"Core & Hermes", "Settings · the Federated Core, its services and the Hermes bridge", "/settings/core", ""}, + "core hermes federated mcp hub bridge espocrm nextcloud plausible gitea"}, +} + +func (s *Server) searchPage(w http.ResponseWriter, r *http.Request) { + q := strings.TrimSpace(r.URL.Query().Get("q")) + var groups []hitGroup + total := 0 + if q != "" { + var err error + groups, err = s.search(q) + if err != nil { + s.serverError(w, err) + return + } + for _, g := range groups { + total += len(g.Hits) + } + } + s.render(w, r, "search", page{Title: "Search", Nav: "search", Query: q, Data: map[string]any{ + "Q": q, + "Groups": groups, + "Total": total, + "Limit": searchLimit, + }}) +} + +// search looks for q in the inventory, fetched items, posts and settings. +// Every word must appear (case-insensitively), in any order. +func (s *Server) search(q string) ([]hitGroup, error) { + words := strings.Fields(strings.ToLower(q)) + matches := func(texts ...string) bool { + all := strings.ToLower(strings.Join(texts, "\n")) + for _, w := range words { + if !strings.Contains(all, w) { + return false + } + } + return true + } + + entries, err := inventory.List(s.DB, "") + if err != nil { + return nil, err + } + ids := map[string]int64{} // inventory name (lower case) → ID, for links + var inv []hit + for _, e := range entries { + ids[strings.ToLower(e.Name)] = e.ID + if matches(e.Name, e.Description, e.TwitterHandle, e.TalkingPoints, strings.Join(e.Websites, " "), + strings.Join(e.Hashtags, " "), strings.Join(e.Keywords, " "), strings.Join(e.Subreddits, " ")) { + inv = append(inv, hit{Title: e.Name, Detail: e.Description, + Link: "/inventory/" + strconv.FormatInt(e.ID, 10), Badge: e.Relationship}) + } + } + entryLink := func(name string) string { + if strings.EqualFold(name, content.OwnName) { + return "/content/own" + } + if id, ok := ids[strings.ToLower(name)]; ok { + return "/content/" + strconv.FormatInt(id, 10) + } + return "/content" + } + + items, err := content.SearchItems(s.DB, words, searchLimit) + if err != nil { + return nil, err + } + var found []hit + for _, it := range items { + name := it.AppName + if strings.EqualFold(name, content.OwnName) { + name = "your own work" + } + title := it.Title + if title == "" { + title = it.Body + } + found = append(found, hit{Title: title, Detail: string(it.Source) + " · " + name + " · " + it.PublishedAt.Local().Format("2 Jan 2006"), + Link: entryLink(it.AppName), Badge: ifElse(it.Dismissed, "dismissed", "")}) + } + + drafts, err := content.SearchDrafts(s.DB, words, searchLimit) + if err != nil { + return nil, err + } + var posts []hit + for _, d := range drafts { + link := "/inbox" + switch d.Status { + case content.StatusScheduled: + link = "/content/scheduled" + case content.StatusPublished: + link = "/content/published" + } + text := d.Content + if d.Title != "" { + text = d.Title + } + detail := d.Where() + if d.InventoryName != "" { + detail += " · " + d.InventoryName + } + posts = append(posts, hit{Title: text, Detail: detail, Link: link, Badge: d.Status}) + } + + var settings []hit + if p, err := profile.Load(s.DB); err == nil && p.IsSet() { + for _, pr := range p.Products { + if matches(pr.Name, pr.Description) { + settings = append(settings, hit{Title: pr.Name, Detail: "Product, in the company profile", Link: "/settings/profile", Badge: "product"}) + } + } + } + for _, sp := range settingsPages { + if matches(sp.Title, sp.Detail, sp.Words) { + settings = append(settings, sp.hit) + } + } + + var groups []hitGroup + for _, g := range []hitGroup{{"Posts", posts}, {"Fetched items", found}, {"Inventory", inv}, {"Settings", settings}} { + if len(g.Hits) > 0 { + groups = append(groups, g) + } + } + return groups, nil +} diff --git a/internal/web/server.go b/internal/web/server.go index 2c470bf..e8f5304 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -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) { diff --git a/internal/web/server_test.go b/internal/web/server_test.go index 8cdf637..cb23c11 100644 --- a/internal/web/server_test.go +++ b/internal/web/server_test.go @@ -11,12 +11,15 @@ import ( "path/filepath" "strings" "testing" + "time" "supermarket/internal/bridge" + "supermarket/internal/content" "supermarket/internal/core" "supermarket/internal/db" "supermarket/internal/inventory" "supermarket/internal/mcpserver" + "supermarket/internal/models" "supermarket/internal/profile" "supermarket/internal/secrets" ) @@ -86,9 +89,9 @@ func TestEveryPageRenders(t *testing.T) { t.Fatal(err) } - for _, path := range []string{"/", "/?msg=saved", "/profile", "/inventory", "/inventory?relationship=partner", + for _, path := range []string{"/", "/?msg=saved", "/settings/profile", "/inventory", "/inventory?relationship=partner", "/inventory/new", "/inventory/1", "/inventory/import", "/inventory/export", - "/settings/ai", "/settings/credentials", "/core", "/static/app.css", "/static/htmx.min.js", "/healthz", + "/settings/ai", "/settings/accounts", "/settings/core", "/static/app.css", "/search", "/search?q=rival", "/search?q=nothing+here", "/static/htmx.min.js", "/healthz", "/content", "/content/1", "/content/1?dismissed=1", "/inbox", "/inbox?msg=drafted", "/content/scheduled", "/content/published"} { rec := do(h, http.MethodGet, path, nil, nil) @@ -114,21 +117,21 @@ func TestGuardRejectsForeignHostsAndCrossSitePosts(t *testing.T) { } form := url.Values{"name": {"Acme"}, "description": {"x"}} - rec = do(h, http.MethodPost, "/profile", strings.NewReader(form.Encode()), map[string]string{ + rec = do(h, http.MethodPost, "/settings/profile", strings.NewReader(form.Encode()), map[string]string{ "Content-Type": "application/x-www-form-urlencoded", "Origin": "https://evil.example", }) if rec.Code != http.StatusForbidden { t.Errorf("cross-origin POST: got %d", rec.Code) } - rec = do(h, http.MethodPost, "/profile", strings.NewReader(form.Encode()), map[string]string{ + rec = do(h, http.MethodPost, "/settings/profile", strings.NewReader(form.Encode()), map[string]string{ "Content-Type": "application/x-www-form-urlencoded", "Sec-Fetch-Site": "cross-site", }) if rec.Code != http.StatusForbidden { t.Errorf("cross-site POST without Origin: got %d", rec.Code) } - if rec := postForm(h, "/profile", form); rec.Code != http.StatusSeeOther { + if rec := postForm(h, "/settings/profile", form); rec.Code != http.StatusSeeOther { t.Errorf("same-origin POST: got %d %s", rec.Code, rec.Body.String()) } } @@ -144,7 +147,7 @@ func TestProfileAndInventoryForms(t *testing.T) { "website_branch": {"", ""}, "website_plausible": {"", ""}, "website_gsc": {"", ""}, "website_bing": {"", ""}, "account_x": {"@acme"}, "subreddits": {"r/selfhosted\n/r/homelab"}, } - if rec := postForm(h, "/profile", form); rec.Code != http.StatusSeeOther { + if rec := postForm(h, "/settings/profile", form); rec.Code != http.StatusSeeOther { t.Fatalf("save profile: %d %s", rec.Code, rec.Body.String()) } p, _ := profile.Load(s.DB) @@ -162,7 +165,7 @@ func TestProfileAndInventoryForms(t *testing.T) { } // Missing description: the form comes back with an error, nothing saved. - rec := postForm(h, "/profile", url.Values{"name": {"Other"}}) + rec := postForm(h, "/settings/profile", url.Values{"name": {"Other"}}) if rec.Code != http.StatusOK || !strings.Contains(rec.Body.String(), "required") { t.Errorf("invalid profile: %d", rec.Code) } @@ -196,20 +199,88 @@ func TestProfileAndInventoryForms(t *testing.T) { } } -func TestCredentialsKeepAndRemove(t *testing.T) { +func TestAccountsKeepAndRemove(t *testing.T) { s, h := newTestServer(t, nil) - postForm(h, "/settings/credentials", url.Values{secrets.AnthropicAPIKey: {" sk-1 "}, secrets.YouTubeAPIKey: {"yt"}}) + postForm(h, "/settings/accounts", url.Values{secrets.XClientID: {" id-1 "}, secrets.YouTubeAPIKey: {"yt"}}) // Empty field keeps the value; remove clears it. - postForm(h, "/settings/credentials", url.Values{secrets.AnthropicAPIKey: {""}, "remove:" + secrets.YouTubeAPIKey: {"on"}}) - if got := s.Secrets.Get(secrets.AnthropicAPIKey); got != "sk-1" { - t.Errorf("anthropic key = %q", got) + postForm(h, "/settings/accounts", url.Values{secrets.XClientID: {""}, "remove:" + secrets.YouTubeAPIKey: {"on"}}) + if got := s.Secrets.Get(secrets.XClientID); got != "id-1" { + t.Errorf("x client id = %q", got) } if s.Secrets.Has(secrets.YouTubeAPIKey) { t.Error("youtube key should be removed") } - page := do(h, http.MethodGet, "/settings/credentials", nil, nil).Body.String() - if strings.Contains(page, "sk-1") { - t.Error("the credentials page must never show a saved value") + // The AI keys aren't on this tab, so it can't change them. + postForm(h, "/settings/accounts", url.Values{secrets.AnthropicAPIKey: {"sk-x"}}) + if s.Secrets.Has(secrets.AnthropicAPIKey) { + t.Error("the accounts form saved an AI key") + } + page := do(h, http.MethodGet, "/settings/accounts", nil, nil).Body.String() + if strings.Contains(page, "id-1") { + t.Error("the accounts page must never show a saved value") + } +} + +func TestAIKeysOnTheAITab(t *testing.T) { + s, h := newTestServer(t, nil) + form := url.Values{"provider": {"anthropic"}, "model": {"claude-opus-5-5"}, "effort": {"medium"}, + secrets.AnthropicAPIKey: {" sk-1 "}} + if rec := postForm(h, "/settings/ai", form); rec.Code != http.StatusSeeOther { + t.Fatalf("save: %d %s", rec.Code, rec.Body.String()) + } + if got := s.Secrets.Get(secrets.AnthropicAPIKey); got != "sk-1" { + t.Errorf("anthropic key = %q", got) + } + // A form that needs fixing still keeps the key typed into it. + rec := postForm(h, "/settings/ai", url.Values{"provider": {"openai"}, "model": {"m"}, secrets.OpenAIAPIKey: {"ok-2"}}) + if rec.Code != http.StatusOK || s.Secrets.Get(secrets.OpenAIAPIKey) != "ok-2" { + t.Errorf("openai without address: %d, key %q", rec.Code, s.Secrets.Get(secrets.OpenAIAPIKey)) + } + postForm(h, "/settings/ai", url.Values{"provider": {"anthropic"}, "model": {"m"}, "remove:" + secrets.AnthropicAPIKey: {"on"}}) + if s.Secrets.Has(secrets.AnthropicAPIKey) { + t.Error("anthropic key should be removed") + } + if page := do(h, http.MethodGet, "/settings/ai", nil, nil).Body.String(); strings.Contains(page, "ok-2") { + t.Error("the AI page must never show a saved key") + } +} + +func TestOldAddressesRedirect(t *testing.T) { + _, h := newTestServer(t, nil) + for old, now := range map[string]string{"/profile": "/settings/profile", "/core": "/settings/core", + "/settings/credentials": "/settings/accounts", "/settings": "/settings/profile"} { + rec := do(h, http.MethodGet, old, nil, nil) + if rec.Code/100 != 3 || rec.Header().Get("Location") != now { + t.Errorf("%s: %d → %q", old, rec.Code, rec.Header().Get("Location")) + } + } +} + +func TestSearch(t *testing.T) { + s, h := newTestServer(t, nil) + if err := inventory.Save(s.DB, &inventory.Entry{Name: "Rival Corp", Relationship: "competitor", Description: "Makes gadgets."}); err != nil { + t.Fatal(err) + } + if _, err := content.SaveItems(s.DB, []models.ContentItem{{ID: "rss:1", AppName: "Rival Corp", Source: models.SourceRSS, + Title: "Gadget 2 launches", Body: "Faster gadgets for everyone", PublishedAt: time.Now()}}); err != nil { + t.Fatal(err) + } + if _, err := content.CreateDrafts(s.DB, []content.Draft{{InventoryName: "Rival Corp", Kind: "competitor", + Channel: "x", Content: "Our widgets beat any gadget"}}); err != nil { + t.Fatal(err) + } + body := do(h, http.MethodGet, "/search?q=GADGET", nil, nil).Body.String() + for _, want := range []string{"Rival Corp", "Gadget 2 launches", "Our widgets beat any gadget", `href="/content/1"`, `href="/inbox"`} { + if !strings.Contains(body, want) { + t.Errorf("search for gadget: missing %q", want) + } + } + // Every word must match. + if body := do(h, http.MethodGet, "/search?q=gadget+launches", nil, nil).Body.String(); strings.Contains(body, "Our widgets") { + t.Error("a draft without \"launches\" matched") + } + if body := do(h, http.MethodGet, "/search?q=anthropic+key", nil, nil).Body.String(); !strings.Contains(body, `href="/settings/ai"`) { + t.Error("settings search should find the AI tab") } } @@ -258,12 +329,12 @@ func TestMCPNeedsTokenAndChecksIn(t *testing.T) { func TestProfileDraftNeedsAI(t *testing.T) { s, h := newTestServer(t, nil) - body := do(h, http.MethodGet, "/profile", nil, nil).Body.String() + body := do(h, http.MethodGet, "/settings/profile", nil, nil).Body.String() if !strings.Contains(body, `choose an AI provider`) || !strings.Contains(body, `class="secondary" disabled>Draft`) { t.Errorf("profile without AI:\n%s", body) } _ = s.Secrets.Set(map[string]string{secrets.AnthropicAPIKey: "k"}) - if body := do(h, http.MethodGet, "/profile", nil, nil).Body.String(); strings.Contains(body, "choose an AI provider") { + if body := do(h, http.MethodGet, "/settings/profile", nil, nil).Body.String(); strings.Contains(body, "choose an AI provider") { t.Error("warning shown with an AI key saved") } } diff --git a/internal/web/settings.go b/internal/web/settings.go index 0840350..082992f 100644 --- a/internal/web/settings.go +++ b/internal/web/settings.go @@ -31,13 +31,15 @@ func (s *Server) aiPage(w http.ResponseWriter, r *http.Request) { } func (s *Server) renderAI(w http.ResponseWriter, r *http.Request, cfg ai.Config, errMsg string) { - s.render(w, r, "ai", page{Title: "AI provider", Nav: "settings", Error: errMsg, Data: map[string]any{ + s.render(w, r, "ai", page{Title: "AI", Nav: "settings/ai", Error: errMsg, Data: map[string]any{ "Cfg": cfg, "AnthropicModels": anthropicModels, "Efforts": efforts, "Tasks": ai.Tasks, "Servers": s.aiServers(), "HasAnthropicKey": s.Secrets.Has(secrets.AnthropicAPIKey), + "Keys": aiKeys, + "Set": s.secretState(secrets.AnthropicAPIKey, secrets.OpenAIAPIKey), "Shared": ai.LoadShared(), }}) } @@ -70,6 +72,11 @@ func (s *Server) aiSave(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusBadRequest) return } + // Keys first: they're kept even if the rest of the form needs fixing. + if err := s.saveSecrets(r, aiKeys); err != nil { + s.serverError(w, err) + return + } cfg := aiFromForm(r) switch { case cfg.Model == "": @@ -132,52 +139,37 @@ func (s *Server) aiModels(w http.ResponseWriter, r *http.Request) { s.fragment(w, "ai", "model-list", data) } -// --- Credentials --- +// --- Secrets forms --- -// credentialFields are the secrets the credentials form edits, in order. -var credentialFields = []struct { +// secretField is one secret a settings form edits. Saved values are never +// shown: an empty field keeps what's saved. +type secretField struct { Group, Name, Label, Help string -}{ - {"AI", secrets.AnthropicAPIKey, "Anthropic API key", "From console.anthropic.com."}, - {"AI", secrets.OpenAIAPIKey, "API key for an OpenAI-compatible server", "Only if your server asks for one (Ollama and LM Studio don't)."}, +} + +// aiKeys are edited on the AI tab. +var aiKeys = []secretField{ + {"anthropic", secrets.AnthropicAPIKey, "Anthropic API key", "From console.anthropic.com."}, + {"openai", secrets.OpenAIAPIKey, "API key for the server", "Only if your server asks for one (Ollama and LM Studio don't)."}, +} + +// accountFields are edited on the Social accounts tab, by network. +var accountFields = []secretField{ {"X", secrets.XBearerToken, "Bearer token", "For reading posts. Needs an X API plan with read access."}, {"X", secrets.XClientID, "OAuth 2.0 client ID", "For posting. From your app in the X developer portal."}, {"X", secrets.XClientSecret, "OAuth 2.0 client secret", "Only for confidential clients; leave empty for a public client."}, {"LinkedIn", secrets.LinkedInClientID, "Client ID", "From your app at linkedin.com/developers."}, {"LinkedIn", secrets.LinkedInClientSecret, "Client secret", ""}, - {"YouTube", secrets.YouTubeAPIKey, "API key", "Free, from console.cloud.google.com (YouTube Data API v3)."}, {"Reddit", secrets.RedditClientID, "Client ID", "From a \"web app\" at reddit.com/prefs/apps: the string under the app's name."}, {"Reddit", secrets.RedditClientSecret, "Client secret", ""}, + {"YouTube", secrets.YouTubeAPIKey, "API key", "Free, from console.cloud.google.com (YouTube Data API v3). For reading channels' videos."}, } -func (s *Server) credentialsPage(w http.ResponseWriter, r *http.Request) { - names := make([]string, 0, len(credentialFields)+2) - for _, f := range credentialFields { - names = append(names, f.Name) - } - names = append(names, secrets.XAccessToken, secrets.LinkedInAccessToken, secrets.RedditAccessToken) - s.render(w, r, "credentials", page{Title: "Credentials", Nav: "settings", Data: map[string]any{ - "Fields": credentialFields, - "Set": s.secretState(names...), - "Connections": s.connections(), - "XRedirect": s.PublicURL + "/auth/x/callback", - "LIRedirect": s.PublicURL + "/auth/linkedin/callback", - "RedditRedirect": s.PublicURL + "/auth/reddit/callback", - "RedditToken": secrets.RedditAccessToken, - "XToken": secrets.XAccessToken, - "LIToken": secrets.LinkedInAccessToken, - }}) -} - -// credentialsSave stores what was typed. An empty field keeps the saved -// value; "remove" clears it. -func (s *Server) credentialsSave(w http.ResponseWriter, r *http.Request) { - if err := r.ParseForm(); err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } +// saveSecrets stores what was typed into these fields. An empty field keeps +// the saved value; "remove:" clears it. +func (s *Server) saveSecrets(r *http.Request, fields []secretField) error { updates := map[string]string{} - for _, f := range credentialFields { + for _, f := range fields { if r.PostForm.Get("remove:"+f.Name) == "on" { updates[f.Name] = "" continue @@ -186,13 +178,91 @@ func (s *Server) credentialsSave(w http.ResponseWriter, r *http.Request) { updates[f.Name] = v } } - if len(updates) > 0 { - if err := s.Secrets.Set(updates); err != nil { - s.serverError(w, err) - return + if len(updates) == 0 { + return nil + } + return s.Secrets.Set(updates) +} + +// --- Social accounts --- + +// network is one card on the Social accounts tab: its keys, and the sign-in +// that lets Supermarket post as you. +type network struct { + Name string + Fields []secretField + Connect *connectInfo // nil: read-only, no sign-in +} + +type connectInfo struct { + Provider string // the /auth/{provider} path segment + Redirect string // the callback URL to register with the network + Setup string // where to register it + Ready bool // the keys the sign-in needs are saved + Signed bool // a token is saved + Account string + At time.Time + Note string +} + +func (s *Server) accountsPage(w http.ResponseWriter, r *http.Request) { + names := []string{secrets.XAccessToken, secrets.LinkedInAccessToken, secrets.RedditAccessToken} + for _, f := range accountFields { + names = append(names, f.Name) + } + set := s.secretState(names...) + conns := s.connections() + connect := func(provider, token, setup, note string, ready bool, account func(string) string) *connectInfo { + c := conns[provider] + return &connectInfo{Provider: provider, Redirect: s.PublicURL + "/auth/" + provider + "/callback", + Setup: setup, Note: note, Ready: ready, Signed: set[token], Account: account(c.Account), At: c.At} + } + at := func(prefix string) func(string) string { + return func(a string) string { + if a == "" { + return "" + } + return prefix + a } } - redirect(w, r, "/settings/credentials", "saved") + var nets []network + for _, name := range []string{"X", "LinkedIn", "Reddit", "YouTube"} { + n := network{Name: name} + for _, f := range accountFields { + if f.Group == name { + n.Fields = append(n.Fields, f) + } + } + switch name { + case "X": + n.Connect = connect("x", secrets.XAccessToken, "In the X developer portal, add this callback URL to your app:", "", + set[secrets.XClientID], at("@")) + case "LinkedIn": + n.Connect = connect("linkedin", secrets.LinkedInAccessToken, "In your LinkedIn app's Auth settings, add this redirect URL:", "", + set[secrets.LinkedInClientID] && set[secrets.LinkedInClientSecret], func(string) string { return "" }) + case "Reddit": + n.Connect = connect("reddit", secrets.RedditAccessToken, "At reddit.com/prefs/apps, create a web app with this redirect URI:", + "Reddit's API terms need approval for commercial use: Supermarket is meant for a few hand-approved posts, not volume.", + set[secrets.RedditClientID] && set[secrets.RedditClientSecret], at("u/")) + } + nets = append(nets, n) + } + s.render(w, r, "accounts", page{Title: "Social accounts", Nav: "settings/accounts", Data: map[string]any{ + "Networks": nets, + "Set": set, + }}) +} + +func (s *Server) accountsSave(w http.ResponseWriter, r *http.Request) { + if err := r.ParseForm(); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if err := s.saveSecrets(r, accountFields); err != nil { + s.serverError(w, err) + return + } + redirect(w, r, "/settings/accounts", "saved") } // --- OAuth --- @@ -256,12 +326,12 @@ func (s *Server) oauthCallback(w http.ResponseWriter, r *http.Request) { delete(s.pending, q.Get("state")) // a state is good for one callback s.mu.Unlock() if p == nil || p.Provider != provider || time.Since(p.Started) > oauthTTL { - redirect(w, r, "/settings/credentials", "oauth-expired") + redirect(w, r, "/settings/accounts", "oauth-expired") return } fail := func(msg string) { - s.render(w, r, "message", page{Title: "Sign-in failed", Nav: "settings", Error: msg, - Data: map[string]string{"Back": "/settings/credentials"}}) + s.render(w, r, "message", page{Title: "Sign-in failed", Nav: "settings/accounts", Error: msg, + Data: map[string]string{"Back": "/settings/accounts"}}) } if e := q.Get("error"); e != "" { fail("The provider said: " + e + " " + q.Get("error_description")) @@ -295,7 +365,7 @@ func (s *Server) oauthCallback(w http.ResponseWriter, r *http.Request) { if err := s.saveConnection("x", Connection{Account: account, At: time.Now()}); err != nil { s.Log.Error("saving connection", "err", err) } - redirect(w, r, "/settings/credentials", "x-connected") + redirect(w, r, "/settings/accounts", "x-connected") case "linkedin": res, err := oauth.LinkedInExchange(ctx, s.Secrets.Get(secrets.LinkedInClientID), s.Secrets.Get(secrets.LinkedInClientSecret), code, p) if err != nil { @@ -314,7 +384,7 @@ func (s *Server) oauthCallback(w http.ResponseWriter, r *http.Request) { if err := s.saveConnection("linkedin", Connection{Account: urn, At: time.Now()}); err != nil { s.Log.Error("saving connection", "err", err) } - redirect(w, r, "/settings/credentials", "li-connected") + redirect(w, r, "/settings/accounts", "li-connected") case "reddit": res, err := oauth.RedditExchange(ctx, s.Secrets.Get(secrets.RedditClientID), s.Secrets.Get(secrets.RedditClientSecret), s.redditUserAgent(), code, p) @@ -336,7 +406,7 @@ func (s *Server) oauthCallback(w http.ResponseWriter, r *http.Request) { if err := s.saveConnection("reddit", Connection{Account: name, At: time.Now()}); err != nil { s.Log.Error("saving connection", "err", err) } - redirect(w, r, "/settings/credentials", "reddit-connected") + redirect(w, r, "/settings/accounts", "reddit-connected") default: http.NotFound(w, r) } diff --git a/internal/web/static/app.css b/internal/web/static/app.css index a2d14b9..8372171 100644 --- a/internal/web/static/app.css +++ b/internal/web/static/app.css @@ -1,94 +1,265 @@ -/* Supermarket. Colors follow the Federated sites: a navy bar, a magenta - accent and a cyan primary button. */ +/* Supermarket. The look follows brain (Federated's superbrain): its colour + tokens, type, radius and shadows, a sidebar with search at the top and + Settings at the bottom, and a top bar with breadcrumbs. Colours are HSL + triples so they can take an alpha: hsl(var(--primary) / 0.2). */ :root { - --navy: #0b1d3a; - --navy-2: #13294f; - --magenta: #c2187a; - --cyan: #0891b2; - --cyan-dark: #0e7490; - --ink: #1b2433; - --muted: #5b6577; - --line: #dde2ea; - --band: #f4f6f9; - --ok: #157f3b; - --bad: #b42318; - --warn-bg: #fff6e5; - --radius: 10px; - font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; - color: var(--ink); - background: var(--band); + --background: 0 0% 100%; + --foreground: 240 10% 3.9%; + --card: 0 0% 100%; + --primary: 245 58% 51%; + --primary-foreground: 0 0% 100%; + --secondary: 240 4.8% 95.9%; + --muted: 240 4.8% 95.9%; + --muted-foreground: 240 3.8% 44.1%; + --accent: 245 58% 95%; + --accent-foreground: 245 58% 51%; + --destructive: 0 72% 51%; + --border: 240 5.9% 90%; + --input: 240 5.9% 86%; + --ring: 245 58% 51%; + --sidebar: 245 30% 97%; + --sidebar-foreground: 240 10% 20%; + --ok: 142 71% 29%; + --ok-bg: 142 60% 95%; + --warn: 32 95% 30%; + --warn-bg: 40 100% 95%; + --warn-border: 38 90% 75%; + --bad-bg: 0 85% 97%; + --bad-border: 0 80% 85%; + --teal: 173 58% 33%; + --teal-bg: 173 50% 94%; + --coral: 12 70% 45%; + --coral-bg: 12 80% 95%; + + --radius: 0.625rem; + --radius-sm: calc(0.625rem - 4px); + --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03), 0 1px 3px 0 rgb(0 0 0 / 0.06); + --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05); + --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.05); + --fast: 150ms; + + --font-sans: "DM Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + --font-display: "Plus Jakarta Sans", var(--font-sans); + --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace; + color-scheme: light; } -* { box-sizing: border-box; } -body { margin: 0; line-height: 1.5; } -a { color: var(--cyan-dark); } -code, pre { font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; font-size: 0.9em; } -pre { background: var(--navy); color: #e6edf7; padding: 0.9rem 1rem; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; } -.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 2rem; padding: 0.8rem 1.5rem; flex-wrap: wrap; } -.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: -0.01em; } -.brand span { color: #f472b6; } -.topbar nav { display: flex; gap: 0.25rem; flex-wrap: wrap; } -.topbar nav a { color: #c9d4e6; text-decoration: none; padding: 0.35rem 0.75rem; border-radius: 6px; } -.topbar nav a:hover { background: var(--navy-2); color: #fff; } -.topbar nav a[aria-current="page"] { background: var(--navy-2); color: #fff; box-shadow: inset 0 -2px 0 var(--magenta); } +/* Dark: brain's readability pass, body text at about 13:1 rather than a + glaring near-white on near-black. */ +@media (prefers-color-scheme: dark) { + :root { + --background: 240 6% 10%; + --foreground: 0 0% 92%; + --card: 240 5% 13%; + --primary: 245 60% 60%; + --primary-foreground: 0 0% 100%; + --secondary: 240 4% 19%; + --muted: 240 4% 19%; + --muted-foreground: 240 5% 64.9%; + --accent: 245 30% 20%; + --accent-foreground: 245 60% 75%; + --destructive: 0 70% 62%; + --border: 240 4% 19%; + --input: 240 4% 25%; + --ring: 245 60% 60%; + --sidebar: 240 6% 8%; + --sidebar-foreground: 0 0% 85%; + --ok: 142 55% 55%; + --ok-bg: 142 30% 14%; + --warn: 38 90% 65%; + --warn-bg: 35 40% 13%; + --warn-border: 35 50% 30%; + --bad-bg: 0 40% 14%; + --bad-border: 0 45% 32%; + --teal: 160 60% 55%; + --teal-bg: 160 30% 14%; + --coral: 20 80% 65%; + --coral-bg: 20 40% 14%; + --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.15), 0 1px 2px -1px rgb(0 0 0 / 0.15); + --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.15); + --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.25), 0 4px 6px -4px rgb(0 0 0 / 0.15); + color-scheme: dark; + } +} -main { max-width: 1080px; margin: 0 auto; padding: 1.5rem; } -footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 2rem 0; } -h1 { font-size: 1.7rem; margin: 0.5rem 0 0.75rem; letter-spacing: -0.02em; } -h2 { font-size: 1.2rem; margin: 0 0 0.75rem; } -h3 { font-size: 1.05rem; margin: 0 0 0.5rem; } -.lede { color: var(--muted); margin-top: 0; } -.help { display: block; color: var(--muted); font-size: 0.85rem; font-weight: normal; margin-top: 0.2rem; } +/* --- Base --- */ +* { box-sizing: border-box; border-color: hsl(var(--border)); } +html { font-size: 106.25%; } /* 17px, as brain */ +body { + margin: 0; line-height: 1.55; font-family: var(--font-sans); + background: hsl(var(--background)); color: hsl(var(--foreground)); + -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; +} +::selection { background: hsl(var(--primary) / 0.2); color: hsl(var(--primary)); } +a { color: hsl(var(--primary)); text-underline-offset: 3px; } +a:hover { text-decoration-thickness: 2px; } +code, pre, kbd { font-family: var(--font-mono); font-size: 0.85em; } +code { background: hsl(var(--muted)); padding: 0.05rem 0.3rem; border-radius: var(--radius-sm); } +pre { background: hsl(var(--muted)); border: 1px solid hsl(var(--border)); padding: 0.9rem 1rem; border-radius: var(--radius); overflow-x: auto; white-space: pre-wrap; } +pre code { background: none; padding: 0; } +.icon { width: 1rem; height: 1rem; flex: none; } +:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; } -.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin: 0 0 1.25rem; } -.card.warn, .warn { background: var(--warn-bg); border-color: #f5d49a; } -.card.empty { text-align: center; color: var(--muted); } +h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; line-height: 1.25; } +h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 0.4rem; } +h2 { font-size: 1.15rem; font-weight: 650; margin: 0 0 0.75rem; } +h3 { font-size: 1rem; font-weight: 650; margin: 0 0 0.5rem; letter-spacing: -0.01em; } +.lede { color: hsl(var(--muted-foreground)); margin: 0 0 1.25rem; font-size: 0.95rem; } +.help { display: block; color: hsl(var(--muted-foreground)); font-size: 0.82rem; font-weight: normal; margin-top: 0.25rem; } +.muted { color: hsl(var(--muted-foreground)); } +.small { font-size: 0.85rem; } + +/* --- Shell: sidebar, top bar, main --- */ +.shell { display: flex; height: 100dvh; overflow: hidden; } +.sidebar { + width: 15rem; flex: none; display: flex; flex-direction: column; + background: hsl(var(--sidebar)); color: hsl(var(--sidebar-foreground)); + border-right: 1px solid hsl(var(--border)); +} +.brand { display: flex; align-items: center; gap: 0.55rem; padding: 0.85rem 0.9rem 0.7rem; color: inherit; text-decoration: none; + font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; letter-spacing: -0.02em; } +.brand .logo { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: var(--radius-sm); background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); } +.brand .logo .icon { width: 0.9rem; height: 0.9rem; } + +.search { position: relative; margin: 0 0.6rem 0.4rem; display: flex; align-items: center; } +.search .icon { position: absolute; left: 0.65rem; color: hsl(var(--muted-foreground)); pointer-events: none; } +.search input { + margin: 0; padding: 0.4rem 2rem 0.4rem 2.1rem; font-size: 0.88rem; + background: hsl(var(--muted) / 0.4); border: 1px solid hsl(var(--border) / 0.8); border-radius: var(--radius); +} +.search input:hover { background: hsl(var(--muted)); } +.search input:focus { background: hsl(var(--background)); } +.search kbd { position: absolute; right: 0.5rem; font-size: 0.65rem; color: hsl(var(--muted-foreground)); border: 1px solid hsl(var(--border)); background: hsl(var(--background)); border-radius: 4px; padding: 0 0.3rem; } +.search input:focus ~ kbd { display: none; } + +.nav { flex: 1; overflow-y: auto; padding: 0.4rem 0.5rem; display: flex; flex-direction: column; gap: 1px; } +.nav-label { padding: 0.9rem 0.6rem 0.3rem; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: hsl(var(--muted-foreground)); } +.nav a, .nav .soon, .sidebar-foot a { + display: flex; align-items: center; gap: 0.55rem; padding: 0.38rem 0.6rem; border-radius: var(--radius); + color: hsl(var(--muted-foreground)); text-decoration: none; font-size: 0.9rem; transition: background var(--fast), color var(--fast); +} +.nav a:hover, .sidebar-foot a:hover { background: hsl(var(--accent) / 0.6); color: hsl(var(--foreground)); } +.nav a[aria-current="page"], .sidebar-foot a[aria-current="page"] { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 600; } +.nav a.open { color: hsl(var(--foreground)); font-weight: 600; } +.nav .soon { cursor: default; opacity: 0.6; } +.nav .soon small { margin-left: auto; font-size: 0.68rem; } +.subnav { margin: 1px 0 4px 1.1rem; padding-left: 0.55rem; border-left: 1px solid hsl(var(--border)); display: flex; flex-direction: column; gap: 1px; } +.subnav a { padding: 0.28rem 0.55rem; font-size: 0.86rem; } +.sidebar-foot { border-top: 1px solid hsl(var(--border)); padding: 0.5rem; } +.version { margin: 0.3rem 0.6rem 0; font-size: 0.68rem; color: hsl(var(--muted-foreground) / 0.8); } +.count-badge { margin-left: auto; min-width: 1.25rem; padding: 0 0.35rem; border-radius: 999px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: 0.7rem; font-weight: 700; text-align: center; line-height: 1.25rem; } + +.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; } +.topbar { display: flex; align-items: center; gap: 0.5rem; min-height: 2.9rem; padding: 0.4rem 1.25rem; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--card)); } +.crumbs { display: flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; min-width: 0; color: hsl(var(--muted-foreground)); } +.crumbs .here { color: hsl(var(--foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.crumbs .sep { opacity: 0.6; } +.menu-button { display: none; } +main { flex: 1; overflow: auto; padding: 1.5rem 2rem 3rem; } +main > * { max-width: 72rem; } +.scrim { display: none; } + +/* Narrow screens: the sidebar slides in over the page. */ +@media (max-width: 900px) { + .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform 250ms ease; box-shadow: var(--shadow-lg); } + body.nav-open .sidebar { transform: none; } + body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 0.45); } + .menu-button { display: inline-grid; } + main { padding: 1rem 1rem 2.5rem; } +} + +/* --- Page parts --- */ +.page-head { margin-bottom: 1.25rem; } +.heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.4rem; } +.heading h1 { margin: 0; } +.buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; } +.buttons form { margin: 0; } + +.card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem 1.4rem; margin: 0 0 1.25rem; } +.card.warn, .warn { background: hsl(var(--warn-bg)); border-color: hsl(var(--warn-border)); } +.card.empty { text-align: center; color: hsl(var(--muted-foreground)); padding: 2.5rem 1.4rem; box-shadow: none; border-style: dashed; } details.card > summary { cursor: pointer; font-weight: 600; } details.card[open] > summary { margin-bottom: 0.75rem; } -.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; } -.module p { color: var(--muted); margin: 0; } -.heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; } -.buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; } +.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; } +a.card { display: block; color: inherit; text-decoration: none; transition: box-shadow 250ms, transform 250ms, border-color 250ms; } +a.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: hsl(var(--primary) / 0.25); } +.module { margin: 0; display: flex; flex-direction: column; gap: 0.4rem; } +.module h3 { display: flex; align-items: center; gap: 0.5rem; margin: 0; } +.module h3 .icon { color: hsl(var(--primary)); } +.module h3 .badge { margin-left: auto; } +.module p { color: hsl(var(--muted-foreground)); margin: 0; font-size: 0.9rem; } +.module .stat { color: hsl(var(--foreground)); font-size: 0.85rem; font-weight: 600; margin-top: auto; padding-top: 0.4rem; } +.module.later { box-shadow: none; background: transparent; border-style: dashed; } +.module.later h3 .icon { color: hsl(var(--muted-foreground)); } -.flash { background: #e7f6ed; border: 1px solid #a8dcb9; color: #0f5a2a; padding: 0.6rem 0.9rem; border-radius: 8px; } -.error { background: #fdecea; border: 1px solid #f3b5ae; color: var(--bad); padding: 0.6rem 0.9rem; border-radius: 8px; } -.ok { color: var(--ok); } -.warn-text { color: #8a5300; } +.flash, .error { padding: 0.6rem 0.9rem; border-radius: var(--radius); border: 1px solid; font-size: 0.92rem; } +.flash { background: hsl(var(--ok-bg)); border-color: hsl(var(--ok) / 0.35); color: hsl(var(--ok)); } +.error { background: hsl(var(--bad-bg)); border-color: hsl(var(--bad-border)); color: hsl(var(--destructive)); } +.ok { color: hsl(var(--ok)); } +.warn-text { color: hsl(var(--warn)); } .steps { list-style: none; margin: 0; padding: 0; } -.steps li { display: flex; gap: 1rem; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px solid var(--line); } +.steps li { display: flex; gap: 1rem; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px solid hsl(var(--border)); } .steps li:last-child { border-bottom: 0; } -.steps li::before { content: "○"; color: var(--muted); width: 1.2rem; flex: none; } -.steps li.done::before { content: "✓"; color: var(--ok); font-weight: 700; } -.steps li a { min-width: 11rem; color: var(--ink); text-decoration: none; } -.steps li span { color: var(--muted); } +.steps li::before { content: "○"; color: hsl(var(--muted-foreground)); width: 1.2rem; flex: none; } +.steps li.done::before { content: "✓"; color: hsl(var(--ok)); font-weight: 700; } +.steps li a { min-width: 11rem; color: hsl(var(--foreground)); text-decoration: none; } +.steps li a:hover { color: hsl(var(--primary)); } +.steps li span { color: hsl(var(--muted-foreground)); font-size: 0.92rem; } -.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--band); color: var(--muted); vertical-align: middle; } -.badge.partner { background: #e0f2f7; color: var(--cyan-dark); } -.badge.competitor { background: #fbe4f0; color: var(--magenta); } -.badge.watch { background: #eef0f4; color: var(--muted); } -.badge.product { background: #e7f6ed; color: var(--ok); } +.badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.08rem 0.55rem; border-radius: 999px; background: hsl(var(--secondary)); color: hsl(var(--muted-foreground)); vertical-align: middle; white-space: nowrap; } +.badge.partner { background: hsl(var(--teal-bg)); color: hsl(var(--teal)); } +.badge.competitor { background: hsl(var(--coral-bg)); color: hsl(var(--coral)); } +.badge.product, .badge.published { background: hsl(var(--ok-bg)); color: hsl(var(--ok)); } +.badge.scheduled, .badge.draft { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); } +.badge.failed { background: hsl(var(--bad-bg)); color: hsl(var(--destructive)); } -.tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; } -.tabs a { padding: 0.45rem 0.9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; text-transform: capitalize; } -.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--magenta); font-weight: 600; } +.tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid hsl(var(--border)); flex-wrap: wrap; } +.tabs a { padding: 0.45rem 0.85rem; text-decoration: none; color: hsl(var(--muted-foreground)); border-bottom: 2px solid transparent; margin-bottom: -1px; text-transform: capitalize; font-size: 0.92rem; } +.tabs a:hover { color: hsl(var(--foreground)); } +.tabs a[aria-current="page"] { color: hsl(var(--foreground)); border-color: hsl(var(--primary)); font-weight: 600; } -table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; } -table.list th, table.list td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; } -table.list th { background: var(--band); font-size: 0.85rem; color: var(--muted); font-weight: 600; } +table.list { width: 100%; border-collapse: separate; border-spacing: 0; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); font-size: 0.92rem; } +table.list th, table.list td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid hsl(var(--border)); vertical-align: top; } +table.list th { background: hsl(var(--muted) / 0.6); font-size: 0.78rem; color: hsl(var(--muted-foreground)); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; } table.list tr:last-child td { border-bottom: 0; } +table.list tbody tr:hover { background: hsl(var(--muted) / 0.35); } -label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.9rem; } -input, select, textarea { display: block; width: 100%; margin-top: 0.3rem; font: inherit; font-weight: normal; padding: 0.5rem 0.65rem; border: 1px solid #c5ccd8; border-radius: 7px; background: #fff; color: var(--ink); } -textarea { resize: vertical; } -input:focus, select:focus, textarea:focus { outline: 2px solid var(--cyan); outline-offset: 0; border-color: var(--cyan); } -input[type="checkbox"], input[type="radio"] { display: inline; width: auto; margin: 0 0.4rem 0 0; } +/* --- Settings: grouped tabs on the left, the section on the right --- */ +.settings { display: flex; gap: 2rem; align-items: flex-start; } +.settings-nav { width: 14rem; flex: none; display: flex; flex-direction: column; gap: 1px; padding: 0.5rem; border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card) / 0.5); position: sticky; top: 0; } +.settings-nav .nav-label { padding: 0.7rem 0.75rem 0.25rem; } +.settings-nav .nav-label:first-child { padding-top: 0.25rem; } +.settings-nav a { display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.75rem; border-radius: var(--radius-sm); color: hsl(var(--muted-foreground)); text-decoration: none; font-size: 0.9rem; } +.settings-nav a .icon { width: 0.9rem; height: 0.9rem; } +.settings-nav a:hover { background: hsl(var(--accent) / 0.6); color: hsl(var(--foreground)); } +.settings-nav a[aria-current="page"] { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 600; } +.settings-body { flex: 1; min-width: 0; } +.settings-body > h2:first-child { font-size: 1.3rem; margin-bottom: 0.3rem; } +@media (max-width: 760px) { + .settings { flex-direction: column; gap: 1rem; } + .settings-nav { width: 100%; position: static; } +} + +/* --- Forms --- */ +label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.9rem; } +input, select, textarea { + display: block; width: 100%; margin-top: 0.3rem; font: inherit; font-size: 0.92rem; font-weight: normal; + padding: 0.5rem 0.7rem; border: 1px solid hsl(var(--input)); border-radius: var(--radius); + background: hsl(var(--background)); color: hsl(var(--foreground)); transition: border-color var(--fast), box-shadow var(--fast); +} +input::placeholder, textarea::placeholder { color: hsl(var(--muted-foreground)); } +input:hover, select:hover, textarea:hover { border-color: hsl(var(--ring) / 0.5); } +input:focus, select:focus, textarea:focus { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.2); } +textarea { resize: vertical; line-height: 1.5; } +input[type="checkbox"], input[type="radio"] { display: inline; width: auto; margin: 0 0.45rem 0 0; accent-color: hsl(var(--primary)); box-shadow: none; } input[type="file"] { border: 0; padding-left: 0; } label.check { font-weight: normal; display: flex; align-items: baseline; gap: 0.2rem; } -label.small { font-size: 0.85rem; color: var(--muted); } -fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem 0.2rem; margin: 0 0 1rem; } +label.small { font-size: 0.85rem; color: hsl(var(--muted-foreground)); } +fieldset { border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 0.9rem 1rem 0.2rem; margin: 0 0 1rem; } fieldset.choice { border: 0; padding: 0; } -legend { font-weight: 600; padding: 0 0.3rem; } +legend { font-weight: 600; font-size: 0.9rem; padding: 0 0.3rem; } +fieldset.choice legend { padding: 0; margin-bottom: 0.4rem; } .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 1.25rem; } .row { display: flex; gap: 0.5rem; align-items: center; } .row input { margin: 0; } @@ -96,59 +267,85 @@ legend { font-weight: 600; padding: 0 0.3rem; } .secret > label:first-child { flex: 1; } .inline-form label { margin-bottom: 0.2rem; } -button, .button { display: inline-block; font: inherit; font-weight: 600; padding: 0.55rem 1.1rem; border-radius: 7px; border: 1px solid var(--cyan-dark); background: var(--cyan); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; } -button:hover, .button:hover { background: var(--cyan-dark); } -button.secondary, .button.secondary { background: #fff; color: var(--cyan-dark); border-color: #b9c3d1; } -button.secondary:hover, .button.secondary:hover { background: var(--band); } -button.danger { background: #fff; color: var(--bad); border-color: #f3b5ae; } -button:disabled { opacity: 0.5; cursor: not-allowed; } +button, .button { + display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; + font: inherit; font-size: 0.9rem; font-weight: 600; padding: 0.5rem 1rem; border-radius: var(--radius); + border: 1px solid transparent; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); + cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm); + transition: background var(--fast), box-shadow var(--fast), transform var(--fast); +} +button:hover, .button:hover { background: hsl(var(--primary) / 0.9); box-shadow: var(--shadow-md); } +button:active, .button:active { transform: scale(0.98); } +button.secondary, .button.secondary { background: hsl(var(--background)); color: hsl(var(--foreground)); border-color: hsl(var(--input)); } +button.secondary:hover, .button.secondary:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); border-color: hsl(var(--accent)); } +button.danger { background: hsl(var(--background)); color: hsl(var(--destructive)); border-color: hsl(var(--bad-border)); } +button.danger:hover { background: hsl(var(--bad-bg)); } +button:disabled, button:disabled:hover { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; } +button.small { padding: 0.28rem 0.75rem; font-size: 0.82rem; } +.icon-button { padding: 0.35rem; background: transparent; color: hsl(var(--foreground)); box-shadow: none; } +.icon-button:hover { background: hsl(var(--accent)); box-shadow: none; } .actions { display: flex; gap: 0.75rem; align-items: center; margin: 1rem 0 1.5rem; flex-wrap: wrap; } .danger-zone { margin-top: 2rem; } .connect { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; } .copy { position: relative; } -.copy button { position: absolute; top: 0.5rem; right: 0.5rem; padding: 0.25rem 0.7rem; font-size: 0.85rem; } +.copy button { position: absolute; top: 0.5rem; right: 0.5rem; padding: 0.25rem 0.7rem; font-size: 0.82rem; } .pills { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; } -.pill { display: inline-block; background: var(--band); border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.85rem; color: var(--ink); font-weight: normal; } -button.pill:hover { background: #e0f2f7; } +.pill { display: inline-block; background: hsl(var(--secondary)); border: 1px solid hsl(var(--border)); border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.82rem; color: hsl(var(--foreground)); font-weight: normal; box-shadow: none; } +button.pill:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); box-shadow: none; } .checks { list-style: none; padding: 0; } .checks li { padding: 0.25rem 0; } .checks li::before { margin-right: 0.5rem; font-weight: 700; } -.checks li.ok::before { content: "✓"; color: var(--ok); } -.checks li.bad::before { content: "✗"; color: var(--bad); } -.checks li.ok { color: var(--ink); } +.checks li.ok::before { content: "✓"; color: hsl(var(--ok)); } +.checks li.bad::before { content: "✗"; color: hsl(var(--destructive)); } +.checks li.ok { color: hsl(var(--foreground)); } -.htmx-indicator { display: none; color: var(--muted); } +/* A network on the Social accounts tab */ +.network .status { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0.9rem; } +.network h2 { display: flex; align-items: center; gap: 0.6rem; } +.network .signin { border-top: 1px solid hsl(var(--border)); margin-top: 0.5rem; padding-top: 1rem; } +.network .signin form { margin: 0.6rem 0 0; } + +.htmx-indicator { display: none; color: hsl(var(--muted-foreground)); } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; } [hidden] { display: none !important; } -/* Content */ -.muted { color: var(--muted); } -.buttons form { margin: 0; } -.items { list-style: none; padding: 0; margin: 0 0 1rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); } -.item { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); } +/* --- Content --- */ +.items { list-style: none; padding: 0; margin: 0 0 1rem; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); box-shadow: var(--shadow-sm); } +.item { padding: 0.75rem 1rem; border-bottom: 1px solid hsl(var(--border)); } .item:last-child { border-bottom: 0; } +.item:hover { background: hsl(var(--muted) / 0.3); } .item label.check { margin: 0; align-items: flex-start; } .item label.check > span { display: flex; flex-direction: column; gap: 0.2rem; } -.item .body { white-space: pre-line; overflow-wrap: anywhere; } -.item.used { background: var(--band); } -.meta { color: var(--muted); font-size: 0.85rem; font-weight: normal; } +.item .body { white-space: pre-line; overflow-wrap: anywhere; font-size: 0.92rem; } +.item.used { background: hsl(var(--muted) / 0.5); } +.meta { color: hsl(var(--muted-foreground)); font-size: 0.82rem; font-weight: normal; } .drafts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; } .draft h3 { margin: 0 0 0.5rem; } .draft .actions { margin: 0.5rem 0; } -.draft.failed textarea { border-color: #f3b5ae; } -.count { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--muted); text-align: right; } -.count.over { color: var(--bad); font-weight: 600; } -button.small { padding: 0.3rem 0.8rem; font-size: 0.85rem; } -.count-badge { display: inline-block; min-width: 1.3rem; padding: 0 0.35rem; margin-left: 0.2rem; border-radius: 999px; background: var(--magenta); color: #fff; font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 1.3rem; } +.draft.failed textarea { border-color: hsl(var(--bad-border)); } +.count { margin: 0.3rem 0 0; font-size: 0.82rem; color: hsl(var(--muted-foreground)); text-align: right; font-family: var(--font-mono); } +.count.over { color: hsl(var(--destructive)); font-weight: 600; } .schedule { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0.5rem; } .schedule label { margin: 0; flex: 1; min-width: 12rem; } .row-actions { white-space: nowrap; } .row-actions form { display: inline-block; margin: 0 0.25rem 0.25rem 0; } .post-text { overflow-wrap: anywhere; } -.small { font-size: 0.85rem; } -.warnings { margin: 0 0 0.75rem; padding: 0.6rem 0.9rem 0.6rem 2rem; background: #fff7e6; border: 1px solid #f5d48f; border-radius: 8px; color: #6b4100; font-size: 0.9rem; } -.rules { margin: 0 0 0.5rem; font-size: 0.9rem; } -.rules summary { cursor: pointer; color: var(--cyan-dark); } -.rules .guidelines { white-space: pre-line; color: var(--muted); } +.warnings { margin: 0 0 0.75rem; padding: 0.6rem 0.9rem 0.6rem 2rem; background: hsl(var(--warn-bg)); border: 1px solid hsl(var(--warn-border)); border-radius: var(--radius); color: hsl(var(--warn)); font-size: 0.88rem; } +.rules { margin: 0 0 0.5rem; font-size: 0.88rem; } +.rules summary { cursor: pointer; color: hsl(var(--primary)); } +.rules .guidelines { white-space: pre-line; color: hsl(var(--muted-foreground)); } form.inline { display: inline-block; margin: 0 0 0.75rem; } + +/* --- Search --- */ +.results { list-style: none; padding: 0; margin: 0 0 1.5rem; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); box-shadow: var(--shadow-sm); } +.results li { border-bottom: 1px solid hsl(var(--border)); } +.results li:last-child { border-bottom: 0; } +.results a { display: block; padding: 0.65rem 1rem; color: inherit; text-decoration: none; } +.results a:hover { background: hsl(var(--accent) / 0.5); } +.results .title { display: flex; gap: 0.5rem; align-items: baseline; font-weight: 600; } +.results .title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; } +.results .title .badge { margin-left: auto; } +.results .detail { display: block; color: hsl(var(--muted-foreground)); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.search-page { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; max-width: 40rem; } +.search-page input { margin: 0; } diff --git a/internal/web/static/app.js b/internal/web/static/app.js index 5137969..5c7f7e0 100644 --- a/internal/web/static/app.js +++ b/internal/web/static/app.js @@ -16,7 +16,29 @@ if (e.target.matches('input[data-toggle="provider"]')) syncProvider(); }); + // Press / to search (unless typing somewhere already). + document.addEventListener("keydown", function (e) { + if (e.key !== "/" || e.ctrlKey || e.metaKey || e.altKey) return; + var t = e.target; + if (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)) return; + var box = document.getElementById("search-box"); + if (box) { + e.preventDefault(); + box.focus(); + box.select(); + } + }); + document.addEventListener("click", function (e) { + // The menu on narrow screens. + if (e.target.closest("[data-nav-toggle]")) { + document.body.classList.toggle("nav-open"); + return; + } + if (e.target.closest("[data-nav-close]")) { + document.body.classList.remove("nav-open"); + return; + } // Copy a
's text: 
+
+  {{with .Connect}}
+  
+  {{end}}
+
+{{end}}
+{{end}}{{template "settings-end"}}{{end}}
diff --git a/internal/web/templates/ai.html b/internal/web/templates/ai.html
index 059ee4b..12d12e7 100644
--- a/internal/web/templates/ai.html
+++ b/internal/web/templates/ai.html
@@ -1,32 +1,39 @@
-{{define "content"}}{{with .Data}}{{$cfg := .Cfg}}
-
-

AI provider

+{{define "content"}}{{template "settings-start" .}}{{with .Data}}{{$cfg := .Cfg}}{{$set := .Set}} +

AI

+

The model Supermarket writes with: drafts, the profile draft, and later the other modules. It's called directly, never through Hermes, so text read from the web can't reach an agent with tools.

-
+
Provider - +
+
-
- - {{range .Servers}}{{end}} - {{if .Servers}}

Found by CoreDesktop's configure ai-servers: {{range $i, $s := .Servers}}{{if $i}}, {{end}}{{$s.Name}} ({{$s.BaseURL}}){{end}}.

{{end}} - -
-
+
+

Key

+ {{if .HasAnthropicKey}}

Using the key saved here.

+ {{else if .Shared}}

Using Hermes' key, shared by supermarket hermes. Hermes uses {{.Shared.Model}}.

+

To use a separate key, for example to see Supermarket's costs apart from Hermes', save it below: it takes the place of Hermes'.

+ {{else}}

No key yet. Save one below, or share Hermes' by running supermarket hermes.

{{end}} + {{range .Keys}}{{if eq .Group "anthropic"}}{{template "key-field" (dict "F" . "Set" (index $set .Name))}}{{end}}{{end}} +
+
+

Server

+ + {{range .Servers}}{{end}} + {{if .Servers}}

Found by CoreDesktop's configure ai-servers: {{range $i, $s := .Servers}}{{if $i}}, {{end}}{{$s.Name}} ({{$s.BaseURL}}){{end}}.

{{end}} + +
+ {{range .Keys}}{{if eq .Group "openai"}}{{template "key-field" (dict "F" . "Set" (index $set .Name))}}{{end}}{{end}} +
+ +
+

Model

{{range .AnthropicModels}} @@ -36,14 +43,14 @@ How hard the model thinks. Medium suits drafting; higher costs more and takes longer. -
-
-

Model per task

-

Leave empty to use the model above. Same provider.

- {{range .Tasks}} - - {{end}} +
+ A different model per task +

Leave empty to use the model above. Same provider.

+ {{range .Tasks}} + + {{end}} +
@@ -51,9 +58,10 @@ Asking the model…
+

Test uses the provider and model in the form, and the keys already saved: save a new key before testing it.

-{{end}}{{end}} +{{end}}{{template "settings-end"}}{{end}} {{define "test-result"}} {{if .Error}}

{{.Error}}

diff --git a/internal/web/templates/content-entry.html b/internal/web/templates/content-entry.html index d4ae639..39a15fd 100644 --- a/internal/web/templates/content-entry.html +++ b/internal/web/templates/content-entry.html @@ -1,21 +1,16 @@ {{define "content"}}{{with .Data}} -

{{.Name}} {{.Entry.Relationship}}

- {{if .Own}}Edit profile{{else}}Edit entry{{end}} + {{if .Own}}Edit profile{{else}}Edit entry{{end}}

{{if .Own}}Posts that promote your own work: pick a product, or fetch your feeds and new pages on your websites. - {{if .Sources}}Reads {{join .Sources ", "}}.{{else}}Add your blog and release feeds, and your websites, to the profile to fetch them.{{end}} + {{if .Sources}}Reads {{join .Sources ", "}}.{{else}}Add your blog and release feeds, and your websites, to the profile to fetch them.{{end}} {{else}}{{if .Sources}}Reads {{join .Sources ", "}}.{{else}}This entry has no sources yet: add an X handle, hashtags, a YouTube channel or RSS feeds to it.{{end}}{{end}} Last fetched {{ago .LastChecked}}; the next fetch looks for posts since {{.Since.Local.Format "2 Jan 15:04"}}.

@@ -25,7 +20,7 @@

{{if .NewItems}}{{.NewItems}} new item{{if ne .NewItems 1}}s{{end}}.{{else}}Nothing new.{{end}}

{{if .Errors}}

Some sources failed; they'll be read from the same point next time:

    {{range .Errors}}
  • {{.}}
  • {{end}}
{{end}} - {{if .Skipped}}

Skipped, for lack of credentials (add them): {{join .Skipped "; "}}.

{{end}} + {{if .Skipped}}

Skipped, for lack of credentials (add them): {{join .Skipped "; "}}.

{{end}} {{end}} @@ -78,7 +73,7 @@ {{else}}

Write drafts from the selected items

- {{if not .ProfileSet}}

Fill in the company profile first: drafts are written in its voice.

{{end}} + {{if not .ProfileSet}}

Fill in the company profile first: drafts are written in its voice.

{{end}}
Channels {{range .Channels}} @@ -105,7 +100,7 @@ {{else}}
-

{{if .ShowDismissed}}Nothing dismissed.{{else if .Own}}No products or news yet: add products, feeds or websites to your profile, then fetch.{{else}}No items yet. Fetch to see what {{.Name}} has been up to.{{end}}

+

{{if .ShowDismissed}}Nothing dismissed.{{else if .Own}}No products or news yet: add products, feeds or websites to your profile, then fetch.{{else}}No items yet. Fetch to see what {{.Name}} has been up to.{{end}}

{{end}} {{end}}{{end}} diff --git a/internal/web/templates/content-published.html b/internal/web/templates/content-published.html index f31a5c8..3d57400 100644 --- a/internal/web/templates/content-published.html +++ b/internal/web/templates/content-published.html @@ -1,9 +1,4 @@ {{define "content"}}{{with .Data}} -

Published

The last 200 posts Supermarket published.

diff --git a/internal/web/templates/content-scheduled.html b/internal/web/templates/content-scheduled.html index 452dc33..cd29d5e 100644 --- a/internal/web/templates/content-scheduled.html +++ b/internal/web/templates/content-scheduled.html @@ -1,9 +1,4 @@ {{define "content"}}{{with .Data}}{{$conn := .Connected}} -

Scheduled

Approved posts, in the order they go out ({{.Zone}}). Supermarket publishes them on time as long as it's running; one more than 12 hours late goes back to the Inbox instead.

diff --git a/internal/web/templates/content.html b/internal/web/templates/content.html index 947a24d..650fe99 100644 --- a/internal/web/templates/content.html +++ b/internal/web/templates/content.html @@ -1,10 +1,5 @@ {{define "content"}}{{with .Data}} - -

Content

+

Sources

Pick an inventory entry to fetch its latest news, choose what to write about, and get a draft for each channel to review in the Inbox.

{{if .Rows}} @@ -16,7 +11,7 @@ {{if .Own}} {{.Name}} your own work product - {{if .Sources}}{{join .Sources ", "}}{{else}}none: add products, websites or feeds to your profile{{end}} + {{if .Sources}}{{join .Sources ", "}}{{else}}none: add products, websites or feeds to your profile{{end}} {{else}} {{.Name}} {{.Entry.Relationship}} diff --git a/internal/web/templates/core.html b/internal/web/templates/core.html index 58a26c6..537803d 100644 --- a/internal/web/templates/core.html +++ b/internal/web/templates/core.html @@ -1,12 +1,13 @@ -{{define "content"}}{{with .Data}} -

Core & Hermes

+{{define "content"}}{{template "settings-start" .}}{{with .Data}} +

Core & Hermes

+

Your Federated Core's services, and Hermes, the agent that reaches them for Supermarket.

Federated Core

{{if .Core}}

{{.Core.Domain}} · {{.Core.Email}}{{if .Core.Name}} · {{.Core.Name}}{{end}}

From CoreDesktop's configure core. To use another Core, change it there and run update.

-

Checking the Core's services…

+

Checking the Core's services…

{{else}}

No Core found. Run configure core in CoreDesktop, then update. Without a Core, everything works except EspoCRM, Plausible and publishing through Gitea.

{{end}} @@ -41,7 +42,7 @@

Hermes runs in CoreDesktop's sandbox, so also let it reach the hub: add mcphub.{{if .Core}}{{.Core.Domain}}{{else}}<your Core's domain>{{end}} to network.allowedDomains in ~/.config/coredesktop/sandbox/hermes.json. Then restart Hermes' gateway: systemctl --user restart hermes-gateway.

Show the MCP token
{{.MCPToken}}

Also in mcp-token in the data folder.

-{{end}}{{end}} +{{end}}{{template "settings-end"}}{{end}} {{define "checks"}} {{if .}} diff --git a/internal/web/templates/credentials.html b/internal/web/templates/credentials.html deleted file mode 100644 index d4437b1..0000000 --- a/internal/web/templates/credentials.html +++ /dev/null @@ -1,51 +0,0 @@ -{{define "content"}}{{with .Data}}{{$set := .Set}} - -

Credentials

-

Kept in secrets.json in Supermarket's data folder, readable only by you. Saved values are never shown: leave a field empty to keep what's saved.

- -
-{{$group := ""}} -{{range .Fields}} - {{if ne .Group $group}}{{if $group}}
{{end}}{{$group = .Group}}

{{.Group}}

{{end}} -
- - {{if index $set .Name}}{{end}} -
-{{end}} -{{if $group}}
{{end}} -
- - -
-

Sign in to post

-
-
-

X

- {{with index .Connections "x"}}{{if .Account}}

Connected as @{{.Account}}, {{ago .At}}.

{{end}}{{end}} - {{if and (index $set .XToken) (not (index .Connections "x").Account)}}

A token is saved.

{{end}} -

In the X developer portal, add this callback URL to your app: {{.XRedirect}}

-
-
-
-

LinkedIn

- {{with index .Connections "linkedin"}}{{if .Account}}

Connected, {{ago .At}}.

{{end}}{{end}} - {{if and (index $set .LIToken) (not (index .Connections "linkedin").Account)}}

A token is saved.

{{end}} -

In your LinkedIn app's Auth settings, add this redirect URL: {{.LIRedirect}}

-
-
-
-

Reddit

- {{with index .Connections "reddit"}}{{if .Account}}

Connected as u/{{.Account}}, {{ago .At}}.

{{end}}{{end}} -

At reddit.com/prefs/apps, create a web app with this redirect URI: {{.RedditRedirect}}. - Reddit's API terms need approval for commercial use: Supermarket is meant for a few hand-approved posts, not volume.

-
-
-
-
-{{end}}{{end}} diff --git a/internal/web/templates/dashboard.html b/internal/web/templates/dashboard.html index 2398e57..0c65ec3 100644 --- a/internal/web/templates/dashboard.html +++ b/internal/web/templates/dashboard.html @@ -1,6 +1,27 @@ -{{define "content"}}{{with .Data}} -

Overview

+{{define "content"}}{{$inbox := .Inbox}}{{with .Data}} +
+

Overview

+

Supermarket's modules, and what's left to set up.

+
+ + +{{if .Pending}}

Setup

    @@ -12,6 +33,16 @@ {{end}}
+{{else}} +
+ Setup: all done +
    + {{range .Steps}} +
  • {{.Label}}{{.Detail}}
  • + {{end}} +
+
+{{end}} {{if .ImportErr}}
@@ -26,14 +57,4 @@ {{if .QueuedPosts}}

Its queued posts are now drafts: {{.QueuedPosts}} waiting in the Inbox.

{{end}} {{end}} - -

Modules

-
-{{range .Modules}} -
-

{{if .Link}}{{.Name}}{{else}}{{.Name}}{{end}} {{.Phase}}

-

{{.Body}}

-
-{{end}} -
{{end}}{{end}} diff --git a/internal/web/templates/inbox.html b/internal/web/templates/inbox.html index 9833dda..f10cd91 100644 --- a/internal/web/templates/inbox.html +++ b/internal/web/templates/inbox.html @@ -44,7 +44,7 @@

{{.Length}} / {{.Limit}}{{if and (eq .Channel "x") .SourceURL}} including the link{{end}}

+ {{if not (index $conn .Channel)}}disabled title="Sign in to {{.ChannelName}} under Settings → Social accounts"{{end}}>Publish now
@@ -53,7 +53,7 @@
- {{if not (index $conn .Channel)}}

{{.ChannelName}} isn't connected: sign in before it's due.

{{end}} + {{if not (index $conn .Channel)}}

{{.ChannelName}} isn't connected: sign in before it's due.

{{end}}
diff --git a/internal/web/templates/layout.html b/internal/web/templates/layout.html index 9d62099..9a9acd1 100644 --- a/internal/web/templates/layout.html +++ b/internal/web/templates/layout.html @@ -10,23 +10,115 @@ -
- Supermarket -
-
- {{if .Flash}}

{{.Flash}}

{{end}} - {{if .Error}}{{end}} - {{template "content" .}} -
-
Supermarket {{.Version}}
+ + +
+ +
+
+ + +
+
+ {{if .Flash}}

{{.Flash}}

{{end}} + {{if .Error}}{{end}} + {{template "content" .}} +
+
+ + +{{/* Settings pages share this frame: a heading, and the tabs on the left + (grouped, as in brain). Call with the page: {{template "settings-start" $}} + … {{template "settings-end"}}. */}} +{{define "settings-start"}} +
+

Settings

+

Your company, the accounts Supermarket posts with, the AI it writes with, and your Federated Core.

+
+ +{{end}} + +{{/* A secret's field: {{template "key-field" (dict "F" secretField "Set" bool)}}. + Saved values are never shown; an empty field keeps what's saved. */}} +{{define "key-field"}} +
+ + {{if .Set}}{{end}} +
+{{end}} + + +{{/* Icons from Lucide (lucide.dev, ISC licence). */}} +{{define "icon"}}{{end}} diff --git a/internal/web/templates/profile.html b/internal/web/templates/profile.html index 1f85e73..e6de2d4 100644 --- a/internal/web/templates/profile.html +++ b/internal/web/templates/profile.html @@ -1,8 +1,8 @@ -{{define "content"}}{{with .Data}} -

Company profile

+{{define "content"}}{{template "settings-start" .}}{{with .Data}} +

Company profile

Everything Supermarket writes, targets and audits starts here.

-
+

Reads your home page and a few pages it links to (about, products, pricing), and fills in what's empty below. Nothing is saved until you press Save.

{{if .NoAI}}

This uses the AI: first choose an AI provider (for Anthropic, add your API key), then come back. Or fill in the form below by hand.

{{end}} @@ -15,7 +15,7 @@ {{if .Drafted}}

Here's a draft. Check every field, correct what's wrong, then Save.

{{end}} - + {{with .P}}

The company

@@ -105,4 +105,4 @@
-{{end}}{{end}} +{{end}}{{template "settings-end"}}{{end}} diff --git a/internal/web/templates/search.html b/internal/web/templates/search.html new file mode 100644 index 0000000..a73aa07 --- /dev/null +++ b/internal/web/templates/search.html @@ -0,0 +1,29 @@ +{{define "content"}}{{with .Data}} +
+

Search

+

Posts, fetched items, the inventory, your products and settings.

+
+ + +{{if .Q}} + {{if .Groups}} + {{$limit := .Limit}} + {{range .Groups}} +

{{.Name}} {{len .Hits}}{{if ge (len .Hits) $limit}}+{{end}}

+ + {{end}} + {{else}} +

Nothing matches “{{.Q}}”. Every word has to appear; try fewer words.

+ {{end}} +{{end}} +{{end}}{{end}}