website

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 66 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package website is the publication website (design expansion phase 7, M28; brief docs/spec/reputecast-design-addon-publish-sell.md): the publisher's site at their custom domain, grown out of the public archive.

  • Turning it on makes every archived campaign a public post (its old archive address redirects), each archived list a tag, the root of the domain the home page and members able to sign in. Turning it off brings the archive back and keeps everything for next time.
  • Posts come from campaigns ("Publish to web": with the send, at a set time, or now for a sent campaign) or are written for the web only in the composer's post mode. A post's web version is drawn from its MJML by internal/website/render, in the site's theme.
  • Visibility, the free preview marker and the meter gate posts on the server (internal/website/gate): text a reader may not see never reaches their browser, the feed, the sitemap or the search index.
  • Members sign in with a link and a 6-digit code (System stream, the contact's language); sessions are a first-party cookie on the site.
  • Views are counted on the server without cookies: one per visitor, page and day, from a hash with a salt that changes daily.

The public pages themselves are rendered by internal/publicpages with the site's frame (templates/site); this package gives them their data.

Index

Constants

View Source
const (
	CommentPending   = "pending"
	CommentPublished = "published"
	CommentHidden    = "hidden"
	CommentDeleted   = "deleted"
)

Comment statuses.

View Source
const (
	CommentsOff     = "off"
	CommentsMembers = "members"
	CommentsPaid    = "paid"
)

Who may comment (Website › Access).

View Source
const (
	ReviewAll   = "all"
	ReviewFirst = "first"
	ReviewNone  = "none"
)

Which comments wait for review.

View Source
const (
	HeldFirstComment = "first_comment"
	HeldReviewAll    = "review_all"
	HeldLinks        = "links"
	HeldBlocked      = "blocked"
)

Why a comment waits for review.

View Source
const (
	// MaxCommentLength is a comment's longest text, in characters.
	MaxCommentLength = 5000
	// MaxDisplayName is a member's longest display name.
	MaxDisplayName = 60
	// CommentsPerPage is how many top-level comments a page of a post shows,
	// each with its replies.
	CommentsPerPage = 50
	// CommentEditFor is how long a member can edit their own comment.
	CommentEditFor = 15 * time.Minute
	// CommentUndoFor is how long Undo takes a moderation decision back.
	CommentUndoFor = 10 * time.Second
)
View Source
const (
	// CommentCanWrite: the form.
	CommentCanWrite = "write"
	// CommentCanSignin: a visitor; "Sign in to join the conversation".
	CommentCanSignin = "signin"
	// CommentCanUpgrade: a free member on a site where paid members comment.
	CommentCanUpgrade = "paid"
	// CommentCanBlocked: a moderator blocked the member.
	CommentCanBlocked = "blocked"
)

What a reader may do under a post.

View Source
const (
	CommentPosted  = "posted"
	CommentHeld    = "held"
	CommentInvalid = "invalid"
	CommentLimited = "limited"
	CommentDenied  = "denied"
)

What came of a comment a reader sent.

View Source
const (
	ImportUploaded  = "uploaded"
	ImportAnalysing = "analysing"
	ImportReady     = "ready"
	ImportImporting = "importing"
	ImportDone      = "done"
	ImportFailed    = "failed"
	ImportCanceled  = "canceled"
)

Import statuses.

View Source
const (
	ImportAsPublished = "as_published"
	ImportAsDrafts    = "as_drafts"
	ImportCopyImages  = "copy"
	ImportLinkImages  = "link"
	// ImportAnyTier maps an old tier to every paid tier; ImportKeepName
	// keeps an author's name as the byline.
	ImportAnyTier  = "any"
	ImportKeepName = "keep"
)

Choices.

View Source
const (
	ImportDecisionImport = "import"
	ImportDecisionSkip   = "skip"
	ImportDecisionUpdate = "update"
)

Decisions on a staged post.

View Source
const (
	ProblemSlugTaken       = "slug_taken"
	ProblemExtraTags       = "extra_tags"
	ProblemAlreadyImported = "already_imported"
	ProblemConvertFailed   = "convert_failed"
)

Problems the import adds to the converter's (importer.Problem codes).

View Source
const (
	OutcomePublished = "published"
	OutcomeDraft     = "draft"
	OutcomeUpdated   = "updated"
	OutcomeSkipped   = "skipped"
	OutcomeFailed    = "failed"
)

Outcomes of a staged post's run.

View Source
const (
	AsVisitor     = "visitor"
	AsFree        = "free"
	AsFreeUsedUp  = "free_used"
	AsPaid        = "paid"
	AsVisitorUsed = "visitor_used"
)

Preview readers ("Preview on web as …").

View Source
const (
	KindCampaign = "campaign"
	KindWeb      = "web"
)

Post kinds.

View Source
const (
	PostDraft       = "draft"
	PostScheduled   = "scheduled"
	PostPublished   = "published"
	PostUnpublished = "unpublished"
)

Post statuses.

View Source
const (
	WhenWithSend = "with_send"
	WhenAt       = "at"
	WhenNow      = "now"
)

Publish modes.

View Source
const (
	// SessionCookie holds a member's session token.
	SessionCookie = "rc_member"
	// MeterCookie is a visitor's meter key (members-only posts read
	// without signing in), enough for a soft limit.
	MeterCookie = "rc_meter"
	// BrowserCookie names the browser that asked for a sign-in link, so its
	// code is typed where it was asked for.
	BrowserCookie = "rc_signin"
)

Cookies of the site: first-party, on the site's own host and path.

View Source
const (
	StatusOff       = "off"
	StatusTurningOn = "turning_on"
	StatusOn        = "on"
)

Website statuses.

View Source
const (
	LayoutFeatured = "featured"
	LayoutList     = "list"
	LayoutGrid     = "grid"
)

Home layouts.

View Source
const (
	SectionSubscribe = "subscribe"
	SectionFeatured  = "featured"
	SectionLatest    = "latest"
	SectionTag       = "tag"
	SectionAbout     = "about"
	SectionTiers     = "tiers"
)

Home section kinds.

View Source
const (
	NavHome    = "home"
	NavTag     = "tag"
	NavPage    = "page"
	NavArchive = "archive"
	NavURL     = "url"
)

Navigation link kinds.

View Source
const (
	PurposeSignin = "signin"
	PurposeSignup = "signup"
	PurposeEmail  = "email"
)

Link purposes.

View Source
const (
	MaxLinksPerHour = 5
	CodeTries       = 3
	// SignupLinkDays is how long a sign-up's confirmation link works.
	SignupLinkDays = 7
	// ResendAfter is how long "Send again" waits.
	ResendAfter = 60 * time.Second
)

Limits of sign-in links.

View Source
const (
	SigninSent      = "sent"
	SigninInvalid   = "invalid"
	SigninLimited   = "limited"
	SigninChallenge = "challenge"
	SigninOff       = "off"
)

Sign-in outcomes.

View Source
const (
	CodeOK      = "ok"
	CodeWrong   = "wrong"
	CodeExpired = "expired"
)

Code outcomes.

View Source
const (
	LinkOK       = "ok"
	LinkExpired  = "expired"
	LinkUsed     = "used"
	LinkReplaced = "replaced"
	LinkUnknown  = "unknown"
)

Link states.

View Source
const (
	PagePost    = "post"
	PageHome    = "home"
	PageArchive = "archive"
	PageTag     = "tag"
	PagePage    = "page"
)

Page kinds whose views are counted.

View Source
const CommentMute linktoken.Kind = 231

CommentMute is the token of a reply email's "Stop these emails".

View Source
const KindDomainProblem = notify.KindWebsiteDomain

KindDomainProblem notifies the people who manage the website that its custom domain stopped checking out or its certificate is failing.

View Source
const KindPostImportDone = notify.KindPostImportDone

KindPostImportDone tells whoever started an import that it ended.

View Source
const MaxFeatured = 3

MaxFeatured is how many posts the home page features.

View Source
const MaxHeaderLinks = 6

MaxHeaderLinks is how many links the header holds.

View Source
const MaxImportFile = 100 << 20

MaxImportFile is the largest export taken (100 MB).

View Source
const MaxTags = 5

MaxTags is how many tags a post has.

Variables

View Source
var HomeID = uuid.Nil

HomeID stands for the home page and the archive in the view counts.

Functions

func AccountQueries

func AccountQueries(ctx context.Context) *store.Queries

AccountQueries are the queries an account section reads its data with (nil outside Account).

func BrowserKey

func BrowserKey(cookie string) string

BrowserKey is a visitor's meter key: the hash of their meter cookie.

func CheckText

func CheckText(ctx context.Context, c WebsiteWebCheck) (title, detail string)

CheckText is a web check in words, as Review & send lists it.

func CodeText

func CodeText(code string) string

CodeText is a code as the email shows it ("482 913").

func CommenterName

func CommenterName(display, first, last string) string

CommenterName is the name a member's comments show: theirs, else their name on the list, else "" (the page says "A reader"). Never their address.

func CommentsErasure

func CommentsErasure() erasure.Source

CommentsErasure is what a contact wrote under posts and the reply emails waiting for them (M61): their comments keep their place, so other members' replies under them stay, but lose their text and address and read "This comment was removed."; the notices go.

func Erasure

func Erasure() erasure.Source

Erasure is the contact's membership of the publication website: sign-ins, sessions and pending sign-in links (review 2026-11 DP-1).

func Has

func Has(key string) bool

Has reports whether the catalog has a key.

func Money

func Money(cents int64, currency string) string

Money writes a price in minor units the design's way: "$8", "$8.50", "¥1,200".

func PostHash

func PostHash(p store.WebsitePost, src string) string

PostHash is what an approval of a post covers, for a post and its content (the demo's request for Daniel's post).

func ProposalRevision

func ProposalRevision(post store.WebsitePost) string

ProposalRevision covers settings as well as content: changing a title or visibility does not increment the composer's content version. It is local concurrency metadata, not content sent to the model.

func Register

func Register(h huma.API, s *Service)

Register adds the website's operations: the Website tab (its states, posts, home and navigation, access), the composer's Web tab, the Campaigns list's Web column, the report's Web section and the contact profile's Website card. Publishing and unpublishing need website:publish (or an approval); turning the site on or off, home, navigation, tags and who can read what need website:manage.

func RegisterAccountSection

func RegisterAccountSection(f AccountSectionFunc)

RegisterAccountSection adds a section to the account page (Purchases, Gifts, Referrals…), after the built-in ones, in registration order.

func RegisterJobs

func RegisterJobs(reg *jobs.Registry, s *Service)

RegisterJobs adds the website's workers and periodic jobs.

func RegisterPageNames

func RegisterPageNames(f PageNames)

RegisterPageNames lets the page builder name the pages of header links.

func SafeReturn

func SafeReturn(p string) string

SafeReturn keeps a return path on the site: a root-relative path, not another host.

func TierLabel

func TierLabel(name string) string

TierLabel is the quiet label of a tier on posts: its last word unless that word is generic ("Weekly Digest Insider" → "Insider"; "Founding member" → "Founding member").

func Token

func Token() string

Token makes a random cookie value.

Types

type Account

type Account struct {
	ContactID   uuid.UUID
	Email       string
	FirstName   string
	LastName    string
	Since       time.Time
	Tiers       []string
	Plan        *earn.PreferencesPaid
	Meter       *AccountMeter
	Lists       []AccountList
	Frequency   string
	PausedUntil *time.Time
	Sessions    []AccountSession
	SessionDays int
	// Sections are the later phases' sections, in their order.
	Sections []AccountSection
}

Account is the member's account page.

type AccountList

type AccountList struct {
	ID          uuid.UUID
	Name        string
	Description string
	Subscribed  bool
	Pending     bool
}

AccountList is a newsletter on the account page.

type AccountMeter

type AccountMeter struct {
	Used  int
	Limit int
	// Reads are the posts it counted ("the runbook, 13 Oct").
	Reads []AccountRead
	Next  time.Time
}

AccountMeter is what the member meter used this month.

type AccountRead

type AccountRead struct {
	Title string
	At    time.Time
}

AccountRead is a post the meter counted.

type AccountSection

type AccountSection struct {
	ID    string
	Title string
	HTML  string
}

AccountSection is a section another part of ReputeCast adds to the account page: its id, title and body (HTML the section draws itself).

type AccountSectionFunc

type AccountSectionFunc func(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, l i18n.Lang) (AccountSection, bool, error)

AccountSectionFunc draws a section for a member (ok false: none).

type AccountSession

type AccountSession struct {
	ID        uuid.UUID
	Current   bool
	Method    string
	CreatedAt time.Time
	LastSeen  time.Time
	ExpiresAt time.Time
}

AccountSession is one of the member's sessions.

type Approvals

type Approvals interface {
	PostDecision(ctx context.Context, ws *store.Workspace, p *authz.Principal, req PostApprovalRequest) (PostApprovalDecision, error)
	RequestPost(ctx context.Context, ws *store.Workspace, p *authz.Principal, req PostApprovalRequest, note string) (uuid.UUID, error)
	// PostPublished settles the approval a publish relied on.
	PostPublished(ctx context.Context, ws *store.Workspace, postID uuid.UUID, hash string) error
	// PostChanged invalidates requests for the post as it was (hash is the
	// post as it is now).
	PostChanged(ctx context.Context, ws *store.Workspace, p *authz.Principal, postID uuid.UUID, title, hash string) error
}

Approvals is the approval rule for publishing posts (internal/approvals): whether a person may publish a post as it is, and asking for approval.

type CampaignDrafts

type CampaignDrafts interface {
	DraftFromPost(ctx context.Context, ws *store.Workspace, p *authz.Principal, name, subject, preheader, mjml string) (uuid.UUID, error)
}

CampaignDrafts makes a campaign draft from a web-only post ("Send as a campaign"), returning its id.

type CertChecker

type CertChecker interface {
	Check(ctx context.Context, domain string) CertInfo
}

CertChecker checks the certificate a domain serves.

type CertInfo

type CertInfo struct {
	// Status is valid, failing or unknown (the check couldn't connect).
	Status   string
	Issuer   string
	NotAfter time.Time
	// Detail says why a certificate fails, in English from the TLS stack.
	Detail    string
	CheckedAt time.Time
}

CertInfo is what a check of the site's certificate found.

type CodeOutcome

type CodeOutcome struct {
	Status    string
	TriesLeft int
	Email     string
	Done      *SigninDone
}

CodeOutcome is the answer to a typed code.

type CommentInput

type CommentInput struct {
	Body string
	// Parent is the thread a reply answers (uuid.Nil: a new thread).
	Parent uuid.UUID
	// Name is the display name the first comment asks for.
	Name string
	IP   *netip.Addr
	Lang i18n.Lang
}

CommentInput is a comment a member sends from a post.

type CommentNoticesArgs

type CommentNoticesArgs struct{}

CommentNoticesArgs is the job that sends reply emails.

func (CommentNoticesArgs) InsertOpts

func (CommentNoticesArgs) InsertOpts() river.InsertOpts

InsertOpts runs once at a time.

func (CommentNoticesArgs) Kind

func (CommentNoticesArgs) Kind() string

Kind implements river.JobArgs.

type CommentOutcome

type CommentOutcome struct {
	Status  string
	ID      uuid.UUID
	Page    int
	Field   string
	Message string
}

CommentOutcome is what came of a comment: posted or held (with its page of the post), or why not, with the field at fault.

type CommentPart

type CommentPart struct {
	Text, Href string
}

CommentPart is a piece of a comment's text: plain text, or a link (Href set) showing Text.

func CommentParts

func CommentParts(body string) []CommentPart

CommentParts splits a comment's text into plain text and its links, for the page to escape and link (rel="nofollow ugc noopener"). Punctuation after an address ("see https://acme.io/docs.") stays text.

type CommentsQuery

type CommentsQuery struct {
	Page        int
	Reply, Edit uuid.UUID
}

CommentsQuery is what the post's address asks for: a page of threads, the thread to reply to, the comment to edit.

type CommentsView

type CommentsView struct {
	// Count is the post's published comments ("Comments (13)").
	Count int64
	// Threads are the top-level comments shown, with their replies, and
	// Shown how many threads that is of Threads. More: another page.
	Threads       []PublicComment
	Shown, Total  int
	Page          int
	More          bool
	Access        string
	Review        string
	FirstReviewed bool
	// NeedsName: the member's first comment asks for a display name,
	// filled in with NameDraft (their name on the list, never the email).
	NeedsName bool
	NameDraft string
	// DisplayName is the name the member's comments show.
	DisplayName string
	// Reply is the thread ?reply= answers; Edit and Delete the reader's own
	// comment ?edit= and ?delete= open.
	Reply, Edit *PublicComment
	// PaidOnly: only paid members comment; SignupOn: visitors can sign up.
	PaidOnly, SignupOn bool
}

CommentsView is a post's comments section as one reader gets it.

type FeedItem

type FeedItem struct {
	Post PublicPost
	// HTML is the post's body for a public post, else its free preview ("").
	HTML string
	// Gated: a members-only or paid post.
	Gated bool
}

FeedItem is a post in a feed: public posts whole, gated posts only as far as anyone may read them.

type FrameLink struct {
	Kind  string
	Label string
	// Path is a path on the site ("/", "/tag/engineering", "/about"), or
	// URL an outside address.
	Path string
	URL  string
	// Key identifies the page the link opens ("tag:<slug>", "page:<slug>",
	// "home", "archive") so the current page can mark it.
	Key string
}

FrameLink is a header link.

type Home

type Home struct {
	Layout   string
	Sections []HomeSection
	// Total is every published post ("All 190 posts in the archive").
	Total int64
	// Tiers are the paid tiers (for labels).
	Tiers []gate.Tier
}

Home is the home page's data, section by section in their order.

type HomeSection

type HomeSection struct {
	Kind string
	// Subscribe: the hero's note under the form.
	Note string
	// Featured, latest and tag rows: their posts.
	Posts []PublicPost
	// A tag row: the tag and its posts' count.
	Tag      *TagRef
	TagCount int64
	// About: its title, text and link (a path on the site or an address).
	AboutTitle, AboutText, AboutLink string
	// Tiers: the upgrade page's cards (nil without paid tiers or payments).
	Upgrade *earn.UpgradeView
}

HomeSection is one shown section of the home page.

type HourlyArgs

type HourlyArgs struct{}

HourlyArgs is the hourly job: views past their keeping, used sign-in links, and the custom domain's certificate.

func (HourlyArgs) InsertOpts

func (HourlyArgs) InsertOpts() river.InsertOpts

InsertOpts runs on the maintenance queue.

func (HourlyArgs) Kind

func (HourlyArgs) Kind() string

Kind implements river.JobArgs.

type ImageFetcher

type ImageFetcher interface {
	Get(ctx context.Context, r feed.Request) (*feed.Response, error)
}

ImageFetcher reads an imported post's images from the old site, through the outbound guard (feed.Fetcher: every address and redirect checked).

type ImportAnalyseArgs

type ImportAnalyseArgs struct {
	ImportID uuid.UUID `json:"import_id"`
}

ImportAnalyseArgs reads an uploaded export into staged posts.

func (ImportAnalyseArgs) InsertOpts

func (ImportAnalyseArgs) InsertOpts() river.InsertOpts

InsertOpts runs once per import at a time.

func (ImportAnalyseArgs) Kind

func (ImportAnalyseArgs) Kind() string

Kind implements river.JobArgs.

type ImportRunArgs

type ImportRunArgs struct {
	ImportID uuid.UUID `json:"import_id"`
}

ImportRunArgs imports an import's posts, from where it got to.

func (ImportRunArgs) InsertOpts

func (ImportRunArgs) InsertOpts() river.InsertOpts

InsertOpts runs once per import at a time, retried a few times before the import stops.

func (ImportRunArgs) Kind

func (ImportRunArgs) Kind() string

Kind implements river.JobArgs.

type ImportTrayJob

type ImportTrayJob struct {
	ID         string
	Title      string
	Status     string // queued, running, done, failed, canceled
	Progress   *int
	Eta        string
	Detail     string
	Href       string
	StartedAt  *time.Time
	FinishedAt *time.Time
}

ImportTrayJob is an import of posts in the background-jobs tray: running ones with their progress, and ones that ended in the last two hours.

type Inserter

type Inserter interface {
	Insert(ctx context.Context, args river.JobArgs, opts *river.InsertOpts) (*rivertype.JobInsertResult, error)
}

Inserter enqueues River jobs (the job client).

type JoinInput

type JoinInput struct {
	Email string
	// Lists are the newsletters ticked, among the offered ones.
	Lists     []uuid.UUID
	ReturnTo  string
	Browser   string
	IP        *netip.Addr
	UserAgent string
	Turnstile string
	Verify    func(answer string) bool
	// Page is the address the reader signed up on (consent evidence).
	Page string
	// Language is the page's language.
	Language string
}

JoinInput signs a reader up from the site: the paywall of a post, or the sign-in page.

type LinkState

type LinkState struct {
	Status   string
	Email    string
	Purpose  string
	ReturnTo string
	Minutes  int
	// SameBrowser: opened where it was asked for.
	SameBrowser bool
}

LinkState is what a sign-in link can do. Reading it uses nothing up.

type PageLinkState

type PageLinkState struct {
	// Linked: the header links to the page.
	Linked bool
	// Full: the header has no room for another link.
	Full bool
}

PageLinkState is a page's place in the header.

type PageNames

type PageNames func(ctx context.Context, q *store.Queries, workspaceID uuid.UUID, slugs []string) (map[string]string, error)

PageNames resolves the custom pages header links point at (the page builder registers it, design expansion phase 7 M29): a page's title by its slug, ok false when it doesn't exist or isn't published.

type Payments

type Payments struct {
	Provider string
	Mode     string
}

Payments is the payment provider the site sells through ("" when none is connected).

type PaywallTier

type PaywallTier struct {
	ID        uuid.UUID
	Name      string
	Label     string
	Monthly   string
	Yearly    string
	TrialDays int
	Benefits  []string
	// Includes is the label of the lower tier it includes ("Insider").
	Includes string
}

PaywallTier is a tier on the paywall card: "Weekly Digest Insider · $8 a month or $80 a year · 14 days free".

type PostAddress

type PostAddress struct {
	// Post is the published post at the address.
	Post *store.WebsitePost
	// RedirectTo is a path on the site: a renamed post's new address, an
	// old archive address, or where an unpublished post now leads.
	RedirectTo string
	// Gone: the post was taken off the site or deleted (410).
	Gone bool
}

PostAddress is what an address under /posts/ leads to.

type PostApprovalDecision

type PostApprovalDecision struct {
	Allowed bool
	// NeedsApproval: Publish becomes Request approval, for Reason, with the
	// rule that matched ("author_lacks_send", "post_publish").
	NeedsApproval bool
	Rule          string
	Reason        string
	Approvers     []string
	// Pending is an open request for this post (its id), Approved one that
	// covers the post as it is.
	Pending  string
	Approved string
	// RequestedBy and RequestedAt describe the pending request.
	RequestedBy string
	RequestedAt *time.Time
}

PostApprovalDecision is whether a person may publish a post as it is.

type PostApprovalRequest

type PostApprovalRequest struct {
	PostID     uuid.UUID
	Title      string
	Kind       string // web or campaign
	Slug       string
	Path       string // "/posts/q4-roadmap-deep-dive"
	Visibility string
	// VisibilityLabel says the visibility in words ("Members", "Paid · all tiers").
	VisibilityLabel string
	// When: now, at (PublishAt), with_send.
	When      string
	PublishAt *time.Time
	// Hash covers the content and the settings above: a change after
	// approval needs a new one.
	Hash string
	// Excerpt and Preview are what the approval review shows (the web preview).
	Excerpt string
}

PostApprovalRequest is what an approval of a post covers: the content (its hash), the address, the visibility and when it goes live.

type PostLabel

type PostLabel struct {
	Kind string
	Text string
}

PostLabel is a post's visibility label on the site: Kind is "members" or "paid" ("" for public posts), Text says it ("Members", "Insider").

type PostView

type PostView struct {
	Post     PublicPost
	Decision gate.Decision
	// Body is what the reader gets: the whole post, or the free preview
	// ("" without a marker: the title, the cover and the excerpt).
	Body string
	// Readers are the tiers that read the post, lowest first (the paywall
	// offers them); Rules the site's access rules.
	Readers []gate.Tier
	Rules   gate.Rules
	Paywall WebsitePaywall
	// SignupOn: readers can sign up from the paywall; Offers are its lists.
	SignupOn bool
	Offers   []SignupOffer
	// Month is the meter's month; Next the first day of the next one.
	Month, Next time.Time
	// More are other posts of the post's first tag.
	More      []PublicPost
	MoreTag   *TagRef
	MoreTotal int64
	SEO       WebsitePostSEO
	Minutes   int
	// BandText is the subscribe band's line under the post (Home &
	// navigation's subscribe section).
	BandText string
	// SessionDays is how long members stay signed in.
	SessionDays int
}

PostView is a published post as one reader gets it. Text the reader may not read isn't in it: the preview stops at the marker, paid blocks they don't hold are a card.

type PublicComment

type PublicComment struct {
	ID uuid.UUID
	// Name is the member's display name ("" for a team reply, which shows
	// as the publication, and for a member who never named themselves).
	Name string
	Team bool
	Body string
	// Status is published, pending (the reader's own, waiting for
	// review) or removed (hidden or deleted, kept for its replies).
	Status string
	Pinned bool
	// Own: the reader wrote it; Editable: still within 15 minutes.
	Own, Editable bool
	CreatedAt     time.Time
	EditedAt      *time.Time
	Replies       []PublicComment
}

PublicComment is a comment as a reader sees it.

type PublicPost

type PublicPost struct {
	ID          uuid.UUID
	Kind        string
	CampaignID  *uuid.UUID
	Slug        string
	Title       string
	Excerpt     string
	CoverURL    string
	CoverAlt    string
	PublishedAt time.Time
	UpdatedAt   time.Time
	Visibility  gate.Visibility
	// Tags are the post's tags in order; the first names it in lists.
	Tags []TagRef
	// Label is the visibility label: "Members", or a tier's ("Insider").
	Label     PostLabel
	Words     int
	HideIndex bool
	// PreviewText is the text before the free preview marker (search).
	PreviewText string
	BodyText    string
	Byline      string
	BylineColor string
}

PublicPost is a published post as the site lists it: what an anonymous visitor may see of it (never its gated text).

type PublicQuery

type PublicQuery struct {
	Tag     *uuid.UUID
	Search  string
	Exclude []uuid.UUID
	Limit   int
	Offset  int
	// IDs lists exactly these posts, in this order (featured posts).
	IDs []uuid.UUID
}

PublicQuery filters the site's lists of posts.

type PublicTag

type PublicTag struct {
	TagRef
	Description string
	Posts       int64
}

PublicTag is a tag's page: its name, description and number of posts.

type ReadOptions

type ReadOptions struct {
	Lang i18n.Lang
	// Preview reads it for the app: nothing is recorded, and Meter, when
	// set, stands in for the reader's month.
	Preview bool
	Meter   *gate.MeterState
}

ReadOptions are how a post is read.

type RedrawArgs

type RedrawArgs struct{}

RedrawArgs is the daily job (and one at start) that draws again the posts RedrawPollPosts finds.

func (RedrawArgs) InsertOpts

func (RedrawArgs) InsertOpts() river.InsertOpts

InsertOpts runs on the maintenance queue, once at a time.

func (RedrawArgs) Kind

func (RedrawArgs) Kind() string

Kind implements river.JobArgs.

type Service

type Service struct {
	Pool  *pgxpool.Pool
	Q     *store.Queries
	Audit *audit.Logger
	Log   *slog.Logger
	Now   func() time.Time
	URLs  publicurl.Builder
	// Forms holds the branding, the custom domain and the archive.
	Forms *forms.Service
	// Audience signs readers up and changes their newsletters.
	Audience *audience.Service
	// Earn gives the paid tiers, their prices and the billing links (nil
	// without payments).
	Earn func() *earn.Service
	// Mail sends the sign-in emails on the System stream.
	Mail      func() mailer.Sender
	Jobs      func() Inserter
	Approvals func() Approvals
	Campaigns func() CampaignDrafts
	// Certs checks the certificate the custom domain serves (nil: unknown).
	Certs func() CertChecker
	// Links signs the tokens in the site's own emails ("Stop these
	// emails" in a comment reply email).
	Links *linktoken.Signer
	// Images reads an imported post's images from the old site (M61; nil:
	// they keep linking there).
	Images func() ImageFetcher
	// contains filtered or unexported fields
}

Service is the website domain.

func (*Service) AcceptDraftIn

func (s *Service) AcceptDraftIn(ctx context.Context, tx pgx.Tx, ws *store.Workspace, p *authz.Principal, target uuid.UUID, base int64, snapshot, title, excerpt, src string, origin audit.ProposalOrigin) (uuid.UUID, error)

AcceptDraftIn changes only editorial content on an exact, unpublished web-only revision. Publication settings, visibility and addresses stay as the person set them. Decision and history share the caller's transaction.

func (*Service) Access

Access returns Website › Access.

func (*Service) Account

func (s *Service) Account(ctx context.Context, ws *store.Workspace, sess *Session, l i18n.Lang) (Account, error)

Account builds the account page of a signed-in member.

func (*Service) BlockCommenter

func (s *Service) BlockCommenter(ctx context.Context, ws *store.Workspace, p *authz.Principal, contact uuid.UUID, block bool) (WebsiteCommenter, error)

BlockCommenter stops a member from commenting, or lets them again. Their comments waiting for review stay there, marked as a blocked commenter's.

func (*Service) CampaignReport

func (s *Service) CampaignReport(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) (*WebsiteCampaignReport, error)

CampaignReport is the Web section of a campaign's report (nil when the campaign has no post on the site).

func (*Service) CampaignWeb

func (s *Service) CampaignWeb(ctx context.Context, ws *store.Workspace, p *authz.Principal, campaignID uuid.UUID) (WebsiteCampaignWeb, error)

CampaignWeb returns a campaign's Web tab.

func (*Service) CampaignWebStates

func (s *Service) CampaignWebStates(ctx context.Context, ws *store.Workspace, ids []uuid.UUID) ([]WebsiteCampaignWebState, error)

CampaignWebStates are the Web column of campaigns: their posts' states (campaigns without one aren't listed).

