Files
supermarket/internal/web/templates/import.html
T
davidandClaude Opus 5.5 4692d72d58 Market import: fill entries in from their websites
A list of just websites and relationships (url:, website:, or a bare
address) can be imported with "Fill in the empty boxes from each
website": each entry is filled in as on New entry, in the background a
few at a time, and saved straight into the Market. Entries already there,
by name or website, are skipped before their site is read; the plan's
limit is kept. The import page shows the progress and each entry's result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 06:41:54 -07:00

62 lines
3.3 KiB
HTML

{{define "content"}}{{with .Data}}
<p><a href="/market">← Market</a></p>
<h1>Import into the Market</h1>
{{template "fill-status" .Fill}}
{{with .Result}}
<section class="card {{if .Errors}}warn{{end}}">
<p>{{.Added}} added, {{.Updated}} updated, {{.Skipped}} skipped (already in the Market).</p>
{{if .Errors}}<ul>{{range .Errors}}<li>{{.}}</li>{{end}}</ul>{{end}}
<p><a href="/market">See the Market</a></p>
</section>
{{end}}
<form class="card" method="post" action="/market/import" enctype="multipart/form-data">
<p>YAML: a list of entries, or a document with an <code>inventory:</code> list. The old app's <code>config.yaml</code> works too (its <code>applications:</code> list).</p>
<label>Paste <textarea name="yaml" rows="12" placeholder="inventory:
- name: Example
relationship: competitor
twitter_handle: example
hashtags: ['#Example']
- url: https://rival.example
relationship: competitor">{{.YAML}}</textarea></label>
<label>…or choose a file <input type="file" name="file" accept=".yaml,.yml,text/yaml"></label>
<div class="cols">
<label>Relationship for entries without one
<select name="relationship">{{range .Relationships}}<option value="{{.}}">{{.}}</option>{{end}}</select>
</label>
<label class="check"><input type="checkbox" name="overwrite"> Replace entries that already exist</label>
</div>
<label class="check"><input type="checkbox" name="fill" {{if .NoAI}}disabled{{end}}> Fill in the empty boxes from each website</label>
<p class="help">{{if .NoAI}}<a href="/settings/ai">Set up the AI</a> to fill entries in. {{end}}Each entry then needs only its website, as <code>url:</code>, and its relationship; the AI fills in the rest, as on New entry, and they're saved straight into the Market. Entries already there, by name or website, are skipped without reading their site.</p>
<div class="actions">
<button type="submit">Import</button>
<button type="submit" name="example" value="federated" class="secondary">Load the Federated example</button>
</div>
<p class="help">The Federated example is the 21 open source applications on a Federated Core, as partners.</p>
</form>
{{end}}{{end}}
{{define "fill-status"}}{{with .}}
<section class="card {{if or .Stopped (.Count "failed")}}warn{{end}}" id="fill-status"{{if .Running}} hx-get="/market/import/status" hx-trigger="every 4s" hx-swap="outerHTML"{{end}}>
<h2>Filled in from their websites</h2>
<p>{{if .Running}}{{.Done}} of {{.Total}} done…{{else if .Stopped}}Stopped with the app after {{.Done}} of {{.Total}}: import the rest again (the ones added are skipped).{{else}}Done: {{.Count "added"}} added, {{.Count "updated"}} updated, {{.Count "skipped"}} skipped, {{.Count "failed"}} failed.{{end}}
Started {{.Started.Format "2 Jan 15:04"}}.</p>
{{if .Lines}}
<table>
<thead><tr><th>Website</th><th>Name</th><th>Result</th><th></th></tr></thead>
<tbody>{{range .Lines}}
<tr>
<td>{{.Site}}</td>
<td>{{if .ID}}<a href="/market/{{.ID}}">{{.Name}}</a>{{else}}{{.Name}}{{end}}</td>
<td>{{.Outcome}}</td>
<td>{{.Note}}{{if and .Note .Filled}}; {{end}}{{if .Filled}}filled: {{range $i, $f := .Filled}}{{if $i}}, {{end}}{{$f}}{{end}}{{end}}</td>
</tr>{{end}}
</tbody>
</table>
{{end}}
{{if not .Running}}<p><a href="/market">See the Market</a></p>{{end}}
</section>
{{end}}{{end}}