Files
supermarket/internal/web/templates/sites.html
T
davidandClaude Opus 5.5 7da7c5fd9c Phase 6 part 5, step 3: theme updates by pull request
The theme carries a MANIFEST of its files' SHA-256s. A site's Theme card
shows its copy's version against Supermarket's and any files changed by
hand; Update the theme opens a pull request that writes new and changed
files, removes retired ones, rebuilds, and lists what it replaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:30:48 -07:00

98 lines
6.5 KiB
HTML

{{define "content"}}{{with .Data}}{{$d := .}}
<div class="heading"><h1>Your site</h1></div>
<p class="lede">What your website is built from. Its pages are lists of sections, and each section type has its own layout in the site's repository. Supermarket reads those types, the fields they take and how your pages use them, and builds new pages only from them. It changes the site only through pull requests; merging publishes.</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?site={{.Index}}" {{if and $d.Current (eq .Index $d.Current.Index)}}aria-current="page"{{end}}>{{.URL}}</a>{{end}}</nav>{{end}}
{{with .Current}}{{$cur := .}}
<section class="card">
{{if .Err}}
<p class="warn-text">{{.URL}}: {{.Err}}. Set it under <a href="/settings/profile">Settings → Profile</a> (the repository as owner/name).</p>
{{else}}
<form method="post" action="/sites/sync" class="row">
<input type="hidden" name="site" value="{{.Index}}">
<div>
<strong>{{.URL}}</strong> <span class="muted">from {{.Repo}}{{with $d.Synced.Branch}}, branch {{.}}{{end}}</span>
<p class="small muted">{{if $d.HasSynced}}{{if not $d.Synced.At.IsZero}}Read from the repository {{ago $d.Synced.At}}.{{end}}{{else}}Not read yet.{{end}}</p>
</div>
<button type="submit" data-busy="Reading…" {{if not $d.Gitea}}disabled title="Save a Gitea token under Settings → Search engines"{{end}}>{{if $d.HasSynced}}Read it again{{else}}Read the repository{{end}}</button>
</form>
{{with $d.Synced.Err}}<p class="error-text">The last read failed: {{.}}</p>{{end}}
{{if not $d.Gitea}}<p class="small">Supermarket reads the repository with your Gitea token: save one under <a href="/settings/search">Settings → Search engines</a>.</p>{{end}}
{{end}}
</section>
{{end}}
{{with .Catalog}}
{{with $d.Theme}}
<section class="card">
<h2>The theme</h2>
{{if .Outdated}}
<p>This site has Supermarket's theme version {{.Version}}; Supermarket has version {{.Latest}}.</p>
<form method="post" action="/sites/theme/update"><input type="hidden" name="site" value="{{$d.Current.Index}}">
<button type="submit" data-busy="Opening…" {{if not $d.Gitea}}disabled{{end}}>Update the theme</button>
<span class="small muted">Opens a pull request that replaces the site's copy, checked with a build.</span></form>
{{else}}<p class="ok">This site has Supermarket's theme, version {{.Version}}: the latest.</p>{{end}}
{{with .Edited}}<p class="warn-text small">Changed by hand in the site's copy of the theme: {{join . ", "}}. An update replaces them; such changes belong in the site's own <code>layouts/</code> or <code>static/</code>, which win over the theme.</p>{{end}}
{{with $d.ThemePR}}<p class="small">Last update: <a href="{{.URL}}" target="_blank" rel="noopener noreferrer">the pull request ↗</a>, {{ago .At}}.</p>{{end}}
</section>
<section class="card">
<h2>First pages</h2>
<p>This site uses Supermarket's theme. Build its pages: each is written from your profile, opens for you to edit and preview, and goes to the site as a pull request.</p>
<div class="row-actions">
{{range $d.Kinds}}
<form method="post" action="/sites/pages"><input type="hidden" name="site" value="{{$d.Current.Index}}"><input type="hidden" name="kind" value="{{.}}">
<button type="submit" class="secondary" data-busy="Writing…">{{kindLabel .}}</button></form>
{{end}}
{{range $d.Products}}
<form method="post" action="/sites/pages"><input type="hidden" name="site" value="{{$d.Current.Index}}"><input type="hidden" name="kind" value="product"><input type="hidden" name="product" value="{{.Name}}">
<button type="submit" class="secondary" data-busy="Writing…">Product page: {{.Name}}</button></form>
{{end}}
</div>
<p class="small muted">Each uses the AI (a paid call). About and Contact join the top menu; Contact has a lead form: connect it under <a href="/sites/forms?site={{$d.Current.Index}}">Lead forms</a>.</p>
</section>
{{end}}
{{with $d.Commits}}
<h2>Latest on the published branch</h2>
<div class="table-wrap"><table class="compact">
<thead><tr><th>When</th><th>Who</th><th>What</th></tr></thead>
<tbody>{{range .}}<tr><td>{{ago .At}}</td><td>{{.Author}}</td><td>{{.Subject}}</td></tr>{{end}}</tbody>
</table></div>
{{end}}
<h2>Section types</h2>
<p class="help">{{len .Types}} types{{with .Helpers}}, sharing {{join . ", "}}{{end}}. Most used first. Open one to see the fields it takes and a real example.</p>
{{range .Types}}
<details class="card">
<summary>{{.Name}} <span class="badge">{{if .Uses}}{{.Uses}} use{{if ne .Uses 1}}s{{end}} on {{len .Pages}} page{{if ne (len .Pages) 1}}s{{end}}{{else}}not used yet{{end}}</span>{{if .Missing}} <span class="badge failed">no layout</span>{{end}}</summary>
{{if .Missing}}<p class="warn-text">Pages use this type, but there's no <code>layouts/partials/sections/{{.Name}}.html</code>, so it won't show. Supermarket won't use it.</p>{{end}}
{{with .Doc}}<p><strong>The README says:</strong> {{ticks .}}</p>{{end}}
{{if .Fields}}<p><strong>Fields in use:</strong> {{range $i, $f := .Fields}}{{if $i}}, {{end}}<code>{{$f.Name}}</code>{{with $f.Items}} (items: {{join . ", "}}){{end}}{{end}}</p>{{end}}
{{with .Layout}}<p class="small"><strong>The layout reads:</strong> {{join . ", "}}</p>{{end}}
{{with .Pages}}<p class="small"><strong>On:</strong> {{join . ", "}}</p>{{end}}
{{with .Example}}<pre class="sample">{{.}}</pre>{{end}}
</details>
{{end}}
<h2>Pages</h2>
{{with $d.SectionPages}}
<div class="table-wrap"><table class="compact">
<thead><tr><th>Address</th><th>Title</th><th>Sections</th></tr></thead>
<tbody>{{range .}}<tr><td><a href="{{$d.Current.Base}}{{.Path}}" target="_blank" rel="noopener noreferrer">{{.Path}}</a>{{if .Draft}} <span class="badge draft">draft</span>{{end}}</td><td>{{.Title}}</td><td class="small">{{join .Types " · "}}</td></tr>{{end}}</tbody>
</table></div>
{{else}}<p class="help">No page is built from sections yet.</p>{{end}}
{{with $d.OtherPages}}
<details class="card">
<summary>{{len .}} other pages, written in Markdown</summary>
<div class="table-wrap"><table class="compact">
<thead><tr><th>Address</th><th>Title</th></tr></thead>
<tbody>{{range .}}<tr><td>{{.Path}}{{if .Draft}} <span class="badge draft">draft</span>{{end}}</td><td>{{.Title}}</td></tr>{{end}}</tbody>
</table></div>
</details>
{{end}}
{{end}}
{{end}}
{{end}}{{end}}