func (*Service) CancelImport

func (s *Service) CancelImport(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WebsiteImport, error)

CancelImport drops an import that hasn't started, with its file, or stops a running one after the post it is on (the run writes its report).

func (*Service) ChangeEmail

func (s *Service) ChangeEmail(ctx context.Context, ws *store.Workspace, sess *Session, newEmail, browser string) (SigninOutcome, error)

ChangeEmail sends a confirmation link to a member's new address; the change happens when it is opened. A taken or suppressed address gets no link, and the answer is the same.

func (*Service) CheckDomains

func (s *Service) CheckDomains(ctx context.Context) error

CheckDomains looks at the custom domain of every site that is on: when it stops checking out or its certificate fails, the people with website:manage are told once per problem, until it is fine again.

func (*Service) CommentAccess

func (s *Service) CommentAccess(ctx context.Context, ws *store.Workspace, p store.WebsitePost, sess *Session, reader gate.Reader) (string, error)

CommentAccess is what a reader may do under a post: CommentCanWrite, or why not. Off (""): the post shows no comments to this reader.

func (*Service) CommentEmailsOf

func (s *Service) CommentEmailsOf(ctx context.Context, ws *store.Workspace, contact uuid.UUID) (email string, on bool, err error)

CommentEmailsOf is a member's reply-email setting and address, for the "Stop these emails" page.

