Files
supermarket/internal/web/templates/sites.html
T
davidandClaude Opus 5.5 9ca09c1ffa Phase 6 part 5, step 2: start a new site
Sites → New site fills an empty Gitea repository with the theme, a
hugo.toml in the site's brand and a starter home page: checked that the
repository is empty and builds with Hugo, then the first commit is pushed
to its default branch. The site joins the profile, and a First pages card
builds its Home, About, Contact and product pages with the page builder;
About and Contact join the top menu.

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

87 lines
5.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}}
{{if $d.Theme}}
<section class="card">
<h2>First pages</h2>
<p>This site uses Supermarket's theme (version {{$d.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}}