Social accounts: X's 127.0.0.1 callback, "Get it" links, save in place; cart logo

- X refuses "localhost" in callback URLs, so its sign-in now uses
  http://127.0.0.1:8470/auth/x/callback (shown on the page and sent to X);
  LinkedIn and Reddit keep localhost.
- Every key, on Social accounts and the AI tab, has a "Get it" link to the
  service's page for it (opens a new tab) and says where on that page to
  find it. Addresses checked on 2026-11-21.
- Each network's card saves its own keys in place (htmx swaps the card),
  saying "Saved." and enabling Connect when ready; no reload. Without
  JavaScript it still saves and reloads.
- The shopping-cart image is the logo in the sidebar, the tab icon (PNG,
  and a multi-size favicon.ico at /favicon.ico) and the touch icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 11:01:01 -07:00
co-authored by Claude Opus 5.5
parent d9b1467365
commit 1f181ed554
10 changed files with 154 additions and 47 deletions
+23 -17
View File
@@ -1,26 +1,33 @@
{{define "content"}}{{template "settings-start" .}}{{with .Data}}{{$set := .Set}}
{{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>
{{/* The key fields of every card belong to this one form (form="accounts"),
so each card's Save saves them all, and the sign-in forms aren't nested. */}}
<form method="post" action="/settings/accounts" id="accounts"></form>
{{range .Networks}}{{template "network" .}}{{end}}
{{end}}{{template "settings-end"}}{{end}}
{{range .Networks}}{{$name := .Name}}
<section class="card network">
{{/* 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>
{{range .Fields}}
<div class="secret">
<label>{{.Label}}
<input type="password" name="{{.Name}}" form="accounts" 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}}" form="accounts"> remove</label>{{end}}
</div>
{{end}}
<button type="submit" form="accounts" class="secondary">Save keys</button>
<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">
@@ -34,4 +41,3 @@
{{end}}
</section>
{{end}}
{{end}}{{template "settings-end"}}{{end}}
+5 -3
View File
@@ -5,6 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="htmx-config" content='{"includeIndicatorStyles": false}'>
<title>{{.Title}} · Supermarket</title>
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="icon" type="image/png" href="/static/favicon.png">
<link rel="apple-touch-icon" href="/static/logo.png">
<link rel="stylesheet" href="/static/app.css">
<script src="/static/htmx.min.js" defer></script>
<script src="/static/app.js" defer></script>
@@ -12,7 +15,7 @@
<body>
<div class="shell">
<aside class="sidebar" id="sidebar">
<a class="brand" href="/"><span class="logo">{{template "icon" "cart"}}</span>Supermarket</a>
<a class="brand" href="/"><img class="logo" src="/static/logo.png" alt="" width="28" height="28">Supermarket</a>
<form class="search" action="/search" method="get" role="search">
{{template "icon" "search"}}
<input type="search" name="q" value="{{.Query}}" placeholder="Search" aria-label="Search" id="search-box">
@@ -95,7 +98,7 @@
Saved values are never shown; an empty field keeps what's saved. */}}
{{define "key-field"}}
<div class="secret">
<label>{{.F.Label}}
<label><span class="label-row">{{.F.Label}}{{with .F.Link}} <a class="get-it" href="{{.}}" target="_blank" rel="noopener noreferrer">Get it ↗</a>{{end}}</span>
<input type="password" name="{{.F.Name}}" autocomplete="off" placeholder="{{if .Set}}saved — type to replace{{else}}not set{{end}}">
{{if .F.Help}}<span class="help">{{.F.Help}} Kept in <code>secrets.json</code>, readable only by you, and never shown again.</span>{{end}}
</label>
@@ -119,6 +122,5 @@
{{- else if eq . "accounts"}}<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><path d="m8.59 13.51 6.83 3.98"/><path d="m15.41 6.51-6.82 3.98"/>
{{- else if eq . "ai"}}<path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/>
{{- else if eq . "core"}}<path d="M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z"/><path d="m2 22 3-3"/><path d="M7.5 13.5 10 11"/><path d="M10.5 16.5 13 14"/><path d="m18 3-4 4h6l-4 4"/>
{{- else if eq . "cart"}}<circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>
{{- else if eq . "menu"}}<path d="M4 12h16"/><path d="M4 6h16"/><path d="M4 18h16"/>
{{- end}}</svg>{{end}}