func (*Service) Comments

Comments lists one tab of Website › Comments, pinned first, then newest.

func (*Service) ContactCard

func (s *Service) ContactCard(ctx context.Context, ws *store.Workspace, p *authz.Principal, contactID uuid.UUID) (WebsiteContactCard, error)

ContactCard returns a contact's Website card.

func (*Service) CountView

func (s *Service) CountView(ctx context.Context, ws *store.Workspace, r *http.Request, kind string, page uuid.UUID)

CountView counts a page view. It never fails a page: errors are logged.

func (*Service) CreateImport

func (s *Service) CreateImport(ctx context.Context, ws *store.Workspace, p *authz.Principal, fileName string, data []byte) (WebsiteImport, error)

CreateImport keeps an uploaded export and reads its posts in the background.

func (*Service) CreatePost

CreatePost starts a web-only post in the composer's post mode, with the workspace's default visibility, its writer as the byline.

func (*Service) CreateTag

CreateTag makes a tag.

func (*Service) DecideComments

DecideComments publishes, hides or deletes comments. Undo takes it back for 10 seconds; a deleted comment's text goes once it has passed.

func (*Service) DeleteOwnComment

func (s *Service) DeleteOwnComment(ctx context.Context, ws *store.Workspace, p store.WebsitePost, sess *Session, id uuid.UUID, l i18n.Lang) (CommentOutcome, error)

DeleteOwnComment deletes a member's own comment, any time: its text goes at once; its replies stay under "This comment was removed."

func (*Service) DeletePost

func (s *Service) DeletePost(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error

DeletePost deletes a post: it leaves the site (its address answers 410).

func (*Service) DeleteTag

func (s *Service) DeleteTag(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error

DeleteTag deletes a tag; its posts lose it and the header its link.

func (*Service) EditComment

func (s *Service) EditComment(ctx context.Context, ws *store.Workspace, p store.WebsitePost, sess *Session, reader gate.Reader, id uuid.UUID, body string, l i18n.Lang) (CommentOutcome, error)

EditComment changes a member's own comment within 15 minutes. It waits for review again when the site reviews every comment, or when a published comment now holds two links or more.

func (*Service) Feed

func (s *Service) Feed(ctx context.Context, ws *store.Workspace, tag *uuid.UUID, limit int) ([]FeedItem, error)

Feed lists the newest posts for the site's feed (or a tag's).

func (*Service) FindPost

func (s *Service) FindPost(ctx context.Context, ws *store.Workspace, ref string) (uuid.UUID, error)

FindPost finds a post by its id or its address (the slug after /posts/).

func (*Service) Frame

func (s *Service) Frame(ctx context.Context, ws *store.Workspace, set *forms.Settings) (SiteFrame, error)

Frame returns the site's frame for a workspace.

func (*Service) Home

func (s *Service) Home(ctx context.Context, ws *store.Workspace, l i18n.Lang, period string) (Home, error)

Home builds the home page. period is the tiers band's Monthly · Yearly pick.

func (*Service) HomeNav

HomeNav returns Website › Home & navigation.

func (*Service) Import

func (s *Service) Import(ctx context.Context, ws *store.Workspace, id uuid.UUID, cursor string, limit int) (WebsiteImport, error)

Import is an import with a page of its posts.

func (*Service) ImportReport

func (s *Service) ImportReport(ctx context.Context, ws *store.Workspace, id uuid.UUID) (*WebsiteImportReportFile, error)

ImportReport is an ended import's report.

func (*Service) ImportTray

func (s *Service) ImportTray(ctx context.Context, ws *store.Workspace) ([]ImportTrayJob, error)

ImportTray lists the imports of posts for the jobs tray, in the reader's language.

func (*Service) Imports

func (s *Service) Imports(ctx context.Context, ws *store.Workspace) (WebsiteImportList, error)

Imports are a workspace's latest imports.

func (*Service) IsOn

func (s *Service) IsOn(ctx context.Context, ws *store.Workspace) (bool, error)

IsOn reports whether a workspace's website is on.

func (*Service) Join

Join signs a reader up: one email, "Confirm your email and continue reading", confirms the newsletters they ticked and signs them in. The page, the time, the IP address and the exact consent text are kept.

func (*Service) KeepDraftIn

func (s *Service) KeepDraftIn(ctx context.Context, tx pgx.Tx, ws *store.Workspace, p *authz.Principal, title, excerpt, src string, origin audit.ProposalOrigin) (uuid.UUID, error)

KeepDraftIn belongs to the human bundle decision. It creates a web-only draft and its first content version, never rendered public content, publication dates, schedules, approval requests or notification jobs.

func (*Service) LLMsPosts

func (s *Service) LLMsPosts(ctx context.Context, ws *store.Workspace) ([]store.WebsiteLLMsPostsRow, error)

LLMsPosts are the posts /llms.txt lists: the sitemap's, newest first, at most 500, with their title and public excerpt (a gated post's too: the file gives nothing a visitor can't read).

func (*Service) Label

func (s *Service) Label(v gate.Visibility, tiers []gate.Tier, l i18n.Lang) PostLabel

Label is a post's visibility label in a language.

func (*Service) LegacyPost

func (s *Service) LegacyPost(ctx context.Context, ws *store.Workspace, key string) (string, error)

LegacyPost is the slug of the post an old address of the site leads to (key as importer.LegacyKey makes it): "" when none does.

func (s *Service) Link(ctx context.Context, ws *store.Workspace, token, browser string) (LinkState, error)

Link describes a sign-in link (the page it opens).

func (*Service) MemberCount

func (s *Service) MemberCount(ctx context.Context, ws *store.Workspace) (int64, error)

MemberCount is how many contacts signed in to the website (the contacts filter "Signed in to the website").

func (*Service) MuteCommentEmails

func (s *Service) MuteCommentEmails(ctx context.Context, ws *store.Workspace, contact uuid.UUID) (bool, error)

MuteCommentEmails turns a member's reply emails off ("Stop these emails"). ok is false when the contact isn't a member of the site.

func (*Service) Overview

func (s *Service) Overview(ctx context.Context, ws *store.Workspace, p *authz.Principal) (WebsiteOverview, error)

Overview returns the Website tab's header and states.

func (s *Service) PageLink(ctx context.Context, q *store.Queries, ws *store.Workspace, slug string) (PageLinkState, error)

PageLink says whether the header links to a page's address.

func (*Service) PastCampaigns

func (s *Service) PastCampaigns(ctx context.Context, ws *store.Workspace) ([]WebsitePastCampaign, error)

PastCampaigns lists the sent campaigns that aren't posts yet, newest first.

func (*Service) PaywallTiers

func (s *Service) PaywallTiers(ctx context.Context, ws *store.Workspace, readers []gate.Tier) ([]PaywallTier, Payments, error)

PaywallTiers are the tiers a reader can buy to read a post, lowest first, with their current prices; nil when nothing can be bought.

func (*Service) PinComment

func (s *Service) PinComment(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, pin bool) (WebsiteComment, error)

PinComment pins a published top-level comment to the top of its post, or unpins it.

func (*Service) Post

Post returns one post.

func (*Service) PostComments

func (s *Service) PostComments(ctx context.Context, ws *store.Workspace, p store.WebsitePost, sess *Session, reader gate.Reader, q CommentsQuery) (*CommentsView, error)

PostComments is a post's comments section for a reader (nil: the post shows no comments). The caller has decided the reader may read the post.

func (*Service) Posts

Posts lists the posts of Website › Posts with their 30-day numbers.

func (*Service) PreviewPost

func (s *Service) PreviewPost(ctx context.Context, ws *store.Workspace, id uuid.UUID, as, tier string, l i18n.Lang) (store.WebsitePost, PostView, gate.Reader, error)

PreviewPost reads a post as one kind of reader for the app, from its content as it is now (published or not). tier is a paid reader's tier ("" for the highest).

func (*Service) PublicPosts

func (s *Service) PublicPosts(ctx context.Context, ws *store.Workspace, f PublicQuery, l i18n.Lang) ([]PublicPost, int64, error)

PublicPosts lists the site's published posts (the archive, a tag page, feeds), newest first, with the total. Their labels are in l.

func (*Service) Publish

Publish publishes a post now, or schedules it.

func (*Service) PublishApproved

func (s *Service) PublishApproved(ctx context.Context, ws *store.Workspace, postID uuid.UUID, approvalID string, approverName string) error

PublishApproved goes ahead with a post once its approval came: now, or at its time. The approver's decision is the authority.

func (*Service) PublishDue

func (s *Service) PublishDue(ctx context.Context) (int, error)

PublishDue publishes the posts whose time came: scheduled at a time, or set to go live with their campaign's send once it started. The minute job runs it.

func (*Service) PublishPast

PublishPast makes posts of sent campaigns, live at their send dates, in the site's theme, with the tags of their lists.

func (*Service) PurgeComments

func (s *Service) PurgeComments(ctx context.Context) error

PurgeComments is the hourly keeping: comments' addresses after 30 days, deleted comments' text once Undo has passed, sent notices after a week.

func (*Service) PurgeImports

func (s *Service) PurgeImports(ctx context.Context) error

PurgeImports drops reports past their 30 days and the files of ended imports the run didn't get to drop.

func (s *Service) PurgeLinks(ctx context.Context) error

PurgeLinks deletes sign-in links a day after they could last be used.

func (*Service) PurgeViews

func (s *Service) PurgeViews(ctx context.Context) error

PurgeViews deletes the hashes and salts of the days before today: run by the nightly job.

func (*Service) ReadPost

func (s *Service) ReadPost(ctx context.Context, ws *store.Workspace, p store.WebsitePost, reader gate.Reader, o ReadOptions) (PostView, error)

ReadPost decides a published post for a reader and records the meter's read when it counts (never for previews).

func (*Service) Reader

func (s *Service) Reader(ctx context.Context, ws *store.Workspace, sess *Session, meterCookie string) (gate.Reader, error)

Reader is who reads a page: the member of a session (with the paid tiers they hold) or a visitor with their meter cookie.

func (*Service) RedrawPollPosts

func (s *Service) RedrawPollPosts(ctx context.Context) (int, error)

RedrawPollPosts draws again the published posts whose web version still shows a poll's answers: drawn before a poll stayed in the inbox, those answers led to /0, /1 … on the site. Each is drawn from the content it was published with, so its version, hash and publication stay; once drawn, its notes list the poll, and it isn't picked again. It returns how many posts it drew.

func (*Service) ReplyToComment

ReplyToComment replies to a comment as the publication: published at once, under the comment's thread, written by the member who sent it.

func (*Service) RequestApproval

func (s *Service) RequestApproval(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in WebsiteApprovalInput) (WebsitePost, error)

RequestApproval asks the workspace's approvers to approve publishing a post as it is.

func (*Service) RequestSignin

func (s *Service) RequestSignin(ctx context.Context, ws *store.Workspace, in SigninInput) (SigninOutcome, error)

RequestSignin sends a sign-in link and code when the address belongs to a member who can get one. The answer is the same either way.

func (*Service) ResolveIssue

func (s *Service) ResolveIssue(ctx context.Context, ws *store.Workspace, slug string) (PostAddress, error)

ResolveIssue is where an archive issue's old address leads once the website is on: its post (a zero PostAddress: the archive shows it).

func (*Service) ResolvePost

func (s *Service) ResolvePost(ctx context.Context, ws *store.Workspace, slug string) (PostAddress, error)

ResolvePost finds the post at /posts/{slug} while the website is on (a zero PostAddress: nothing there, 404).

func (*Service) Rules

func (s *Service) Rules(ctx context.Context, ws *store.Workspace) (gate.Rules, []gate.Tier, error)

Rules are the site's access rules and every paid tier, for pages that gate themselves (gate.Page).

func (*Service) RunImport

func (s *Service) RunImport(ctx context.Context, id uuid.UUID) error

RunImport imports an import's posts, after the last one it went through: images copied (or kept linking), each post made with its old address leading to it, published at its original date or kept as a draft. It is the website.import_run job. A canceled import stops after the post it is on. At the end it writes the report, drops the file, records one audit entry and tells whoever started it.

func (*Service) RunImportAnalyse

func (s *Service) RunImportAnalyse(ctx context.Context, id uuid.UUID) error

RunImportAnalyse reads an uploaded export into staged posts, with the default decisions — published posts import, drafts and posts imported before are skipped, a slug another post holds gets "-2" — and the default choices: original dates, images copied, old tiers and authors matched by name. It is the website.import_analyse job.

func (*Service) RunTurnOn

func (s *Service) RunTurnOn(ctx context.Context, wsID uuid.UUID) error

RunTurnOn makes the posts, tags and redirects of a website being turned on, then puts it on. It resumes where it stopped.

func (*Service) SaveAccess

SaveAccess saves Website › Access, with an audit entry per part changed.

func (*Service) SaveCampaignWeb

func (s *Service) SaveCampaignWeb(ctx context.Context, ws *store.Workspace, p *authz.Principal, campaignID uuid.UUID, in WebsitePostInput) (WebsiteCampaignWeb, error)

SaveCampaignWeb saves a campaign's Web tab: its post is made on the first save.

func (*Service) SaveCommentSettings

func (s *Service) SaveCommentSettings(ctx context.Context, ws *store.Workspace, sess *Session, name string, emails bool) error

SaveCommentSettings saves the account page's Comments section: the display name (empty: the next comment asks; cut at 60 characters) and reply emails.

func (*Service) SaveHomeNav

SaveHomeNav saves Website › Home & navigation, with an audit entry per part changed: the home page, the navigation, the site's identity.

func (*Service) SaveName

func (s *Service) SaveName(ctx context.Context, ws *store.Workspace, sess *Session, first, last string) error

SaveName changes the member's name.

func (*Service) SaveNewsletters

func (s *Service) SaveNewsletters(ctx context.Context, ws *store.Workspace, sess *Session, in audience.PreferencesInput, ev audience.PublicEvidence) error

SaveNewsletters applies the account page's newsletters, as the preference center does: joining needs no confirmation (the member's session proves the address), leaving is immediate. Only the lists the page shows count: a member can't join a private list (VIP, beta, a paid tier's) by posting its id.

