Files
davidandClaude Opus 5.5 98913971ea Phase 6 part 4: post as the LinkedIn company page
A second LinkedIn app (Community Management API) with its own sign-in on
Settings → Social accounts: the pages the member may post for are listed
and one chosen, new LinkedIn drafts default to the page or to you, and
each draft can switch before it's published. Schema 25.

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

77 lines
5.1 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>
<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 .Signed}}<p>Connected{{with .Account}} as <strong>{{.}}</strong>{{end}}{{if not .At.IsZero}}, {{ago .At}}{{end}}.</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}}
<p class="help">{{.Setup}} <code>{{.Redirect}}</code>{{with .Note}}<br>{{.}}{{end}}</p>
<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}}Reconnect{{else}}Connect{{end}} {{$name}}</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}}