Files
davidandClaude Opus 5.5 bae468e01c Social accounts: the redirect address at the top of each card
It sat under the Save button, while the keys' help pointed below to it.
Now it comes first, with a Copy button, ahead of the keys that need it.

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

81 lines
5.8 KiB
HTML

{{define "content"}}{{template "settings-start" .}}{{with .Data}}
<h2>Social accounts</h2>
<p class="lede">The keys Supermarket reads posts with, and the sign-ins it publishes with. Keys are kept in <code>secrets.json</code> in Supermarket's data folder, readable only by you; saved values are never shown, and an empty field keeps what's saved.</p>
{{range .Networks}}{{template "network" .}}{{end}}
{{end}}{{template "settings-end"}}{{end}}
{{/* One network's card. Its keys form saves in place (htmx swaps the card
for the server's new copy); the sign-in form is a sibling, not nested. */}}
{{define "network"}}{{$set := .Set}}{{$name := .Name}}
<section class="card network" id="network-{{.Name}}">
<h2>{{.Name}}
{{with .Connect}}{{if .Signed}}<span class="badge published">connected{{with .Account}} as {{.}}{{end}}</span>{{else}}<span class="badge">not connected</span>{{end}}{{end}}
</h2>
{{with .Connect}}<p class="help">{{.Setup}} <code id="redirect-{{.Provider}}">{{.Redirect}}</code> <button type="button" class="link small" data-copy="redirect-{{.Provider}}">Copy</button>{{with .Note}}<br>{{.}}{{end}}</p>{{end}}
<form method="post" action="/settings/accounts" hx-post="/settings/accounts" hx-target="closest section" hx-swap="outerHTML" autocomplete="off">
<input type="hidden" name="network" value="{{.Name}}">
{{range .Fields}}
<div class="secret">
<label><span class="label-row">{{.Label}}{{with .Link}} <a class="get-it" href="{{.}}" target="_blank" rel="noopener noreferrer">Get it ↗</a>{{end}}</span>
<input type="password" name="{{.Name}}" autocomplete="off" placeholder="{{if index $set .Name}}saved — type to replace{{else}}not set{{end}}">
{{if .Help}}<span class="help">{{.Help}}</span>{{end}}
</label>
{{if index $set .Name}}<label class="check small"><input type="checkbox" name="remove:{{.Name}}"> remove</label>{{end}}
</div>
{{end}}
<div class="row">
<button type="submit" class="secondary">Save {{.Name}} keys</button>
{{if .Saved}}<span class="ok small" role="status">Saved.</span>{{end}}
</div>
</form>
{{with .Connect}}
<div class="signin">
<h3>Sign in to post</h3>
{{if .Accounts}}<ul class="accounts">{{range .Accounts}}
<li><strong>{{.Name}}</strong> <span class="muted small">{{if eq .Owner 0}}the company's{{else}}someone's own{{end}}, since {{.Created.Local.Format "2 Jan 2006"}}{{if not .Expires.IsZero}}, until {{.Expires.Local.Format "2 Jan 2006"}}{{end}}</span>
<form class="inline" method="post" action="/settings/posting/{{.ID}}/remove" data-confirm="Sign {{.Name}} out? Posts scheduled to it go back to Posts."><button type="submit" class="secondary small">Sign out</button></form></li>
{{end}}</ul>
<p class="help">Who may post to each: <a href="/settings/posting">Settings → Posting accounts</a>.</p>{{end}}
{{with .Expiry}}
{{if .Expired}}<p class="error">The sign-in expired on {{.At.Local.Format "2 Jan 2006"}}: reconnect to publish again.</p>
{{else if .Soon}}<p class="warn-text"><strong>The 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"}}.</strong> Reconnect now to keep posting.</p>
{{else}}<p class="help">The sign-in lasts until {{.At.Local.Format "2 Jan 2006"}}; {{.Network}} doesn't let it be renewed without signing in again. Supermarket reminds you two weeks before.</p>{{end}}
{{end}}
<form method="post" action="/auth/{{.Provider}}/start">
<button type="submit" {{if not .Ready}}disabled title="Save the client ID{{if ne .Provider "x"}} and secret{{end}} first"{{end}}>{{if .Signed}}Add or reconnect a company account{{else}}Connect {{$name}}{{end}}</button>
</form>
</div>
{{with .Page}}{{$pg := .}}
<form method="post" action="/settings/accounts/linkedin-page" class="signin">
<h3>The company page</h3>
{{if .Signed}}
{{if .Orgs}}
<fieldset><legend>Post as</legend>
{{range .Orgs}}<label class="check"><input type="radio" name="org" value="{{.URN}}" {{if and $pg.Chosen (eq $pg.Chosen.URN .URN)}}checked{{end}}> {{.Name}}{{with .Vanity}} <span class="muted small">linkedin.com/company/{{.}}</span>{{end}} <span class="badge">{{.Role}}</span></label>{{end}}
</fieldset>
{{else}}
{{with .Note}}<p class="warn-text">Couldn't list your pages: {{.}}</p>{{end}}
<label>The page's number <span class="muted">(from its admin view: linkedin.com/company/&lt;number&gt;/admin)</span>
<input name="org_manual" value="{{with $pg.Chosen}}{{.ID}}{{end}}" placeholder="12345678"></label>
{{end}}
{{with .Chosen}}<p class="small">Posting as <strong>{{.Name}}</strong>.</p>{{end}}
{{else}}<p class="help">Once connected, choose the page here.</p>{{end}}
<fieldset><legend>New LinkedIn drafts post as</legend>
<label class="check"><input type="radio" name="default" value="" {{if ne .Default "page"}}checked{{end}}> You</label>
<label class="check"><input type="radio" name="default" value="page" {{if eq .Default "page"}}checked{{end}}> The company page</label>
<span class="help">Each draft can still be switched before it's published.</span>
</fieldset>
<label>Permissions to ask for <input name="scopes" value="{{.Scopes}}">
<span class="help">As on the approved app's Auth tab: posting as the page (<code>w_organization_social</code>) and reading the pages you manage (<code>r_organization_admin</code> or <code>rw_organization_admin</code>). Reconnect after changing them.</span></label>
<div class="row">
<button type="submit" class="secondary">Save</button>
{{if .Signed}}<button type="submit" class="secondary" name="do" value="refresh">List my pages again</button>{{end}}
</div>
</form>
{{end}}
{{end}}
</section>
{{end}}