func (*Service) SavePostContent

func (s *Service) SavePostContent(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in WebsitePostContent) (WebsitePostSaved, error)

SavePostContent saves a web-only post's content (autosave, Save, a template or a restored version).

func (*Service) SendAsCampaign

func (s *Service) SendAsCampaign(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WebsiteSentAsCampaign, error)

SendAsCampaign makes a campaign draft of a web-only post: its title as the subject, its excerpt as the preheader and its blocks as the email. The audience is left to pick in the composer.

func (*Service) SendCommentNotices

func (s *Service) SendCommentNotices(ctx context.Context) (int, error)

SendCommentNotices sends the reply emails that are due: one per member who got none in the last hour. It returns how many went.

func (*Service) SessionFor

func (s *Service) SessionFor(ctx context.Context, ws *store.Workspace, cookie string) (*Session, error)

SessionFor reads a member's session from its cookie (nil when there is none, it ended or expired, or the contact is gone). A session is touched at most every ten minutes.

func (s *Service) SetPageLink(ctx context.Context, q *store.Queries, ws *store.Workspace, by *uuid.UUID, from, slug, label string, on bool) (bool, error)

SetPageLink adds, updates or removes the header link of a page, in the caller's transaction. from is the address the link pointed at before (a page that moved); label overrides the page's name ("Field Guide"). It reports whether the header changed.

func (*Service) SetRedirect

SetRedirect changes where an unpublished post's address sends readers.

func (*Service) SignOut

func (s *Service) SignOut(ctx context.Context, ws *store.Workspace, sess *Session) error

SignOut ends the session of a cookie.

func (*Service) SignOutEverywhere

func (s *Service) SignOutEverywhere(ctx context.Context, ws *store.Workspace, p *authz.Principal, contactID uuid.UUID) (WebsiteSignedOut, error)

SignOutEverywhere ends every session of a member, from their contact profile (subscribers:edit). It is audited and on their timeline.

func (*Service) SignOutEverywhereSelf

func (s *Service) SignOutEverywhereSelf(ctx context.Context, ws *store.Workspace, sess *Session) error

SignOutEverywhereSelf ends every session of the member, from their account page.

func (*Service) SigninWithCode

func (s *Service) SigninWithCode(ctx context.Context, ws *store.Workspace, browser, code string, ev audience.PublicEvidence) (CodeOutcome, error)

SigninWithCode checks a code typed in the browser that asked for it.

func (s *Service) SigninWithLink(ctx context.Context, ws *store.Workspace, token, browser string, ev audience.PublicEvidence) (LinkState, *SigninDone, error)

SigninWithLink uses a link (the Continue of the page it opens).

func (*Service) SiteTags

func (s *Service) SiteTags(ctx context.Context, ws *store.Workspace) ([]PublicTag, error)

SiteTags are the tags with published posts, most posts first (the archive's filter).

func (*Service) Sitemap

func (s *Service) Sitemap(ctx context.Context, ws *store.Workspace) ([]SitemapEntry, error)

Sitemap lists the site's posts (but those hidden from search) and tags.

func (*Service) StartImport

func (s *Service) StartImport(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WebsiteImport, error)

StartImport starts a ready import in the background. Keeping posts published needs no approval: where publishing posts needs one, the import goes as drafts or not at all.

func (*Service) TagBySlug

func (s *Service) TagBySlug(ctx context.Context, ws *store.Workspace, slug string) (*PublicTag, error)

TagBySlug finds a tag of the site while it is on (nil: none).

func (*Service) Tags

func (s *Service) Tags(ctx context.Context, ws *store.Workspace) ([]WebsiteTag, error)

Tags lists the website's tags.

func (*Service) TurnOff

TurnOff turns the website off: the home page, web-only posts, sign-in, the account page and the paywall go offline; the archive comes back. Every post and setting is kept for next time.

func (*Service) TurnOn

TurnOn starts turning the website on. A certificate that fails stops it; a domain that isn't verified yet runs the site at the instance's address until it is.

func (*Service) UndoCommentDecision

func (s *Service) UndoCommentDecision(ctx context.Context, ws *store.Workspace, p *authz.Principal, decision uuid.UUID) error

UndoCommentDecision takes a decision on comments back within 10 seconds: each comment is as it was, and reply emails follow.

func (*Service) UndoPublish

func (s *Service) UndoPublish(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (WebsitePost, error)

UndoPublish takes back a publish within 10 seconds ("Undo" on the toast): the post goes back to where it was.

func (*Service) Unpublish

Unpublish takes a post off the site: the home page, tags, the archive, feeds and the sitemap. Its address answers 410, or redirects.

func (*Service) UnsubscribeAll

func (s *Service) UnsubscribeAll(ctx context.Context, ws *store.Workspace, sess *Session, ev audience.PublicEvidence) error

UnsubscribeAll takes the member off every newsletter; they stay a member.

func (*Service) UpdateImport

UpdateImport changes an import's choices, mappings and decisions while it waits to start.

func (*Service) UpdatePost

UpdatePost saves a post's settings. A changed address keeps the old one as a redirect once the post was published.

func (*Service) UpdateTag

func (s *Service) UpdateTag(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in WebsiteTagInput) (WebsiteTag, error)

UpdateTag changes a tag.

func (*Service) WithHomeNavDraft

func (s *Service) WithHomeNavDraft(ctx context.Context, ws *store.Workspace, in WebsiteHomeNavInput) (context.Context, error)

WithHomeNavDraft returns ctx with unsaved Home & navigation settings laid over the saved ones: the site's pages built in it (the tab's live preview) read them. Nothing is saved; settings that wouldn't save are refused the same way.

func (*Service) WriteComment

func (s *Service) WriteComment(ctx context.Context, ws *store.Workspace, p store.WebsitePost, sess *Session, reader gate.Reader, in CommentInput) (CommentOutcome, error)

WriteComment posts a member's comment under a post, or a reply to one of its threads, after the limits (10 in 10 minutes and 50 a day per member, 30 an hour per network) and the checks. A comment that needs review waits for it; the people who moderate hear about it.

type Session

type Session struct {
	ID        uuid.UUID
	ContactID uuid.UUID
	Email     string
	FirstName string
	LastName  string
	Method    string
	CreatedAt time.Time
	ExpiresAt time.Time
}

Session is a member's signed-in session.

func (*Session) FirstOrName

func (m *Session) FirstOrName() string

FirstOrName is what the header pill says ("Sam").

func (*Session) Name

func (m *Session) Name() string

Name is the member's name, else the part of their address before @.

type SigninDone

type SigninDone struct {
	Token     string
	ExpiresAt time.Time
	Email     string
	ReturnTo  string
	Purpose   string
	// Lists were confirmed by a sign-up.
	Lists []uuid.UUID
	// SameBrowser: the link was opened where it was asked for.
	SameBrowser bool
	// Taken: an email change whose new address another contact holds.
	Taken bool
}

SigninDone is a reader just signed in: the session's cookie and where they go next.

type SigninInput

type SigninInput struct {
	Email    string
	ReturnTo string
	// Browser is the browser's sign-in cookie (the code is typed there).
	Browser   string
	IP        *netip.Addr
	Turnstile string
	// Verify checks a Turnstile answer (nil: Turnstile isn't set up).
	Verify func(answer string) bool
}

SigninInput asks for a sign-in link.

type SigninOutcome

type SigninOutcome struct {
	Status  string
	Email   string
	RetryIn time.Duration
	// Minutes is how long links work.
	Minutes int
	Message string
}

SigninOutcome is the answer to "send me a link".

type SignupOffer

type SignupOffer struct {
	ID      uuid.UUID
	Name    string
	Consent string
	Checked bool
}

SignupOffer is a newsletter the paywall and the sign-up form offer.

type SiteFrame

type SiteFrame struct {
	// On is the website being on: the navigation, Subscribe and Sign in.
	// Off, public pages and the shop keep the logo in place of the
	// navigation.
	On bool
	// SigninOn is "Members can sign in" (Sign in in the header).
	SigninOn bool
	// Title is the site's title ("The Acme newsletter") and Short the
	// publisher's name for phones ("Acme"); Tagline is under the title.
	Title   string
	Short   string
	Tagline string
	// Description is the site's description (search engines, link previews).
	Description string
	SocialImage string
	Index       bool
	// Nav are the header links, resolved: a path on the site ("/tag/engineering")
	// or an outside address.
	Nav    []FrameLink
	Footer WebsiteFooter
	// ShareButtons is "Share buttons on posts": the share row under every
	// published post.
	ShareButtons bool
}

SiteFrame is what every page of the site shows around its content (the header, the navigation and the footer): the frame the pages of later phases share (internal/publicpages/templates/site/frame.html).

type SitemapEntry

type SitemapEntry struct {
	Path    []string
	LastMod time.Time
}

SitemapEntry is an address of the site for search engines.

type TLSChecker

type TLSChecker struct {
	Policy  netguard.Policy
	Timeout time.Duration
	Now     func() time.Time
}

TLSChecker connects to the domain on port 443 through the outbound guard.

func (TLSChecker) Check

func (c TLSChecker) Check(ctx context.Context, domain string) CertInfo

Check implements CertChecker.

type TagRef

type TagRef struct {
	ID   uuid.UUID
	Name string
	Slug string
}

TagRef is a tag of a post.

type TickArgs

type TickArgs struct{}

TickArgs is the minute job: posts whose time came, and posts of the campaigns the archive filed since.

func (TickArgs) InsertOpts

func (TickArgs) InsertOpts() river.InsertOpts

InsertOpts runs once at a time.

func (TickArgs) Kind

func (TickArgs) Kind() string

Kind implements river.JobArgs.

type TurnOnArgs

type TurnOnArgs struct {
	WorkspaceID uuid.UUID `json:"workspace_id"`
}

TurnOnArgs runs turning a website on: tags from the archived lists, a post for every archived campaign, the redirects of their old addresses.

func (TurnOnArgs) InsertOpts

func (TurnOnArgs) InsertOpts() river.InsertOpts

InsertOpts runs one at a time per workspace.

func (TurnOnArgs) Kind

func (TurnOnArgs) Kind() string

Kind implements river.JobArgs.

type WebsiteAbout

type WebsiteAbout struct {
	Title string `json:"title" maxLength:"80"`
	Text  string `json:"text" maxLength:"1200"`
	// Link is a path on the site ("/about") or an address.
	Link string `json:"link" maxLength:"500"`
}

WebsiteAbout is the home page's about section.

type WebsiteAccess

type WebsiteAccess struct {
	SigninOn    bool `json:"signinOn"`
	LinkMinutes int  `json:"linkMinutes"`
	SessionDays int  `json:"sessionDays"`
	// The sign-in email's sender and stream (the workspace default, System).
	SenderName  string `json:"senderName"`
	SenderEmail string `json:"senderEmail"`
	// SystemProvider names the System stream's provider ("Postmark").
	SystemProvider     string                 `json:"systemProvider"`
	SignupOn           bool                   `json:"signupOn"`
	Lists              []WebsiteAccessList    `json:"lists"`
	DefaultVisibility  string                 `json:"defaultVisibility" enum:"public,members,paid"`
	CampaignVisibility string                 `json:"campaignVisibility" enum:"audience,public,members,paid"`
	MeterVisitorsOn    bool                   `json:"meterVisitorsOn"`
	MeterVisitors      int                    `json:"meterVisitors"`
	MeterMembersOn     bool                   `json:"meterMembersOn"`
	MeterMembers       int                    `json:"meterMembers"`
	NeverFree          []WebsiteNeverFreePost `json:"neverFree"`
	Paywall            WebsitePaywall         `json:"paywall"`
	Tiers              []WebsiteTierOption    `json:"tiers"`
	Payments           WebsitePayments        `json:"payments"`
	Members            WebsiteMembersFacts    `json:"members"`
	// Gated are the published members-only and paid posts (turning
	// sign-in off makes them unreadable on the web).
	MembersOnlyPosts int64     `json:"membersOnlyPosts"`
	PaidPosts        int64     `json:"paidPosts"`
	Since            time.Time `json:"since"`
	UpdatedAt        time.Time `json:"updatedAt"`
	UpdatedBy        string    `json:"updatedBy,omitempty"`
	// Comments is who may comment on posts: nobody (off, every site's
	// default), signed-in members, or paid members only. CommentsReview is
	// which comments wait for review: every comment, a member's first, or
	// none.
	Comments       string `json:"comments" enum:"off,members,paid"`
	CommentsReview string `json:"commentsReview" enum:"all,first,none"`
	// CommentsWaiting counts the comments waiting for review; Moderators
	// are the people who can moderate them (comments:moderate).
	CommentsWaiting int64    `json:"commentsWaiting"`
	Moderators      []string `json:"moderators"`
}

WebsiteAccess is Website › Access.

type WebsiteAccessInput

type WebsiteAccessInput struct {
	SigninOn           bool                `json:"signinOn"`
	LinkMinutes        int                 `json:"linkMinutes" enum:"10,15,30,60"`
	SessionDays        int                 `json:"sessionDays" minimum:"7" maximum:"365"`
	SignupOn           bool                `json:"signupOn"`
	Lists              []WebsiteSignupList `json:"lists" maxItems:"50"`
	DefaultVisibility  string              `json:"defaultVisibility" enum:"public,members,paid"`
	CampaignVisibility string              `json:"campaignVisibility" enum:"audience,public,members,paid"`
	MeterVisitorsOn    bool                `json:"meterVisitorsOn"`
	MeterVisitors      int                 `json:"meterVisitors" minimum:"0" maximum:"100"`
	MeterMembersOn     bool                `json:"meterMembersOn"`
	MeterMembers       int                 `json:"meterMembers" minimum:"0" maximum:"100"`
	// NeverFree are the posts left out of the meter.
	NeverFree []string       `json:"neverFree" maxItems:"200"`
	Paywall   WebsitePaywall `json:"paywall"`
	// Comments and CommentsReview change who may comment and which comments
	// wait for review (left out: as they are).
	Comments       string `json:"comments,omitempty" enum:"off,members,paid,"`
	CommentsReview string `json:"commentsReview,omitempty" enum:"all,first,none,"`
}

WebsiteAccessInput saves Website › Access.

type WebsiteAccessList

type WebsiteAccessList struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Public  bool   `json:"public"`
	Offered bool   `json:"offered"`
	Checked bool   `json:"checked"`
	// Consent is the consent text shown with it (kept with every sign-up).
	Consent string `json:"consent"`
}

