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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 07:50:24 -07:00
co-authored by Claude Opus 5.5
parent 81a7d0596c
commit a89121f1ec
29 changed files with 1141 additions and 364 deletions
+20 -1
View File
@@ -406,7 +406,7 @@ Part 4, promoting our own products:
invites feedback, and the Inbox warns that self-promotion is often invites feedback, and the Inbox warns that self-promotion is often
restricted. 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 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 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: 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 until the user decides to merge; posting works again now, which was the
condition for merging. 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 **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` 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 and tag `v0.1.0`. Then Phase 2, Prospects → EspoCRM, which depends on the
+7 -5
View File
@@ -34,10 +34,12 @@ After that, CoreDesktop's `update` keeps it current: it pulls this repository an
Then open Supermarket and: Then open Supermarket and:
1. **Profile**: enter your website and press *Draft*. Correct the draft and save it. 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 > 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. 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. 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 ## The `supermarket` command
@@ -88,7 +90,7 @@ MCPHUB_AUTH=<your own hub token from your Core: the part after "Basic ">
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`. 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. 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/<provider>/call
- X developer portal, your app's *User authentication settings*: `http://localhost:8470/auth/x/callback` - 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` - 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. The old terminal app used `http://localhost:8080/callback`; you can remove that one.
+1 -1
View File
@@ -52,7 +52,7 @@ func UserAgent(version, username string) string {
} }
// ErrUnauthorized means the token was refused even after a refresh. // 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 { func (c *Client) do(ctx context.Context, method, path string, form url.Values, out any) error {
for attempt := 0; ; attempt++ { for attempt := 0; ; attempt++ {
+53
View File
@@ -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)
}
+1 -1
View File
@@ -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) id, secret := s.Secrets.Get(secrets.RedditClientID), s.Secrets.Get(secrets.RedditClientSecret)
if id == "" || secret == "" { 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() s.mu.Lock()
tok, exp := s.redditAppToken, s.redditAppTokenExp tok, exp := s.redditAppToken, s.redditAppTokenExp
+4 -4
View File
@@ -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), rows = append(rows, contentRow{Entry: e, Name: e.Name, Sources: fetcher.Sources(&e),
Waiting: counts[strings.ToLower(e.Name)], LastChecked: last}) 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 { type channelChoice struct {
@@ -181,7 +181,7 @@ func (s *Server) contentEntry(w http.ResponseWriter, r *http.Request) {
s.serverError(w, err) s.serverError(w, err)
return 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) { 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 return
} }
d.Fetched, d.NewItems, d.Errors, d.Skipped = true, n, res.Errors, res.Skipped 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. // 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) s.serverError(w, err)
return 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 { if len(ids) == 0 {
showErr("Select at least one item first.") showErr("Select at least one item first.")
+2 -2
View File
@@ -101,7 +101,7 @@ func TestDraftsPage(t *testing.T) {
body := rec.Body.String() body := rec.Body.String()
if rec.Code != 200 || strings.Index(body, "X text") > strings.Index(body, "LinkedIn text") || 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, "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) 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() body = do(h, http.MethodGet, "/content/own", nil, nil).Body.String()
for _, want := range []string{"<h1>Acme <span class=\"badge product\">", `value="product:acme-mail"`, `action="/content/own/fetch"`, for _, want := range []string{"<h1>Acme <span class=\"badge product\">", `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) { if !strings.Contains(body, want) {
t.Errorf("own page lacks %q", want) t.Errorf("own page lacks %q", want)
} }
+3 -3
View File
@@ -92,7 +92,7 @@ func (s *Server) renderInbox(w http.ResponseWriter, r *http.Request, errMsg stri
if len(pending) > 0 { if len(pending) > 0 {
sections = append(sections, inboxSection{Module: "Content", Batches: groupBatches(pending)}) 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, "Sections": sections,
"Reddit": s.redditViews(r.Context(), pending), "Reddit": s.redditViews(r.Context(), pending),
"Connected": s.connected(), "Connected": s.connected(),
@@ -160,7 +160,7 @@ func (s *Server) renderScheduled(w http.ResponseWriter, r *http.Request, errMsg
s.serverError(w, err) s.serverError(w, err)
return 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"), "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) s.serverError(w, err)
return 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 <input type="datetime-local">, read in the // dateTimeLocal is the format of <input type="datetime-local">, read in the
+12 -18
View File
@@ -50,11 +50,6 @@ type step struct {
Link string 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) { func (s *Server) dashboard(w http.ResponseWriter, r *http.Request) {
p, err := profile.Load(s.DB) p, err := profile.Load(s.DB)
if err != nil { if err != nil {
@@ -86,27 +81,24 @@ func (s *Server) dashboard(w http.ResponseWriter, r *http.Request) {
steps := []step{ steps := []step{
{Label: "AI provider", Done: aiErr == nil, Link: "/settings/ai", {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")}, 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)")}, 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", {Label: "Inventory", Done: len(entries) > 0, Link: "/inventory",
Detail: inventorySummary(counts)}, Detail: inventorySummary(counts)},
{Label: "Social accounts", Done: s.Secrets.Has(secrets.XAccessToken) || s.Secrets.Has(secrets.LinkedInAccessToken) || s.Secrets.Has(secrets.RedditAccessToken), {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)}, Link: "/settings/accounts", Detail: s.connectionSummary(conns)},
{Label: "Federated Core", Done: s.Core != nil, Link: "/core", {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")}, 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")}, 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) 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{ s.render(w, r, "dashboard", page{Title: "Overview", Nav: "home", Data: map[string]any{
"Steps": steps, "Steps": steps,
@@ -114,6 +106,8 @@ func (s *Server) dashboard(w http.ResponseWriter, r *http.Request) {
"ImportStatus": s.ImportStatus, "ImportStatus": s.ImportStatus,
"ImportErr": errString(s.ImportErr), "ImportErr": errString(s.ImportErr),
"QueuedPosts": queued, "QueuedPosts": queued,
"Scheduled": len(scheduled),
"Pending": pending,
}}) }})
} }
@@ -226,7 +220,7 @@ func (s *Server) corePage(w http.ResponseWriter, r *http.Request) {
command: socat command: socat
args: ["STDIO", "UNIX-CONNECT:` + d.MCPSocket + `"]` args: ["STDIO", "UNIX-CONNECT:` + d.MCPSocket + `"]`
d.HermesEnv = `MCPHUB_AUTH=<your own hub token from your Core: the part after "Basic ">` d.HermesEnv = `MCPHUB_AUTH=<your own hub token from your Core: the part after "Basic ">`
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 { func publicPort(u string) string {
+4 -4
View File
@@ -36,7 +36,7 @@ func (s *Server) profilePage(w http.ResponseWriter, r *http.Request) {
d.DraftURL = p.Websites[0].URL d.DraftURL = p.Websites[0].URL
} }
d.NoAI = !s.aiReady() 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) // 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 := profileFromForm(r)
p.Clean() p.Clean()
if !p.IsSet() { 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)}) Error: "The company's name and description are required.", Data: withBlankRows(p)})
return return
} }
@@ -111,7 +111,7 @@ func (s *Server) profileSave(w http.ResponseWriter, r *http.Request) {
s.serverError(w, err) s.serverError(w, err)
return 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, // 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.Drafted = drafted
d.DraftURL = siteURL d.DraftURL = siteURL
d.NoAI = !s.aiReady() 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) cfg, err := ai.LoadConfig(s.DB)
+167
View File
@@ -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
}
+73 -8
View File
@@ -76,9 +76,7 @@ func (s *Server) Handler() (http.Handler, error) {
mux.HandleFunc("GET /{$}", s.dashboard) mux.HandleFunc("GET /{$}", s.dashboard)
mux.HandleFunc("GET /profile", s.profilePage) mux.HandleFunc("GET /search", s.searchPage)
mux.HandleFunc("POST /profile", s.profileSave)
mux.HandleFunc("POST /profile/draft", s.profileDraft)
mux.HandleFunc("GET /inventory", s.inventoryList) mux.HandleFunc("GET /inventory", s.inventoryList)
mux.HandleFunc("GET /inventory/new", s.inventoryEdit) 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("POST /inventory/import", s.inventoryImport)
mux.HandleFunc("GET /inventory/export", s.inventoryExport) 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("GET /settings/ai", s.aiPage)
mux.HandleFunc("POST /settings/ai", s.aiSave) mux.HandleFunc("POST /settings/ai", s.aiSave)
mux.HandleFunc("POST /settings/ai/test", s.aiTest) mux.HandleFunc("POST /settings/ai/test", s.aiTest)
mux.HandleFunc("GET /settings/ai/models", s.aiModels) mux.HandleFunc("GET /settings/ai/models", s.aiModels)
mux.HandleFunc("GET /settings/credentials", s.credentialsPage) mux.HandleFunc("GET /settings/accounts", s.accountsPage)
mux.HandleFunc("POST /settings/credentials", s.credentialsSave) mux.HandleFunc("POST /settings/accounts", s.accountsSave)
mux.HandleFunc("POST /auth/{provider}/start", s.oauthStart) mux.HandleFunc("POST /auth/{provider}/start", s.oauthStart)
mux.HandleFunc("GET /auth/{provider}/callback", s.oauthCallback) 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 /drafts/{id}/{action}", s.draftAction)
mux.HandleFunc("POST /reddit/rules/{name}", s.refreshRules) mux.HandleFunc("POST /reddit/rules/{name}", s.refreshRules)
mux.HandleFunc("GET /core", s.corePage) mux.HandleFunc("GET /settings/core", s.corePage)
mux.HandleFunc("GET /core/checks", s.coreChecks) 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 return s.guard(mux), nil
} }
@@ -179,6 +194,23 @@ func (s *Server) loadTemplates() error {
"join": strings.Join, "join": strings.Join,
"ago": ago, "ago": ago,
"add": func(a, b int) int { return a + b }, "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, "xreserve": twitter.URLReserve,
"truncate": func(n int, s string) string { "truncate": func(n int, s string) string {
r := []rune(s) r := []rune(s)
@@ -210,14 +242,47 @@ func (s *Server) loadTemplates() error {
// page is what every template gets. // page is what every template gets.
type page struct { type page struct {
Title string Title string
Nav string // which nav item is current Nav string // which menu item is current: "home", "content/inbox", "settings/ai"…
Version string Version string
Flash string Flash string
Error string Error string
Data any 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 // render writes a full page, or only its "content" block for htmx requests
// that ask for a fragment. // that ask for a fragment.
func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, p page) { func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, p page) {
+88 -17
View File
@@ -11,12 +11,15 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
"time"
"supermarket/internal/bridge" "supermarket/internal/bridge"
"supermarket/internal/content"
"supermarket/internal/core" "supermarket/internal/core"
"supermarket/internal/db" "supermarket/internal/db"
"supermarket/internal/inventory" "supermarket/internal/inventory"
"supermarket/internal/mcpserver" "supermarket/internal/mcpserver"
"supermarket/internal/models"
"supermarket/internal/profile" "supermarket/internal/profile"
"supermarket/internal/secrets" "supermarket/internal/secrets"
) )
@@ -86,9 +89,9 @@ func TestEveryPageRenders(t *testing.T) {
t.Fatal(err) 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", "/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", "/content/1", "/content/1?dismissed=1", "/inbox", "/inbox?msg=drafted",
"/content/scheduled", "/content/published"} { "/content/scheduled", "/content/published"} {
rec := do(h, http.MethodGet, path, nil, nil) rec := do(h, http.MethodGet, path, nil, nil)
@@ -114,21 +117,21 @@ func TestGuardRejectsForeignHostsAndCrossSitePosts(t *testing.T) {
} }
form := url.Values{"name": {"Acme"}, "description": {"x"}} 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", "Content-Type": "application/x-www-form-urlencoded",
"Origin": "https://evil.example", "Origin": "https://evil.example",
}) })
if rec.Code != http.StatusForbidden { if rec.Code != http.StatusForbidden {
t.Errorf("cross-origin POST: got %d", rec.Code) 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", "Content-Type": "application/x-www-form-urlencoded",
"Sec-Fetch-Site": "cross-site", "Sec-Fetch-Site": "cross-site",
}) })
if rec.Code != http.StatusForbidden { if rec.Code != http.StatusForbidden {
t.Errorf("cross-site POST without Origin: got %d", rec.Code) 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()) 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": {"", ""}, "website_branch": {"", ""}, "website_plausible": {"", ""}, "website_gsc": {"", ""}, "website_bing": {"", ""},
"account_x": {"@acme"}, "subreddits": {"r/selfhosted\n/r/homelab"}, "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()) t.Fatalf("save profile: %d %s", rec.Code, rec.Body.String())
} }
p, _ := profile.Load(s.DB) 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. // 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") { if rec.Code != http.StatusOK || !strings.Contains(rec.Body.String(), "required") {
t.Errorf("invalid profile: %d", rec.Code) 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) 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. // Empty field keeps the value; remove clears it.
postForm(h, "/settings/credentials", url.Values{secrets.AnthropicAPIKey: {""}, "remove:" + secrets.YouTubeAPIKey: {"on"}}) postForm(h, "/settings/accounts", url.Values{secrets.XClientID: {""}, "remove:" + secrets.YouTubeAPIKey: {"on"}})
if got := s.Secrets.Get(secrets.AnthropicAPIKey); got != "sk-1" { if got := s.Secrets.Get(secrets.XClientID); got != "id-1" {
t.Errorf("anthropic key = %q", got) t.Errorf("x client id = %q", got)
} }
if s.Secrets.Has(secrets.YouTubeAPIKey) { if s.Secrets.Has(secrets.YouTubeAPIKey) {
t.Error("youtube key should be removed") t.Error("youtube key should be removed")
} }
page := do(h, http.MethodGet, "/settings/credentials", nil, nil).Body.String() // The AI keys aren't on this tab, so it can't change them.
if strings.Contains(page, "sk-1") { postForm(h, "/settings/accounts", url.Values{secrets.AnthropicAPIKey: {"sk-x"}})
t.Error("the credentials page must never show a saved value") 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) { func TestProfileDraftNeedsAI(t *testing.T) {
s, h := newTestServer(t, nil) 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, `<a href="/settings/ai">choose an AI provider</a>`) || !strings.Contains(body, `class="secondary" disabled>Draft`) { if !strings.Contains(body, `<a href="/settings/ai">choose an AI provider</a>`) || !strings.Contains(body, `class="secondary" disabled>Draft`) {
t.Errorf("profile without AI:\n%s", body) t.Errorf("profile without AI:\n%s", body)
} }
_ = s.Secrets.Set(map[string]string{secrets.AnthropicAPIKey: "k"}) _ = 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") t.Error("warning shown with an AI key saved")
} }
} }
+115 -45
View File
@@ -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) { 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, "Cfg": cfg,
"AnthropicModels": anthropicModels, "AnthropicModels": anthropicModels,
"Efforts": efforts, "Efforts": efforts,
"Tasks": ai.Tasks, "Tasks": ai.Tasks,
"Servers": s.aiServers(), "Servers": s.aiServers(),
"HasAnthropicKey": s.Secrets.Has(secrets.AnthropicAPIKey), "HasAnthropicKey": s.Secrets.Has(secrets.AnthropicAPIKey),
"Keys": aiKeys,
"Set": s.secretState(secrets.AnthropicAPIKey, secrets.OpenAIAPIKey),
"Shared": ai.LoadShared(), "Shared": ai.LoadShared(),
}}) }})
} }
@@ -70,6 +72,11 @@ func (s *Server) aiSave(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return 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) cfg := aiFromForm(r)
switch { switch {
case cfg.Model == "": case cfg.Model == "":
@@ -132,52 +139,37 @@ func (s *Server) aiModels(w http.ResponseWriter, r *http.Request) {
s.fragment(w, "ai", "model-list", data) s.fragment(w, "ai", "model-list", data)
} }
// --- Credentials --- // --- Secrets forms ---
// credentialFields are the secrets the credentials form edits, in order. // secretField is one secret a settings form edits. Saved values are never
var credentialFields = []struct { // shown: an empty field keeps what's saved.
type secretField struct {
Group, Name, Label, Help string 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.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.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."}, {"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.LinkedInClientID, "Client ID", "From your app at linkedin.com/developers."},
{"LinkedIn", secrets.LinkedInClientSecret, "Client secret", ""}, {"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.RedditClientID, "Client ID", "From a \"web app\" at reddit.com/prefs/apps: the string under the app's name."},
{"Reddit", secrets.RedditClientSecret, "Client secret", ""}, {"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) { // saveSecrets stores what was typed into these fields. An empty field keeps
names := make([]string, 0, len(credentialFields)+2) // the saved value; "remove:<name>" clears it.
for _, f := range credentialFields { func (s *Server) saveSecrets(r *http.Request, fields []secretField) error {
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
}
updates := map[string]string{} updates := map[string]string{}
for _, f := range credentialFields { for _, f := range fields {
if r.PostForm.Get("remove:"+f.Name) == "on" { if r.PostForm.Get("remove:"+f.Name) == "on" {
updates[f.Name] = "" updates[f.Name] = ""
continue continue
@@ -186,13 +178,91 @@ func (s *Server) credentialsSave(w http.ResponseWriter, r *http.Request) {
updates[f.Name] = v updates[f.Name] = v
} }
} }
if len(updates) > 0 { if len(updates) == 0 {
if err := s.Secrets.Set(updates); err != nil { 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
}
}
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) s.serverError(w, err)
return return
} }
} redirect(w, r, "/settings/accounts", "saved")
redirect(w, r, "/settings/credentials", "saved")
} }
// --- OAuth --- // --- 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 delete(s.pending, q.Get("state")) // a state is good for one callback
s.mu.Unlock() s.mu.Unlock()
if p == nil || p.Provider != provider || time.Since(p.Started) > oauthTTL { 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 return
} }
fail := func(msg string) { fail := func(msg string) {
s.render(w, r, "message", page{Title: "Sign-in failed", Nav: "settings", Error: msg, s.render(w, r, "message", page{Title: "Sign-in failed", Nav: "settings/accounts", Error: msg,
Data: map[string]string{"Back": "/settings/credentials"}}) Data: map[string]string{"Back": "/settings/accounts"}})
} }
if e := q.Get("error"); e != "" { if e := q.Get("error"); e != "" {
fail("The provider said: " + e + " " + q.Get("error_description")) 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 { if err := s.saveConnection("x", Connection{Account: account, At: time.Now()}); err != nil {
s.Log.Error("saving connection", "err", err) s.Log.Error("saving connection", "err", err)
} }
redirect(w, r, "/settings/credentials", "x-connected") redirect(w, r, "/settings/accounts", "x-connected")
case "linkedin": case "linkedin":
res, err := oauth.LinkedInExchange(ctx, s.Secrets.Get(secrets.LinkedInClientID), s.Secrets.Get(secrets.LinkedInClientSecret), code, p) res, err := oauth.LinkedInExchange(ctx, s.Secrets.Get(secrets.LinkedInClientID), s.Secrets.Get(secrets.LinkedInClientSecret), code, p)
if err != nil { 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 { if err := s.saveConnection("linkedin", Connection{Account: urn, At: time.Now()}); err != nil {
s.Log.Error("saving connection", "err", err) s.Log.Error("saving connection", "err", err)
} }
redirect(w, r, "/settings/credentials", "li-connected") redirect(w, r, "/settings/accounts", "li-connected")
case "reddit": case "reddit":
res, err := oauth.RedditExchange(ctx, s.Secrets.Get(secrets.RedditClientID), s.Secrets.Get(secrets.RedditClientSecret), res, err := oauth.RedditExchange(ctx, s.Secrets.Get(secrets.RedditClientID), s.Secrets.Get(secrets.RedditClientSecret),
s.redditUserAgent(), code, p) 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 { if err := s.saveConnection("reddit", Connection{Account: name, At: time.Now()}); err != nil {
s.Log.Error("saving connection", "err", err) s.Log.Error("saving connection", "err", err)
} }
redirect(w, r, "/settings/credentials", "reddit-connected") redirect(w, r, "/settings/accounts", "reddit-connected")
default: default:
http.NotFound(w, r) http.NotFound(w, r)
} }
+300 -103
View File
@@ -1,94 +1,265 @@
/* Supermarket. Colors follow the Federated sites: a navy bar, a magenta /* Supermarket. The look follows brain (Federated's superbrain): its colour
accent and a cyan primary button. */ 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 { :root {
--navy: #0b1d3a; --background: 0 0% 100%;
--navy-2: #13294f; --foreground: 240 10% 3.9%;
--magenta: #c2187a; --card: 0 0% 100%;
--cyan: #0891b2; --primary: 245 58% 51%;
--cyan-dark: #0e7490; --primary-foreground: 0 0% 100%;
--ink: #1b2433; --secondary: 240 4.8% 95.9%;
--muted: #5b6577; --muted: 240 4.8% 95.9%;
--line: #dde2ea; --muted-foreground: 240 3.8% 44.1%;
--band: #f4f6f9; --accent: 245 58% 95%;
--ok: #157f3b; --accent-foreground: 245 58% 51%;
--bad: #b42318; --destructive: 0 72% 51%;
--warn-bg: #fff6e5; --border: 240 5.9% 90%;
--radius: 10px; --input: 240 5.9% 86%;
font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --ring: 245 58% 51%;
color: var(--ink); --sidebar: 245 30% 97%;
background: var(--band); --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; } /* Dark: brain's readability pass, body text at about 13:1 rather than a
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: -0.01em; } glaring near-white on near-black. */
.brand span { color: #f472b6; } @media (prefers-color-scheme: dark) {
.topbar nav { display: flex; gap: 0.25rem; flex-wrap: wrap; } :root {
.topbar nav a { color: #c9d4e6; text-decoration: none; padding: 0.35rem 0.75rem; border-radius: 6px; } --background: 240 6% 10%;
.topbar nav a:hover { background: var(--navy-2); color: #fff; } --foreground: 0 0% 92%;
.topbar nav a[aria-current="page"] { background: var(--navy-2); color: #fff; box-shadow: inset 0 -2px 0 var(--magenta); } --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; } /* --- Base --- */
footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 2rem 0; } * { box-sizing: border-box; border-color: hsl(var(--border)); }
h1 { font-size: 1.7rem; margin: 0.5rem 0 0.75rem; letter-spacing: -0.02em; } html { font-size: 106.25%; } /* 17px, as brain */
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; } body {
h3 { font-size: 1.05rem; margin: 0 0 0.5rem; } margin: 0; line-height: 1.55; font-family: var(--font-sans);
.lede { color: var(--muted); margin-top: 0; } background: hsl(var(--background)); color: hsl(var(--foreground));
.help { display: block; color: var(--muted); font-size: 0.85rem; font-weight: normal; margin-top: 0.2rem; } -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; } h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; line-height: 1.25; }
.card.warn, .warn { background: var(--warn-bg); border-color: #f5d49a; } h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 0.4rem; }
.card.empty { text-align: center; color: var(--muted); } 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 > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 0.75rem; } details.card[open] > summary { margin-bottom: 0.75rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; } .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.module p { color: var(--muted); margin: 0; } a.card { display: block; color: inherit; text-decoration: none; transition: box-shadow 250ms, transform 250ms, border-color 250ms; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; } a.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: hsl(var(--primary) / 0.25); }
.buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; } .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; } .flash, .error { padding: 0.6rem 0.9rem; border-radius: var(--radius); border: 1px solid; font-size: 0.92rem; }
.error { background: #fdecea; border: 1px solid #f3b5ae; color: var(--bad); padding: 0.6rem 0.9rem; border-radius: 8px; } .flash { background: hsl(var(--ok-bg)); border-color: hsl(var(--ok) / 0.35); color: hsl(var(--ok)); }
.ok { color: var(--ok); } .error { background: hsl(var(--bad-bg)); border-color: hsl(var(--bad-border)); color: hsl(var(--destructive)); }
.warn-text { color: #8a5300; } .ok { color: hsl(var(--ok)); }
.warn-text { color: hsl(var(--warn)); }
.steps { list-style: none; margin: 0; padding: 0; } .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:last-child { border-bottom: 0; }
.steps li::before { content: "○"; color: var(--muted); width: 1.2rem; flex: none; } .steps li::before { content: "○"; color: hsl(var(--muted-foreground)); width: 1.2rem; flex: none; }
.steps li.done::before { content: "✓"; color: var(--ok); font-weight: 700; } .steps li.done::before { content: "✓"; color: hsl(var(--ok)); font-weight: 700; }
.steps li a { min-width: 11rem; color: var(--ink); text-decoration: none; } .steps li a { min-width: 11rem; color: hsl(var(--foreground)); text-decoration: none; }
.steps li span { color: var(--muted); } .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 { 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: #e0f2f7; color: var(--cyan-dark); } .badge.partner { background: hsl(var(--teal-bg)); color: hsl(var(--teal)); }
.badge.competitor { background: #fbe4f0; color: var(--magenta); } .badge.competitor { background: hsl(var(--coral-bg)); color: hsl(var(--coral)); }
.badge.watch { background: #eef0f4; color: var(--muted); } .badge.product, .badge.published { background: hsl(var(--ok-bg)); color: hsl(var(--ok)); }
.badge.product { background: #e7f6ed; color: 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 { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid hsl(var(--border)); 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 { 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[aria-current="page"] { color: var(--ink); border-color: var(--magenta); font-weight: 600; } .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 { 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 var(--line); vertical-align: top; } 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: var(--band); font-size: 0.85rem; color: var(--muted); font-weight: 600; } 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 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; } /* --- Settings: grouped tabs on the left, the section on the right --- */
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); } .settings { display: flex; gap: 2rem; align-items: flex-start; }
textarea { resize: vertical; } .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; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cyan); outline-offset: 0; border-color: var(--cyan); } .settings-nav .nav-label { padding: 0.7rem 0.75rem 0.25rem; }
input[type="checkbox"], input[type="radio"] { display: inline; width: auto; margin: 0 0.4rem 0 0; } .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; } input[type="file"] { border: 0; padding-left: 0; }
label.check { font-weight: normal; display: flex; align-items: baseline; gap: 0.2rem; } label.check { font-weight: normal; display: flex; align-items: baseline; gap: 0.2rem; }
label.small { font-size: 0.85rem; color: var(--muted); } label.small { font-size: 0.85rem; color: hsl(var(--muted-foreground)); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem 0.2rem; margin: 0 0 1rem; } 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; } 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; } .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 { display: flex; gap: 0.5rem; align-items: center; }
.row input { margin: 0; } .row input { margin: 0; }
@@ -96,59 +267,85 @@ legend { font-weight: 600; padding: 0 0.3rem; }
.secret > label:first-child { flex: 1; } .secret > label:first-child { flex: 1; }
.inline-form label { margin-bottom: 0.2rem; } .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, .button {
button:hover, .button:hover { background: var(--cyan-dark); } display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
button.secondary, .button.secondary { background: #fff; color: var(--cyan-dark); border-color: #b9c3d1; } font: inherit; font-size: 0.9rem; font-weight: 600; padding: 0.5rem 1rem; border-radius: var(--radius);
button.secondary:hover, .button.secondary:hover { background: var(--band); } border: 1px solid transparent; background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
button.danger { background: #fff; color: var(--bad); border-color: #f3b5ae; } cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm);
button:disabled { opacity: 0.5; cursor: not-allowed; } 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; } .actions { display: flex; gap: 0.75rem; align-items: center; margin: 1rem 0 1.5rem; flex-wrap: wrap; }
.danger-zone { margin-top: 2rem; } .danger-zone { margin-top: 2rem; }
.connect { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; } .connect { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.copy { position: relative; } .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; } .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; } .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: #e0f2f7; } button.pill:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); box-shadow: none; }
.checks { list-style: none; padding: 0; } .checks { list-style: none; padding: 0; }
.checks li { padding: 0.25rem 0; } .checks li { padding: 0.25rem 0; }
.checks li::before { margin-right: 0.5rem; font-weight: 700; } .checks li::before { margin-right: 0.5rem; font-weight: 700; }
.checks li.ok::before { content: "✓"; color: var(--ok); } .checks li.ok::before { content: "✓"; color: hsl(var(--ok)); }
.checks li.bad::before { content: "✗"; color: var(--bad); } .checks li.bad::before { content: "✗"; color: hsl(var(--destructive)); }
.checks li.ok { color: var(--ink); } .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; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
[hidden] { display: none !important; } [hidden] { display: none !important; }
/* Content */ /* --- Content --- */
.muted { color: var(--muted); } .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); }
.buttons form { margin: 0; } .item { padding: 0.75rem 1rem; border-bottom: 1px solid hsl(var(--border)); }
.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); }
.item:last-child { border-bottom: 0; } .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 { margin: 0; align-items: flex-start; }
.item label.check > span { display: flex; flex-direction: column; gap: 0.2rem; } .item label.check > span { display: flex; flex-direction: column; gap: 0.2rem; }
.item .body { white-space: pre-line; overflow-wrap: anywhere; } .item .body { white-space: pre-line; overflow-wrap: anywhere; font-size: 0.92rem; }
.item.used { background: var(--band); } .item.used { background: hsl(var(--muted) / 0.5); }
.meta { color: var(--muted); font-size: 0.85rem; font-weight: normal; } .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; } .drafts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }
.draft h3 { margin: 0 0 0.5rem; } .draft h3 { margin: 0 0 0.5rem; }
.draft .actions { margin: 0.5rem 0; } .draft .actions { margin: 0.5rem 0; }
.draft.failed textarea { border-color: #f3b5ae; } .draft.failed textarea { border-color: hsl(var(--bad-border)); }
.count { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--muted); text-align: right; } .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: var(--bad); font-weight: 600; } .count.over { color: hsl(var(--destructive)); 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; }
.schedule { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0.5rem; } .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; } .schedule label { margin: 0; flex: 1; min-width: 12rem; }
.row-actions { white-space: nowrap; } .row-actions { white-space: nowrap; }
.row-actions form { display: inline-block; margin: 0 0.25rem 0.25rem 0; } .row-actions form { display: inline-block; margin: 0 0.25rem 0.25rem 0; }
.post-text { overflow-wrap: anywhere; } .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: hsl(var(--warn-bg)); border: 1px solid hsl(var(--warn-border)); border-radius: var(--radius); color: hsl(var(--warn)); font-size: 0.88rem; }
.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.88rem; }
.rules { margin: 0 0 0.5rem; font-size: 0.9rem; } .rules summary { cursor: pointer; color: hsl(var(--primary)); }
.rules summary { cursor: pointer; color: var(--cyan-dark); } .rules .guidelines { white-space: pre-line; color: hsl(var(--muted-foreground)); }
.rules .guidelines { white-space: pre-line; color: var(--muted); }
form.inline { display: inline-block; margin: 0 0 0.75rem; } 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; }
+22
View File
@@ -16,7 +16,29 @@
if (e.target.matches('input[data-toggle="provider"]')) syncProvider(); 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) { 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 <pre>'s text: <button data-copy="id-of-pre"> // Copy a <pre>'s text: <button data-copy="id-of-pre">
var copy = e.target.closest("[data-copy]"); var copy = e.target.closest("[data-copy]");
if (copy) { if (copy) {
+37
View File
@@ -0,0 +1,37 @@
{{define "content"}}{{template "settings-start" .}}{{with .Data}}{{$set := .Set}}
<h2>Social accounts</h2>
<p class="lede">The keys Supermarket reads posts with, and the sign-ins it publishes with. Keys are kept in <code>secrets.json</code> in Supermarket's data folder, readable only by you; saved values are never shown, and an empty field keeps what's saved.</p>
{{/* The key fields of every card belong to this one form (form="accounts"),
so each card's Save saves them all, and the sign-in forms aren't nested. */}}
<form method="post" action="/settings/accounts" id="accounts"></form>
{{range .Networks}}{{$name := .Name}}
<section class="card network">
<h2>{{.Name}}
{{with .Connect}}{{if .Signed}}<span class="badge published">connected{{with .Account}} as {{.}}{{end}}</span>{{else}}<span class="badge">not connected</span>{{end}}{{end}}
</h2>
{{range .Fields}}
<div class="secret">
<label>{{.Label}}
<input type="password" name="{{.Name}}" form="accounts" autocomplete="off" placeholder="{{if index $set .Name}}saved — type to replace{{else}}not set{{end}}">
{{if .Help}}<span class="help">{{.Help}}</span>{{end}}
</label>
{{if index $set .Name}}<label class="check small"><input type="checkbox" name="remove:{{.Name}}" form="accounts"> remove</label>{{end}}
</div>
{{end}}
<button type="submit" form="accounts" class="secondary">Save keys</button>
{{with .Connect}}
<div class="signin">
<h3>Sign in to post</h3>
{{if .Signed}}<p>Connected{{with .Account}} as <strong>{{.}}</strong>{{end}}{{if not .At.IsZero}}, {{ago .At}}{{end}}.</p>{{end}}
<p class="help">{{.Setup}} <code>{{.Redirect}}</code>{{with .Note}}<br>{{.}}{{end}}</p>
<form method="post" action="/auth/{{.Provider}}/start">
<button type="submit" {{if not .Ready}}disabled title="Save the client ID{{if ne .Provider "x"}} and secret{{end}} first"{{end}}>{{if .Signed}}Reconnect{{else}}Connect{{end}} {{$name}}</button>
</form>
</div>
{{end}}
</section>
{{end}}
{{end}}{{template "settings-end"}}{{end}}
+27 -19
View File
@@ -1,32 +1,39 @@
{{define "content"}}{{with .Data}}{{$cfg := .Cfg}} {{define "content"}}{{template "settings-start" .}}{{with .Data}}{{$cfg := .Cfg}}{{$set := .Set}}
<nav class="tabs"> <h2>AI</h2>
<a href="/settings/ai" aria-current="page">AI provider</a> <p class="lede">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.</p>
<a href="/settings/credentials">Credentials</a>
</nav>
<h1>AI provider</h1>
<form method="post" action="/settings/ai" id="ai-form"> <form method="post" action="/settings/ai" id="ai-form" autocomplete="off">
<section class="card"> <section class="card">
<fieldset class="choice"> <fieldset class="choice">
<legend>Provider</legend> <legend>Provider</legend>
<label class="check"><input type="radio" name="provider" value="anthropic" {{if ne $cfg.Provider "openai"}}checked{{end}} data-toggle="provider"> <label class="check"><input type="radio" name="provider" value="anthropic" {{if ne $cfg.Provider "openai"}}checked{{end}} data-toggle="provider"> Anthropic (Claude)</label>
Anthropic (Claude)
{{if .HasAnthropicKey}}<span class="help">— with the key saved under <a href="/settings/credentials">Credentials</a></span>
{{else if .Shared}}<span class="help">— with Hermes' key, shared by <code>supermarket hermes</code> (Hermes uses {{.Shared.Model}}). A key saved under <a href="/settings/credentials">Credentials</a> would take its place.</span>
{{else}}<span class="help">— add the API key under <a href="/settings/credentials">Credentials</a>, or share Hermes' by running <code>supermarket hermes</code></span>{{end}}</label>
<label class="check"><input type="radio" name="provider" value="openai" {{if eq $cfg.Provider "openai"}}checked{{end}} data-toggle="provider"> <label class="check"><input type="radio" name="provider" value="openai" {{if eq $cfg.Provider "openai"}}checked{{end}} data-toggle="provider">
A server on your network (Ollama, LM Studio, llama.cpp, vLLM) or another OpenAI-compatible service</label> A server on your network (Ollama, LM Studio, llama.cpp, vLLM) or another OpenAI-compatible service</label>
</fieldset> </fieldset>
</section>
<div data-show-for="openai"> <section class="card" data-show-for="anthropic">
<label>Server address <input name="base_url" id="base_url" value="{{$cfg.BaseURL}}" placeholder="http://192.168.1.20:11434" list="servers"> <h3>Key</h3>
{{if .HasAnthropicKey}}<p class="ok">Using the key saved here.</p>
{{else if .Shared}}<p class="ok">Using Hermes' key, shared by <code>supermarket hermes</code>. Hermes uses {{.Shared.Model}}.</p>
<p class="help">To use a separate key, for example to see Supermarket's costs apart from Hermes', save it below: it takes the place of Hermes'.</p>
{{else}}<p class="warn-text">No key yet. Save one below, or share Hermes' by running <code>supermarket hermes</code>.</p>{{end}}
{{range .Keys}}{{if eq .Group "anthropic"}}{{template "key-field" (dict "F" . "Set" (index $set .Name))}}{{end}}{{end}}
</section>
<section class="card" data-show-for="openai">
<h3>Server</h3>
<label>Address <input name="base_url" id="base_url" value="{{$cfg.BaseURL}}" placeholder="http://192.168.1.20:11434" list="servers">
<span class="help">Supermarket runs in Docker: for a server on this computer use <code>http://host.docker.internal:11434</code>, and use an IP address rather than a <code>.local</code> name.</span></label> <span class="help">Supermarket runs in Docker: for a server on this computer use <code>http://host.docker.internal:11434</code>, and use an IP address rather than a <code>.local</code> name.</span></label>
<datalist id="servers">{{range .Servers}}<option value="{{.BaseURL}}">{{.Name}}</option>{{end}}</datalist> <datalist id="servers">{{range .Servers}}<option value="{{.BaseURL}}">{{.Name}}</option>{{end}}</datalist>
{{if .Servers}}<p class="help">Found by CoreDesktop's <code>configure ai-servers</code>: {{range $i, $s := .Servers}}{{if $i}}, {{end}}{{$s.Name}} ({{$s.BaseURL}}){{end}}.</p>{{end}} {{if .Servers}}<p class="help">Found by CoreDesktop's <code>configure ai-servers</code>: {{range $i, $s := .Servers}}{{if $i}}, {{end}}{{$s.Name}} ({{$s.BaseURL}}){{end}}.</p>{{end}}
<button type="button" class="secondary" hx-get="/settings/ai/models" hx-include="#base_url" hx-target="#model-list">List its models</button> <button type="button" class="secondary" hx-get="/settings/ai/models" hx-include="#base_url" hx-target="#model-list">List its models</button>
<div id="model-list"></div> <div id="model-list"></div>
</div> {{range .Keys}}{{if eq .Group "openai"}}{{template "key-field" (dict "F" . "Set" (index $set .Name))}}{{end}}{{end}}
</section>
<section class="card">
<h3>Model</h3>
<label>Model <input name="model" value="{{$cfg.Model}}" list="anthropic-models" required></label> <label>Model <input name="model" value="{{$cfg.Model}}" list="anthropic-models" required></label>
<datalist id="anthropic-models">{{range .AnthropicModels}}<option value="{{.}}">{{end}}</datalist> <datalist id="anthropic-models">{{range .AnthropicModels}}<option value="{{.}}">{{end}}</datalist>
@@ -36,14 +43,14 @@
</select> </select>
<span class="help">How hard the model thinks. Medium suits drafting; higher costs more and takes longer.</span> <span class="help">How hard the model thinks. Medium suits drafting; higher costs more and takes longer.</span>
</label> </label>
</section>
<section class="card"> <details>
<h2>Model per task</h2> <summary>A different model per task</summary>
<p class="help">Leave empty to use the model above. Same provider.</p> <p class="help">Leave empty to use the model above. Same provider.</p>
{{range .Tasks}} {{range .Tasks}}
<label>{{.Label}} <input name="task_{{.ID}}" value="{{index $cfg.TaskModels .ID}}" list="anthropic-models"></label> <label>{{.Label}} <input name="task_{{.ID}}" value="{{index $cfg.TaskModels .ID}}" list="anthropic-models"></label>
{{end}} {{end}}
</details>
</section> </section>
<div class="actions"> <div class="actions">
@@ -51,9 +58,10 @@
<button type="button" class="secondary" hx-post="/settings/ai/test" hx-include="#ai-form" hx-target="#test-result" hx-indicator="#testing">Test</button> <button type="button" class="secondary" hx-post="/settings/ai/test" hx-include="#ai-form" hx-target="#test-result" hx-indicator="#testing">Test</button>
<span id="testing" class="htmx-indicator">Asking the model…</span> <span id="testing" class="htmx-indicator">Asking the model…</span>
</div> </div>
<p class="help">Test uses the provider and model in the form, and the keys already saved: save a new key before testing it.</p>
<div id="test-result"></div> <div id="test-result"></div>
</form> </form>
{{end}}{{end}} {{end}}{{template "settings-end"}}{{end}}
{{define "test-result"}} {{define "test-result"}}
{{if .Error}}<p class="error">{{.Error}}</p> {{if .Error}}<p class="error">{{.Error}}</p>
+5 -10
View File
@@ -1,21 +1,16 @@
{{define "content"}}{{with .Data}} {{define "content"}}{{with .Data}}
<nav class="tabs">
<a href="/content" aria-current="page">Sources</a>
<a href="/content/scheduled">Scheduled</a>
<a href="/content/published">Published</a>
</nav>
<div class="heading"> <div class="heading">
<h1>{{.Name}} <span class="badge {{.Entry.Relationship}}">{{.Entry.Relationship}}</span></h1> <h1>{{.Name}} <span class="badge {{.Entry.Relationship}}">{{.Entry.Relationship}}</span></h1>
<div class="buttons"> <div class="buttons">
<form method="post" action="{{.Base}}/fetch" data-busy="Fetching…"> <form method="post" action="{{.Base}}/fetch" data-busy="Fetching…">
<button type="submit" {{if not .Sources}}disabled{{end}}>Fetch new</button> <button type="submit" {{if not .Sources}}disabled{{end}}>Fetch new</button>
</form> </form>
{{if .Own}}<a class="button secondary" href="/profile">Edit profile</a>{{else}}<a class="button secondary" href="/inventory/{{.Entry.ID}}">Edit entry</a>{{end}} {{if .Own}}<a class="button secondary" href="/settings/profile">Edit profile</a>{{else}}<a class="button secondary" href="/inventory/{{.Entry.ID}}">Edit entry</a>{{end}}
</div> </div>
</div> </div>
<p class="lede"> <p class="lede">
{{if .Own}}Posts that promote your own work: pick a product, or fetch your feeds and new pages on your websites. {{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 <a href="/profile">profile</a> to fetch them.{{end}} {{if .Sources}}Reads {{join .Sources ", "}}.{{else}}Add your blog and release feeds, and your websites, to the <a href="/settings/profile">profile</a> 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}} {{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"}}. Last fetched {{ago .LastChecked}}; the next fetch looks for posts since {{.Since.Local.Format "2 Jan 15:04"}}.
</p> </p>
@@ -25,7 +20,7 @@
<p><strong>{{if .NewItems}}{{.NewItems}} new item{{if ne .NewItems 1}}s{{end}}.{{else}}Nothing new.{{end}}</strong></p> <p><strong>{{if .NewItems}}{{.NewItems}} new item{{if ne .NewItems 1}}s{{end}}.{{else}}Nothing new.{{end}}</strong></p>
{{if .Errors}}<p class="warn-text">Some sources failed; they'll be read from the same point next time:</p> {{if .Errors}}<p class="warn-text">Some sources failed; they'll be read from the same point next time:</p>
<ul>{{range .Errors}}<li>{{.}}</li>{{end}}</ul>{{end}} <ul>{{range .Errors}}<li>{{.}}</li>{{end}}</ul>{{end}}
{{if .Skipped}}<p class="muted">Skipped, for lack of credentials (<a href="/settings/credentials">add them</a>): {{join .Skipped "; "}}.</p>{{end}} {{if .Skipped}}<p class="muted">Skipped, for lack of credentials (<a href="/settings/accounts">add them</a>): {{join .Skipped "; "}}.</p>{{end}}
</section> </section>
{{end}} {{end}}
@@ -78,7 +73,7 @@
{{else}} {{else}}
<section class="card"> <section class="card">
<h2>Write drafts from the selected items</h2> <h2>Write drafts from the selected items</h2>
{{if not .ProfileSet}}<p class="warn-text">Fill in the <a href="/profile">company profile</a> first: drafts are written in its voice.</p>{{end}} {{if not .ProfileSet}}<p class="warn-text">Fill in the <a href="/settings/profile">company profile</a> first: drafts are written in its voice.</p>{{end}}
<fieldset class="choice"> <fieldset class="choice">
<legend>Channels</legend> <legend>Channels</legend>
{{range .Channels}} {{range .Channels}}
@@ -105,7 +100,7 @@
</form> </form>
{{else}} {{else}}
<section class="card empty"> <section class="card empty">
<p>{{if .ShowDismissed}}Nothing dismissed.{{else if .Own}}No products or news yet: add products, feeds or websites to your <a href="/profile">profile</a>, then fetch.{{else}}No items yet. Fetch to see what {{.Name}} has been up to.{{end}}</p> <p>{{if .ShowDismissed}}Nothing dismissed.{{else if .Own}}No products or news yet: add products, feeds or websites to your <a href="/settings/profile">profile</a>, then fetch.{{else}}No items yet. Fetch to see what {{.Name}} has been up to.{{end}}</p>
</section> </section>
{{end}} {{end}}
{{end}}{{end}} {{end}}{{end}}
@@ -1,9 +1,4 @@
{{define "content"}}{{with .Data}} {{define "content"}}{{with .Data}}
<nav class="tabs">
<a href="/content">Sources</a>
<a href="/content/scheduled">Scheduled</a>
<a href="/content/published" aria-current="page">Published</a>
</nav>
<h1>Published</h1> <h1>Published</h1>
<p class="lede">The last 200 posts Supermarket published.</p> <p class="lede">The last 200 posts Supermarket published.</p>
@@ -1,9 +1,4 @@
{{define "content"}}{{with .Data}}{{$conn := .Connected}} {{define "content"}}{{with .Data}}{{$conn := .Connected}}
<nav class="tabs">
<a href="/content">Sources</a>
<a href="/content/scheduled" aria-current="page">Scheduled</a>
<a href="/content/published">Published</a>
</nav>
<h1>Scheduled</h1> <h1>Scheduled</h1>
<p class="lede">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.</p> <p class="lede">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.</p>
+2 -7
View File
@@ -1,10 +1,5 @@
{{define "content"}}{{with .Data}} {{define "content"}}{{with .Data}}
<nav class="tabs"> <h1>Sources</h1>
<a href="/content" aria-current="page">Sources</a>
<a href="/content/scheduled">Scheduled</a>
<a href="/content/published">Published</a>
</nav>
<h1>Content</h1>
<p class="lede">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 <a href="/inbox">Inbox</a>.</p> <p class="lede">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 <a href="/inbox">Inbox</a>.</p>
{{if .Rows}} {{if .Rows}}
@@ -16,7 +11,7 @@
{{if .Own}} {{if .Own}}
<td><a href="/content/own">{{.Name}}</a> <span class="muted small">your own work</span></td> <td><a href="/content/own">{{.Name}}</a> <span class="muted small">your own work</span></td>
<td><span class="badge product">product</span></td> <td><span class="badge product">product</span></td>
<td>{{if .Sources}}{{join .Sources ", "}}{{else}}<span class="muted">none: add products, websites or feeds to your <a href="/profile">profile</a></span>{{end}}</td> <td>{{if .Sources}}{{join .Sources ", "}}{{else}}<span class="muted">none: add products, websites or feeds to your <a href="/settings/profile">profile</a></span>{{end}}</td>
{{else}} {{else}}
<td><a href="/content/{{.Entry.ID}}">{{.Name}}</a></td> <td><a href="/content/{{.Entry.ID}}">{{.Name}}</a></td>
<td><span class="badge {{.Entry.Relationship}}">{{.Entry.Relationship}}</span></td> <td><span class="badge {{.Entry.Relationship}}">{{.Entry.Relationship}}</span></td>
+5 -4
View File
@@ -1,12 +1,13 @@
{{define "content"}}{{with .Data}} {{define "content"}}{{template "settings-start" .}}{{with .Data}}
<h1>Core &amp; Hermes</h1> <h2>Core &amp; Hermes</h2>
<p class="lede">Your Federated Core's services, and Hermes, the agent that reaches them for Supermarket.</p>
<section class="card"> <section class="card">
<h2>Federated Core</h2> <h2>Federated Core</h2>
{{if .Core}} {{if .Core}}
<p><strong>{{.Core.Domain}}</strong> · {{.Core.Email}}{{if .Core.Name}} · {{.Core.Name}}{{end}}</p> <p><strong>{{.Core.Domain}}</strong> · {{.Core.Email}}{{if .Core.Name}} · {{.Core.Name}}{{end}}</p>
<p class="help">From CoreDesktop's <code>configure core</code>. To use another Core, change it there and run <code>update</code>.</p> <p class="help">From CoreDesktop's <code>configure core</code>. To use another Core, change it there and run <code>update</code>.</p>
<div hx-get="/core/checks" hx-trigger="load" hx-swap="outerHTML"><p class="help">Checking the Core's services…</p></div> <div hx-get="/settings/core/checks" hx-trigger="load" hx-swap="outerHTML"><p class="help">Checking the Core's services…</p></div>
{{else}} {{else}}
<p>No Core found. Run <code>configure core</code> in CoreDesktop, then <code>update</code>. Without a Core, everything works except EspoCRM, Plausible and publishing through Gitea.</p> <p>No Core found. Run <code>configure core</code> in CoreDesktop, then <code>update</code>. Without a Core, everything works except EspoCRM, Plausible and publishing through Gitea.</p>
{{end}} {{end}}
@@ -41,7 +42,7 @@
<p>Hermes runs in CoreDesktop's sandbox, so also let it reach the hub: add <code>mcphub.{{if .Core}}{{.Core.Domain}}{{else}}&lt;your Core's domain&gt;{{end}}</code> to <code>network.allowedDomains</code> in <code>~/.config/coredesktop/sandbox/hermes.json</code>. Then restart Hermes' gateway: <code>systemctl --user restart hermes-gateway</code>.</p> <p>Hermes runs in CoreDesktop's sandbox, so also let it reach the hub: add <code>mcphub.{{if .Core}}{{.Core.Domain}}{{else}}&lt;your Core's domain&gt;{{end}}</code> to <code>network.allowedDomains</code> in <code>~/.config/coredesktop/sandbox/hermes.json</code>. Then restart Hermes' gateway: <code>systemctl --user restart hermes-gateway</code>.</p>
<details><summary>Show the MCP token</summary><pre>{{.MCPToken}}</pre><p class="help">Also in <code>mcp-token</code> in the data folder.</p></details> <details><summary>Show the MCP token</summary><pre>{{.MCPToken}}</pre><p class="help">Also in <code>mcp-token</code> in the data folder.</p></details>
</details> </details>
{{end}}{{end}} {{end}}{{template "settings-end"}}{{end}}
{{define "checks"}} {{define "checks"}}
{{if .}} {{if .}}
-51
View File
@@ -1,51 +0,0 @@
{{define "content"}}{{with .Data}}{{$set := .Set}}
<nav class="tabs">
<a href="/settings/ai">AI provider</a>
<a href="/settings/credentials" aria-current="page">Credentials</a>
</nav>
<h1>Credentials</h1>
<p class="lede">Kept in <code>secrets.json</code> in Supermarket's data folder, readable only by you. Saved values are never shown: leave a field empty to keep what's saved.</p>
<form method="post" action="/settings/credentials">
{{$group := ""}}
{{range .Fields}}
{{if ne .Group $group}}{{if $group}}</section>{{end}}{{$group = .Group}}<section class="card"><h2>{{.Group}}</h2>{{end}}
<div class="secret">
<label>{{.Label}}
<input type="password" name="{{.Name}}" autocomplete="off" placeholder="{{if index $set .Name}}saved — type to replace{{else}}not set{{end}}">
{{if .Help}}<span class="help">{{.Help}}</span>{{end}}
</label>
{{if index $set .Name}}<label class="check small"><input type="checkbox" name="remove:{{.Name}}"> remove</label>{{end}}
</div>
{{end}}
{{if $group}}</section>{{end}}
<div class="actions"><button type="submit">Save</button></div>
</form>
<section class="card">
<h2>Sign in to post</h2>
<div class="connect">
<div>
<h3>X</h3>
{{with index .Connections "x"}}{{if .Account}}<p>Connected as @{{.Account}}, {{ago .At}}.</p>{{end}}{{end}}
{{if and (index $set .XToken) (not (index .Connections "x").Account)}}<p>A token is saved.</p>{{end}}
<p class="help">In the X developer portal, add this callback URL to your app: <code>{{.XRedirect}}</code></p>
<form method="post" action="/auth/x/start"><button type="submit" {{if not (index $set "x.client_id")}}disabled{{end}}>{{if index $set .XToken}}Reconnect{{else}}Connect{{end}} X</button></form>
</div>
<div>
<h3>LinkedIn</h3>
{{with index .Connections "linkedin"}}{{if .Account}}<p>Connected, {{ago .At}}.</p>{{end}}{{end}}
{{if and (index $set .LIToken) (not (index .Connections "linkedin").Account)}}<p>A token is saved.</p>{{end}}
<p class="help">In your LinkedIn app's Auth settings, add this redirect URL: <code>{{.LIRedirect}}</code></p>
<form method="post" action="/auth/linkedin/start"><button type="submit" {{if not (and (index $set "linkedin.client_id") (index $set "linkedin.client_secret"))}}disabled{{end}}>{{if index $set .LIToken}}Reconnect{{else}}Connect{{end}} LinkedIn</button></form>
</div>
<div>
<h3>Reddit</h3>
{{with index .Connections "reddit"}}{{if .Account}}<p>Connected as u/{{.Account}}, {{ago .At}}.</p>{{end}}{{end}}
<p class="help">At reddit.com/prefs/apps, create a <strong>web app</strong> with this redirect URI: <code>{{.RedditRedirect}}</code>.
Reddit's API terms need approval for commercial use: Supermarket is meant for a few hand-approved posts, not volume.</p>
<form method="post" action="/auth/reddit/start"><button type="submit" {{if not (and (index $set "reddit.client_id") (index $set "reddit.client_secret"))}}disabled{{end}}>{{if index $set .RedditToken}}Reconnect{{else}}Connect{{end}} Reddit</button></form>
</div>
</div>
</section>
{{end}}{{end}}
+33 -12
View File
@@ -1,6 +1,27 @@
{{define "content"}}{{with .Data}} {{define "content"}}{{$inbox := .Inbox}}{{with .Data}}
<h1>Overview</h1> <div class="page-head">
<h1>Overview</h1>
<p class="lede">Supermarket's modules, and what's left to set up.</p>
</div>
<div class="grid">
{{range .Modules}}
{{if .Link}}
<a class="card module" href="{{.Link}}">
<h3>{{template "icon" .ID}}{{.Name}} <span class="badge">{{.Phase}}</span></h3>
<p>{{.Body}}</p>
{{if eq .ID "content"}}<span class="stat">{{if $inbox}}{{$inbox}} waiting in the Inbox{{else}}Inbox empty{{end}}{{with $.Data.Scheduled}} · {{.}} scheduled{{end}}</span>{{end}}
</a>
{{else}}
<section class="card module later">
<h3>{{template "icon" .ID}}{{.Name}} <span class="badge">{{.Phase}}</span></h3>
<p>{{.Body}}</p>
</section>
{{end}}
{{end}}
</div>
{{if .Pending}}
<section class="card"> <section class="card">
<h2>Setup</h2> <h2>Setup</h2>
<ul class="steps"> <ul class="steps">
@@ -12,6 +33,16 @@
{{end}} {{end}}
</ul> </ul>
</section> </section>
{{else}}
<details class="card">
<summary>Setup: all done</summary>
<ul class="steps">
{{range .Steps}}
<li class="done"><a href="{{.Link}}"><strong>{{.Label}}</strong></a><span>{{.Detail}}</span></li>
{{end}}
</ul>
</details>
{{end}}
{{if .ImportErr}} {{if .ImportErr}}
<section class="card warn"> <section class="card warn">
@@ -26,14 +57,4 @@
{{if .QueuedPosts}}<p>Its queued posts are now drafts: <a href="/inbox">{{.QueuedPosts}} waiting in the Inbox</a>.</p>{{end}} {{if .QueuedPosts}}<p>Its queued posts are now drafts: <a href="/inbox">{{.QueuedPosts}} waiting in the Inbox</a>.</p>{{end}}
</details> </details>
{{end}} {{end}}
<h2>Modules</h2>
<div class="grid">
{{range .Modules}}
<section class="card module">
<h3>{{if .Link}}<a href="{{.Link}}">{{.Name}}</a>{{else}}{{.Name}}{{end}} <span class="badge">{{.Phase}}</span></h3>
<p>{{.Body}}</p>
</section>
{{end}}
</div>
{{end}}{{end}} {{end}}{{end}}
+2 -2
View File
@@ -44,7 +44,7 @@
<p class="count{{if .TooLong}} over{{end}}" id="count-{{.ID}}">{{.Length}} / {{.Limit}}{{if and (eq .Channel "x") .SourceURL}} including the link{{end}}</p> <p class="count{{if .TooLong}} over{{end}}" id="count-{{.ID}}">{{.Length}} / {{.Limit}}{{if and (eq .Channel "x") .SourceURL}} including the link{{end}}</p>
<div class="actions"> <div class="actions">
<button type="submit" name="action" value="publish" formaction="/drafts/{{.ID}}/publish" <button type="submit" name="action" value="publish" formaction="/drafts/{{.ID}}/publish"
{{if not (index $conn .Channel)}}disabled title="Sign in to {{.ChannelName}} under Settings → Credentials"{{end}}>Publish now</button> {{if not (index $conn .Channel)}}disabled title="Sign in to {{.ChannelName}} under Settings → Social accounts"{{end}}>Publish now</button>
<button type="submit" class="secondary">Save</button> <button type="submit" class="secondary">Save</button>
</div> </div>
<div class="schedule"> <div class="schedule">
@@ -53,7 +53,7 @@
</label> </label>
<button type="submit" class="secondary" formaction="/drafts/{{.ID}}/schedule">Schedule</button> <button type="submit" class="secondary" formaction="/drafts/{{.ID}}/schedule">Schedule</button>
</div> </div>
{{if not (index $conn .Channel)}}<p class="help">{{.ChannelName}} isn't connected: <a href="/settings/credentials">sign in</a> before it's due.</p>{{end}} {{if not (index $conn .Channel)}}<p class="help">{{.ChannelName}} isn't connected: <a href="/settings/accounts">sign in</a> before it's due.</p>{{end}}
</form> </form>
<form method="post" action="/drafts/{{.ID}}/discard" data-confirm="Discard this {{.Where}} draft?"> <form method="post" action="/drafts/{{.ID}}/discard" data-confirm="Discard this {{.Where}} draft?">
<button type="submit" class="danger small">Discard</button> <button type="submit" class="danger small">Discard</button>
+106 -14
View File
@@ -10,23 +10,115 @@
<script src="/static/app.js" defer></script> <script src="/static/app.js" defer></script>
</head> </head>
<body> <body>
<header class="topbar"> <div class="shell">
<a class="brand" href="/">Super<span>market</span></a> <aside class="sidebar" id="sidebar">
<nav> <a class="brand" href="/"><span class="logo">{{template "icon" "cart"}}</span>Supermarket</a>
<a href="/" {{if eq .Nav "home"}}aria-current="page"{{end}}>Overview</a> <form class="search" action="/search" method="get" role="search">
<a href="/profile" {{if eq .Nav "profile"}}aria-current="page"{{end}}>Profile</a> {{template "icon" "search"}}
<a href="/inbox" {{if eq .Nav "inbox"}}aria-current="page"{{end}}>Inbox{{if .Inbox}} <span class="count-badge">{{.Inbox}}</span>{{end}}</a> <input type="search" name="q" value="{{.Query}}" placeholder="Search" aria-label="Search" id="search-box">
<a href="/content" {{if eq .Nav "content"}}aria-current="page"{{end}}>Content</a> <kbd title="Press / to search">/</kbd>
<a href="/inventory" {{if eq .Nav "inventory"}}aria-current="page"{{end}}>Inventory</a> </form>
<a href="/settings/ai" {{if eq .Nav "settings"}}aria-current="page"{{end}}>Settings</a> <nav class="nav" aria-label="Main">
<a href="/core" {{if eq .Nav "core"}}aria-current="page"{{end}}>Core &amp; Hermes</a> <a href="/" {{if eq .Nav "home"}}aria-current="page"{{end}}>{{template "icon" "overview"}}<span>Overview</span></a>
<a href="/inventory" {{if eq .Nav "inventory"}}aria-current="page"{{end}}>{{template "icon" "inventory"}}<span>Inventory</span></a>
<div class="nav-label">Modules</div>
{{$nav := .Nav}}{{$inbox := .Inbox}}
{{range .Modules}}
{{if .Link}}
<a href="{{.Link}}" {{if eq $nav .ID}}aria-current="page"{{end}} class="{{if hasPrefix $nav .ID}}open{{end}}">{{template "icon" .ID}}<span>{{.Name}}</span></a>
{{if eq .ID "content"}}
<div class="subnav">
<a href="/inbox" {{if eq $nav "content/inbox"}}aria-current="page"{{end}}>Inbox{{if $inbox}} <span class="count-badge" title="{{$inbox}} waiting for review">{{$inbox}}</span>{{end}}</a>
<a href="/content" {{if eq $nav "content/sources"}}aria-current="page"{{end}}>Sources</a>
<a href="/content/scheduled" {{if eq $nav "content/scheduled"}}aria-current="page"{{end}}>Scheduled</a>
<a href="/content/published" {{if eq $nav "content/published"}}aria-current="page"{{end}}>Published</a>
</div>
{{end}}
{{else}}
<span class="soon" title="{{.Body}}">{{template "icon" .ID}}<span>{{.Name}}</span><small>{{.Phase}}</small></span>
{{end}}
{{end}}
</nav> </nav>
</header> <div class="sidebar-foot">
<main> <a href="/settings/profile" {{if hasPrefix .Nav "settings"}}aria-current="page"{{end}}>{{template "icon" "settings"}}<span>Settings</span></a>
<p class="version">Supermarket {{.Version}}</p>
</div>
</aside>
<div class="scrim" data-nav-close></div>
<div class="main-col">
<header class="topbar">
<button type="button" class="icon-button menu-button" data-nav-toggle aria-controls="sidebar" aria-label="Open navigation">{{template "icon" "menu"}}</button>
<nav class="crumbs" aria-label="Breadcrumb">
{{with .Section}}<span>{{.}}</span><span class="sep" aria-hidden="true">/</span>{{end}}
<span class="here">{{.Title}}</span>
</nav>
</header>
<main>
{{if .Flash}}<p class="flash" role="status">{{.Flash}}</p>{{end}} {{if .Flash}}<p class="flash" role="status">{{.Flash}}</p>{{end}}
{{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}} {{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}}
{{template "content" .}} {{template "content" .}}
</main> </main>
<footer>Supermarket {{.Version}}</footer> </div>
</div>
</body> </body>
</html> </html>
{{/* 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"}}
<div class="page-head">
<h1>Settings</h1>
<p class="lede">Your company, the accounts Supermarket posts with, the AI it writes with, and your Federated Core.</p>
</div>
<div class="settings">
<nav class="settings-nav" aria-label="Settings sections">
<div class="nav-label">Company</div>
<a href="/settings/profile" {{if eq .Nav "settings/profile"}}aria-current="page"{{end}}>{{template "icon" "profile"}}Profile</a>
<div class="nav-label">Connections</div>
<a href="/settings/accounts" {{if eq .Nav "settings/accounts"}}aria-current="page"{{end}}>{{template "icon" "accounts"}}Social accounts</a>
<a href="/settings/core" {{if eq .Nav "settings/core"}}aria-current="page"{{end}}>{{template "icon" "core"}}Core &amp; Hermes</a>
<div class="nav-label">AI</div>
<a href="/settings/ai" {{if eq .Nav "settings/ai"}}aria-current="page"{{end}}>{{template "icon" "ai"}}AI</a>
</nav>
<div class="settings-body">
{{end}}
{{define "settings-end"}}
</div>
</div>
{{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"}}
<div class="secret">
<label>{{.F.Label}}
<input type="password" name="{{.F.Name}}" autocomplete="off" placeholder="{{if .Set}}saved — type to replace{{else}}not set{{end}}">
{{if .F.Help}}<span class="help">{{.F.Help}} Kept in <code>secrets.json</code>, readable only by you, and never shown again.</span>{{end}}
</label>
{{if .Set}}<label class="check small"><input type="checkbox" name="remove:{{.F.Name}}"> remove</label>{{end}}
</div>
{{end}}
{{/* Icons from Lucide (lucide.dev, ISC licence). */}}
{{define "icon"}}<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
{{- if eq . "search"}}<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>
{{- else if eq . "overview"}}<rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/>
{{- else if eq . "inventory"}}<path d="m16 6 4 14"/><path d="M12 6v14"/><path d="M8 8v12"/><path d="M4 4v16"/>
{{- else if eq . "content"}}<path d="M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"/><path d="M18 14h-8"/><path d="M15 18h-5"/><path d="M10 6h8v4h-8V6Z"/>
{{- else if eq . "prospects"}}<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>
{{- else if eq . "seo"}}<polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/>
{{- else if eq . "metrics"}}<path d="M3 3v18h18"/><path d="M18 17V9"/><path d="M13 17V5"/><path d="M8 17v-3"/>
{{- else if eq . "sites"}}<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>
{{- else if eq . "settings"}}<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>
{{- else if eq . "profile"}}<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>
{{- else if eq . "accounts"}}<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><path d="m8.59 13.51 6.83 3.98"/><path d="m15.41 6.51-6.82 3.98"/>
{{- else if eq . "ai"}}<path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/>
{{- else if eq . "core"}}<path d="M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z"/><path d="m2 22 3-3"/><path d="M7.5 13.5 10 11"/><path d="M10.5 16.5 13 14"/><path d="m18 3-4 4h6l-4 4"/>
{{- else if eq . "cart"}}<circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>
{{- else if eq . "menu"}}<path d="M4 12h16"/><path d="M4 6h16"/><path d="M4 18h16"/>
{{- end}}</svg>{{end}}
+5 -5
View File
@@ -1,8 +1,8 @@
{{define "content"}}{{with .Data}} {{define "content"}}{{template "settings-start" .}}{{with .Data}}
<h1>Company profile</h1> <h2>Company profile</h2>
<p class="lede">Everything Supermarket writes, targets and audits starts here.</p> <p class="lede">Everything Supermarket writes, targets and audits starts here.</p>
<form class="card inline-form" method="post" action="/profile/draft"> <form class="card inline-form" method="post" action="/settings/profile/draft">
<label for="draft_url"><strong>Draft from your website</strong></label> <label for="draft_url"><strong>Draft from your website</strong></label>
<p class="help">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.</p> <p class="help">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.</p>
{{if .NoAI}}<p class="warn-text">This uses the AI: first <a href="/settings/ai">choose an AI provider</a> (for Anthropic, add your API key), then come back. Or fill in the form below by hand.</p>{{end}} {{if .NoAI}}<p class="warn-text">This uses the AI: first <a href="/settings/ai">choose an AI provider</a> (for Anthropic, add your API key), then come back. Or fill in the form below by hand.</p>{{end}}
@@ -15,7 +15,7 @@
{{if .Drafted}}<p class="flash">Here's a draft. Check every field, correct what's wrong, then Save.</p>{{end}} {{if .Drafted}}<p class="flash">Here's a draft. Check every field, correct what's wrong, then Save.</p>{{end}}
<form method="post" action="/profile"> <form method="post" action="/settings/profile">
{{with .P}} {{with .P}}
<section class="card"> <section class="card">
<h2>The company</h2> <h2>The company</h2>
@@ -105,4 +105,4 @@
<div class="actions"><button type="submit">Save</button></div> <div class="actions"><button type="submit">Save</button></div>
</form> </form>
{{end}}{{end}} {{end}}{{template "settings-end"}}{{end}}
+29
View File
@@ -0,0 +1,29 @@
{{define "content"}}{{with .Data}}
<div class="page-head">
<h1>Search</h1>
<p class="lede">Posts, fetched items, the inventory, your products and settings.</p>
</div>
<form class="search-page" action="/search" method="get" role="search">
<input type="search" name="q" value="{{.Q}}" placeholder="e.g. a company, a product, or words from a post" aria-label="Search for" autofocus>
<button type="submit">Search</button>
</form>
{{if .Q}}
{{if .Groups}}
{{$limit := .Limit}}
{{range .Groups}}
<h2>{{.Name}} <span class="muted small">{{len .Hits}}{{if ge (len .Hits) $limit}}+{{end}}</span></h2>
<ul class="results">
{{range .Hits}}
<li><a href="{{.Link}}">
<span class="title"><span>{{truncate 140 .Title}}</span>{{with .Badge}}<span class="badge {{.}}">{{.}}</span>{{end}}</span>
{{with .Detail}}<span class="detail">{{truncate 200 .}}</span>{{end}}
</a></li>
{{end}}
</ul>
{{end}}
{{else}}
<section class="card empty"><p>Nothing matches “{{.Q}}”. Every word has to appear; try fewer words.</p></section>
{{end}}
{{end}}
{{end}}{{end}}