Files
supermarket/internal/web/templates/layout.html
T
davidandClaude Opus 5.5 19476edea2 Light and dark: a switch in the top bar
Three choices: as the device is (the default), light, or dark, kept in
a "theme" cookie per browser. The dark colours move to dark.css, linked
with a media attribute from the cookie, so the server renders the page
in the chosen colours with no flash (the CSP allows no inline script).
app.js sets the cookie and switches the media at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 06:44:38 -07:00

349 lines
26 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{.CSRF}}">
<meta name="htmx-config" content='{"includeIndicatorStyles": false}'>
<title>{{.Title}} · Supermarket</title>
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="icon" type="image/png" href="/static/favicon.png">
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
<link rel="stylesheet" href="/static/app.css">
<link rel="stylesheet" href="/static/dark.css" media="{{.DarkMedia}}" id="dark-css">
<script src="/static/htmx.min.js" defer></script>
<script src="/static/app.js" defer></script>
</head>
<body>
{{if .Bare}}
<div class="bare-shell">
<p class="brand"><img class="logo" src="/static/logo.png" alt="" width="28" height="28">Supermarket</p>
<main class="bare-main">
{{if .Flash}}<p class="flash" role="status">{{.Flash}}</p>{{end}}
{{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}}
{{template "content" .}}
</main>
<p class="version">Supermarket {{.Version}}</p>
{{template "theme-switch" .}}
</div>
{{else}}
<div class="shell">
<aside class="sidebar" id="sidebar">
<a class="brand" href="/"><img class="logo" src="/static/logo.png" alt="" width="28" height="28">Supermarket</a>
{{if .Teams}}<form class="team-switch" method="post" action="/teams/switch">
<label class="visually-hidden" for="team-pick">Team</label>
<select name="team" id="team-pick" data-autosubmit>{{range .Teams}}<option value="{{.ID}}" {{if eq .ID $.TeamID}}selected{{end}}>{{.Name}}</option>{{end}}</select>
<noscript><button type="submit" class="secondary small">Switch</button></noscript>
<a href="/teams/new" class="small">New team</a>
</form>{{end}}
<form class="search" action="/search" method="get" role="search">
{{template "icon" "search"}}
<input type="search" name="q" value="{{.Query}}" placeholder="Search" aria-label="Search" id="search-box">
<kbd title="Press / to search">/</kbd>
</form>
<nav class="nav" aria-label="Main">
<a href="/" {{if eq .Nav "home"}}aria-current="page"{{end}}>{{template "icon" "overview"}}<span>Overview</span></a>
{{with .Viewer}}{{if .Platform}}<a href="/platform" {{if eq $.Nav "platform"}}aria-current="page"{{end}}>{{template "icon" "info"}}<span>Platform</span></a>{{end}}{{end}}
<a href="/approvals" {{if eq .Nav "approvals"}}aria-current="page"{{end}}>{{template "icon" "ai"}}<span>Approvals</span>{{with .Approvals}} <span class="count-badge" title="{{.}} waiting for you">{{.}}</span>{{end}}</a>
{{if .Can "market"}}<a href="/market" {{if eq .Nav "inventory"}}aria-current="page"{{end}}>{{template "icon" "inventory"}}<span>Market</span></a>{{end}}
{{if .Modules}}<div class="nav-label">Modules</div>{{end}}
{{$nav := .Nav}}{{$inbox := .Inbox}}
{{range .Modules}}
{{if .Link}}
<div class="nav-row">
<a href="{{.Link}}" {{if eq $nav .ID}}aria-current="page"{{end}} class="{{if hasPrefix $nav .ID}}open{{end}}">{{template "icon" .ID}}<span>{{.Name}}</span><span class="count-badge nav-sum" hidden></span></a>
<button type="button" class="nav-toggle" aria-controls="subnav-{{.ID}}" aria-expanded="true" aria-label="Show or hide {{.Name}}'s pages" hidden>{{template "icon" "chevron"}}</button>
</div>
{{if eq .ID "content"}}
<div class="subnav" id="subnav-content" data-subnav="content"{{if hasPrefix $nav "content"}} data-current{{end}}>
<a href="/posts" {{if eq $nav "content/posts"}}aria-current="page"{{end}}>Posts{{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}}
{{if eq .ID "seo"}}
<div class="subnav" id="subnav-seo" data-subnav="seo"{{if hasPrefix $nav "seo"}} data-current{{end}}>
<a href="/seo/check" {{if eq $nav "seo/check"}}aria-current="page"{{end}}>Morning check</a>
<a href="/seo/report" {{if eq $nav "seo/report"}}aria-current="page"{{end}}>Monday report</a>
<a href="/seo/next" {{if eq $nav "seo/next"}}aria-current="page"{{end}}>What to write next</a>
<a href="/seo" {{if eq $nav "seo/ranks"}}aria-current="page"{{end}}>What ranks</a>
<a href="/seo/links" {{if eq $nav "seo/links"}}aria-current="page"{{end}}>Links</a>
<a href="/seo/changes" {{if eq $nav "seo/changes"}}aria-current="page"{{end}}>Changes</a>
<a href="/seo/keywords" {{if eq $nav "seo/keywords"}}aria-current="page"{{end}}>Next keywords</a>
<a href="/seo/briefs" {{if eq $nav "seo/briefs"}}aria-current="page"{{end}}>Briefs and pages</a>
<a href="/seo/audit" {{if eq $nav "seo/audit"}}aria-current="page"{{end}}>Audit</a>
<a href="/seo/engines" {{if eq $nav "seo/engines"}}aria-current="page"{{end}}>Search engines</a>
</div>
{{end}}
{{if eq .ID "metrics"}}
<div class="subnav" id="subnav-metrics" data-subnav="metrics"{{if hasPrefix $nav "metrics"}} data-current{{end}}>
<a href="/metrics" {{if eq $nav "metrics/overview"}}aria-current="page"{{end}}>MRR and NRR</a>
<a href="/metrics/spend" {{if eq $nav "metrics/spend"}}aria-current="page"{{end}}>Spend and CAC</a>
<a href="/metrics/clv" {{if eq $nav "metrics/clv"}}aria-current="page"{{end}}>CLV and cohorts</a>
<a href="/metrics/customers" {{if eq $nav "metrics/customers"}}aria-current="page"{{end}}>Customers and the CRM</a>
<a href="/metrics/publish" {{if eq $nav "metrics/publish"}}aria-current="page"{{end}}>Publish</a>
</div>
{{end}}
{{if eq .ID "sites"}}
<div class="subnav" id="subnav-sites" data-subnav="sites"{{if hasPrefix $nav "sites"}} data-current{{end}}>
<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>
<a href="/sites/forms" {{if eq $nav "sites/forms"}}aria-current="page"{{end}}>Lead forms</a>
<a href="/sites/new" {{if eq $nav "sites/new"}}aria-current="page"{{end}}>New site</a>
</div>
{{end}}
{{if eq .ID "prospects"}}
<div class="subnav" id="subnav-prospects" data-subnav="prospects"{{if hasPrefix $nav "prospects"}} data-current{{end}}>
<a href="/signals" {{if eq $nav "prospects/signals"}}aria-current="page"{{end}}>Signals</a>
<a href="/prospects" {{if eq $nav "prospects/review"}}aria-current="page"{{end}}>Review{{with $.NewProspects}} <span class="count-badge" title="{{.}} waiting for review">{{.}}</span>{{end}}</a>
<a href="/outreach" {{if eq $nav "prospects/outreach"}}aria-current="page"{{end}}>Outreach{{with $.Drafts}} <span class="count-badge" title="{{.}} drafts to review">{{.}}</span>{{end}}</a>
<a href="/prospects/suppressed" {{if eq $nav "prospects/suppressed"}}aria-current="page"{{end}}>Suppression list</a>
<a href="/crm" {{if eq $nav "prospects/crm"}}aria-current="page"{{end}}>CRM queue</a>
</div>
{{end}}
{{else}}
<span class="soon" title="{{.Body}}">{{template "icon" .ID}}<span>{{.Name}}</span><small>{{.Phase}}</small></span>
{{end}}
{{end}}
</nav>
<div class="sidebar-foot">
{{if .Can "admin"}}<a href="/settings/profile" {{if hasPrefix .Nav "settings"}}aria-current="page"{{end}}>{{template "icon" "settings"}}<span>Settings</span></a>{{end}}
{{with .Viewer}}{{with .User}}<div class="who"><a href="/settings/account" title="Your account">{{if .Name}}{{.Name}}{{else}}{{.Email}}{{end}}</a>
<form method="post" action="/signout"><button type="submit" class="secondary small">Sign out</button></form></div>{{end}}{{end}}
<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}}{{if ne . $.Title}}<span>{{.}}</span><span class="sep" aria-hidden="true">/</span>{{end}}{{end}}
<span class="here">{{.Title}}</span>
</nav>
{{template "theme-switch" .}}
</header>
<main>
{{with .Viewer}}{{if .Viewing}}<div class="card warn viewing" role="status"><p><strong>Viewing this team as the platform's admin</strong>, read-only, until {{.Session.ViewUntil.Local.Format "15:04"}}: {{.Session.ViewReason}}</p>
<form method="post" action="/platform/stop-viewing"><button type="submit" class="secondary small">Stop viewing</button></form></div>{{end}}{{end}}
{{with .Lapse}}<p class="card warn" role="status">{{.}} {{with $.Viewer}}{{if eq (print .Member.Role) "owner"}}<a href="/settings/billing">Pay now</a>{{end}}{{end}}</p>{{end}}
{{if .Flash}}<p class="flash" role="status">{{.Flash}}</p>{{end}}
{{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}}
{{template "content" .}}
</main>
</div>
</div>
{{end}}
</body>
</html>
{{/* Light, dark, or as the device is: {{template "theme-switch" .}}. The
choice is the "theme" cookie, for this browser; app.js sets it. */}}
{{define "theme-switch"}}
<div class="theme-switch" role="group" aria-label="Colours">
{{range .Themes}}<button type="button" class="icon-button" data-theme-set="{{.}}" aria-pressed="{{if eq . $.ThemeName}}true{{else}}false{{end}}" title="{{if eq . "system"}}As your device is{{else if eq . "light"}}Light{{else}}Dark{{end}}">{{template "icon" .}}<span class="visually-hidden">{{if eq . "system"}}As your device is{{else if eq . "light"}}Light{{else}}Dark{{end}}</span></button>{{end}}
</div>
{{end}}
{{/* 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">{{if .Can "admin"}}Your company, the accounts Supermarket posts with, the prospecting tools it reads, the AI it writes with, and your Federated Core.{{else}}Your account.{{end}}</p>
</div>
<div class="settings">
<nav class="settings-nav" aria-label="Settings sections">
{{with .Viewer}}{{if .User}}<div class="nav-label">You</div>
<a href="/settings/account" {{if eq $.Nav "settings/account"}}aria-current="page"{{end}}>{{template "icon" "profile"}}Your account</a>
{{if .Member.Admin}}<a href="/settings/users" {{if eq $.Nav "settings/users"}}aria-current="page"{{end}}>{{template "icon" "prospects"}}Users</a>{{end}}{{end}}{{end}}
{{if $.Can "admin"}}
<div class="nav-label">Company</div>
<a href="/settings/profile" {{if eq .Nav "settings/profile"}}aria-current="page"{{end}}>{{template "icon" "profile"}}Profile</a>
{{with $.Viewer}}{{if .User}}<a href="/settings/signin" {{if eq $.Nav "settings/signin"}}aria-current="page"{{end}}>{{template "icon" "core"}}Sign-in</a>{{end}}{{end}}
{{if $.Multi}}<a href="/settings/domain" {{if eq .Nav "settings/domain"}}aria-current="page"{{end}}>{{template "icon" "sites"}}Domain</a>{{end}}
<div class="nav-label">Connections</div>
<a href="/settings/connections" {{if eq .Nav "settings/connections"}}aria-current="page"{{end}}>{{template "icon" "core"}}All connections</a>
<a href="/settings/agents" {{if eq .Nav "settings/agents"}}aria-current="page"{{end}}>{{template "icon" "ai"}}Agents</a>
<a href="/settings/posting" {{if eq .Nav "settings/posting"}}aria-current="page"{{end}}>{{template "icon" "accounts"}}Posting accounts</a>
<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>
<a href="/settings/sources" {{if eq .Nav "settings/sources"}}aria-current="page"{{end}}>{{template "icon" "prospects"}}Lead sources</a>
<a href="/settings/email" {{if eq .Nav "settings/email"}}aria-current="page"{{end}}>{{template "icon" "email"}}Email</a>
<a href="/settings/tracking" {{if eq .Nav "settings/tracking"}}aria-current="page"{{end}}>{{template "icon" "metrics"}}Website &amp; sales</a>
<a href="/settings/search" {{if eq .Nav "settings/search"}}aria-current="page"{{end}}>{{template "icon" "seo"}}Search engines</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>
<div class="nav-label">Data</div>
<a href="/settings/backups" {{if eq .Nav "settings/backups"}}aria-current="page"{{end}}>{{template "icon" "backups"}}Backups</a>
<a href="/settings/activity" {{if eq .Nav "settings/activity"}}aria-current="page"{{end}}>{{template "icon" "backups"}}Activity</a>
{{if $.Billing}}<a href="/settings/billing" {{if eq $.Nav "settings/billing"}}aria-current="page"{{end}}>{{template "icon" "metrics"}}Billing</a>{{end}}
{{with $.Viewer}}{{if and .User (eq (print .Member.Role) "owner")}}<a href="/settings/data" {{if eq $.Nav "settings/data"}}aria-current="page"{{end}}>{{template "icon" "backups"}}Your data</a>{{end}}{{end}}
<a href="/settings/about" {{if eq .Nav "settings/about"}}aria-current="page"{{end}}>{{template "icon" "info"}}About</a>
{{end}}
</nav>
<div class="settings-body">
{{end}}
{{define "settings-end"}}
</div>
</div>
{{end}}
{{/* Sign-ins running out: {{template "reminders" .Reminders}}. */}}
{{define "reminders"}}{{range .}}
<section class="card warn reminder" role="status">
<p><strong>{{if .Expired}}{{.Network}}'s sign-in expired on {{.At.Local.Format "2 Jan 2006"}}.{{else}}{{.Network}}'s sign-in expires {{if eq .Days 0}}today{{else if eq .Days 1}}tomorrow{{else}}in {{.Days}} days{{end}}, on {{.At.Local.Format "2 Jan 2006"}}.{{end}}</strong>
{{if .Expired}}Nothing can be published to {{.Network}} until you reconnect; scheduled posts for it come back to Posts.{{else}}After that, nothing can be published to {{.Network}} until you reconnect.{{end}}</p>
<a class="button" href="/settings/accounts">Reconnect {{.Network}}</a>
</section>
{{end}}{{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><span class="label-row">{{.F.Label}}{{with .F.Link}} <a class="get-it" href="{{.}}" target="_blank" rel="noopener noreferrer">Get it ↗</a>{{end}}</span>
<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 . "email"}}<rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>
{{- 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 . "info"}}<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>
{{- else if eq . "backups"}}<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/>
{{- else if eq . "chevron"}}<path d="m6 9 6 6 6-6"/>
{{- else if eq . "menu"}}<path d="M4 12h16"/><path d="M4 6h16"/><path d="M4 18h16"/>
{{- else if eq . "system"}}<rect width="20" height="14" x="2" y="3" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/>
{{- else if eq . "light"}}<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>
{{- else if eq . "dark"}}<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>
{{- end}}</svg>{{end}}
{{define "seo-sites"}}
{{if not .Connected}}
<section class="card empty"><p>Connect Google Search Console under <a href="/settings/search">Settings → Search engines</a> first.</p></section>
{{else if not .Sites}}
<section class="card empty"><p>Choose the Search Console property for your website under <a href="/settings/search">Settings → Search engines</a>.</p></section>
{{else if gt (len .Sites) 1}}{{$d := .}}
<nav class="tabs">{{range .Sites}}<a href="{{$d.Path}}?site={{.Index}}" {{if eq .Index $d.Current.Index}}aria-current="page"{{end}}>{{.URL}}</a>{{end}}</nav>
{{end}}
{{end}}
{{/* A Sites page's status, as a badge. */}}
{{define "page-status"}}
{{- if eq .Status "draft"}}<span class="badge draft">draft</span>
{{- 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"}}{{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"}}{{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}}
{{/* SEO: the morning check's chart, and the searches that gained and lost most (the check and the Monday report). */}}
{{define "click-chart"}}
<figure class="click-chart">
<svg class="chart line-chart" viewBox="0 0 {{.W}} {{.H}}" role="img" aria-label="Clicks by day, this week against the week before">
<text x="0" y="{{.MaxY}}" dominant-baseline="hanging">{{.Max}}</text><text x="0" y="148">0</text>
<line class="axis" x1="28" y1="148" x2="{{.W}}" y2="148"></line>
{{with .Prev}}<polyline class="prev" points="{{.}}"></polyline>{{end}}
<polyline class="this" points="{{.This}}"></polyline>
{{range .Dots}}<circle cx="{{.X}}" cy="{{.Y}}" r="3.5"><title>{{.Title}}</title></circle>{{end}}
{{range .Labels}}<text x="{{.X}}" y="166" text-anchor="middle">{{.Text}}</text>{{end}}
</svg>
<figcaption class="small muted"><span class="key this"></span> clicks this week · <span class="key prev"></span> the week before, day for day</figcaption>
</figure>
{{end}}
{{define "query-changes"}}
{{if or .Gains .Losses}}
<div class="cols">
{{template "query-list" dict "Title" "↑ Searches that gained most clicks" "List" .Gains}}
{{template "query-list" dict "Title" "↓ Searches that lost most clicks" "List" .Losses}}
</div>
<p class="help">Every change counts in these two lists, however small: they're for a look. What really moved, past your thresholds, is listed on its own.</p>
{{end}}
{{end}}
{{define "query-list"}}
<section class="card">
<h3>{{.Title}}</h3>
{{with .List}}
<table class="list">
<thead><tr><th>Search</th><th class="num">Clicks</th><th class="num">Position</th></tr></thead>
<tbody>{{range .}}<tr>
<td>{{.Query}}</td>
<td class="num">{{num .Before.Clicks}} → <strong>{{if .NoData}}<span class="muted">no data</span>{{else}}{{num .After.Clicks}}{{end}}</strong></td>
<td class="num">{{if .NoData}}{{dec1 .Before.Position}} → <span class="muted">no data</span>{{else if .New}}<span class="muted">new</span> {{dec1 .After.Position}}{{else}}{{dec1 .Before.Position}} → {{dec1 .After.Position}}{{end}}</td>
</tr>{{end}}</tbody>
</table>
{{else}}<p class="help">None this week.</p>{{end}}
</section>
{{end}}
{{/* An agent's scopes: {{template "agent-scopes" (dict "Scopes" … "Grants" …)}} */}}
{{define "agent-scopes"}}{{$sc := .Scopes}}
<fieldset class="access">
<legend>May</legend>
<table class="list access-grid"><tbody>
{{range .Grants}}{{$a := print (index $sc .ID)}}<tr>
<td>{{.Name}}</td>
<td><label class="check"><input type="radio" name="scope:{{.ID}}" value="" {{if eq $a ""}}checked{{end}}> Nothing</label></td>
<td><label class="check"><input type="radio" name="scope:{{.ID}}" value="read" {{if eq $a "view"}}checked{{end}}> Read</label></td>
<td><label class="check"><input type="radio" name="scope:{{.ID}}" value="act" {{if eq $a "edit"}}checked{{end}}> Read and act</label></td>
</tr>{{end}}
</tbody></table>
<p class="help"><em>Read and act</em> lets it change things, such as writing drafts. Anything that leaves Supermarket (a post, an email, a site push) waits for a person's approval (Phase 11, part 3).</p>
</fieldset>
{{end}}
{{/* Users (Settings → Users, and one user's page). */}}
{{define "user-status"}}{{if eq .Status "invited"}}{{if .InviteEnd.IsZero}}<span class="pill warn">Invitation expired</span>{{else}}<span class="pill">Invited</span> <span class="muted small">until {{.InviteEnd.Local.Format "2 Jan"}}</span>{{end}}{{else if eq .Status "disabled"}}<span class="pill">Turned off</span>{{else if .Locked}}<span class="pill warn">Locked</span>{{else}}<span class="pill ok">Active</span>{{if .TwoFactor}} <span class="muted small">two-factor</span>{{end}}{{end}}{{end}}
{{/* Role and modules: {{template "access-fields" (dict "Role" … "Modules" … "Grants" …)}} */}}
{{define "access-fields"}}{{$mods := .Modules}}
<fieldset class="access">
<legend>Access</legend>
<label class="check"><input type="radio" name="role" value="admin" {{if eq (print .Role) "admin"}}checked{{end}}> <span><strong>Admin</strong>: every module, Settings, users and connections</span></label>
<label class="check"><input type="radio" name="role" value="member" {{if ne (print .Role) "admin"}}checked{{end}}> <span><strong>Member</strong>: these modules</span></label>
<table class="list access-grid">
<tbody>
{{range .Grants}}{{$a := print (index $mods .ID)}}<tr>
<td>{{.Name}}</td>
<td><label class="check"><input type="radio" name="module:{{.ID}}" value="" {{if eq $a ""}}checked{{end}}> No access</label></td>
<td><label class="check"><input type="radio" name="module:{{.ID}}" value="view" {{if eq $a "view"}}checked{{end}}> View</label></td>
<td><label class="check"><input type="radio" name="module:{{.ID}}" value="edit" {{if eq $a "edit"}}checked{{end}}> Edit</label></td>
</tr>{{end}}
</tbody>
</table>
<p class="help">An admin has them all, whatever is chosen here. <em>View</em> shows a module's pages without the buttons and forms that change things.</p>
</fieldset>
{{end}}