WebsiteAccessList is a list as Website › Access offers it on sign-up.

type WebsiteAddress

type WebsiteAddress struct {
	// Domain is the custom domain as typed (any status).
	Domain       string     `json:"domain"`
	DomainStatus string     `json:"domainStatus" enum:"none,pending,verified,failed"`
	DomainDetail string     `json:"domainDetail"`
	CheckedAt    *time.Time `json:"checkedAt,omitempty"`
	VerifiedAt   *time.Time `json:"verifiedAt,omitempty"`
	// Target is the host the domain's CNAME must point at.
	Target string `json:"target"`
	// Host is the site's address without the scheme: the custom domain
	// once verified, else the instance's /p/<workspace>.
	Host string `json:"host"`
	URL  string `json:"url"`
	// Fallback is the instance's address of the site (until the domain checks out).
	Fallback    string             `json:"fallback"`
	Certificate WebsiteCertificate `json:"certificate"`
}

WebsiteAddress is where the site runs.

type WebsiteApprovalInput

type WebsiteApprovalInput struct {
	Note string `json:"note,omitempty" maxLength:"1000"`
}

WebsiteApprovalInput asks for approval to publish a post.

type WebsiteArchiveFacts

type WebsiteArchiveFacts struct {
	Enabled bool                 `json:"enabled"`
	Index   bool                 `json:"index"`
	Issues  int64                `json:"issues"`
	Since   int                  `json:"since"`
	URL     string               `json:"url"`
	Feed    string               `json:"feed"`
	Lists   []WebsiteArchiveList `json:"lists"`
	// Tags are the lists with archived campaigns: the tags turning on makes.
	Tags []string `json:"tags"`
}

WebsiteArchiveFacts are the archive as it stands: what turning the website on makes of it.

type WebsiteArchiveList

type WebsiteArchiveList struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Issues   int64  `json:"issues"`
	Public   bool   `json:"public"`
	Archived bool   `json:"archived"`
}

WebsiteArchiveList is a list in the archive.

type WebsiteByline

type WebsiteByline struct {
	UserID string `json:"userId,omitempty"`
	Name   string `json:"name"`
	Color  string `json:"color,omitempty"`
}

WebsiteByline is who a post is by: a member of the workspace or a written name.

type WebsiteCampaignPath

type WebsiteCampaignPath struct {
	api.WorkspaceInput
	CampaignID string `path:"campaignId" format:"uuid" doc:"The campaign's id"`
}

WebsiteCampaignPath is a campaign's path.

type WebsiteCampaignReport

type WebsiteCampaignReport struct {
	PostID      string     `json:"postId"`
	Title       string     `json:"title"`
	URL         string     `json:"url"`
	Status      string     `json:"status" enum:"draft,scheduled,published,unpublished"`
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
	// Views are the last 30 days; ViewsAllTime every view.
	Views        int64 `json:"views"`
	ViewsAllTime int64 `json:"viewsAllTime"`
	// Signups are members who joined from the post, Upgrades readers who
	// upgraded to a paid tier from it (30 days).
	Signups   int64           `json:"signups"`
	Upgrades  int64           `json:"upgrades"`
	Referrers []WebsiteSource `json:"referrers"`
	UTM       []WebsiteSource `json:"utm"`
	From      time.Time       `json:"from"`
	Until     time.Time       `json:"until"`
}

WebsiteCampaignReport is the Web section of a campaign's report.

type WebsiteCampaignReportView

type WebsiteCampaignReportView struct {
	// Report is nil when the campaign has no post on the site.
	Report *WebsiteCampaignReport `json:"report,omitempty"`
}

WebsiteCampaignReportView is the Web section of a campaign's report.

type WebsiteCampaignStates

type WebsiteCampaignStates struct {
	SiteOn bool                      `json:"siteOn"`
	States []WebsiteCampaignWebState `json:"states"`
}

WebsiteCampaignStates are the Web column of the Campaigns list.

type WebsiteCampaignWeb

type WebsiteCampaignWeb struct {
	// SiteOn: the website is on (off, the tab says so and offers nothing).
	SiteOn bool   `json:"siteOn"`
	Host   string `json:"host"`
	// Chip is the composer header's Web chip.
	Chip string `json:"chip" enum:"off,with_send,scheduled,published,unpublished"`
	// Post is the campaign's post: saved settings, or the defaults (ID "").
	Post WebsitePost `json:"post"`
	// CampaignStatus, ScheduledAt and SentAt say when "with the send" is.
	CampaignStatus string     `json:"campaignStatus"`
	ScheduledAt    *time.Time `json:"scheduledAt,omitempty"`
	SentAt         *time.Time `json:"sentAt,omitempty"`
	// FollowsAudience is the visibility rule for posts from campaigns
	// ("Follows the audience: the Weekly Digest is free.").
	FollowsAudience bool     `json:"followsAudience"`
	AudienceLists   []string `json:"audienceLists"`
}

WebsiteCampaignWeb is a campaign's Web tab in the composer: whether it goes on the website and how.

type WebsiteCampaignWebState

type WebsiteCampaignWebState struct {
	CampaignID  string     `json:"campaignId"`
	PostID      string     `json:"postId,omitempty"`
	Chip        string     `json:"chip" enum:"off,with_send,scheduled,published,unpublished"`
	Slug        string     `json:"slug,omitempty"`
	URL         string     `json:"url,omitempty"`
	Visibility  string     `json:"visibility,omitempty"`
	Featured    bool       `json:"featured"`
	PublishAt   *time.Time `json:"publishAt,omitempty"`
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
	// UnpublishedAt is when a published post was taken down.
	UnpublishedAt *time.Time `json:"unpublishedAt,omitempty"`
}

WebsiteCampaignWebState is a campaign's post in the Campaigns list's Web column and in Review & send.

type WebsiteCertificate

type WebsiteCertificate struct {
	Status   string     `json:"status" enum:"valid,failing,pending,unknown,none"`
	Issuer   string     `json:"issuer,omitempty"`
	RenewsAt *time.Time `json:"renewsAt,omitempty"`
	Detail   string     `json:"detail,omitempty"`
}

WebsiteCertificate is the certificate the custom domain serves.

type WebsiteComment

type WebsiteComment struct {
	ID        string `json:"id"`
	PostID    string `json:"postId"`
	PostTitle string `json:"postTitle"`
	// URL is the comment on the site (…/posts/<slug>#comment-<id>).
	URL string `json:"url"`
	// ParentID is the comment a reply answers ("" for a top-level
	// comment), ParentName who wrote it (the publication's name for a team
	// reply).
	ParentID   string `json:"parentId,omitempty"`
	ParentName string `json:"parentName,omitempty"`
	// A member's comment: their contact, the name it shows and their
	// address (for the team only, never on the site), whether they're
	// blocked. A team reply shows as the publication; By is who wrote it.
	ContactID  string `json:"contactId,omitempty"`
	Name       string `json:"name"`
	Email      string `json:"email,omitempty"`
	Blocked    bool   `json:"blocked"`
	Team       bool   `json:"team"`
	By         string `json:"by,omitempty"`
	Body       string `json:"body"`
	Status     string `json:"status" enum:"pending,published,hidden,deleted"`
	HeldReason string `json:"heldReason,omitempty" enum:"first_comment,review_all,links,blocked,"`
	Pinned     bool   `json:"pinned"`
	Replies    int64  `json:"replies"`
	// Links is how many links the text holds (two or more hold it).
	Links     int        `json:"links"`
	CreatedAt time.Time  `json:"createdAt"`
	EditedAt  *time.Time `json:"editedAt,omitempty"`
	// PublishedAt is when it first showed on the site.
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
	ModeratedBy string     `json:"moderatedBy,omitempty"`
	ModeratedAt *time.Time `json:"moderatedAt,omitempty"`
	// FirstReply is the first published reply, for the thread's preview.
	FirstReply *WebsiteCommentReply `json:"firstReply,omitempty"`
}

WebsiteComment is a comment in Website › Comments.

type WebsiteCommentCounts

type WebsiteCommentCounts struct {
	Pending   int64 `json:"pending"`
	Published int64 `json:"published"`
	Hidden    int64 `json:"hidden"`
}

WebsiteCommentCounts are the tabs' counts.

type WebsiteCommentDecision

type WebsiteCommentDecision struct {
	DecisionID string    `json:"decisionId"`
	UndoUntil  time.Time `json:"undoUntil"`
	Count      int       `json:"count"`
}

WebsiteCommentDecision is a decision made, with how long Undo works.

type WebsiteCommentDecisionInput

type WebsiteCommentDecisionInput struct {
	IDs      []string `json:"ids" minItems:"1" maxItems:"200"`
	Decision string   `json:"decision" enum:"publish,hide,delete"`
}

WebsiteCommentDecisionInput publishes, hides or deletes comments.

type WebsiteCommentDecisionPath

type WebsiteCommentDecisionPath struct {
	api.WorkspaceInput
	Decision string `path:"decision" format:"uuid" doc:"The decision's id (decisionId)"`
}

WebsiteCommentDecisionPath is a moderation decision's path.

type WebsiteCommentFilter

type WebsiteCommentFilter struct {
	Status string `query:"status" enum:"pending,published,hidden," doc:"The tab: waiting for review (the default), published or hidden"`
	Post   string `query:"post" maxLength:"64" doc:"A post's id"`
	Search string `query:"q" maxLength:"200" doc:"Words in the comment, the commenter's name or address"`
	Cursor string `query:"cursor" maxLength:"200" doc:"nextCursor of the page before"`
	Limit  int    `query:"limit" minimum:"0" maximum:"100" doc:"Comments per page (50 by default)"`
}

WebsiteCommentFilter narrows Website › Comments.

type WebsiteCommentList

type WebsiteCommentList struct {
	Items      []WebsiteComment     `json:"items"`
	NextCursor string               `json:"nextCursor,omitempty"`
	Counts     WebsiteCommentCounts `json:"counts"`
	// Comments and Review are the site's settings (Website › Access);
	// Publication is the name team replies show ("Reply as …").
	Comments    string `json:"comments" enum:"off,members,paid"`
	Review      string `json:"review" enum:"all,first,none"`
	Publication string `json:"publication"`
	// PublicationMark is the letter the site's mark shows (its publisher's
	// initial), on team replies.
	PublicationMark string `json:"publicationMark"`
	// Posts are the posts with comments, for the post filter.
	Posts []WebsiteCommentPost `json:"posts"`
}

WebsiteCommentList is a page of one tab of Website › Comments.

type WebsiteCommentPath

type WebsiteCommentPath struct {
	api.WorkspaceInput
	Comment string `path:"comment" format:"uuid" doc:"The comment's id"`
}

WebsiteCommentPath is a comment's path.

