Fixes from the first round of TEST.md

SEO: a domain property (sc-domain:) covers every subdomain, so the shop,
Gitea and forum were counted as the website. What ranks, the morning
check, the Monday report, keywords, change candidates and the audit's
traffic now read only the website's own host (with or without www).
The report keeps pages worth a proposal apart from "Waiting for your
yes", explains only moves past the thresholds, and says "places up/down".

Also:
- Feed summaries drop the posts' scripts and styles.
- Spend you log can't be negative.
- Test and check buttons can't be clicked twice while they run.
- Previews show the site's web fonts and icon sprites.
- Backups are read without leaving -wal/-shm files; deleting one removes
  them, and leftovers are swept at start.
- The Overview's setup flags a CRM that Hermes can't reach.
- Import now says what came in; adding a prospect that exists says so;
  prospects can be deleted.
- Signal tags and brief addresses keep accented letters (Ü → u).
- Page errors start with a capital; clearer messages for bad uploads,
  CRM retry and cancel, keywords, and the finished audit.
- The module you're in stays unfolded in the sidebar.
- A picked keyword can be unpicked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 06:31:42 -07:00
co-authored by Claude Opus 5.5
parent 3ddf716e71
commit c36f786ae9
52 changed files with 796 additions and 128 deletions
+54 -1
View File
@@ -16,6 +16,8 @@ import (
"strings"
"sync"
"time"
"unicode"
"unicode/utf8"
"supermarket/internal/api/reddit"
"supermarket/internal/api/twitter"
@@ -484,8 +486,9 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, p p
p.NewProspects = s.newProspects()
p.Drafts = s.outreachDrafts()
if p.Flash == "" {
p.Flash = flashes[r.URL.Query().Get("msg")]
p.Flash = flashText(r.URL.Query())
}
p.Error = sentence(p.Error)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := t.ExecuteTemplate(w, "layout.html", p); err != nil {
s.Log.Error("render", "page", name, "err", err)
@@ -525,6 +528,10 @@ var flashes = map[string]string{
"proposed": "Proposed: read each one, edit it if you like, then say yes or no.",
"approved": "Approved: Supermarket is making the pull request; it shows here in a minute.",
"declined": "Declined.",
"keyword-picked": "Picked. Write its brief when you're ready.",
"keyword-dismissed": "Dismissed: it's under Dismissed if you change your mind.",
"keyword-back": "Back among the candidates.",
"audited": "The audit is done.",
"auditing": "Auditing. It reads up to 300 pages politely, so it takes a few minutes; this page updates when it's done.",
"no-data": "There isn't two weeks of Search Console data yet.",
"reddit-connected": "Reddit is connected.",
@@ -536,10 +543,14 @@ var flashes = map[string]string{
"suppressed": "Added to the suppression list.",
"unsuppressed": "Taken off the suppression list.",
"prospect-added": "Added. Review it below.",
"crm-retried": "Queued again: Hermes tries it on its next run.",
"crm-cancelled": "Taken back: Hermes won't do it.",
"prospect-exists": "Already there: nothing new was added. It's in the list below.",
"outcome": "Outcome recorded.",
"discovering": "Searching. It takes a few minutes; new companies appear in Review, tagged with this signal.",
"rules-refreshed": "Rules refreshed.",
"imported": "Imported.",
"imported-counts": "Imported: %d new steps in the funnel, %d new people to review, %d new on the suppression list.",
"hunter-done": "Hunter.io search done: the result is on the card.",
"verified": "Checked with Hunter.io: the result is on each person.",
"drafted-outreach": "Drafted. Read it, edit it, then queue it to send.",
@@ -561,6 +572,48 @@ var flashes = map[string]string{
"unscheduled": "Back in Posts: edit it, then publish or schedule it again.",
}
// sentence starts a message with a capital letter: errors from deeper
// down are written in lower case, to be wrapped.
func sentence(msg string) string {
r, n := utf8.DecodeRuneInString(msg)
if n == 0 || !unicode.IsLower(r) {
return msg
}
return string(unicode.ToUpper(r)) + msg[n:]
}
// flashText is the message a redirect asked for (?msg=), from the fixed
// list. A message with %d verbs takes its numbers from n1, n2… (digits
// only), so nothing but a number can be put into it from the address.
func flashText(q url.Values) string {
msg := flashes[q.Get("msg")]
if n := strings.Count(msg, "%d"); n > 0 {
args := make([]any, n)
for i := range args {
v, _ := strconv.Atoi(q.Get("n" + strconv.Itoa(i+1)))
args[i] = v
}
msg = fmt.Sprintf(msg, args...)
}
return msg
}
// redirectCounts redirects with a message that has numbers in it.
func redirectCounts(w http.ResponseWriter, r *http.Request, path, msg string, counts ...int) {
base, frag, hasFrag := strings.Cut(path, "#")
for i, c := range counts {
sep := "?"
if strings.Contains(base, "?") {
sep = "&"
}
base += sep + "n" + strconv.Itoa(i+1) + "=" + strconv.Itoa(c)
}
if hasFrag {
base += "#" + frag
}
redirect(w, r, base, msg)
}
func redirect(w http.ResponseWriter, r *http.Request, path, msg string) {
if msg != "" {
// The message goes in the query, before any #fragment.