Files
davidandClaude Opus 5.5 cd24f2a06d Phase 1, part 4: promote the company's own products
- Content lists the company first, at /content/own: its products from
  the profile (always there to pick from), its own feeds (a new profile
  field for the blog, news and releases), and new or updated pages from
  its websites' sitemaps, with each page's title and description.
- Drafts from it are kind "product" (utm_campaign=product), filed under
  the company's name, and prompted to promote the company's own work
  without unsupported claims; on Reddit, in the makers' voice, with a
  warning that self-promotion is often restricted.

This completes Phase 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 14:42:37 -07:00

164 lines
5.0 KiB
Go

// Package profile is the company profile: what the company sells, to whom,
// in what voice, and where it lives online. Every module reads it.
package profile
import (
"strings"
"supermarket/internal/db"
)
const settingKey = "profile"
type Product struct {
Name string `json:"name"`
Description string `json:"description"`
URL string `json:"url"`
Pricing string `json:"pricing"`
Benefits []string `json:"benefits"`
}
// Targets is the ideal customer profile.
type Targets struct {
Industries []string `json:"industries"`
CompanySizes []string `json:"company_sizes"`
Roles []string `json:"roles"`
Regions []string `json:"regions"`
Problems []string `json:"problems"`
BuyingSignals []string `json:"buying_signals"`
Technologies []string `json:"technologies"`
}
type Website struct {
URL string `json:"url"`
Repo string `json:"repo"` // Gitea repository of the Hugo site
Branch string `json:"branch"` // the branch that gets published
PlausibleSite string `json:"plausible_site"`
SearchConsoleProperty string `json:"search_console_property"`
BingSite string `json:"bing_site"`
}
type Accounts struct {
X string `json:"x"` // handle, without @
LinkedIn string `json:"linkedin"` // organization page URL
Reddit string `json:"reddit"` // user name, without u/
Subreddits []string `json:"subreddits"`
}
type Profile struct {
Name string `json:"name"`
Description string `json:"description"`
Positioning string `json:"positioning"`
Voice string `json:"voice"`
Avoid []string `json:"avoid"`
Products []Product `json:"products"`
Targets Targets `json:"targets"`
Websites []Website `json:"websites"`
Accounts Accounts `json:"accounts"`
Keywords []string `json:"keywords"`
// Feeds are the company's own RSS/Atom feeds: its blog, news and
// releases (e.g. a GitHub or Gitea releases.atom), for promoting its
// own work.
Feeds []string `json:"feeds"`
}
// IsSet reports whether the profile has the minimum the other modules need.
func (p *Profile) IsSet() bool {
return strings.TrimSpace(p.Name) != "" && strings.TrimSpace(p.Description) != ""
}
// Load returns the saved profile, or an empty one.
func Load(d *db.DB) (*Profile, error) {
p := &Profile{}
if _, err := d.GetJSON(settingKey, p); err != nil {
return nil, err
}
return p, nil
}
// Save stores the profile after tidying it.
func Save(d *db.DB, p *Profile) error {
p.Clean()
return d.PutJSON(settingKey, p)
}
// Clean trims whitespace and drops empty list entries, products and websites.
func (p *Profile) Clean() {
p.Name = strings.TrimSpace(p.Name)
p.Description = strings.TrimSpace(p.Description)
p.Positioning = strings.TrimSpace(p.Positioning)
p.Voice = strings.TrimSpace(p.Voice)
p.Avoid = CleanList(p.Avoid)
p.Keywords = CleanList(p.Keywords)
p.Feeds = CleanList(p.Feeds)
products := p.Products[:0]
for _, pr := range p.Products {
pr.Name = strings.TrimSpace(pr.Name)
pr.Description = strings.TrimSpace(pr.Description)
pr.URL = strings.TrimSpace(pr.URL)
pr.Pricing = strings.TrimSpace(pr.Pricing)
pr.Benefits = CleanList(pr.Benefits)
if pr.Name != "" {
products = append(products, pr)
}
}
p.Products = products
websites := p.Websites[:0]
for _, w := range p.Websites {
w.URL = strings.TrimRight(strings.TrimSpace(w.URL), "/")
w.Repo = strings.TrimSpace(w.Repo)
w.Branch = strings.TrimSpace(w.Branch)
w.PlausibleSite = strings.TrimSpace(w.PlausibleSite)
w.SearchConsoleProperty = strings.TrimSpace(w.SearchConsoleProperty)
w.BingSite = strings.TrimSpace(w.BingSite)
if w.URL != "" {
if w.Branch == "" && w.Repo != "" {
w.Branch = "main"
}
websites = append(websites, w)
}
}
p.Websites = websites
t := &p.Targets
t.Industries = CleanList(t.Industries)
t.CompanySizes = CleanList(t.CompanySizes)
t.Roles = CleanList(t.Roles)
t.Regions = CleanList(t.Regions)
t.Problems = CleanList(t.Problems)
t.BuyingSignals = CleanList(t.BuyingSignals)
t.Technologies = CleanList(t.Technologies)
a := &p.Accounts
a.X = strings.TrimPrefix(strings.TrimSpace(a.X), "@")
a.LinkedIn = strings.TrimSpace(a.LinkedIn)
a.Reddit = strings.TrimPrefix(strings.TrimPrefix(strings.TrimSpace(a.Reddit), "/"), "u/")
subs := CleanList(a.Subreddits)
for i, s := range subs {
subs[i] = strings.TrimPrefix(strings.TrimPrefix(s, "/"), "r/")
}
a.Subreddits = subs
}
// CleanList trims entries and drops empty ones and duplicates, keeping order.
func CleanList(in []string) []string {
out := make([]string, 0, len(in))
seen := map[string]bool{}
for _, s := range in {
s = strings.TrimSpace(s)
if s == "" || seen[strings.ToLower(s)] {
continue
}
seen[strings.ToLower(s)] = true
out = append(out, s)
}
return out
}
// Lines splits text into one entry per line, for the form's list fields.
func Lines(text string) []string {
return CleanList(strings.Split(strings.ReplaceAll(text, "\r\n", "\n"), "\n"))
}