type WebsiteCommentPost

type WebsiteCommentPost struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	Comments int64  `json:"comments"`
}

WebsiteCommentPost is a post with comments (waiting, published or hidden).

type WebsiteCommentReply

type WebsiteCommentReply struct {
	Name      string    `json:"name"`
	Team      bool      `json:"team"`
	By        string    `json:"by,omitempty"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"createdAt"`
}

WebsiteCommentReply is a reply as a thread's preview shows it: who (the publication for a team reply, By who wrote it) and its text.

type WebsiteCommentReplyInput

type WebsiteCommentReplyInput struct {
	Body string `json:"body" minLength:"1" maxLength:"5000"`
}

WebsiteCommentReplyInput is a reply as the publication.

type WebsiteCommenter

type WebsiteCommenter struct {
	ContactID string     `json:"contactId"`
	Name      string     `json:"name"`
	Blocked   bool       `json:"blocked"`
	BlockedAt *time.Time `json:"blockedAt,omitempty"`
	// Held are their comments waiting for review, now marked as a blocked
	// commenter's.
	Held int64 `json:"held"`
}

WebsiteCommenter is a member as a commenter: blocked or not.

type WebsiteContactCard

type WebsiteContactCard struct {
	SiteOn bool   `json:"siteOn"`
	Host   string `json:"host"`
	// Member: they signed in to the website at least once.
	Member bool       `json:"member"`
	Since  *time.Time `json:"since,omitempty"`
	// Plan is free, or the paid tiers they hold.
	Paid       bool       `json:"paid"`
	Tiers      []string   `json:"tiers"`
	LastSignIn *time.Time `json:"lastSignIn,omitempty"`
	LastMethod string     `json:"lastMethod,omitempty" enum:"link,code,signup,"`
	SignIns    int        `json:"signIns"`
	// Sessions are active; SessionEnds is when the latest one ends.
	Sessions    int        `json:"sessions"`
	SessionEnds *time.Time `json:"sessionEnds,omitempty"`
	// Meter is the paid posts a free member read for free this month
	// (when that meter is on).
	Meter  *WebsiteMeterUse     `json:"meter,omitempty"`
	Events []WebsiteMemberEvent `json:"events"`
	// CanSignOut: holds subscribers:edit; Reason says why not.
	CanSignOut bool   `json:"canSignOut"`
	Reason     string `json:"reason,omitempty"`
}

WebsiteContactCard is the Website card of a contact's profile.

type WebsiteContactPath

type WebsiteContactPath struct {
	api.WorkspaceInput
	ContactID string `path:"contactId" format:"uuid" doc:"The contact's id"`
}

WebsiteContactPath is a contact's path.

type WebsiteFallback

type WebsiteFallback struct {
	Token    string `json:"token"`
	Fallback string `json:"fallback"`
	// Source is the token as written with the word before it ("Hi {{
	// first_name | default: "there" }}"), Sample how the web reads it.
	Source string `json:"source"`
	Sample string `json:"sample"`
}

WebsiteFallback is a personalization token the web shows with its fallback.

type WebsiteFeaturedPost

type WebsiteFeaturedPost struct {
	ID          string     `json:"id"`
	Title       string     `json:"title"`
	Tag         string     `json:"tag,omitempty"`
	Visibility  string     `json:"visibility"`
	Tiers       []string   `json:"tiers"`
	Status      string     `json:"status"`
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
}

WebsiteFeaturedPost is a featured post in Home & navigation.

type WebsiteFeedURLs

type WebsiteFeedURLs struct {
	Sitemap     string `json:"sitemap"`
	Feed        string `json:"feed"`
	TagFeed     string `json:"tagFeed"`
	ArchiveFeed string `json:"archiveFeed"`
	LLMs        string `json:"llms"`
}

WebsiteFeedURLs are the site's sitemap, feed and llms.txt addresses.

type WebsiteFooter

type WebsiteFooter struct {
	Archive     bool `json:"archive"`
	RSS         bool `json:"rss"`
	Preferences bool `json:"preferences"`
}

WebsiteFooter are the footer's switches. Privacy and "Sent with ReputeCast" follow the branding.

type WebsiteHelpers

type WebsiteHelpers struct {
	Manage  []string `json:"manage"`
	Publish []string `json:"publish"`
}

WebsiteHelpers are the members holding website:manage and website:publish.

type WebsiteHiddenBlock

type WebsiteHiddenBlock struct {
	// ID is the block's Visibility id (the composer selects it).
	ID string `json:"id,omitempty"`
	// Name is the block's own name; Kind a well-known block (view_online,
	// footer, referral, header, poll) or block.
	Name      string `json:"name,omitempty"`
	Kind      string `json:"kind" enum:"view_online,footer,referral,header,poll,block"`
	Reason    string `json:"reason" enum:"email_only,conditional,hidden"`
	Condition string `json:"condition,omitempty"`
	Line      int    `json:"line"`
}

WebsiteHiddenBlock is a block left out of a post's web version.

type WebsiteHomeNav

type WebsiteHomeNav struct {
	Layout   string                `json:"layout" enum:"featured,list,grid"`
	Featured []WebsiteFeaturedPost `json:"featured"`
	Sections []WebsiteHomeSection  `json:"sections"`
	About    WebsiteAbout          `json:"about"`
	Header   []WebsiteNavItem      `json:"header"`
	Footer   WebsiteFooter         `json:"footer"`
	// PrivacyURL and PoweredBy are the branding's (Forms & pages ›
	// Branding & domain), shown and changed here too.
	PrivacyURL string `json:"privacyUrl"`
	PoweredBy  bool   `json:"poweredBy"`
	// ShareButtons is "Share buttons on posts" (Copy link and the share
	// links under every published post).
	ShareButtons bool                `json:"shareButtons"`
	Identity     WebsiteIdentity     `json:"identity"`
	Index        bool                `json:"index"`
	URLs         WebsiteFeedURLs     `json:"urls"`
	Tags         []WebsiteTag        `json:"tags"`
	Pages        []WebsitePageOption `json:"pages"`
	// Logo is the branding's logo (the favicon), "" for the initial.
	Initial   string    `json:"initial"`
	UpdatedAt time.Time `json:"updatedAt"`
	UpdatedBy string    `json:"updatedBy,omitempty"`
}

WebsiteHomeNav is Website › Home & navigation.

type WebsiteHomeNavInput

type WebsiteHomeNavInput struct {
	Layout     string               `json:"layout" enum:"featured,list,grid"`
	Featured   []string             `json:"featured" maxItems:"3"`
	Sections   []WebsiteHomeSection `json:"sections" maxItems:"30"`
	About      WebsiteAbout         `json:"about"`
	Header     []WebsiteNavLink     `json:"header" maxItems:"12"`
	Footer     WebsiteFooter        `json:"footer"`
	PrivacyURL string               `json:"privacyUrl" maxLength:"500"`
	PoweredBy  bool                 `json:"poweredBy"`
	// ShareButtons turns the share row under posts on or off; omitted
	// keeps it as it is.
	ShareButtons *bool           `json:"shareButtons,omitempty"`
	Identity     WebsiteIdentity `json:"identity"`
	Index        bool            `json:"index"`
}

WebsiteHomeNavInput saves Website › Home & navigation.

type WebsiteHomeSection

type WebsiteHomeSection struct {
	Kind string `json:"kind" enum:"subscribe,featured,latest,tag,about,tiers"`
	On   bool   `json:"on"`
	// Count is how many posts the latest posts and tag rows show.
	Count int `json:"count,omitempty" minimum:"0" maximum:"24"`
	// Tag is a tag row's tag.
	Tag string `json:"tag,omitempty"`
	// Note is the subscribe band's line under its form ("Free, every
	// Tuesday. Unsubscribe any time with one click.").
	Note string `json:"note,omitempty" maxLength:"200"`
	// Text is the subscribe band's line under every post ("The Weekly
	// Digest, every Tuesday.").
	Text string `json:"text,omitempty" maxLength:"300"`
}

WebsiteHomeSection is one section of the home page, in its order.

type WebsiteIdentity

type WebsiteIdentity struct {
	Title       string `json:"title" maxLength:"80"`
	Tagline     string `json:"tagline" maxLength:"160"`
	Description string `json:"description" maxLength:"300"`
	SocialImage string `json:"socialImage" maxLength:"1000"`
}

WebsiteIdentity is the site's title, tagline, description and images.

type WebsiteImport

type WebsiteImport struct {
	ID       string `json:"id"`
	Source   string `json:"source" enum:"substack,ghost,wordpress"`
	Status   string `json:"status" enum:"uploaded,analysing,ready,importing,done,failed,canceled"`
	FileName string `json:"fileName"`
	FileSize int64  `json:"fileSize"`
	// CreatedBy names who uploaded it.
	CreatedBy  string     `json:"createdBy"`
	CreatedAt  time.Time  `json:"createdAt"`
	UpdatedAt  time.Time  `json:"updatedAt"`
	FinishedAt *time.Time `json:"finishedAt,omitempty"`
	// Error says why it failed.
	Error  string              `json:"error,omitempty"`
	Counts WebsiteImportCounts `json:"counts"`
	// Progress is the run's, once it started.
	Progress *WebsiteImportProgress `json:"progress,omitempty"`
	Options  WebsiteImportOptions   `json:"options"`
	// Tiers and Authors are the old site's, as the posts name them, with
	// what each maps to.
	Tiers   []WebsiteImportTier   `json:"tiers"`
	Authors []WebsiteImportAuthor `json:"authors"`
	// PaidTiers and Team are what they can map to.
	PaidTiers []WebsiteImportChoice `json:"paidTiers"`
	Team      []WebsiteImportChoice `json:"team"`
	// Posts is a page of the staged posts (newest first, drafts last).
	Posts      []WebsiteImportPost `json:"posts"`
	NextCursor string              `json:"nextCursor,omitempty" doc:"Pass as ?cursor= for the next page of posts"`
	// ReportURL downloads the report once the import ended (kept 30 days).
	ReportURL string `json:"reportUrl,omitempty"`
}

WebsiteImport is an import of posts: its file, how far it got, what the export holds, the choices and a page of its posts.

type WebsiteImportAuthor

type WebsiteImportAuthor struct {
	Name  string `json:"name"`
	Posts int64  `json:"posts"`
	// UserID is a team member's id, or "keep".
	UserID string `json:"userId"`
}

WebsiteImportAuthor is an old author the posts name.

type WebsiteImportChoice

type WebsiteImportChoice struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

WebsiteImportChoice is a tier or a team member a mapping can pick.

type WebsiteImportCounts

type WebsiteImportCounts struct {
	Found           int64 `json:"found"`
	ToImport        int64 `json:"toImport"`
	ToUpdate        int64 `json:"toUpdate"`
	Skipped         int64 `json:"skipped"`
	Drafts          int64 `json:"drafts"`
	DraftsSkipped   int64 `json:"draftsSkipped"`
	AlreadyImported int64 `json:"alreadyImported"`
	Paid            int64 `json:"paid"`
	Members         int64 `json:"members"`
	Images          int64 `json:"images"`
	WithProblems    int64 `json:"withProblems"`
}

WebsiteImportCounts are the Review step's numbers.

type WebsiteImportDecision

type WebsiteImportDecision struct {
	ID       string `json:"id" format:"uuid"`
	Decision string `json:"decision" enum:"import,skip,update" doc:"update: import again over the post imported before"`
}

WebsiteImportDecision is the decision on one staged post.

type WebsiteImportList

type WebsiteImportList struct {
	Items []WebsiteImportSummary `json:"items"`
}

WebsiteImportList is a workspace's latest 50 imports, newest first.

type WebsiteImportOptions

type WebsiteImportOptions struct {
	// Publish: as_published keeps the original dates and publishes;
	// as_drafts imports every post as a draft.
	Publish string `json:"publish" enum:"as_published,as_drafts"`
	// Images: copy them to ReputeCast, or keep linking to the old site.
	Images string `json:"images" enum:"copy,link"`
	// Tiers maps an old tier to a tier's id, or "any" (every paid tier).
	Tiers map[string]string `json:"tiers"`
	// Author maps an old author to a team member's id, or "keep" (the
	// name as the byline).
	Author map[string]string `json:"author"`
}

WebsiteImportOptions are an import's choices.

type WebsiteImportOptionsInput

type WebsiteImportOptionsInput struct {
	Publish   string                  `json:"publish,omitempty" enum:"as_published,as_drafts"`
	Images    string                  `json:"images,omitempty" enum:"copy,link"`
	Tiers     map[string]string       `json:"tiers,omitempty" doc:"Old tier → tier id or any"`
	Author    map[string]string       `json:"author,omitempty" doc:"Old author → team member id or keep"`
	Decisions []WebsiteImportDecision `json:"decisions,omitempty" maxItems:"10000"`
}

WebsiteImportOptionsInput changes an import's choices and decisions before it starts.

type WebsiteImportPath

type WebsiteImportPath struct {
	api.WorkspaceInput
	Import string `path:"import" format:"uuid" doc:"The import's id"`
}

WebsiteImportPath is an import's path.

type WebsiteImportPost

type WebsiteImportPost struct {
	ID          string     `json:"id"`
	SourceID    string     `json:"sourceId"`
	Title       string     `json:"title"`
	Slug        string     `json:"slug"`
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
	// Status is as it was on the old site.
	Status     string                 `json:"status" enum:"published,draft"`
	Visibility string                 `json:"visibility" enum:"public,members,paid"`
	TierRefs   []string               `json:"tierRefs"`
	Tags       []string               `json:"tags"`
	Author     string                 `json:"author"`
	Images     int                    `json:"images"`
	Problems   []WebsiteImportProblem `json:"problems"`
	Decision   string                 `json:"decision" enum:"import,skip,update"`
	// AlreadyImported: an earlier import made this post (PostID).
	AlreadyImported bool `json:"alreadyImported"`
	// PostID is the post it became, or the one imported before.
	PostID string `json:"postId,omitempty"`
	// SourceURL is its address on the old site (a path when the export
	// doesn't say where the site was).
	SourceURL string `json:"sourceUrl"`
	// Outcome is what the run did with it, once it ran.
	Outcome string `json:"outcome,omitempty" enum:"published,draft,updated,skipped,failed,"`
}

