Phase 1, part 2: Inbox, scheduled publishing and UTM tags

- Inbox: a top-level page, with a count in the menu, for everything
  waiting for approval; Content's drafts are reviewed there. /drafts
  redirects to it.
- Scheduling: publish a draft now or at a time (migration 3 adds
  publish_at). A scheduler in the app publishes due drafts every 30
  seconds. Posts more than 12 hours overdue, or refused before posting,
  go back to the Inbox with the reason. Content gets Scheduled and
  Published tabs.
- UTM tags on links to the company's own websites and product pages,
  added when publishing; drafts stay untagged.
- The container runs in the computer's time zone, so times are shown
  and read correctly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 13:17:38 -07:00
co-authored by Claude Opus 5.5
parent 13bf18facc
commit f275f039f9
24 changed files with 873 additions and 184 deletions
+2 -1
View File
@@ -1,7 +1,8 @@
{{define "content"}}{{with .Data}}
<nav class="tabs">
<a href="/content" aria-current="page">Sources</a>
<a href="/drafts">Drafts{{if .Drafts}} ({{.Drafts}}){{end}}</a>
<a href="/content/scheduled">Scheduled</a>
<a href="/content/published">Published</a>
</nav>
<div class="heading">
<h1>{{.Entry.Name}} <span class="badge {{.Entry.Relationship}}">{{.Entry.Relationship}}</span></h1>
@@ -0,0 +1,27 @@
{{define "content"}}{{with .Data}}
<nav class="tabs">
<a href="/content">Sources</a>
<a href="/content/scheduled">Scheduled</a>
<a href="/content/published" aria-current="page">Published</a>
</nav>
<h1>Published</h1>
<p class="lede">The last 200 posts Supermarket published.</p>
{{if .Drafts}}
<table class="list">
<thead><tr><th>When</th><th>Channel</th><th>Entry</th><th>Post</th></tr></thead>
<tbody>
{{range .Drafts}}
<tr>
<td>{{.PublishedAt.Local.Format "2 Jan 2006 15:04"}}</td>
<td>{{.ChannelName}}</td>
<td>{{.InventoryName}}</td>
<td class="post-text">{{if .PostURL}}<a href="{{.PostURL}}" target="_blank" rel="noopener noreferrer">{{truncate 200 .Content}}</a>{{else}}{{truncate 200 .Content}}{{end}}</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<section class="card empty"><p>Nothing published yet.</p></section>
{{end}}
{{end}}{{end}}
@@ -0,0 +1,36 @@
{{define "content"}}{{with .Data}}{{$conn := .Connected}}
<nav class="tabs">
<a href="/content">Sources</a>
<a href="/content/scheduled" aria-current="page">Scheduled</a>
<a href="/content/published">Published</a>
</nav>
<h1>Scheduled</h1>
<p class="lede">Approved posts, in the order they go out ({{.Zone}}). Supermarket publishes them on time as long as it's running; one more than 12 hours late goes back to the Inbox instead.</p>
{{if .Drafts}}
<table class="list">
<thead><tr><th>When</th><th>Channel</th><th>Entry</th><th>Post</th><th></th></tr></thead>
<tbody>
{{range .Drafts}}
<tr>
<td>{{.PublishAt.Local.Format "Mon 2 Jan 15:04"}}</td>
<td>{{.ChannelName}}{{if not (index $conn .Channel)}}<br><span class="warn-text small">not connected</span>{{end}}</td>
<td>{{.InventoryName}}</td>
<td class="post-text">{{truncate 200 .Content}}</td>
<td class="row-actions">
<form method="post" action="/drafts/{{.ID}}/publish" data-busy="Publishing…">
<input type="hidden" name="from" value="scheduled">
<button type="submit" class="small" {{if not (index $conn .Channel)}}disabled{{end}}>Publish now</button>
</form>
<form method="post" action="/drafts/{{.ID}}/unschedule">
<button type="submit" class="secondary small">Unschedule</button>
</form>
</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<section class="card empty"><p>Nothing scheduled. Schedule drafts from the <a href="/inbox">Inbox</a>.</p></section>
{{end}}
{{end}}{{end}}
+3 -2
View File
@@ -1,10 +1,11 @@
{{define "content"}}{{with .Data}}
<nav class="tabs">
<a href="/content" aria-current="page">Sources</a>
<a href="/drafts">Drafts{{if .Drafts}} ({{.Drafts}}){{end}}</a>
<a href="/content/scheduled">Scheduled</a>
<a href="/content/published">Published</a>
</nav>
<h1>Content</h1>
<p class="lede">Pick an inventory entry to fetch its latest news, choose what to write about, and get a draft for each channel to review on the <a href="/drafts">Drafts</a> page.</p>
<p class="lede">Pick an inventory entry to fetch its latest news, choose what to write about, and get a draft for each channel to review in the <a href="/inbox">Inbox</a>.</p>
{{if .Rows}}
<table class="list">
+1 -1
View File
@@ -23,7 +23,7 @@
<details class="card">
<summary>Imported from the old terminal app {{ago .ImportStatus.At}}</summary>
<ul>{{range .ImportStatus.Summary}}<li>{{.}}</li>{{end}}</ul>
{{if .QueuedPosts}}<p>Its queued posts are now drafts: <a href="/drafts">{{.QueuedPosts}} waiting for review</a>.</p>{{end}}
{{if .QueuedPosts}}<p>Its queued posts are now drafts: <a href="/inbox">{{.QueuedPosts}} waiting in the Inbox</a>.</p>{{end}}
</details>
{{end}}
@@ -1,12 +1,11 @@
{{define "content"}}{{with .Data}}{{$conn := .Connected}}
<nav class="tabs">
<a href="/content">Sources</a>
<a href="/drafts" aria-current="page">Drafts</a>
</nav>
<h1>Drafts</h1>
<p class="lede">Each draft is for one channel, and is published on its own: if one channel fails, the other isn't posted twice. The source link is added when publishing.</p>
{{define "content"}}{{with .Data}}{{$conn := .Connected}}{{$now := .Now}}{{$zone := .Zone}}
<h1>Inbox</h1>
<p class="lede">Everything waiting for your approval. Nothing is published until you say so: publish a draft now, or schedule it.
{{if .Tagged}}Links to your own sites get UTM tags when published.{{end}}</p>
{{if .Batches}}
{{if .Sections}}
{{range .Sections}}
<h2>{{.Module}}</h2>
{{range .Batches}}
<section class="card batch">
<p class="meta">
@@ -18,7 +17,7 @@
{{range .Drafts}}
<div class="draft{{if eq .Status "failed"}} failed{{end}}">
<h3>{{.ChannelName}}</h3>
{{if .Error}}<p class="error">Last attempt failed: {{.Error}}</p>{{end}}
{{if .Error}}<p class="error">{{.Error}}</p>{{end}}
<form method="post" action="/drafts/{{.ID}}/save" data-busy-on="publish" data-busy="Publishing…">
<textarea name="content" rows="{{if eq .Channel "x"}}5{{else}}12{{end}}"
data-count="{{.Channel}}" data-limit="{{.Limit}}" data-reserve="{{if eq .Channel "x"}}{{xreserve .SourceURL}}{{else}}0{{end}}"
@@ -26,9 +25,16 @@
<p class="count{{if .TooLong}} over{{end}}" id="count-{{.ID}}">{{.Length}} / {{.Limit}}{{if and (eq .Channel "x") .SourceURL}} including the link{{end}}</p>
<div class="actions">
<button type="submit" name="action" value="publish" formaction="/drafts/{{.ID}}/publish"
{{if not (index $conn .Channel)}}disabled title="Sign in to {{.ChannelName}} under Settings → Credentials"{{end}}>Publish to {{.ChannelName}}</button>
{{if not (index $conn .Channel)}}disabled title="Sign in to {{.ChannelName}} under Settings → Credentials"{{end}}>Publish now</button>
<button type="submit" class="secondary">Save</button>
</div>
<div class="schedule">
<label class="small">Or publish at ({{$zone}})
<input type="datetime-local" name="when" value="{{$now}}">
</label>
<button type="submit" class="secondary" formaction="/drafts/{{.ID}}/schedule">Schedule</button>
</div>
{{if not (index $conn .Channel)}}<p class="help">{{.ChannelName}} isn't connected: <a href="/settings/credentials">sign in</a> before it's due.</p>{{end}}
</form>
<form method="post" action="/drafts/{{.ID}}/discard" data-confirm="Discard this {{.ChannelName}} draft?">
<button type="submit" class="danger small">Discard</button>
@@ -38,26 +44,10 @@
</div>
</section>
{{end}}
{{end}}
{{else}}
<section class="card empty">
<p>No drafts waiting. Write some from the <a href="/content">Sources</a> page.</p>
<p>Nothing waiting. Write posts from <a href="/content">Content</a>; scheduled ones are under <a href="/content/scheduled">Content → Scheduled</a>.</p>
</section>
{{end}}
{{if .Published}}
<h2>Recently published</h2>
<table class="list">
<thead><tr><th>When</th><th>Channel</th><th>Entry</th><th>Post</th></tr></thead>
<tbody>
{{range .Published}}
<tr>
<td>{{ago .PublishedAt}}</td>
<td>{{.ChannelName}}</td>
<td>{{.InventoryName}}</td>
<td>{{if .PostURL}}<a href="{{.PostURL}}" target="_blank" rel="noopener noreferrer">{{truncate 80 .Content}}</a>{{else}}{{truncate 80 .Content}}{{end}}</td>
</tr>
{{end}}
</tbody>
</table>
{{end}}
{{end}}{{end}}
+1
View File
@@ -15,6 +15,7 @@
<nav>
<a href="/" {{if eq .Nav "home"}}aria-current="page"{{end}}>Overview</a>
<a href="/profile" {{if eq .Nav "profile"}}aria-current="page"{{end}}>Profile</a>
<a href="/inbox" {{if eq .Nav "inbox"}}aria-current="page"{{end}}>Inbox{{if .Inbox}} <span class="count-badge">{{.Inbox}}</span>{{end}}</a>
<a href="/content" {{if eq .Nav "content"}}aria-current="page"{{end}}>Content</a>
<a href="/inventory" {{if eq .Nav "inventory"}}aria-current="page"{{end}}>Inventory</a>
<a href="/settings/ai" {{if eq .Nav "settings"}}aria-current="page"{{end}}>Settings</a>