Phase 5 part 4: landing pages per buying signal
Each signal's page lists its landing pages with their Gitea status, live address and 30-day visitors from Plausible, and builds a new one. Pages can be duplicated as variants (B, C…, with their own utm_content), taken off the site through a pull request that deletes the file, or have their pull request closed. The scorecard counts live pages. Schema 23. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"supermarket/internal/sites"
|
||||
"supermarket/internal/tracking"
|
||||
"time"
|
||||
|
||||
"supermarket/internal/ai"
|
||||
@@ -64,7 +66,13 @@ func (s *Server) renderSignals(w http.ResponseWriter, r *http.Request, errMsg st
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
live, err := sites.LivePageCounts(s.DB)
|
||||
if err != nil {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
s.render(w, r, "signals", page{Title: "Signals", Nav: "prospects/signals", Error: errMsg, Data: map[string]any{
|
||||
"LivePages": live,
|
||||
"Rows": rows,
|
||||
"Signals": list,
|
||||
"Stages": signals.Stages,
|
||||
@@ -92,6 +100,10 @@ type signalData struct {
|
||||
Posts []content.Draft // written for it
|
||||
Links []string // the websites, tagged with its campaign
|
||||
|
||||
Pages []signalPage // its landing pages and their variants
|
||||
PageSites []siteRepo // websites a landing page can go on
|
||||
VisitorsErr string // why page visitors couldn't be read
|
||||
|
||||
Runs []discovery.Run
|
||||
Running bool
|
||||
Research string // why Claude can't search, or ""
|
||||
@@ -101,6 +113,13 @@ type signalData struct {
|
||||
MaxResults int
|
||||
}
|
||||
|
||||
// signalPage is a landing page on a signal's page.
|
||||
type signalPage struct {
|
||||
sites.SitePage
|
||||
Address string // on the live site
|
||||
Visitors int // last 30 days; -1 when unknown
|
||||
}
|
||||
|
||||
type channelRow struct {
|
||||
Channel string
|
||||
Row signals.Row
|
||||
@@ -171,6 +190,10 @@ func (s *Server) renderSignal(w http.ResponseWriter, r *http.Request, sig *signa
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
if err := s.signalPages(r.Context(), sig, &d); err != nil {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
cs, ps, err := prospects.Review(s.DB, prospects.StatusNew, sig.ID, 1000)
|
||||
if err != nil {
|
||||
s.serverError(w, err)
|
||||
@@ -667,3 +690,61 @@ func tagLink(site, slug string) string {
|
||||
u.RawQuery = q.Encode()
|
||||
return u.String()
|
||||
}
|
||||
|
||||
// signalPages fills in a signal's landing pages: their state on Gitea
|
||||
// (merged, closed), and each live one's visitors over 30 days.
|
||||
func (s *Server) signalPages(ctx context.Context, sig *signals.Signal, d *signalData) error {
|
||||
ps, err := sites.SignalPages(s.DB, sig.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, sr := range s.siteRepos() {
|
||||
if sr.Repo != "" {
|
||||
d.PageSites = append(d.PageSites, sr)
|
||||
}
|
||||
}
|
||||
if s.gitea() != nil {
|
||||
gctx, cancel := context.WithTimeout(ctx, 15*time.Second)
|
||||
for i := range ps {
|
||||
if ps[i].Status == sites.PagePR || ps[i].Status == sites.PageRemoving {
|
||||
s.refreshPagePR(gctx, &ps[i])
|
||||
}
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
prof, _ := profile.Load(s.DB)
|
||||
bySite := map[string][]string{}
|
||||
for _, p := range ps {
|
||||
if p.Live() {
|
||||
bySite[p.Site] = append(bySite[p.Site], p.Path)
|
||||
}
|
||||
}
|
||||
visitors := map[string]map[string]int{}
|
||||
if pl := s.plausible(); pl != nil && prof != nil && len(bySite) > 0 {
|
||||
pctx, cancel := context.WithTimeout(ctx, 15*time.Second)
|
||||
for _, w := range prof.Websites {
|
||||
paths := bySite[w.URL]
|
||||
if len(paths) == 0 {
|
||||
continue
|
||||
}
|
||||
v, err := tracking.PageVisitors(pctx, pl, tracking.SiteID(w), paths)
|
||||
if err != nil {
|
||||
d.VisitorsErr = err.Error()
|
||||
continue
|
||||
}
|
||||
visitors[w.URL] = v
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
for _, p := range ps {
|
||||
sp := signalPage{SitePage: p, Visitors: -1}
|
||||
if p.Live() {
|
||||
sp.Address = strings.TrimRight(p.Site, "/") + p.Path
|
||||
if v, ok := visitors[p.Site]; ok {
|
||||
sp.Visitors = v[p.Path]
|
||||
}
|
||||
}
|
||||
d.Pages = append(d.Pages, sp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func (s *Server) compose(ctx context.Context, cur siteRepo, p *sites.SitePage, p
|
||||
// checkPage checks the sections; a problem is kept as the page's error,
|
||||
// for the user to fix in the YAML.
|
||||
func (s *Server) checkPage(cat *sites.Catalog, p *sites.SitePage, campaign string) error {
|
||||
ch, err := sites.Check(cat, p.Sections, p.Site, campaign)
|
||||
ch, err := sites.Check(cat, p.Sections, p.Site, campaign, sites.Content(p))
|
||||
if err != nil {
|
||||
p.Error, p.Warnings, p.Claims = "Fix this before pushing: "+err.Error(), nil, nil
|
||||
return nil
|
||||
@@ -233,7 +233,7 @@ func (s *Server) renderSitePage(w http.ResponseWriter, r *http.Request, errMsg,
|
||||
errMsg = "" // the page shows its own
|
||||
}
|
||||
cur, ok := s.pageSite(p)
|
||||
if p.Status == sites.PagePR && s.gitea() != nil {
|
||||
if (p.Status == sites.PagePR || p.Status == sites.PageRemoving) && s.gitea() != nil {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
|
||||
s.refreshPagePR(ctx, p)
|
||||
cancel()
|
||||
@@ -270,10 +270,30 @@ func (s *Server) renderSitePage(w http.ResponseWriter, r *http.Request, errMsg,
|
||||
s.render(w, r, "sites-page", page{Title: or(p.Title, "New page"), Nav: "sites/pages", Error: errMsg, Flash: flash, Data: data})
|
||||
}
|
||||
|
||||
// refreshPagePR notes when a page's pull request is merged or closed.
|
||||
// refreshPagePR notes when a page's pull request (adding or removing it)
|
||||
// is merged or closed.
|
||||
func (s *Server) refreshPagePR(ctx context.Context, p *sites.SitePage) {
|
||||
_, full, err := gitea.ParseRepo(p.Repo)
|
||||
if err != nil || p.PRNumber == 0 {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if p.Status == sites.PageRemoving {
|
||||
pull, err := s.gitea().GetPull(ctx, full, p.RemovalPRNumber)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case pull.Merged:
|
||||
p.Status = sites.PageRemoved
|
||||
case pull.State == "closed":
|
||||
p.Status, p.RemovalPRNumber, p.RemovalPRURL = sites.PageMerged, 0, ""
|
||||
default:
|
||||
return
|
||||
}
|
||||
_ = sites.SavePage(s.DB, p)
|
||||
return
|
||||
}
|
||||
if p.PRNumber == 0 {
|
||||
return
|
||||
}
|
||||
pull, err := s.gitea().GetPull(ctx, full, p.PRNumber)
|
||||
@@ -316,15 +336,62 @@ func (s *Server) sitePageAction(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/sites/pages", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
if !p.Editable() {
|
||||
s.renderSitePage(w, r, "This page can't be changed here any more.", "")
|
||||
return
|
||||
}
|
||||
cur, ok := s.pageSite(p)
|
||||
if !ok {
|
||||
s.renderSitePage(w, r, "This page's website or repository isn't in the profile any more.", "")
|
||||
return
|
||||
}
|
||||
back := "/sites/pages/" + strconv.FormatInt(id, 10)
|
||||
if ret := r.PostFormValue("return"); strings.HasPrefix(ret, "/signals/") && !strings.Contains(ret, "//") {
|
||||
back = ret
|
||||
}
|
||||
switch action {
|
||||
case "duplicate":
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Minute)
|
||||
defer cancel()
|
||||
v, err := sites.Variant(s.DB, p)
|
||||
if err != nil {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
if notes := strings.TrimSpace(r.PostFormValue("variant_notes")); notes != "" {
|
||||
v.Notes = notes
|
||||
if err := s.compose(ctx, cur, v, true); err != nil {
|
||||
v.Error = "Couldn't write the variant: " + err.Error()
|
||||
}
|
||||
} else if cat, err := s.catalog(ctx, cur, false); err == nil {
|
||||
_ = s.checkPage(cat, v, s.campaignOf(v)) // its links get its own utm_content
|
||||
}
|
||||
if err := sites.SavePage(s.DB, v); err != nil {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/sites/pages/"+strconv.FormatInt(v.ID, 10), http.StatusSeeOther)
|
||||
return
|
||||
case "remove", "close":
|
||||
if s.gitea() == nil {
|
||||
s.renderSitePage(w, r, "Save a Gitea token under Settings → Search engines first.", "")
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Minute)
|
||||
defer cancel()
|
||||
var err error
|
||||
if action == "remove" {
|
||||
err = sites.Remove(ctx, s.DB, s.applier(seoSite{Index: cur.Index, URL: cur.URL}), p)
|
||||
} else {
|
||||
err = sites.ClosePR(ctx, s.DB, s.gitea(), cur.Repo, p)
|
||||
}
|
||||
if err != nil {
|
||||
s.renderSitePage(w, r, err.Error(), "")
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, back, http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
if !p.Editable() {
|
||||
s.renderSitePage(w, r, "This page can't be changed here any more.", "")
|
||||
return
|
||||
}
|
||||
// Every action keeps the user's edits first.
|
||||
if _, has := r.PostForm["sections"]; has {
|
||||
p.Title = strings.TrimSpace(r.PostFormValue("title"))
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
|
||||
"supermarket/internal/ai"
|
||||
"supermarket/internal/signals"
|
||||
"supermarket/internal/sites"
|
||||
|
||||
"supermarket/internal/hugorepo"
|
||||
"supermarket/internal/hugorepo/hugotest"
|
||||
@@ -305,3 +307,139 @@ func TestSitePageBuilder(t *testing.T) {
|
||||
t.Errorf("after delete: %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignalLandingPages(t *testing.T) {
|
||||
if hugorepo.HugoVersion(context.Background()) == "" {
|
||||
t.Skip("no hugo")
|
||||
}
|
||||
clone := hugotest.Site(t, map[string]string{
|
||||
"layouts/partials/render-sections.html": `{{ range .Params.sections }}{{ partial (printf "sections/%s.html" .type) . }}{{ end }}`,
|
||||
"layouts/partials/sections/hero.html": `<h2>{{ .title }}</h2>{{ range .ctas }}<a href="{{ .url }}">{{ .label }}</a>{{ end }}`,
|
||||
"layouts/_default/single.html": `{{ define "main" }}<h1>{{ .Title }}</h1>{{ partial "render-sections.html" . }}{{ .Content }}{{ end }}`,
|
||||
"content/landing.md": "---\ntitle: Landing\nsections:\n - type: hero\n title: Hello\n---\n",
|
||||
})
|
||||
var opened []map[string]string
|
||||
merged := map[string]bool{}
|
||||
var closed []string
|
||||
g := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
const repo = "/api/v1/repos/Us/site"
|
||||
switch {
|
||||
case r.URL.Path == repo:
|
||||
fmt.Fprintf(w, `{"full_name":"Us/site","default_branch":"main","clone_url":%q,"permissions":{"push":true}}`, clone)
|
||||
case r.URL.Path == repo+"/pulls" && r.Method == http.MethodPost:
|
||||
var body map[string]string
|
||||
json.NewDecoder(r.Body).Decode(&body)
|
||||
opened = append(opened, body)
|
||||
fmt.Fprintf(w, `{"number":%d,"state":"open","html_url":"https://gitea.example/pulls/%d"}`, len(opened), len(opened))
|
||||
case strings.HasPrefix(r.URL.Path, repo+"/pulls/") && r.Method == http.MethodPatch:
|
||||
closed = append(closed, strings.TrimPrefix(r.URL.Path, repo+"/pulls/"))
|
||||
fmt.Fprint(w, `{}`)
|
||||
case strings.HasPrefix(r.URL.Path, repo+"/pulls/"):
|
||||
n := strings.TrimPrefix(r.URL.Path, repo+"/pulls/")
|
||||
if merged[n] {
|
||||
fmt.Fprintf(w, `{"number":%s,"state":"closed","merged":true,"merged_at":"2026-11-22T10:00:00Z"}`, n)
|
||||
} else {
|
||||
fmt.Fprintf(w, `{"number":%s,"state":"open"}`, n)
|
||||
}
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}))
|
||||
defer g.Close()
|
||||
var plausibleQuery string
|
||||
pl := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
raw, _ := io.ReadAll(r.Body)
|
||||
plausibleQuery = string(raw)
|
||||
fmt.Fprint(w, `{"results":[{"dimensions":["/for-churches/"],"metrics":[42]},{"dimensions":["/for-churches-b/"],"metrics":[7]}]}`)
|
||||
}))
|
||||
defer pl.Close()
|
||||
composed, _ := json.Marshal(map[string]any{"path": "/for-churches/", "title": "For churches", "description": "d",
|
||||
"sections_yaml": "- type: hero\n title: One bill\n ctas:\n - label: Start\n url: /pricing/\n", "needs": []string{}})
|
||||
newAIClient = func(ai.Config, *secrets.Store) (ai.Client, error) { return cannedAI{string(composed)}, nil }
|
||||
defer func() { newAIClient = ai.New }()
|
||||
|
||||
s, h := newTestServer(t, nil)
|
||||
profile.Save(s.DB, &profile.Profile{Name: "Us", Description: "Widgets.", Websites: []profile.Website{{URL: "https://us.example/", Repo: "Us/site"}}})
|
||||
sig := &signals.Signal{Name: "Churches", Slug: "churches", Status: "testing"}
|
||||
signals.Save(s.DB, sig)
|
||||
sigURL := "/signals/" + strconv.FormatInt(sig.ID, 10)
|
||||
postForm(h, "/settings/search", url.Values{"gitea_url": {g.URL}, secrets.GiteaToken: {"tok"}})
|
||||
s.DB.PutJSON(plausibleURLKey, pl.URL)
|
||||
s.Secrets.Set(map[string]string{secrets.PlausibleAPIKey: "pk"})
|
||||
|
||||
body := do(h, http.MethodGet, sigURL, nil, nil).Body.String()
|
||||
if !strings.Contains(body, "No landing page for this signal yet") || !strings.Contains(body, `name="signal" value="`+strconv.FormatInt(sig.ID, 10)) {
|
||||
t.Errorf("before: %s", body)
|
||||
}
|
||||
// Built from the signal's page, pushed with a pull request, merged.
|
||||
postForm(h, "/sites/pages", url.Values{"site": {"0"}, "kind": {"landing"}, "signal": {strconv.FormatInt(sig.ID, 10)}})
|
||||
postForm(h, "/sites/pages/1/pr", url.Values{"title": {"For churches"}, "description": {"d"}, "path": {"/for-churches/"},
|
||||
"sections": {"- type: hero\n title: One bill\n ctas:\n - label: Start\n url: /pricing/\n"}})
|
||||
if len(opened) != 1 {
|
||||
t.Fatalf("no pull request: %v", opened)
|
||||
}
|
||||
merged["1"] = true // and really merged: main moves to the page's branch
|
||||
if out, err := exec.Command("git", "--git-dir", strings.TrimPrefix(clone, "file://"), "update-ref", "refs/heads/main", "refs/heads/supermarket/site-page-1").CombinedOutput(); err != nil {
|
||||
t.Fatalf("merge: %s", out)
|
||||
}
|
||||
body = do(h, http.MethodGet, sigURL, nil, nil).Body.String()
|
||||
if !strings.Contains(body, `href="https://us.example/for-churches/"`) || !strings.Contains(body, ">merged<") || !strings.Contains(body, "<td>42</td>") ||
|
||||
!strings.Contains(body, "Remove from the site") {
|
||||
t.Errorf("live page: %s", body)
|
||||
}
|
||||
if !strings.Contains(plausibleQuery, `"site_id":"us.example"`) || !strings.Contains(plausibleQuery, `"/for-churches/"`) {
|
||||
t.Errorf("plausible query: %s", plausibleQuery)
|
||||
}
|
||||
if body := do(h, http.MethodGet, "/signals", nil, nil).Body.String(); !strings.Contains(body, `title="Landing pages on your website">1 page<`) {
|
||||
t.Errorf("scorecard: %s", body)
|
||||
}
|
||||
|
||||
// A variant: its own address, B, links with its own utm_content.
|
||||
rec := postForm(h, "/sites/pages/1/duplicate", url.Values{})
|
||||
if rec.Header().Get("Location") != "/sites/pages/2" {
|
||||
t.Fatalf("duplicate: %d %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
body = do(h, http.MethodGet, "/sites/pages/2", nil, nil).Body.String()
|
||||
if !strings.Contains(body, `value="/for-churches-b/"`) || !strings.Contains(body, "Variant <strong>B</strong>") ||
|
||||
!strings.Contains(body, "utm_campaign=churches&utm_content=for-churches-b&utm_medium=landing") {
|
||||
t.Errorf("variant: %s", body)
|
||||
}
|
||||
// A second one is C.
|
||||
postForm(h, "/sites/pages/2/duplicate", url.Values{})
|
||||
if p, _ := sites.GetPage(s.DB, 3); p.Path != "/for-churches-c/" || p.Source.Variant != "C" || p.Source.VariantOf != 1 {
|
||||
t.Errorf("third: %+v", p)
|
||||
}
|
||||
if p, _ := sites.GetPage(s.DB, 1); p.Source.Variant != "A" {
|
||||
t.Errorf("original: %+v", p.Source)
|
||||
}
|
||||
// Variant B goes up as a pull request, then is closed without merging.
|
||||
postForm(h, "/sites/pages/2/pr", url.Values{"title": {"For churches B"}, "description": {"d"}, "path": {"/for-churches-b/"},
|
||||
"sections": {"- type: hero\n title: Shorter\n"}})
|
||||
postForm(h, "/sites/pages/2/close", url.Values{"return": {sigURL}})
|
||||
if p, _ := sites.GetPage(s.DB, 2); p.Status != sites.PageClosed || len(closed) != 1 || closed[0] != "2" {
|
||||
t.Errorf("closed: %s %v", p.Status, closed)
|
||||
}
|
||||
|
||||
// Removing the original: a pull request deleting its file.
|
||||
rec = postForm(h, "/sites/pages/1/remove", url.Values{"return": {sigURL}})
|
||||
if rec.Header().Get("Location") != sigURL || len(opened) != 3 {
|
||||
t.Fatalf("remove: %d %s %v", rec.Code, rec.Body.String(), opened)
|
||||
}
|
||||
if pr := opened[2]; pr["head"] != "supermarket/remove-site-page-1" || pr["title"] != "Sites: remove /for-churches/" {
|
||||
t.Errorf("removal pull request: %v", pr)
|
||||
}
|
||||
out, _ := exec.Command("git", "--git-dir", strings.TrimPrefix(clone, "file://"), "ls-tree", "-r", "--name-only", "supermarket/remove-site-page-1").CombinedOutput()
|
||||
if strings.Contains(string(out), "for-churches.md") || !strings.Contains(string(out), "landing.md") {
|
||||
t.Errorf("files on the removal branch: %s", out)
|
||||
}
|
||||
if body := do(h, http.MethodGet, sigURL, nil, nil).Body.String(); !strings.Contains(body, "removal pull request open") {
|
||||
t.Errorf("removing: %s", body)
|
||||
}
|
||||
merged["3"] = true
|
||||
if body := do(h, http.MethodGet, sigURL, nil, nil).Body.String(); !strings.Contains(body, ">removed<") {
|
||||
t.Errorf("removed: %s", body)
|
||||
}
|
||||
if body := do(h, http.MethodGet, "/signals", nil, nil).Body.String(); strings.Contains(body, "Landing pages on your website") {
|
||||
t.Error("still counted as live")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,3 +445,10 @@ svg.chart text { font-size: 9px; fill: hsl(var(--muted-foreground)); }
|
||||
table.cohorts td, table.cohorts th { padding-left: 0.4rem; padding-right: 0.4rem; font-size: 0.85rem; }
|
||||
.table-wrap { overflow-x: auto; }
|
||||
table.compact th, table.compact td { white-space: nowrap; padding-left: 0.5rem; padding-right: 0.5rem; font-size: 0.85rem; }
|
||||
/* A button that opens a small form below it (Sites: variants). */
|
||||
details.inline-details { display: inline-block; vertical-align: top; }
|
||||
details.inline-details > summary { list-style: none; cursor: pointer; }
|
||||
details.inline-details > summary::-webkit-details-marker { display: none; }
|
||||
details.inline-details[open] { display: block; white-space: normal; margin: 0.4rem 0; }
|
||||
details.inline-details form { margin-top: 0.5rem; min-width: 18rem; }
|
||||
.button.small { padding: 0.28rem 0.75rem; font-size: 0.82rem; }
|
||||
|
||||
@@ -195,5 +195,7 @@
|
||||
{{- else if eq .Status "merged"}}<span class="badge published">merged</span>
|
||||
{{- else if eq .Status "closed"}}<span class="badge">closed</span>
|
||||
{{- else if eq .Status "failed"}}<span class="badge failed">failed</span>
|
||||
{{- else if eq .Status "removing"}}<span class="badge scheduled">removal pull request open</span>
|
||||
{{- else if eq .Status "removed"}}<span class="badge">removed</span>
|
||||
{{- end}}{{if and .Error (ne .Status "failed")}} <span class="badge failed">to fix</span>{{end}}
|
||||
{{end}}
|
||||
|
||||
@@ -97,6 +97,48 @@
|
||||
<ul class="small">{{range $i, $u := .}}<li><code id="link-{{$i}}">{{$u}}</code> <button type="button" class="link small" data-copy="link-{{$i}}">Copy</button></li>{{end}}</ul>
|
||||
{{end}}
|
||||
|
||||
<h2>Landing pages</h2>
|
||||
{{$sig := $s}}
|
||||
{{if .Pages}}
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Page</th><th>Status</th><th>Visitors, 30 days</th><th></th></tr></thead>
|
||||
<tbody>{{range .Pages}}<tr>
|
||||
<td>{{with .Source.Variant}}<span class="badge">{{.}}</span> {{end}}<a href="/sites/pages/{{.ID}}">{{or .Title "Untitled"}}</a><br>
|
||||
<span class="small muted">{{if .Address}}<a href="{{.Address}}" target="_blank" rel="noopener noreferrer">{{.Address}}</a>{{else}}{{.Site}}{{.Path}}{{end}}</span></td>
|
||||
<td>{{template "page-status" .}}</td>
|
||||
<td>{{if ge .Visitors 0}}{{.Visitors}}{{else}}<span class="muted">—</span>{{end}}</td>
|
||||
<td><div class="row-actions">
|
||||
<details class="inline-details"><summary class="button secondary small">Duplicate as a variant</summary>
|
||||
<form method="post" action="/sites/pages/{{.ID}}/duplicate">
|
||||
<label class="small">What to change in the variant <span class="muted">(optional: empty makes an exact copy to edit)</span>
|
||||
<textarea name="variant_notes" rows="2" placeholder="A shorter page, with the price in the hero."></textarea></label>
|
||||
<button type="submit" class="small" data-busy="Making it…">Make the variant</button>
|
||||
</form>
|
||||
</details>
|
||||
{{if eq .Status "merged"}}<form method="post" action="/sites/pages/{{.ID}}/remove" data-confirm="Open a pull request that takes {{.Path}} off the site?">
|
||||
<input type="hidden" name="return" value="/signals/{{$sig.ID}}"><button type="submit" class="secondary small" data-busy="Opening…">Remove from the site</button></form>{{end}}
|
||||
{{if or (eq .Status "pr") (eq .Status "removing")}}<form method="post" action="/sites/pages/{{.ID}}/close" data-confirm="Close the pull request without merging?">
|
||||
<input type="hidden" name="return" value="/signals/{{$sig.ID}}"><button type="submit" class="secondary small">Close the pull request</button></form>{{end}}
|
||||
</div></td>
|
||||
</tr>{{end}}</tbody>
|
||||
</table></div>
|
||||
{{with .VisitorsErr}}<p class="small warn-text">Couldn't read visitors from Plausible: {{.}}</p>{{end}}
|
||||
<p class="small muted">Visitors are everyone who saw the page, however they came. A variant's links to your site carry its own <code>utm_content</code>, so sign-ups that keep the tags can be told apart.</p>
|
||||
{{else}}<p class="help">No landing page for this signal yet.</p>{{end}}
|
||||
{{if .PageSites}}
|
||||
<form method="post" action="/sites/pages" class="card">
|
||||
<input type="hidden" name="kind" value="landing"><input type="hidden" name="signal" value="{{$s.ID}}">
|
||||
<div class="cols">
|
||||
{{if gt (len .PageSites) 1}}<label>Website <select name="site">{{range .PageSites}}<option value="{{.Index}}">{{.URL}}</option>{{end}}</select></label>
|
||||
{{else}}{{range .PageSites}}<input type="hidden" name="site" value="{{.Index}}">{{end}}{{end}}
|
||||
<label>Address <span class="muted">(optional)</span> <input name="path" placeholder="/{{$s.Slug}}/"></label>
|
||||
</div>
|
||||
<label>What the page should do <span class="muted">(optional; the signal's angle is used)</span> <textarea name="notes" rows="2"></textarea></label>
|
||||
<button type="submit" data-busy="Reading the site and writing…">Build a landing page for it</button>
|
||||
<span class="small muted">Its links to your site carry utm_campaign={{$s.Slug}}. You review it before anything goes to Gitea.</span>
|
||||
</form>
|
||||
{{else}}<p class="small">Landing pages need a website with a Hugo repository in <a href="/settings/profile">Settings → Profile</a>.</p>{{end}}
|
||||
|
||||
{{if .Events}}
|
||||
<h2>Latest steps</h2>
|
||||
<table class="list">
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<tbody>
|
||||
{{range .Rows}}
|
||||
<tr>
|
||||
<td>{{with .Signal}}<a href="/signals/{{.ID}}">{{.Name}}</a> <span class="badge {{.Status}}">{{.Status}}</span>{{else}}<span class="muted">No signal</span>{{end}}</td>
|
||||
<td>{{with .Signal}}<a href="/signals/{{.ID}}">{{.Name}}</a> <span class="badge {{.Status}}">{{.Status}}</span>{{with index $.Data.LivePages .ID}} <span class="badge published" title="Landing pages on your website">{{.}} page{{if ne . 1}}s{{end}}</span>{{end}}{{else}}<span class="muted">No signal</span>{{end}}</td>
|
||||
{{range .Cells}}<td class="num">{{if .Count}}{{.Count}}{{with .Rate}}<span class="rate">{{.}}</span>{{end}}{{else}}<span class="muted">·</span>{{end}}</td>{{end}}
|
||||
<td class="num">{{if .RevenueCents}}{{money .RevenueCents}}{{else}}<span class="muted">·</span>{{end}}</td>
|
||||
<td class="num">{{if .SpendCents}}{{money .SpendCents}}{{else}}<span class="muted">·</span>{{end}}</td>
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
</section>
|
||||
{{end}}
|
||||
|
||||
{{with $p.Source.Variant}}<p class="small">Variant <strong>{{.}}</strong>{{if $p.Source.VariantOf}} of <a href="/sites/pages/{{$p.Source.VariantOf}}">the original page</a>{{end}}.{{if $p.Source.VariantOf}} Its links to your site carry their own <code>utm_content</code>.{{end}}</p>{{end}}
|
||||
{{with $p.RemovalPRURL}}<p>The pull request that takes it off the site: <a href="{{.}}" target="_blank" rel="noopener noreferrer">{{.}} ↗</a></p>{{end}}
|
||||
{{with $p.Error}}<p class="error" role="alert">{{.}}</p>{{end}}
|
||||
{{if $p.Editable}}
|
||||
<form method="post" action="/sites/pages/{{$p.ID}}/save" class="card">
|
||||
@@ -50,6 +52,25 @@
|
||||
<section class="card"><pre class="sample">{{$p.Sections}}</pre></section>
|
||||
{{end}}
|
||||
|
||||
<section class="card">
|
||||
<form method="post" action="/sites/pages/{{$p.ID}}/duplicate">
|
||||
<label>Duplicate as a variant, to test against this one <span class="muted">(optional: what to change; empty makes an exact copy to edit)</span>
|
||||
<textarea name="variant_notes" rows="2"></textarea></label>
|
||||
<button type="submit" class="secondary" data-busy="Making it…">Make a variant</button>
|
||||
</form>
|
||||
{{if eq $p.Status "merged"}}
|
||||
<form method="post" action="/sites/pages/{{$p.ID}}/remove" data-confirm="Open a pull request that takes {{$p.Path}} off the site?">
|
||||
<button type="submit" class="secondary" data-busy="Opening…">Remove from the site</button>
|
||||
<span class="small muted">Opens a pull request deleting the page; merging takes it off.</span>
|
||||
</form>
|
||||
{{end}}
|
||||
{{if or (eq $p.Status "pr") (eq $p.Status "removing")}}
|
||||
<form method="post" action="/sites/pages/{{$p.ID}}/close" data-confirm="Close the pull request without merging?">
|
||||
<button type="submit" class="secondary">Close the pull request</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</section>
|
||||
|
||||
<form method="post" action="/sites/pages/{{$p.ID}}/delete" class="danger-zone">
|
||||
<button type="submit" class="secondary" data-confirm="Forget this page? Its branch and pull request on Gitea stay.">Delete</button>
|
||||
<span class="small muted">Forgets the page here. Its branch and pull request on Gitea stay; close them there.</span>
|
||||
|
||||
Reference in New Issue
Block a user