WebsiteImportPost is a staged post.

type WebsiteImportProblem

type WebsiteImportProblem struct {
	Code   string `json:"code" enum:"embed_link,image_alt,image_failed,shortcode,slug_taken,extra_tags,already_imported,convert_failed"`
	Detail string `json:"detail,omitempty"`
	// Text names the problem ("Slug taken"); Note says more when there is
	// more to say ("imported as how-we-test-email-rendering-2").
	Text string `json:"text"`
	Note string `json:"note,omitempty"`
}

WebsiteImportProblem is something about a post the import couldn't keep as it was, in the reader's words.

type WebsiteImportProgress

type WebsiteImportProgress struct {
	// Done counts the posts gone through of Total (the ones to import or
	// update).
	Done         int64      `json:"done"`
	Total        int64      `json:"total"`
	Published    int64      `json:"published"`
	Drafts       int64      `json:"drafts"`
	Updated      int64      `json:"updated"`
	Failed       int64      `json:"failed"`
	Skipped      int64      `json:"skipped"`
	ImagesCopied int64      `json:"imagesCopied"`
	ImagesFailed int64      `json:"imagesFailed"`
	StartedAt    *time.Time `json:"startedAt,omitempty"`
}

WebsiteImportProgress is how far a run got.

type WebsiteImportReportFile

type WebsiteImportReportFile struct {
	ContentType        string `header:"Content-Type"`
	ContentDisposition string `header:"Content-Disposition"`
	CacheControl       string `header:"Cache-Control"`
	Body               []byte
}

WebsiteImportReportFile is the report, as CSV.

type WebsiteImportSummary

type WebsiteImportSummary struct {
	ID         string     `json:"id"`
	Source     string     `json:"source" enum:"substack,ghost,wordpress"`
	Status     string     `json:"status" enum:"uploaded,analysing,ready,importing,done,failed,canceled"`
	FileName   string     `json:"fileName"`
	FileSize   int64      `json:"fileSize"`
	CreatedBy  string     `json:"createdBy"`
	CreatedAt  time.Time  `json:"createdAt"`
	FinishedAt *time.Time `json:"finishedAt,omitempty"`
}

WebsiteImportSummary is an import in the list of a workspace's imports.

type WebsiteImportTier

type WebsiteImportTier struct {
	Ref   string `json:"ref"`
	Posts int64  `json:"posts"`
	// TierID is a tier's id, or "any".
	TierID string `json:"tierId"`
}

WebsiteImportTier is an old tier the posts name.

type WebsiteMemberEvent

type WebsiteMemberEvent struct {
	ID   string    `json:"id"`
	Kind string    `json:"kind" enum:"signed_in,link_refused,signed_out_everywhere,joined,email_changed"`
	At   time.Time `json:"at"`
	// Method is how they signed in (link, code, signup).
	Method      string `json:"method,omitempty"`
	SameBrowser *bool  `json:"sameBrowser,omitempty"`
	// Actor is the person who signed them out everywhere.
	Actor  string `json:"actor,omitempty"`
	Detail string `json:"detail,omitempty"`
}

WebsiteMemberEvent is one of a member's website events (the contact's timeline).

type WebsiteMemberPath

type WebsiteMemberPath struct {
	api.WorkspaceInput
	Contact string `path:"contact" format:"uuid" doc:"The member's contact id"`
}

WebsiteMemberPath is a website member's path.

type WebsiteMembersFacts

type WebsiteMembersFacts struct {
	SigninOn    bool                `json:"signinOn"`
	SessionDays int                 `json:"sessionDays"`
	LinkMinutes int                 `json:"linkMinutes"`
	SignupOn    bool                `json:"signupOn"`
	SignupLists []WebsiteAccessList `json:"signupLists"`
	// SignedIn are members who signed in since the website was turned on;
	// LastWeek in the last 7 days; Paid the paid members.
	SignedIn int64 `json:"signedIn"`
	LastWeek int64 `json:"lastWeek"`
	Paid     int64 `json:"paid"`
}

WebsiteMembersFacts are the members and sign-up settings in short.

type WebsiteMeterUse

type WebsiteMeterUse struct {
	Used  int64 `json:"used"`
	Limit int   `json:"limit"`
	// Month is the first day of the calendar month.
	Month time.Time `json:"month"`
}

WebsiteMeterUse is how much of the meter a member used this month.

type WebsiteNavItem

type WebsiteNavItem struct {
	WebsiteNavLink
	// Name is the tag's or page's name; Detail what it is ("Tag", 143
	// posts; a page's address).
	Name  string `json:"name"`
	Posts int64  `json:"posts"`
	Path  string `json:"path"`
}

WebsiteNavItem is a header link with what it opens.

type WebsiteNavLink struct {
	Kind string `json:"kind" enum:"home,tag,page,archive,url"`
	// Ref is a tag's id or a page's slug.
	Ref string `json:"ref,omitempty" maxLength:"120"`
	// Label overrides the tag's or page's name (an outside address needs one).
	Label string `json:"label,omitempty" maxLength:"40"`
	URL   string `json:"url,omitempty" maxLength:"500"`
}

WebsiteNavLink is a link of the header.

type WebsiteNeverFreePost

type WebsiteNeverFreePost struct {
	ID          string     `json:"id"`
	Title       string     `json:"title"`
	Visibility  string     `json:"visibility"`
	Tiers       []string   `json:"tiers"`
	Status      string     `json:"status"`
	PublishAt   *time.Time `json:"publishAt,omitempty"`
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
}

WebsiteNeverFreePost is a post left out of the meter.

type WebsiteNumbers

type WebsiteNumbers struct {
	Views    int64     `json:"views"`
	Visitors int64     `json:"visitors"`
	Signups  int64     `json:"signups"`
	Upgrades int64     `json:"upgrades"`
	From     time.Time `json:"from"`
	Until    time.Time `json:"until"`
}

WebsiteNumbers are the site's numbers for the last 30 days.

type WebsiteOffFacts

type WebsiteOffFacts struct {
	WebOnly     int64 `json:"webOnly"`
	PaidMembers int64 `json:"paidMembers"`
	// PublicPages and Shop stay online (the page builder fills them).
	PublicPages int64 `json:"publicPages"`
	Shop        bool  `json:"shop"`
}

WebsiteOffFacts are what goes offline when the website is turned off.

type WebsiteOverview

type WebsiteOverview struct {
	Status     string              `json:"status" enum:"off,turning_on,on"`
	Address    WebsiteAddress      `json:"address"`
	TurnedOnAt *time.Time          `json:"turnedOnAt,omitempty"`
	TurnedOnBy string              `json:"turnedOnBy,omitempty"`
	Progress   *WebsiteProgress    `json:"progress,omitempty"`
	Numbers    WebsiteNumbers      `json:"numbers"`
	Posts      WebsitePostCounts   `json:"posts"`
	Archive    WebsiteArchiveFacts `json:"archive"`
	Members    WebsiteMembersFacts `json:"members"`
	Off        WebsiteOffFacts     `json:"off"`
	HomeLayout string              `json:"homeLayout" enum:"featured,list,grid"`
	Title      string              `json:"title"`
	UpdatedAt  time.Time           `json:"updatedAt"`
	UpdatedBy  string              `json:"updatedBy,omitempty"`
	// Helpers are whom to ask for what the caller's role lacks ("Ask Sofia
	// Rossi, Marcus Chen or Linh Nguyen"); empty for what it holds.
	Helpers WebsiteHelpers `json:"helpers"`
}

WebsiteOverview is the Website tab's header and its off and turning-on states.

type WebsitePageOption

type WebsitePageOption struct {
	Slug  string `json:"slug"`
	Title string `json:"title"`
}

WebsitePageOption is a page header links can point at (the page builder's).

type WebsitePastCampaign

type WebsitePastCampaign struct {
	ID         string    `json:"id"`
	Name       string    `json:"name"`
	Subject    string    `json:"subject"`
	Lists      []string  `json:"lists"`
	SentAt     time.Time `json:"sentAt"`
	Recipients int64     `json:"recipients"`
	// Note says why it isn't on the web yet: left out of the archive by
	// hand, or its list isn't public ("" when it simply wasn't archived).
	Note string `json:"note" enum:"archive_hidden,list_private,"`
	// Visibility is what "Follow the audience" gives it.
	Visibility string `json:"visibility" enum:"public,members,paid"`
}

WebsitePastCampaign is a sent campaign that isn't a post yet ("Publish past campaigns").

type WebsitePayments

type WebsitePayments struct {
	Connected bool   `json:"connected"`
	Mode      string `json:"mode" enum:"live,test,"`
	Account   string `json:"account"`
}

WebsitePayments is the payment connection the paid tiers sell through.

type WebsitePaywall

type WebsitePaywall struct {
	Heading string `json:"heading" maxLength:"120"`
	Text    string `json:"text" maxLength:"400"`
	// Tiers are the tiers to show, in order (empty: every public tier).
	Tiers []string `json:"tiers" maxItems:"10"`
	// Upgrade and Signup are the button labels; Free is the free row.
	Upgrade string `json:"upgrade" maxLength:"40"`
	Signup  string `json:"signup" maxLength:"40"`
	Free    string `json:"free" maxLength:"200"`
}

WebsitePaywall is the paywall card's text and the tiers it offers.

func DefaultPaywall

func DefaultPaywall() WebsitePaywall

DefaultPaywall is the paywall card before anyone edits it, in English.

func DefaultPaywallIn

func DefaultPaywallIn(l i18n.Lang) WebsitePaywall

DefaultPaywallIn is the paywall card before anyone edits it, in a language.

type WebsitePost

type WebsitePost struct {
	WebsitePostRow
	CoverURL      string         `json:"coverUrl"`
	CoverAlt      string         `json:"coverAlt"`
	TitleEdited   bool           `json:"titleEdited"`
	ExcerptEdited bool           `json:"excerptEdited"`
	WebOn         bool           `json:"webOn"`
	SEO           WebsitePostSEO `json:"seo"`
	// MJML is a web-only post's content; Version its saved version and
	// PublishedVersion the one live on the site (lower: unpublished changes).
	MJML             string     `json:"mjml"`
	Version          int        `json:"version"`
	PublishedVersion int        `json:"publishedVersion"`
	AutosavedAt      *time.Time `json:"autosavedAt,omitempty"`
	// Base is the address before the slug ("news.acme.io/posts/").
	Base           string              `json:"base"`
	Words          int                 `json:"words"`
	ReadingMinutes int                 `json:"readingMinutes"`
	Checks         []WebsiteWebCheck   `json:"checks"`
	Publish        WebsitePublishState `json:"publish"`
	// Bylines are the workspace's members a byline can name.
	Bylines []WebsiteByline `json:"bylines"`
	// CommentsOff: comments are off for this post, whatever the site's
	// setting (Website › Access).
	CommentsOff bool `json:"commentsOff"`
}

WebsitePost is one post: its settings, its content (web-only posts), its web checks and whether the person may publish it.

type WebsitePostApproval

type WebsitePostApproval struct {
	ID          string    `json:"id"`
	Status      string    `json:"status" enum:"pending,approved,changes_requested,rejected"`
	RequestedBy string    `json:"requestedBy"`
	RequestedAt time.Time `json:"requestedAt"`
	Approvers   []string  `json:"approvers"`
	Rule        string    `json:"rule"`
	Note        string    `json:"note,omitempty"`
}

WebsitePostApproval is a post's open approval request.

type WebsitePostCampaign

type WebsitePostCampaign struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Status      string     `json:"status"`
	SentAt      *time.Time `json:"sentAt,omitempty"`
	ScheduledAt *time.Time `json:"scheduledAt,omitempty"`
}

WebsitePostCampaign is the campaign a post comes from.

type WebsitePostContent

type WebsitePostContent struct {
	MJML string `json:"mjml" maxLength:"2000000"`
	// BaseVersion is the version the edit started from: another save since
	// then is a conflict (409) unless Force.
	BaseVersion int    `json:"baseVersion" minimum:"0"`
	Force       bool   `json:"force,omitempty"`
	Source      string `json:"source,omitempty" enum:"autosave,manual,import,template,restore,"`
	Label       string `json:"label,omitempty" maxLength:"80"`
}

WebsitePostContent is an autosave or a save of a web-only post's content.

type WebsitePostCounts

type WebsitePostCounts struct {
	All           int64 `json:"all"`
	Published     int64 `json:"published"`
	FromCampaigns int64 `json:"fromCampaigns"`
	WebOnly       int64 `json:"webOnly"`
	Scheduled     int64 `json:"scheduled"`
	Draft         int64 `json:"draft"`
	Unpublished   int64 `json:"unpublished"`
	MembersOnly   int64 `json:"membersOnly"`
	Paid          int64 `json:"paid"`
}

WebsitePostCounts are the posts by status.

type WebsitePostCreate

type WebsitePostCreate struct {
	Title string `json:"title,omitempty" maxLength:"200"`
	// MJML is the post's starting content (empty: the composer's gallery).
	MJML string `json:"mjml,omitempty" maxLength:"2000000"`
}

WebsitePostCreate starts a web-only post.

type WebsitePostFilter

type WebsitePostFilter struct {
	Status     string `query:"status" enum:"all,published,scheduled,draft,unpublished," doc:"A status (all by default)"`
	Visibility string `query:"visibility" enum:"public,members,paid,"`
	Tag        string `query:"tag" doc:"A tag's id"`
	Source     string `query:"source" enum:"campaign,web,"`
	Search     string `query:"q" maxLength:"200" doc:"Search by title"`
	Page       int    `query:"page" minimum:"0" maximum:"10000"`
	PageSize   int    `query:"pageSize" minimum:"0" maximum:"100"`
}

WebsitePostFilter narrows Website › Posts.

type WebsitePostInput

