Phase 5 part 5: check the live site after a merge

Merged Sites pages are checked on the live site until they answer with
their own words and title; removed ones until they're gone. The SEO loop,
the page, the signal's page and Sites → Publishing check (or Check now);
two hours without the page points at the deploy hook. Pages going live or
away go to IndexNow. Sites → Publishing lists what's waiting, open pull
requests and recent merges. Schema 24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 14:28:42 -07:00
co-authored by Claude Opus 5.5
parent 062fcf2e59
commit e2a72d5ef9
18 changed files with 746 additions and 63 deletions
+1
View File
@@ -274,6 +274,7 @@ func (s *Server) RunSEO(ctx context.Context) {
}
s.refreshChanges(ctx)
s.refreshBriefs(ctx)
s.refreshSitePages(ctx)
s.pingNewlyLive(ctx)
select {
case <-ctx.Done():
+1
View File
@@ -183,6 +183,7 @@ func (s *Server) Handler() (http.Handler, error) {
mux.HandleFunc("POST /sites/pages", s.sitePageNew)
mux.HandleFunc("GET /sites/pages/{id}", s.sitePagePage)
mux.HandleFunc("POST /sites/pages/{id}/{action}", s.sitePageAction)
mux.HandleFunc("GET /sites/publishing", s.sitesPublishingPage)
mux.HandleFunc("GET /sites/previews", s.sitesPreviewsPage)
mux.HandleFunc("POST /sites/previews/build", s.sitesPreviewBuild)
mux.HandleFunc("POST /sites/previews/delete", s.sitesPreviewDelete)
+1 -1
View File
@@ -100,7 +100,7 @@ func TestEveryPageRenders(t *testing.T) {
"/settings/ai", "/settings/accounts", "/settings/core", "/static/app.css", "/favicon.ico", "/static/favicon.png", "/static/logo.png", "/static/apple-touch-icon.png", "/search", "/crm", "/search?q=rival", "/search?q=nothing+here", "/static/htmx.min.js", "/healthz",
"/content", "/content/1", "/content/1?dismissed=1", "/posts", "/posts?msg=drafted",
"/content/scheduled", "/content/published",
"/prospects", "/prospects?status=accepted", "/prospects?status=rejected", "/prospects/new", "/prospects/suppressed", "/outreach", "/outreach?tab=queued", "/outreach?tab=sent", "/outreach?tab=replied", "/outreach?tab=failed", "/settings/email", "/settings/tracking", "/settings/search", "/seo", "/seo/check", "/seo/report", "/seo/audit", "/seo/changes", "/seo/keywords", "/seo/briefs", "/seo/engines", "/metrics", "/metrics/customers", "/metrics/customers?show=all", "/metrics/spend", "/metrics/clv", "/metrics/clv?view=profit", "/metrics/publish", "/sites", "/sites?site=0", "/sites/previews", "/sites/pages",
"/prospects", "/prospects?status=accepted", "/prospects?status=rejected", "/prospects/new", "/prospects/suppressed", "/outreach", "/outreach?tab=queued", "/outreach?tab=sent", "/outreach?tab=replied", "/outreach?tab=failed", "/settings/email", "/settings/tracking", "/settings/search", "/seo", "/seo/check", "/seo/report", "/seo/audit", "/seo/changes", "/seo/keywords", "/seo/briefs", "/seo/engines", "/metrics", "/metrics/customers", "/metrics/customers?show=all", "/metrics/spend", "/metrics/clv", "/metrics/clv?view=profit", "/metrics/publish", "/sites", "/sites?site=0", "/sites/previews", "/sites/pages", "/sites/publishing",
"/signals", "/signals?period=30d&channel=email", "/signals/new", "/settings/sources"} {
rec := do(h, http.MethodGet, path, nil, nil)
if rec.Code != http.StatusOK {
+8
View File
@@ -712,6 +712,14 @@ func (s *Server) signalPages(ctx context.Context, sig *signals.Signal, d *signal
}
cancel()
}
lctx, lcancel := context.WithTimeout(ctx, 15*time.Second)
for i := range ps {
if ps[i].Waiting() && time.Since(ps[i].CheckedAt) > time.Minute {
sites.CheckLive(lctx, s.liveFetcher(), &ps[i], time.Now())
_ = sites.SavePage(s.DB, &ps[i])
}
}
lcancel()
prof, _ := profile.Load(s.DB)
bySite := map[string][]string{}
for _, p := range ps {
+103 -40
View File
@@ -238,7 +238,14 @@ func (s *Server) renderSitePage(w http.ResponseWriter, r *http.Request, errMsg,
s.refreshPagePR(ctx, p)
cancel()
}
data := map[string]any{"P": p, "Kind": sites.KindLabel(p.Kind), "Gitea": s.gitea() != nil, "Site": cur, "HasSite": ok}
if p.Waiting() && time.Since(p.CheckedAt) > time.Minute {
ctx, cancel := context.WithTimeout(r.Context(), 15*time.Second)
sites.CheckLive(ctx, s.liveFetcher(), p, time.Now())
cancel()
_ = sites.SavePage(s.DB, p)
}
data := map[string]any{"P": p, "Kind": sites.KindLabel(p.Kind), "Gitea": s.gitea() != nil, "Site": cur, "HasSite": ok,
"Late": p.Late(time.Now())}
if ok && p.Branch != "" {
for _, pv := range s.previews(cur.Repo) {
if pv.Branch == p.Branch && pv.Commit != "" {
@@ -270,50 +277,29 @@ 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 (adding or removing it)
// is merged or closed.
// refreshPagePR follows a page's pull request on Gitea.
func (s *Server) refreshPagePR(ctx context.Context, p *sites.SitePage) {
_, full, err := gitea.ParseRepo(p.Repo)
if err != nil {
return
if g := s.gitea(); g != nil {
_, _ = sites.RefreshPR(ctx, s.DB, g, p, time.Now())
}
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
}
// refreshSitePages follows the pages' pull requests and checks the live
// site for those waiting on it; the SEO loop runs it.
func (s *Server) refreshSitePages(ctx context.Context) {
var g interface {
GetPull(context.Context, string, int64) (*gitea.Pull, error)
}
if p.PRNumber == 0 {
return
if c := s.gitea(); c != nil {
g = c
}
pull, err := s.gitea().GetPull(ctx, full, p.PRNumber)
if err != nil {
return
if err := sites.Refresh(ctx, s.DB, g, s.liveFetcher(), time.Now()); err != nil {
s.Log.Warn("sites: checking pages", "err", err)
}
switch {
case pull.Merged:
p.Status = sites.PageMerged
if pull.MergedAt != nil {
p.MergedAt = *pull.MergedAt
} else {
p.MergedAt = time.Now()
}
case pull.State == "closed":
p.Status = sites.PageClosed
default:
return
}
_ = sites.SavePage(s.DB, p)
}
func (s *Server) liveFetcher() *seo.Fetcher {
return seo.NewFetcher("Supermarket/" + s.Version + " (Sites)")
}
func (s *Server) sitePageAction(w http.ResponseWriter, r *http.Request) {
@@ -346,6 +332,16 @@ func (s *Server) sitePageAction(w http.ResponseWriter, r *http.Request) {
back = ret
}
switch action {
case "check":
ctx, cancel := context.WithTimeout(r.Context(), 20*time.Second)
defer cancel()
sites.CheckLive(ctx, s.liveFetcher(), p, time.Now())
if err := sites.SavePage(s.DB, p); err != nil {
s.serverError(w, err)
return
}
http.Redirect(w, r, back, http.StatusSeeOther)
return
case "duplicate":
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Minute)
defer cancel()
@@ -461,3 +457,70 @@ func (s *Server) sitePageAction(w http.ResponseWriter, r *http.Request) {
}
s.renderSitePage(w, r, "", flash)
}
// --- Publishing ---
// mergeRow is a merged pull request on the publishing page.
type mergeRow struct {
gitea.Pull
Ours bool // opened by Supermarket (a supermarket/ branch)
Page *sites.SitePage // the Sites page it added or removed, if any
}
func (s *Server) sitesPublishingPage(w http.ResponseWriter, r *http.Request) {
all, cur := s.currentSite(r)
data := map[string]any{"Sites": all, "Current": cur, "Gitea": s.gitea() != nil}
if cur != nil && cur.Repo != "" {
ps, err := sites.Pages(s.DB, cur.URL)
if err != nil {
s.serverError(w, err)
return
}
if g := s.gitea(); g != nil {
ctx, cancel := context.WithTimeout(r.Context(), 15*time.Second)
for i := range ps {
if ps[i].Status == sites.PagePR || ps[i].Status == sites.PageRemoving {
_, _ = sites.RefreshPR(ctx, s.DB, g, &ps[i], time.Now())
}
}
pulls, err := g.ClosedPulls(ctx, cur.Repo, 30)
cancel()
if err != nil {
data["PullsErr"] = err.Error()
}
var merges []mergeRow
for _, pl := range pulls {
if !pl.Merged {
continue
}
m := mergeRow{Pull: pl, Ours: strings.HasPrefix(pl.Head.Ref, "supermarket/")}
for i := range ps {
if pl.Head.Ref == ps[i].Branch || pl.Head.Ref == ps[i].RemovalBranch {
m.Page = &ps[i]
}
}
merges = append(merges, m)
}
data["Merges"] = merges
}
lctx, lcancel := context.WithTimeout(r.Context(), 20*time.Second)
for i := range ps {
if ps[i].Waiting() && time.Since(ps[i].CheckedAt) > time.Minute {
sites.CheckLive(lctx, s.liveFetcher(), &ps[i], time.Now())
_ = sites.SavePage(s.DB, &ps[i])
}
}
lcancel()
var waiting, open []sites.SitePage
for _, p := range ps {
switch {
case p.Waiting():
waiting = append(waiting, p)
case p.Status == sites.PagePR || p.Status == sites.PageRemoving:
open = append(open, p)
}
}
data["Waiting"], data["Open"], data["Now"] = waiting, open, time.Now()
}
s.render(w, r, "sites-publishing", page{Title: "Publishing", Nav: "sites/publishing", Data: data})
}
+81 -5
View File
@@ -14,6 +14,7 @@ import (
"strconv"
"strings"
"testing"
"time"
"supermarket/internal/ai"
"supermarket/internal/signals"
@@ -219,8 +220,16 @@ func TestSitePageBuilder(t *testing.T) {
newAIClient = func(ai.Config, *secrets.Store) (ai.Client, error) { return cannedAI{string(composed)}, nil }
defer func() { newAIClient = ai.New }()
live := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/for-churches/" {
http.NotFound(w, r)
return
}
fmt.Fprint(w, `<html><head><title>For churches · Us</title></head><body><h1>For churches</h1><h2>Run your church on one bill</h2></body></html>`)
}))
defer live.Close()
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"}}})
profile.Save(s.DB, &profile.Profile{Name: "Us", Description: "Widgets.", Websites: []profile.Website{{URL: live.URL + "/", Repo: "Us/site"}}})
sig := &signals.Signal{Name: "Churches", Slug: "churches", Status: "testing"}
if err := signals.Save(s.DB, sig); err != nil {
t.Fatal(err)
@@ -296,7 +305,8 @@ func TestSitePageBuilder(t *testing.T) {
// Gitea says it's merged: the page shows it, and can't be edited.
body = do(h, http.MethodGet, "/sites/pages/1", nil, nil).Body.String()
if !strings.Contains(body, ">merged<") || strings.Contains(body, `name="sections"`) {
if !strings.Contains(body, ">live<") || !strings.Contains(body, "On the live site since") || !strings.Contains(body, "Live: the title and the words match.") ||
strings.Contains(body, `name="sections"`) {
t.Errorf("merged: %s", body)
}
if body := postForm(h, "/sites/pages/1/save", form(good)).Body.String(); !strings.Contains(body, "can&#39;t be changed") {
@@ -358,8 +368,17 @@ func TestSignalLandingPages(t *testing.T) {
newAIClient = func(ai.Config, *secrets.Store) (ai.Client, error) { return cannedAI{string(composed)}, nil }
defer func() { newAIClient = ai.New }()
gone := false
live := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/for-churches/" || gone {
http.NotFound(w, r)
return
}
fmt.Fprint(w, `<html><head><title>For churches</title></head><body><h2>One bill</h2></body></html>`)
}))
defer live.Close()
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"}}})
profile.Save(s.DB, &profile.Profile{Name: "Us", Description: "Widgets.", Websites: []profile.Website{{URL: live.URL + "/", Repo: "Us/site", PlausibleSite: "us.example"}}})
sig := &signals.Signal{Name: "Churches", Slug: "churches", Status: "testing"}
signals.Save(s.DB, sig)
sigURL := "/signals/" + strconv.FormatInt(sig.ID, 10)
@@ -383,7 +402,7 @@ func TestSignalLandingPages(t *testing.T) {
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>") ||
if !strings.Contains(body, `href="`+live.URL+`/for-churches/"`) || !strings.Contains(body, ">live<") || !strings.Contains(body, "<td>42</td>") ||
!strings.Contains(body, "Remove from the site") {
t.Errorf("live page: %s", body)
}
@@ -436,10 +455,67 @@ func TestSignalLandingPages(t *testing.T) {
t.Errorf("removing: %s", body)
}
merged["3"] = true
if body := do(h, http.MethodGet, sigURL, nil, nil).Body.String(); !strings.Contains(body, ">removed<") {
if body := do(h, http.MethodGet, sigURL, nil, nil).Body.String(); !strings.Contains(body, "removal merged, still on the site") {
t.Errorf("removal merged: %s", body)
}
// The site's deploy takes it off; the publishing page's check sees it.
gone = true
p, _ := sites.GetPage(s.DB, 1)
p.CheckedAt = time.Time{}
sites.SavePage(s.DB, p)
if body := do(h, http.MethodGet, "/sites/pages/1", nil, nil).Body.String(); !strings.Contains(body, "Off the live site since") || !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")
}
}
func TestSitesPublishing(t *testing.T) {
g := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/api/v1/repos/Us/site/pulls":
if r.URL.Query().Get("state") != "closed" {
t.Errorf("query: %s", r.URL.RawQuery)
}
fmt.Fprint(w, `[
{"number":5,"state":"closed","merged":true,"merged_at":"2026-11-22T09:00:00Z","title":"Sites: landing page /for-churches/","head":{"ref":"supermarket/site-page-1"},"html_url":"https://g/5"},
{"number":4,"state":"closed","merged":false,"title":"Abandoned","head":{"ref":"x"}},
{"number":3,"state":"closed","merged":true,"merged_at":"2026-11-21T09:00:00Z","title":"Fix the footer","head":{"ref":"footer"},"user":{"login":"carly"},"html_url":"https://g/3"}]`)
case "/api/v1/repos/Us/site/pulls/5":
fmt.Fprint(w, `{"number":5,"state":"closed","merged":true,"merged_at":"2026-11-22T09:00:00Z"}`)
default:
http.NotFound(w, r)
}
}))
defer g.Close()
live := httptest.NewServer(http.NotFoundHandler())
defer live.Close()
s, h := newTestServer(t, nil)
profile.Save(s.DB, &profile.Profile{Name: "Us", Websites: []profile.Website{{URL: live.URL + "/", Repo: "Us/site"}}})
postForm(h, "/settings/search", url.Values{"gitea_url": {g.URL}, secrets.GiteaToken: {"tok"}})
p := &sites.SitePage{Site: live.URL, Repo: "Us/site", Kind: "landing", Path: "/for-churches/", Title: "For churches",
Status: sites.PagePR, PRNumber: 5, Branch: "supermarket/site-page-1", Sections: "- type: hero\n title: Hi\n"}
if err := sites.SavePage(s.DB, p); err != nil {
t.Fatal(err)
}
body := do(h, http.MethodGet, "/sites/publishing", nil, nil).Body.String()
for _, want := range []string{
// The merge was noticed, and the page isn't live yet.
`<a href="/sites/pages/1">For churches</a>`, "Not on the site yet (it answers 404).",
`href="https://g/5"`, "Sites: landing page /for-churches/", "<td class=\"small\">Supermarket</td>", "merged, not live yet",
"Fix the footer", "carly",
} {
if !strings.Contains(body, want) {
t.Errorf("missing %q in %s", want, body)
}
}
if strings.Contains(body, "Abandoned") {
t.Error("an unmerged pull request is listed")
}
// The page editor offers a check now.
if body := do(h, http.MethodGet, "/sites/pages/1", nil, nil).Body.String(); !strings.Contains(body, "Check the live site now") {
t.Errorf("page: %s", body)
}
}
+3 -2
View File
@@ -64,6 +64,7 @@
<a href="/sites" {{if eq $nav "sites/site"}}aria-current="page"{{end}}>Sections and pages</a>
<a href="/sites/pages" {{if hasPrefix $nav "sites/pages"}}aria-current="page"{{end}}>New pages</a>
<a href="/sites/previews" {{if eq $nav "sites/previews"}}aria-current="page"{{end}}>Previews</a>
<a href="/sites/publishing" {{if eq $nav "sites/publishing"}}aria-current="page"{{end}}>Publishing</a>
</div>
{{end}}
{{if eq .ID "prospects"}}
@@ -192,10 +193,10 @@
{{- else if eq .Status "working"}}<span class="badge scheduled">pushing…</span>
{{- else if eq .Status "pushed"}}<span class="badge scheduled">on its branch</span>
{{- else if eq .Status "pr"}}<span class="badge scheduled">pull request open</span>
{{- else if eq .Status "merged"}}<span class="badge published">merged</span>
{{- else if eq .Status "merged"}}{{if .LiveAt.IsZero}}<span class="badge scheduled" title="Merged; waiting to see it on the live site">merged, not live yet</span>{{else}}<span class="badge published" title="Merged and seen on the live site">live</span>{{end}}
{{- 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>
{{- else if eq .Status "removed"}}{{if .GoneAt.IsZero}}<span class="badge scheduled">removal merged, still on the site</span>{{else}}<span class="badge">removed</span>{{end}}
{{- end}}{{if and .Error (ne .Status "failed")}} <span class="badge failed">to fix</span>{{end}}
{{end}}
+9 -1
View File
@@ -3,11 +3,19 @@
<p class="lede">{{.Kind}} for {{$p.Site}}{{with .From}}, from {{join . "; "}}{{end}}.
{{template "page-status" $p}}</p>
{{if or $p.PRURL .Preview}}
{{if or $p.PRURL .Preview $p.LiveNote}}
<section class="card">
{{with .Preview}}<p><a class="button" href="{{.}}" target="_blank" rel="noopener">Open the preview ↗</a> <span class="small muted">built {{ago $d.PreviewAt}} from the branch {{$p.Branch}}</span></p>{{end}}
{{with $p.PRURL}}<p>The pull request: <a href="{{.}}" target="_blank" rel="noopener noreferrer">{{.}} ↗</a>{{if eq $p.Status "merged"}}, merged {{ago $p.MergedAt}}{{end}}</p>{{end}}
{{with $p.Note}}<p class="small">{{.}}</p>{{end}}
{{if or (eq $p.Status "merged") (eq $p.Status "removing") (eq $p.Status "removed")}}
<div class="status-line">
{{if not $p.LiveAt.IsZero}}{{if ne $p.Status "removed"}}<p class="ok">On the live site since {{ago $p.LiveAt}}: <a href="{{$p.Address}}" target="_blank" rel="noopener noreferrer">{{$p.Address}} ↗</a></p>{{end}}{{end}}
{{if eq $p.Status "removed"}}{{if not $p.GoneAt.IsZero}}<p class="ok">Off the live site since {{ago $p.GoneAt}}.</p>{{end}}{{end}}
{{with $p.LiveNote}}<p class="small">{{if $d.Late}}<span class="warn-text">{{.}} It's been over two hours since the merge: check that the site's deploy (the Gitea hook) ran.</span>{{else}}{{.}}{{end}} {{if not $p.CheckedAt.IsZero}}<span class="muted">Checked {{ago $p.CheckedAt}}.</span>{{end}}</p>{{end}}
{{if $p.Waiting}}<form method="post" action="/sites/pages/{{$p.ID}}/check"><button type="submit" class="secondary small" data-busy="Checking…">Check the live site now</button></form>{{end}}
</div>
{{end}}
</section>
{{end}}
@@ -0,0 +1,48 @@
{{define "content"}}{{with .Data}}{{$d := .}}
<div class="heading"><h1>Publishing</h1></div>
<p class="lede">Merging a pull request on Gitea publishes it: your Gitea hook deploys the site. Supermarket follows its pull requests, and after a merge checks the live site until the page is there, with its title and its own words, or, for a removal, gone. It checks every 30 minutes, and whenever you open the page.</p>
{{if not .Sites}}
<section class="card empty"><p>Add your website and its Hugo repository under <a href="/settings/profile">Settings → Profile</a> first.</p></section>
{{else}}
{{if gt (len .Sites) 1}}<nav class="tabs">{{range .Sites}}<a href="/sites/publishing?site={{.Index}}" {{if and $d.Current (eq .Index $d.Current.Index)}}aria-current="page"{{end}}>{{.URL}}</a>{{end}}</nav>{{end}}
{{with .Current}}
{{if .Err}}<section class="card"><p class="warn-text">{{.URL}}: {{.Err}}.</p></section>{{else}}
<h2>Waiting for the live site</h2>
{{with $d.Waiting}}
<div class="table-wrap"><table>
<thead><tr><th>Page</th><th>Merged</th><th>Last check</th></tr></thead>
<tbody>{{range .}}<tr>
<td><a href="/sites/pages/{{.ID}}">{{or .Title .Path}}</a><br><span class="small muted">{{.Address}}</span></td>
<td class="small">{{if eq .Status "removed"}}removal {{end}}{{if not .MergedAt.IsZero}}{{ago .MergedAt}}{{end}}</td>
<td class="small">{{if .Late $d.Now}}<span class="warn-text">{{.LiveNote}} Over two hours since the merge: check that the deploy ran.</span>{{else}}{{or .LiveNote "Not checked yet."}}{{end}}</td>
</tr>{{end}}</tbody>
</table></div>
{{else}}<p class="help">Nothing waiting: every merged page is on the live site.</p>{{end}}
{{with $d.Open}}
<h2>Pull requests waiting for you</h2>
<ul class="items">{{range .}}<li class="item"><a href="/sites/pages/{{.ID}}">{{or .Title .Path}}</a> {{template "page-status" .}}
{{if eq .Status "removing"}}<a class="small" href="{{.RemovalPRURL}}" target="_blank" rel="noopener noreferrer">the pull request ↗</a>{{else}}<a class="small" href="{{.PRURL}}" target="_blank" rel="noopener noreferrer">the pull request ↗</a>{{end}}</li>{{end}}</ul>
{{end}}
<h2>Recent merges</h2>
{{with $d.PullsErr}}<p class="warn-text">Couldn't read the pull requests from Gitea: {{.}}</p>{{end}}
{{if not $d.Gitea}}<p class="help">Save a Gitea token under <a href="/settings/search">Settings → Search engines</a> to see them.</p>
{{else}}{{with $d.Merges}}
<div class="table-wrap"><table>
<thead><tr><th>Merged</th><th>Pull request</th><th>From</th><th>On the live site</th></tr></thead>
<tbody>{{range .}}<tr>
<td class="small">{{with .MergedAt}}{{ago .}}{{end}}</td>
<td><a href="{{.HTMLURL}}" target="_blank" rel="noopener noreferrer">{{.Title}}</a><br><span class="small muted">{{.Head.Ref}}</span></td>
<td class="small">{{if .Ours}}Supermarket{{else}}{{.User.Login}}{{end}}</td>
<td class="small">{{with .Page}}<a href="/sites/pages/{{.ID}}">{{template "page-status" .}}</a>{{else}}<span class="muted">—</span>{{end}}</td>
</tr>{{end}}</tbody>
</table></div>
<p class="small muted">SEO changes and briefs follow their own pages to the live site, under SEO → Changes and Briefs and pages.</p>
{{else}}<p class="help">No merged pull requests yet. Changes pushed straight to the published branch aren't pull requests: they're under <a href="/sites?site={{$d.Current.Index}}">Sections and pages</a>, in the latest commits.</p>{{end}}{{end}}
{{end}}
{{end}}
{{end}}
{{end}}{{end}}