Files
davidandClaude Opus 5.5 5451fe6d63 Reddit: posted by hand, with the rules pasted
Reddit's API isn't open to apps like this one, so Supermarket no longer
signs in to Reddit, publishes or schedules there, or reads subreddits and
the account's posts. The internal/api/reddit client, Reddit's OAuth, its
keys and its Social accounts card are gone.

Supermarket still writes the post. Each Reddit draft in Posts has a box
for its subreddit's rules, with a link to them on Reddit: pasted once,
they're kept (subreddits.data, as pasted_rules) and given to the model
for later drafts. Open in Reddit saves the edits and opens the submit
page filled in; Copy title and Copy text (with the tagged source link)
cover a box that comes up empty; Mark as posted records it. Warnings come
from the pasted rules and the posts marked as posted. Fill's subreddit
suggestions are kept unchecked, and say so.

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

102 lines
6.2 KiB
HTML

{{define "content"}}{{with .Data}}{{$conn := .Connected}}{{$accounts := .Accounts}}{{$chosen := .Chosen}}{{$now := .Now}}{{$zone := .Zone}}{{$reddit := .Reddit}}
<h1>Posts</h1>
<p class="lede">Everything waiting for your approval. Nothing is published until you say so: publish a draft now, or schedule it. Reddit posts you post yourself.
{{if .Tagged}}Links to your own sites get UTM tags when published.{{end}}</p>
{{template "reminders" .Reminders}}
{{if .Sections}}
{{range .Sections}}
<h2>{{.Module}}</h2>
{{range .Batches}}
<section class="card batch">
<p class="meta">
{{if .InventoryName}}<strong>{{.InventoryName}}</strong> <span class="badge {{.Kind}}">{{.Kind}}</span> ·{{end}}
written {{ago .CreatedAt}}
{{if .SourceURL}} · <a href="{{.SourceURL}}" target="_blank" rel="noopener noreferrer">source</a>{{end}}
</p>
<div class="drafts">
{{range .Drafts}}
<div class="draft{{if eq .Status "failed"}} failed{{end}}">
<h3>{{.Where}}{{with by .WrittenBy}} <span class="muted small">{{.}}</span>{{end}}</h3>
{{if .Error}}<p class="error">{{.Error}}</p>{{end}}
{{$rv := index $reddit .ID}}
{{if $rv}}
{{if $rv.Warnings}}<ul class="warnings">{{range $rv.Warnings}}<li>{{.}}</li>{{end}}</ul>{{end}}
<details class="rules" {{if not $rv.Info}}open{{end}}>
<summary>r/{{.Target}}'s rules{{with $rv.Info}} · pasted {{ago .SavedAt}}{{else}} · not pasted yet{{end}}</summary>
<form method="post" action="/reddit/rules/{{.Target}}">
<p class="help">Supermarket can't read them from Reddit. <a href="{{$rv.RulesURL}}" target="_blank" rel="noopener noreferrer">Open r/{{.Target}}'s rules ↗</a>, copy them, and paste them here: the next drafts for r/{{.Target}} follow them, and the warnings above use them. To use them for this draft, write it again after saving.</p>
<textarea name="rules" rows="6" aria-label="r/{{.Target}}'s rules" placeholder="Paste the rules here">{{with $rv.Info}}{{.Rules}}{{end}}</textarea>
<button type="submit" class="secondary small">Save rules</button>
</form>
</details>
{{end}}
<form method="post" action="/drafts/{{.ID}}/save" data-busy-on="publish" data-busy="Publishing…">
{{if eq .Channel "reddit"}}
<label class="small">Title
<input name="title" id="title-{{.ID}}" value="{{.Title}}" maxlength="300" required>
</label>
{{end}}
<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}}"
aria-describedby="count-{{.ID}}" id="text-{{.ID}}">{{.Content}}</textarea>
{{if eq .Channel "reddit"}}{{if .SourceURL}}<p class="help">The source link is added at the end as “Source: …”.</p>{{end}}{{end}}
{{if eq .Channel "reddit"}}
<p class="count{{if .TooLong}} over{{end}}" id="count-{{.ID}}">{{.Length}} / {{.Limit}}</p>
<div class="by-hand">
<p class="small"><strong>Post it yourself.</strong> <em>Open in Reddit</em> saves your edits and opens r/{{.Target}}'s submit page in a new tab with the title and text filled in{{if .SourceURL}} (links to your sites tagged){{end}}. If a box comes up empty, copy it from here. Check it there and post.</p>
<div class="row">
<button type="submit" formaction="/drafts/{{.ID}}/open" formtarget="_blank">Open in Reddit ↗</button>
<button type="button" class="secondary small" data-copy="title-{{.ID}}">Copy title</button>
<button type="button" class="secondary small" data-copy="text-{{.ID}}" data-copy-suffix="{{with $rv}}{{.Suffix}}{{end}}">Copy text</button>
<button type="submit" class="secondary small">Save</button>
</div>
</div>
{{else}}
{{$d := .}}{{$accts := index $accounts .Channel}}
{{if $accts}}
<fieldset class="post-as">
<legend class="small">Post as{{if gt (len $accts) 1}} <span class="muted">(choose several to post a copy to each)</span>{{end}}</legend>
{{range $accts}}<label class="check small"><input type="checkbox" name="accounts" value="{{.ID}}" {{if eq (index $chosen $d.ID) .ID}}checked{{end}}> {{.Label}}</label>{{end}}
</fieldset>
{{end}}
<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 → Social accounts"{{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/accounts">sign in</a> before it's due.</p>{{end}}
{{end}}
</form>
{{if eq .Channel "reddit"}}
<form method="post" action="/drafts/{{.ID}}/posted" class="by-hand-done">
<label class="small">Posted it? Paste the link to your post (optional)
<span class="row"><input name="post_url" type="text" inputmode="url" placeholder="https://www.reddit.com/r/{{.Target}}/comments/…">
<button type="submit" class="secondary small">Mark as posted</button></span>
</label>
</form>
{{end}}
<form method="post" action="/drafts/{{.ID}}/discard" data-confirm="Discard this {{.Where}} draft?">
<button type="submit" class="danger small">Discard</button>
</form>
</div>
{{end}}
</div>
</section>
{{end}}
{{end}}
{{else}}
<section class="card empty">
<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}}
{{end}}{{end}}