type WebsitePostInput struct {
	Title   string `json:"title" maxLength:"200"`
	Slug    string `json:"slug" maxLength:"120"`
	Excerpt string `json:"excerpt" maxLength:"400"`
	// UseSubject and UsePreheader go back to the campaign's subject and
	// preheader (posts from campaigns).
	UseSubject   bool   `json:"useSubject,omitempty"`
	UsePreheader bool   `json:"usePreheader,omitempty"`
	CoverURL     string `json:"coverUrl" maxLength:"1000"`
	CoverAlt     string `json:"coverAlt" maxLength:"300"`
	// The byline: a member, or a written name.
	BylineUserID string `json:"bylineUserId,omitempty" maxLength:"64"`
	BylineName   string `json:"bylineName,omitempty" maxLength:"120"`
	// Tags are tag ids, in order (up to 5).
	Tags       []string       `json:"tags" maxItems:"5"`
	Visibility string         `json:"visibility" enum:"public,members,paid"`
	Tiers      []string       `json:"tiers" maxItems:"10" doc:"A paid post's tiers; empty for every paid tier"`
	NeverFree  bool           `json:"neverFree"`
	Featured   bool           `json:"featured"`
	SEO        WebsitePostSEO `json:"seo"`
	// WebOn is a campaign's "Publish to <domain>" switch.
	WebOn bool `json:"webOn"`
	// When a post goes live: with the campaign's send, at a time, or now
	// (a sent campaign; web-only posts publish with Publish).
	PublishMode string     `json:"publishMode" enum:"with_send,at,now"`
	PublishAt   *time.Time `json:"publishAt,omitempty"`
	PublishTZ   string     `json:"publishTz,omitempty" maxLength:"64"`
	// CommentsOff is the post's "Comments" setting: true is "Off for this
	// post", false "Use the site's setting" (left out: as it is).
	CommentsOff *bool `json:"commentsOff,omitempty"`
}

WebsitePostInput saves a post's settings: the Web tab of the composer.

type WebsitePostList

type WebsitePostList struct {
	Posts    []WebsitePostRow  `json:"posts"`
	Total    int64             `json:"total"`
	Counts   WebsitePostCounts `json:"counts"`
	Page     int               `json:"page"`
	PageSize int               `json:"pageSize"`
	// From and Until are the 30 days of the numbers.
	From  time.Time `json:"from"`
	Until time.Time `json:"until"`
}

WebsitePostList is a page of Website › Posts.

type WebsitePostPath

type WebsitePostPath struct {
	api.WorkspaceInput
	Post string `path:"post" format:"uuid" doc:"The post's id"`
}

WebsitePostPath is a post's path (exported: Huma reads embedded path structs only when their type is exported).

type WebsitePostRow

type WebsitePostRow struct {
	ID      string `json:"id"`
	Kind    string `json:"kind" enum:"campaign,web"`
	Title   string `json:"title"`
	Excerpt string `json:"excerpt"`
	Slug    string `json:"slug"`
	// URL is the post's address on the site.
	URL string `json:"url"`
	// Status is draft, scheduled (a time, or with a scheduled send),
	// published or unpublished.
	Status          string               `json:"status" enum:"draft,scheduled,published,unpublished"`
	PublishMode     string               `json:"publishMode" enum:"with_send,at,now"`
	PublishAt       *time.Time           `json:"publishAt,omitempty"`
	PublishTZ       string               `json:"publishTz,omitempty"`
	PublishedAt     *time.Time           `json:"publishedAt,omitempty"`
	UnpublishedAt   *time.Time           `json:"unpublishedAt,omitempty"`
	UnpublishedBy   string               `json:"unpublishedBy,omitempty"`
	UnpublishReason string               `json:"unpublishReason,omitempty"`
	RedirectTo      string               `json:"redirectTo,omitempty"`
	Campaign        *WebsitePostCampaign `json:"campaign,omitempty"`
	Byline          WebsiteByline        `json:"byline"`
	Visibility      string               `json:"visibility" enum:"public,members,paid"`
	Tiers           []WebsiteTierRef     `json:"tiers"`
	NeverFree       bool                 `json:"neverFree"`
	HasMarker       bool                 `json:"hasMarker"`
	MarkerAfter     int                  `json:"markerAfter"`
	Featured        bool                 `json:"featured"`
	Tags            []WebsiteTagRef      `json:"tags"`
	// Views, Signups and Upgrades are the last 30 days; ViewsAllTime is
	// every view (an unpublished post's views before it was taken down).
	Views        int64                `json:"views"`
	ViewsAllTime int64                `json:"viewsAllTime"`
	Signups      int64                `json:"signups"`
	Upgrades     int64                `json:"upgrades"`
	Approval     *WebsitePostApproval `json:"approval,omitempty"`
	CreatedBy    string               `json:"createdBy"`
	UpdatedAt    time.Time            `json:"updatedAt"`
	// Comments are the post's published comments, CommentsPending those
	// waiting for review.
	Comments        int64 `json:"comments"`
	CommentsPending int64 `json:"commentsPending"`
}

WebsitePostRow is a post in Website › Posts.

type WebsitePostSEO

type WebsitePostSEO struct {
	Title          string `json:"title" maxLength:"120"`
	Description    string `json:"description" maxLength:"300"`
	SocialImage    string `json:"socialImage" maxLength:"500"`
	CanonicalURL   string `json:"canonicalUrl" maxLength:"500"`
	HideFromSearch bool   `json:"hideFromSearch"`
}

WebsitePostSEO are a post's search and social settings.

type WebsitePostSaved

type WebsitePostSaved struct {
	Version int       `json:"version"`
	SavedAt time.Time `json:"savedAt"`
}

WebsitePostSaved is a saved version.

type WebsiteProgress

type WebsiteProgress struct {
	StartedAt  *time.Time          `json:"startedAt,omitempty"`
	FinishedAt *time.Time          `json:"finishedAt,omitempty"`
	Tags       WebsiteProgressStep `json:"tags"`
	Posts      WebsiteProgressStep `json:"posts"`
	Redirects  WebsiteProgressStep `json:"redirects"`
	// Pages is the home page, sign-in and the account: waiting or done.
	Pages string `json:"pages" enum:"waiting,done"`
}

WebsiteProgress is turning the website on, step by step.

type WebsiteProgressStep

type WebsiteProgressStep struct {
	Done  int64    `json:"done"`
	Total int64    `json:"total"`
	Names []string `json:"names,omitempty"`
}

WebsiteProgressStep is one step of turning the website on.

type WebsitePublishInput

type WebsitePublishInput struct {
	When string     `json:"when" enum:"now,at"`
	At   *time.Time `json:"at,omitempty"`
	TZ   string     `json:"tz,omitempty" maxLength:"64"`
}

WebsitePublishInput publishes a post now or at a time.

type WebsitePublishPastInput

type WebsitePublishPastInput struct {
	Campaigns []string `json:"campaigns" minItems:"1" maxItems:"100"`
	// Visibility: audience follows each campaign's audience (public, or
	// paid for a paid-only send).
	Visibility string `json:"visibility" enum:"audience,public,members"`
}

WebsitePublishPastInput publishes sent campaigns as posts.

type WebsitePublishPastResult

type WebsitePublishPastResult struct {
	Published int `json:"published"`
}

WebsitePublishPastResult is how many posts went live.

type WebsitePublishState

type WebsitePublishState struct {
	// CanPublish: holds website:publish and nothing blocks (or the post
	// is approved as it is).
	CanPublish bool `json:"canPublish"`
	// NeedsApproval: Publish becomes Request approval, for Rule.
	NeedsApproval bool     `json:"needsApproval"`
	Rule          string   `json:"rule,omitempty" enum:"author_lacks_send,post_publish,"`
	Approvers     []string `json:"approvers"`
	// Pending is an open request for this post.
	Pending     *WebsitePostApproval `json:"pending,omitempty"`
	ApprovedID  string               `json:"approvedId,omitempty"`
	Blocked     bool                 `json:"blocked"`
	BlockReason string               `json:"blockReason,omitempty"`
}

WebsitePublishState says whether the person may publish the post as it is.

type WebsiteSentAsCampaign

type WebsiteSentAsCampaign struct {
	CampaignID string `json:"campaignId"`
}

WebsiteSentAsCampaign is the campaign draft made from a post.

type WebsiteSignedOut

type WebsiteSignedOut struct {
	Sessions int64 `json:"sessions"`
}

WebsiteSignedOut is how many sessions signing out everywhere ended.

type WebsiteSignupList

type WebsiteSignupList struct {
	ListID  string `json:"listId" format:"uuid"`
	Checked bool   `json:"checked"`
	Consent string `json:"consent,omitempty" maxLength:"300"`
}

WebsiteSignupList is a list offered on sign-up, whether it's checked, and the consent text shown with it (kept with each sign-up).

type WebsiteSlugOwner

type WebsiteSlugOwner struct {
	ID     string    `json:"id"`
	Title  string    `json:"title"`
	Status string    `json:"status"`
	Since  time.Time `json:"since"`
}

WebsiteSlugOwner is the post that holds, or once held, an address.

type WebsiteSource

type WebsiteSource struct {
	// Key is the referring domain ("" for email clients and direct, "other"
	// for the rest) or the utm_source value.
	Key   string `json:"key"`
	Label string `json:"label"`
	Views int64  `json:"views"`
}

WebsiteSource is one row of a post's sources: a referrer or a UTM source.

type WebsiteTag

type WebsiteTag struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
	// Posts are its published posts; Unpublished its posts taken down
	// ("its only post is unpublished").
	Posts       int64 `json:"posts"`
	Unpublished int64 `json:"unpublished"`
	// InNav is "Show in navigation": the tag is one of the header links.
	InNav bool `json:"inNav"`
	// URL and Feed are its page and its feed.
	URL  string `json:"url"`
	Feed string `json:"feed"`
	// List is the list it was made from when the website was turned on.
	List string `json:"list,omitempty"`
}

WebsiteTag is a tag with its posts and its place in the navigation.

type WebsiteTagInput

type WebsiteTagInput struct {
	Name        string `json:"name" minLength:"1" maxLength:"60"`
	Slug        string `json:"slug,omitempty" maxLength:"80"`
	Description string `json:"description,omitempty" maxLength:"300"`
	InNav       bool   `json:"inNav"`
}

WebsiteTagInput creates or changes a tag.

type WebsiteTagPath

type WebsiteTagPath struct {
	api.WorkspaceInput
	Tag string `path:"tag" format:"uuid" doc:"The tag's id"`
}

WebsiteTagPath is a tag's path.

type WebsiteTagRef

type WebsiteTagRef struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

WebsiteTagRef is a tag of a post.

type WebsiteTierOption

type WebsiteTierOption struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Label string `json:"label"`
	// Monthly and Yearly are the current prices in cents (0: none), with
	// their currency; TrialDays the free days.
	Monthly   int64  `json:"monthly"`
	Yearly    int64  `json:"yearly"`
	Currency  string `json:"currency"`
	TrialDays int    `json:"trialDays"`
	// Includes names the lower tier whose content it includes ("Insider").
	Includes string `json:"includes,omitempty"`
	Public   bool   `json:"public"`
}

WebsiteTierOption is a paid tier as the paywall card can offer it.

type WebsiteTierRef

type WebsiteTierRef struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// Label is the tier's quiet label on posts ("Insider").
	Label string `json:"label"`
}

WebsiteTierRef is a paid tier a post is for.

type WebsiteTurnOffInput

type WebsiteTurnOffInput struct {
	Confirm string `json:"confirm" maxLength:"300"`
}

WebsiteTurnOffInput turns the website off: the site's address, typed.

type WebsiteTurnOnInput

type WebsiteTurnOnInput struct {
	Layout   string              `json:"layout" enum:"featured,list,grid"`
	SigninOn bool                `json:"signinOn"`
	Lists    []WebsiteSignupList `json:"lists,omitempty" maxItems:"50"`
}

WebsiteTurnOnInput turns the website on, with the home layout and the members' settings of the turn-on page.

type WebsiteUnpublishInput

type WebsiteUnpublishInput struct {
	Reason string `json:"reason,omitempty" maxLength:"300"`
	// RedirectTo is a path on the site the post's address sends readers
	// to ("/posts/…", "/archive"); empty answers 410.
	RedirectTo string `json:"redirectTo,omitempty" maxLength:"300"`
}

WebsiteUnpublishInput takes a post off the site.

type WebsiteWebCheck

type WebsiteWebCheck struct {
	Key    string `json:"key" enum:"address,cover,tokens,hidden"`
	Status string `json:"status" enum:"pass,warn,info,block"`
	// Address: the path; Taken: who holds it; Suggestion: a free slug.
	Path       string               `json:"path,omitempty"`
	Taken      *WebsiteSlugOwner    `json:"taken,omitempty"`
	Suggestion string               `json:"suggestion,omitempty"`
	Fallbacks  []WebsiteFallback    `json:"fallbacks"`
	Hidden     []WebsiteHiddenBlock `json:"hidden"`
}

WebsiteWebCheck is one of a post's web checks.

type Words

type Words struct{ L i18n.Lang }

Words are the site's built-in words (header, footer, paywall, sign-in, account) in one language: this package's catalog, English until a language ships them. The publisher's own text (titles, the paywall's heading) is content and isn't translated.

func WordsIn

func WordsIn(l i18n.Lang) Words

WordsIn returns the site's words in a language.

func (Words) HTML

func (w Words) HTML(key string, args i18n.Args, tags i18n.Tags) string

HTML is a sentence with markup: values are escaped, tags go through tags.

func (Words) Text

func (w Words) Text(key string, args i18n.Args) string

Text is a word or sentence as plain text.

Directories

Path Synopsis
Package gate decides what a reader of the publication website may read (design expansion phase 7, brief §3.3): a post's or a page's visibility (Public, Members, Paid for every tier or chosen tiers), the meter (N free posts per calendar month for visitors and for free members) and "Never free".
Package gate decides what a reader of the publication website may read (design expansion phase 7, brief §3.3): a post's or a page's visibility (Public, Members, Paid for every tier or chosen tiers), the meter (N free posts per calendar month for visitors and for free members) and "Never free".
Package importer reads the exports of other platforms into posts and converts their HTML into the MJML a ReputeCast post holds (M61, G-26):
Package importer reads the exports of other platforms into posts and converts their HTML into the MJML a ReputeCast post holds (M61, G-26):
Package render draws a post's web version from its MJML (design expansion phase 7, brief §3.1): the email's blocks in the site's theme and its 680 px reading column, not the email's tables.
Package render draws a post's web version from its MJML (design expansion phase 7, brief §3.1): the email's blocks in the site's theme and its 680 px reading column, not the email's tables.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL