Phase 1, part 3: Reddit
- Sign in with a Reddit web app; access tokens refresh automatically, and an app-only token reads rules before sign-in. - Reddit drafts: a title and text for one subreddit, chosen when writing. The subreddit's guidelines and rules go into the prompt, which asks for a community member's post that discloses the affiliation and avoids marketing language. - The Inbox shows the subreddit's rules (cached for a day, with Refresh) and warns, without blocking, about promotion rules, restricted subreddits, link-only subreddits, posting in the same subreddit within a week, more than 1 in 10 recent posts linking to the company's sites, and new accounts. - Publishing makes a text post with the source link at the end, or a link post where the subreddit takes only links. - Migration 4 adds the draft's title and subreddit, and the rules cache. Publishers now take a Post, which carries the title and subreddit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,8 +60,14 @@
|
||||
<fieldset class="choice">
|
||||
<legend>Channels</legend>
|
||||
{{range .Channels}}
|
||||
<label class="check"><input type="checkbox" name="channel" value="{{.ID}}" {{if .Connected}}checked{{end}}> {{.Name}}{{if not .Connected}} <span class="muted">(not connected: you can draft, but not publish yet)</span>{{end}}</label>
|
||||
{{/* Reddit is never pre-checked: each post there is a deliberate choice. */}}
|
||||
<label class="check"><input type="checkbox" name="channel" value="{{.ID}}" {{if and .Connected (ne .ID "reddit")}}checked{{end}}> {{.Name}}{{if not .Connected}} <span class="muted">(not connected: you can draft, but not publish yet)</span>{{end}}</label>
|
||||
{{end}}
|
||||
<label class="small">Subreddit, for Reddit
|
||||
<input name="subreddit" list="subreddits" placeholder="e.g. selfhosted" autocomplete="off">
|
||||
<datalist id="subreddits">{{range .Subreddits}}<option value="{{.}}">{{end}}</datalist>
|
||||
<span class="help">One subreddit per post. Its rules are read and followed when writing{{if .Subreddits}}; suggestions come from this entry and your profile{{end}}.</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset class="choice">
|
||||
<legend>Posts</legend>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
{{range .Drafts}}
|
||||
<tr>
|
||||
<td>{{.PublishedAt.Local.Format "2 Jan 2006 15:04"}}</td>
|
||||
<td>{{.ChannelName}}</td>
|
||||
<td>{{.Where}}</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>
|
||||
<td class="post-text">{{if .PostURL}}<a href="{{.PostURL}}" target="_blank" rel="noopener noreferrer">{{if .Title}}<strong>{{.Title}}</strong> {{end}}{{truncate 200 .Content}}</a>{{else}}{{if .Title}}<strong>{{.Title}}</strong> {{end}}{{truncate 200 .Content}}{{end}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
{{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>{{.Where}}{{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="post-text">{{if .Title}}<strong>{{.Title}}</strong> {{end}}{{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">
|
||||
|
||||
@@ -39,6 +39,13 @@
|
||||
<p class="help">In your LinkedIn app's Auth settings, add this redirect URL: <code>{{.LIRedirect}}</code></p>
|
||||
<form method="post" action="/auth/linkedin/start"><button type="submit" {{if not (and (index $set "linkedin.client_id") (index $set "linkedin.client_secret"))}}disabled{{end}}>{{if index $set .LIToken}}Reconnect{{else}}Connect{{end}} LinkedIn</button></form>
|
||||
</div>
|
||||
<div>
|
||||
<h3>Reddit</h3>
|
||||
{{with index .Connections "reddit"}}{{if .Account}}<p>Connected as u/{{.Account}}, {{ago .At}}.</p>{{end}}{{end}}
|
||||
<p class="help">At reddit.com/prefs/apps, create a <strong>web app</strong> with this redirect URI: <code>{{.RedditRedirect}}</code>.
|
||||
Reddit's API terms need approval for commercial use: Supermarket is meant for a few hand-approved posts, not volume.</p>
|
||||
<form method="post" action="/auth/reddit/start"><button type="submit" {{if not (and (index $set "reddit.client_id") (index $set "reddit.client_secret"))}}disabled{{end}}>{{if index $set .RedditToken}}Reconnect{{else}}Connect{{end}} Reddit</button></form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{{end}}{{end}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{define "content"}}{{with .Data}}{{$conn := .Connected}}{{$now := .Now}}{{$zone := .Zone}}
|
||||
{{define "content"}}{{with .Data}}{{$conn := .Connected}}{{$now := .Now}}{{$zone := .Zone}}{{$reddit := .Reddit}}
|
||||
<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>
|
||||
@@ -16,12 +16,31 @@
|
||||
<div class="drafts">
|
||||
{{range .Drafts}}
|
||||
<div class="draft{{if eq .Status "failed"}} failed{{end}}">
|
||||
<h3>{{.ChannelName}}</h3>
|
||||
<h3>{{.Where}}</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}}
|
||||
{{with $rv.Info}}
|
||||
<details class="rules">
|
||||
<summary>r/{{.Name}}'s rules{{if .Rules}} ({{len .Rules}}){{end}} · read {{ago .FetchedAt}}</summary>
|
||||
{{if .SubmitText}}<p class="guidelines">{{truncate 1200 .SubmitText}}</p>{{end}}
|
||||
{{if .Rules}}<ol>{{range .Rules}}<li><strong>{{.Name}}</strong>{{if .Description}}: {{truncate 500 .Description}}{{end}}</li>{{end}}</ol>{{end}}
|
||||
<p class="muted small">Posts: {{if eq .SubmissionType "self"}}text only{{else if eq .SubmissionType "link"}}links only{{else}}text or links{{end}}{{if .Subscribers}} · {{.Subscribers}} members{{end}}</p>
|
||||
</details>
|
||||
{{end}}
|
||||
<form method="post" action="/reddit/rules/{{.Target}}" class="inline"><button type="submit" class="secondary small">{{if $rv.Info}}Refresh rules{{else}}Read rules{{end}}</button></form>
|
||||
{{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" 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}}">{{.Content}}</textarea>
|
||||
{{if eq .Channel "reddit"}}{{if .SourceURL}}<p class="help">The source link is added at the end as “Source: …”.</p>{{end}}{{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"
|
||||
@@ -36,7 +55,7 @@
|
||||
</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?">
|
||||
<form method="post" action="/drafts/{{.ID}}/discard" data-confirm="Discard this {{.Where}} draft?">
|
||||
<button type="submit" class="danger small">Discard</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user