Documentation
¶
Overview ¶
Package pages implements landing and sales pages (design expansion phase 7, M29): pages built with blocks on the publisher's theme in the composer's page mode, their versions, publish checks, statuses and numbers, the built-in pages and the shop's switch.
Index ¶
- Constants
- Variables
- func BlockRefs(v string) []string
- func FormsIn(src string) []uuid.UUID
- func Local(at, tz string) (time.Time, bool)
- func Money(cents int64, currency string) string
- func ProductsIn(src string) []uuid.UUID
- func Register(h huma.API, s *Service)
- func RegisterJobs(reg *jobs.Registry, s *Service)
- func Reserved(slug string) bool
- func SafeURL(raw string, link bool) (string, bool)
- func Sanitize(src string) string
- func Slugify(name string) string
- func TemplateHTML(template string, o TemplateOptions) string
- func UniqueIDs(src string) string
- func VideoOf(raw string) (site, id string, ok bool)
- type ApprovalDecision
- type ApprovalHooks
- type ApprovalRequest
- type Approvals
- type DueArgs
- type EventInfo
- type FormPage
- type FormPages
- type FormPathInput
- type Link
- type LivePage
- type Moment
- type PageApproval
- type PageApprovalInput
- type PageCheck
- type PageContentInput
- type PageCounts
- type PageCreate
- type PageDetail
- type PageDiff
- type PageDiffBlock
- type PageDiffLine
- type PageDiffSetting
- type PageDraft
- type PageListItem
- type PageLive
- type PageNumbers
- type PagePath
- type PagePerson
- type PagePublishInput
- type PagePublishState
- type PageReminderFlow
- type PageReminders
- type PageResult
- type PageSaved
- type PageSettings
- type PageSettingsInput
- type PageTemplateCount
- type PageUnpublishInput
- type PageVersionDetail
- type PageVersionItem
- type PageVersionList
- type PagesOverview
- type PagesShop
- type PagesStats
- type PagesTheme
- type ReminderRequest
- type Resolved
- type Selling
- type Service
- func (s *Service) Conversion(ctx context.Context, ws *store.Workspace, page uuid.UUID, kind string, ...) error
- func (s *Service) Create(ctx context.Context, ws *store.Workspace, p *authz.Principal, in PageCreate) (PageDetail, error)
- func (s *Service) CreateReminders(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (PageReminders, error)
- func (s *Service) Delete(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
- func (s *Service) Detail(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (PageDetail, error)
- func (s *Service) Diff(ctx context.Context, ws *store.Workspace, id uuid.UUID) (PageDiff, error)
- func (s *Service) Draft(ctx context.Context, ws *store.Workspace, id uuid.UUID) (*LivePage, error)
- func (s *Service) Overview(ctx context.Context, ws *store.Workspace, p *authz.Principal, period string) (PagesOverview, error)
- func (s *Service) PagesUsingForm(ctx context.Context, ws *store.Workspace, formID uuid.UUID) (FormPages, error)
- func (s *Service) Publish(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (PageDetail, error)
- func (s *Service) PublishApproved(ctx context.Context, ws *store.Workspace, id uuid.UUID, ...) error
- func (s *Service) PublishDue(ctx context.Context) (int, error)
- func (s *Service) RecordEventDate(ctx context.Context, ws *store.Workspace, contact uuid.UUID, ev EventInfo) error
- func (s *Service) Reminders(ctx context.Context, ws *store.Workspace, id uuid.UUID) (PageReminders, error)
- func (s *Service) RequestApproval(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (PageDetail, error)
- func (s *Service) Resolve(ctx context.Context, ws *store.Workspace, slug string) (Resolved, error)
- func (s *Service) Restore(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (PageDetail, error)
- func (s *Service) SaveContent(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (PageSaved, error)
- func (s *Service) SaveSettings(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (PageDetail, error)
- func (s *Service) SetShop(ctx context.Context, ws *store.Workspace, p *authz.Principal, on bool) (PagesShop, error)
- func (s *Service) ShopOn(ctx context.Context, ws *store.Workspace) (bool, error)
- func (s *Service) ShopText(ctx context.Context, ws *store.Workspace) (string, string)
- func (s *Service) Undo(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (PageDetail, error)
- func (s *Service) Unpublish(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (PageDetail, error)
- func (s *Service) Version(ctx context.Context, ws *store.Workspace, id uuid.UUID, version int32) (PageVersionDetail, error)
- func (s *Service) Versions(ctx context.Context, ws *store.Workspace, id uuid.UUID) (PageVersionList, error)
- type ShopInput
- type TemplateOptions
- type Usage
Constants ¶
const ( ElForm = "rc-form" // a signup form: one of the workspace's forms ElCountdown = "rc-countdown" // to a date and time in a time zone ElEvent = "rc-event" // a webinar's or an event's details ElProduct = "rc-product" // one digital product with its Buy button ElProducts = "rc-products" // a product grid: digital or store products ElStoreProduct = "rc-store-product" // one product of a connected store (phase 7, X20) ElTiers = "rc-tiers" // the paid tiers (phase 6) ElPosts = "rc-posts" // recent posts of a tag ElVideo = "rc-video" // YouTube or Vimeo, loaded only when the reader clicks )
Blocks that show live data are custom elements in the page's HTML: the page builder edits their attributes in its Block tab, and the site draws them on every request (render.go) with the product's current price, the form's fields, the time left before a countdown ends.
const ( CheckAddress = "address" // the address is free (or the page's own) CheckHeading = "heading" // a heading opens the page CheckMoments = "moments" // no countdown or event in the past CheckProduct = "product" // a product block's product: picked and published CheckStripe = "stripe" // Buy buttons need a payment connection CheckForm = "form" // a signup block's form: picked and live CheckImages = "images" // images have alt text CheckLinks = "links" // links answer CheckVisibility = "visibility" // Members and Paid need the website CheckStoreBlocks = "store_blocks" // store products need a connected store (phase 7, X20) )
Check keys.
const ( CheckPass = "pass" CheckWarn = "warn" CheckBlock = "block" )
Check statuses.
const ( ResultSignups = "signups" ResultRegistrations = "registrations" ResultSales = "sales" ResultNone = "none" )
Result kinds: what a page brings in.
const ( TemplateAbout = "about" TemplateLeadMagnet = "lead_magnet" TemplateLaunch = "launch" TemplateWebinar = "webinar" TemplateSales = "sales" TemplateBlank = "blank" )
Templates a page starts from.
const ( StatusDraft = "draft" StatusScheduled = "scheduled" StatusPublished = "published" StatusUnpublished = "unpublished" )
Statuses of a page.
const ( VisibilityPublic = "public" VisibilityMembers = "members" VisibilityPaid = "paid" )
Who may read a page.
const ( MaxHTML = 2 << 20 MaxProject = 6 << 20 )
Limits of what a page holds.
Variables ¶
var TemplateKeys = []string{TemplateAbout, TemplateLeadMagnet, TemplateLaunch, TemplateWebinar, TemplateSales, TemplateBlank}
TemplateKeys are the templates in the picker's order.
Functions ¶
func FormsIn ¶
FormsIn lists the signup forms a page's HTML uses (the form builder's "Used on pages").
func ProductsIn ¶
ProductsIn lists the digital products a page's HTML shows (product blocks and grids), for a product's "used on" and the composer's picker.
func RegisterJobs ¶
RegisterJobs adds the scheduled publisher.
func SafeURL ¶
SafeURL keeps http(s) addresses and paths on the site (and mailto: and tel: for links); anything else ("javascript:", "data:") is refused.
func Sanitize ¶
Sanitize keeps what the page blocks may contain. Unknown elements are unwrapped (their text stays); dangerous ones are dropped with their content. It is idempotent.
func TemplateHTML ¶
func TemplateHTML(template string, o TemplateOptions) string
TemplateHTML is a template's blocks.
Types ¶
type ApprovalDecision ¶
type ApprovalDecision struct {
Allowed bool
NeedsApproval bool
Rule string
Reason string
Approvers []string
// Approved is the approval that covers the page as it is.
Approved string
Pending string
RequestedBy string
RequestedAt *time.Time
}
ApprovalDecision is what the approval rules say about publishing.
type ApprovalHooks ¶
type ApprovalHooks interface {
PageChanged(ctx context.Context, ws *store.Workspace, p *authz.Principal, pageID uuid.UUID, name, hash string) error
PagePublished(ctx context.Context, ws *store.Workspace, pageID uuid.UUID, hash string) error
}
ApprovalHooks are told what happened to a page after a request: a change invalidates the requests for the page as it was, and a publish marks the approval it relied on (internal/approvals implements them).
type ApprovalRequest ¶
type ApprovalRequest struct {
PageID uuid.UUID
Name string
Slug string
Path string
Visibility string
Template string
When string
PublishAt *time.Time
Hash string
}
ApprovalRequest is what an approval to publish a page covers: the page as it is (one hash of its content, address, settings and time).
type Approvals ¶
type Approvals interface {
PageDecision(ctx context.Context, ws *store.Workspace, p *authz.Principal, req ApprovalRequest) (ApprovalDecision, error)
RequestPage(ctx context.Context, ws *store.Workspace, p *authz.Principal, req ApprovalRequest, note string) (uuid.UUID, error)
}
Approvals applies the workspace's approval rules to pages (internal/approvals implements it).
type DueArgs ¶
type DueArgs struct{}
DueArgs publishes the scheduled pages whose time came.
func (DueArgs) InsertOpts ¶
func (DueArgs) InsertOpts() river.InsertOpts
InsertOpts runs one at a time.
type EventInfo ¶
type EventInfo struct {
Title, Date, Start, End, TZ, Link, Field, Reminders string
}
EventInfo is a page's event block: its title, date, start and end ("HH:MM"), time zone, joining link, the date field registrations write and when the reminders go.
func FirstEvent ¶
FirstEvent is a page's first event block (ok false: none).
type FormPage ¶
type FormPage struct {
ID string `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
URL string `json:"url"`
Status string `json:"status" enum:"draft,scheduled,published,unpublished"`
// Live: the live version uses the form (not only the draft).
Live bool `json:"live"`
}
FormPage is a page that uses a form.
type FormPages ¶
type FormPages struct {
Items []FormPage `json:"items"`
}
FormPages are the pages that use a form.
type FormPathInput ¶
type FormPathInput struct {
api.WorkspaceInput
Form string `path:"form" format:"uuid" doc:"Form id"`
}
FormPathInput names a form in the path.
type LivePage ¶
type LivePage struct {
ID uuid.UUID
Slug string
Name string
Template string
Version int32
HTML string
Settings PageSettings
// PublishedAt is when this version went live.
PublishedAt *time.Time
}
LivePage is a page as readers see it.
type PageApproval ¶
type PageApproval struct {
ID string `json:"id"`
RequestedBy string `json:"requestedBy"`
RequestedAt time.Time `json:"requestedAt"`
}
PageApproval is a page's open approval request.
type PageApprovalInput ¶
type PageApprovalInput struct {
Note string `json:"note,omitempty" maxLength:"1000"`
}
PageApprovalInput asks for approval to publish.
type PageCheck ¶
type PageCheck struct {
Key string `json:"key" enum:"address,heading,moments,product,stripe,form,images,links,visibility,store_blocks"`
Status string `json:"status" enum:"pass,warn,block"`
// Path is the address (/field-guide).
Path string `json:"path,omitempty"`
// Count is how many blocks, images or links it's about.
Count int `json:"count,omitempty"`
// Ref is what the check names: a product's or form's id, an image's
// address, a link's; Name and Detail say it in words.
Ref string `json:"ref,omitempty"`
Name string `json:"name,omitempty"`
Detail string `json:"detail,omitempty"`
// Problem is a product's or form's state: missing, draft, archived,
// paused, deleted; a link's HTTP status.
Problem string `json:"problem,omitempty"`
HTTPStatus int `json:"httpStatus,omitempty"`
// PWYW: the price is a pay-what-you-want minimum.
PWYW bool `json:"pwyw,omitempty"`
By string `json:"by,omitempty"`
At *time.Time `json:"at,omitempty"`
// Account and Mode are the payment connection's (Acme Media, live).
Account string `json:"account,omitempty"`
Mode string `json:"mode,omitempty"`
}
PageCheck is one publish check.
type PageContentInput ¶
type PageContentInput struct {
HTML string `json:"html" maxLength:"2097152"`
Project json.RawMessage `json:"project,omitempty"`
// BaseVersion is the version the editor started from: a newer one
// saved meanwhile is a conflict unless Force.
BaseVersion int32 `json:"baseVersion" minimum:"1"`
// Manual: Save (or a block added, moved or deleted) rather than the
// 30-second autosave.
Manual bool `json:"manual,omitempty"`
// Force keeps this version on top of a newer one ("Keep mine").
Force bool `json:"force,omitempty"`
}
PageContentInput saves the draft's content (autosave or Save).
type PageCounts ¶
type PageCounts struct {
Blocks int `json:"blocks"`
Images int `json:"images"`
ImagesWithAlt int `json:"imagesWithAlt"`
Links int `json:"links"`
}
PageCounts are the status bar's numbers.
type PageCreate ¶
type PageCreate struct {
Template string `json:"template" enum:"about,lead_magnet,launch,webinar,sales,blank"`
Name string `json:"name" maxLength:"120"`
// Slug is the page's address on the site ("warm-up-planner"); empty
// takes it from the name.
Slug string `json:"slug,omitempty" maxLength:"80"`
}
PageCreate starts a page from a template.
type PageDetail ¶
type PageDetail struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Template string `json:"template" enum:"about,lead_magnet,launch,webinar,sales,blank"`
Status string `json:"status" enum:"draft,scheduled,published,unpublished"`
// Changes: published, with saved changes not published yet.
Changes bool `json:"changes"`
// Host and Path make the address: news.acme.io + /field-guide.
Host string `json:"host"`
Path string `json:"path"`
URL string `json:"url"`
Settings PageSettings `json:"settings"`
Draft PageDraft `json:"draft"`
Live *PageLive `json:"live,omitempty"`
// Scheduled pages.
PublishAt *time.Time `json:"publishAt,omitempty"`
PublishTZ string `json:"publishTz,omitempty"`
// Unpublished pages.
UnpublishedAt *time.Time `json:"unpublishedAt,omitempty"`
UnpublishReason string `json:"unpublishReason,omitempty"`
RedirectTo string `json:"redirectTo,omitempty"`
Checks []PageCheck `json:"checks"`
Counts PageCounts `json:"counts"`
Versions int64 `json:"versions"`
Publish PagePublishState `json:"publish"`
Numbers PageNumbers `json:"numbers"`
CreatedAt time.Time `json:"createdAt"`
NavFull bool `json:"navFull"`
// WebsiteOn: the website is on (Members and Paid need sign-in).
WebsiteOn bool `json:"websiteOn"`
}
PageDetail is a page in the builder.
type PageDiff ¶
type PageDiff struct {
// First: the page was never published; Since is the live version.
First bool `json:"first"`
Since int32 `json:"since"`
PublishedAt *time.Time `json:"publishedAt,omitempty"`
PublishedBy string `json:"publishedBy,omitempty"`
Version int32 `json:"version"`
Blocks []PageDiffBlock `json:"blocks"`
Settings []PageDiffSetting `json:"settings"`
}
PageDiff is what publishing would change.
type PageDiffBlock ¶
type PageDiffBlock struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind" enum:"changed,added,removed,moved"`
Lines []PageDiffLine `json:"lines"`
}
PageDiffBlock is a block that changed.
func DiffBlocks ¶
func DiffBlocks(ctx context.Context, before, after string) []PageDiffBlock
DiffBlocks compares two versions of a page's blocks.
type PageDiffLine ¶
PageDiffLine is a line of a block: removed, added or unchanged.
type PageDiffSetting ¶
type PageDiffSetting struct {
Key string `json:"key"`
Before string `json:"before"`
After string `json:"after"`
}
PageDiffSetting is a setting that changed.
type PageDraft ¶
type PageDraft struct {
Version int32 `json:"version"`
HTML string `json:"html"`
Project json.RawMessage `json:"project"`
SavedAt time.Time `json:"savedAt"`
SavedBy *PagePerson `json:"savedBy,omitempty"`
// Autosaved: the last save was an autosave.
Autosaved bool `json:"autosaved"`
}
PageDraft is the page as edited.
type PageListItem ¶
type PageListItem struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Path string `json:"path"`
URL string `json:"url"`
Template string `json:"template" enum:"about,lead_magnet,launch,webinar,sales,blank"`
Status string `json:"status" enum:"draft,scheduled,published,unpublished"`
Changes bool `json:"changes"`
// FirstPublishedAt is the status's date ("Published · 1 Oct").
FirstPublishedAt *time.Time `json:"firstPublishedAt,omitempty"`
PublishedAt *time.Time `json:"publishedAt,omitempty"`
PublishAt *time.Time `json:"publishAt,omitempty"`
UnpublishedAt *time.Time `json:"unpublishedAt,omitempty"`
// CountdownEnded is when a countdown of the live page ended ("Countdown
// ended 6 Oct").
CountdownEnded *time.Time `json:"countdownEnded,omitempty"`
Visibility string `json:"visibility" enum:"public,members,paid"`
Views int64 `json:"views"`
Result PageResult `json:"result"`
EditedBy *PagePerson `json:"editedBy,omitempty"`
EditedAt time.Time `json:"editedAt"`
}
PageListItem is a row of Your pages.
type PageLive ¶
type PageLive struct {
Version int32 `json:"version"`
Slug string `json:"slug"`
Path string `json:"path"`
URL string `json:"url"`
PublishedAt *time.Time `json:"publishedAt,omitempty"`
PublishedBy *PagePerson `json:"publishedBy,omitempty"`
}
PageLive is what readers see.
type PageNumbers ¶
type PageNumbers struct {
Views int64 `json:"views"`
Result PageResult `json:"result"`
}
PageNumbers are a page's 30-day numbers.
type PagePath ¶
type PagePath struct {
api.WorkspaceInput
Page string `path:"page" format:"uuid" doc:"The page's id"`
}
PagePath is a page of the workspace (exported: Huma reads embedded path structs only when their type is exported).
type PagePerson ¶
type PagePerson struct {
ID string `json:"id"`
Name string `json:"name"`
Initials string `json:"initials"`
// AvatarColor is the member's avatar color ("" for the default).
AvatarColor string `json:"avatarColor"`
}
PagePerson is who saved or published.
type PagePublishInput ¶
type PagePublishInput struct {
When string `json:"when" enum:"now,at"`
At *time.Time `json:"at,omitempty"`
TZ string `json:"tz,omitempty" maxLength:"64"`
}
PagePublishInput publishes a page now or at a time.
type PagePublishState ¶
type PagePublishState struct {
CanEdit bool `json:"canEdit"`
CanPublish bool `json:"canPublish"`
CanManage bool `json:"canManage" doc:"Navigation, visibility and the paywall (website:manage)"`
// Publishers are who can publish when the person can't.
Publishers []string `json:"publishers"`
// NeedsApproval: the workspace's rules want an approval first.
NeedsApproval bool `json:"needsApproval"`
Rule string `json:"rule,omitempty"`
Approvers []string `json:"approvers"`
Reason string `json:"reason,omitempty"`
// Pending is an open approval request.
Pending *PageApproval `json:"pending,omitempty"`
}
PagePublishState says what the person may do with the page.
type PageReminderFlow ¶
type PageReminderFlow struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
}
PageReminderFlow is the reminder automation.
type PageReminders ¶
type PageReminders struct {
// Available: the page has event details with a date field.
Available bool `json:"available"`
Field string `json:"field"`
Title string `json:"title"`
Reminders string `json:"reminders"`
Flow *PageReminderFlow `json:"automation,omitempty"`
}
PageReminders is the offer and what exists.
type PageResult ¶
type PageResult struct {
Kind string `json:"kind" enum:"signups,registrations,sales,none"`
Count int64 `json:"count"`
AmountCents int64 `json:"amountCents"`
Currency string `json:"currency"`
// Conversion is the result over the views, in percent (1.9).
Conversion float64 `json:"conversion"`
}
PageResult is a page's result over the period.
type PageSaved ¶
type PageSaved struct {
Version int32 `json:"version"`
SavedAt time.Time `json:"savedAt"`
SavedBy *PagePerson `json:"savedBy,omitempty"`
Changes bool `json:"changes"`
Checks []PageCheck `json:"checks"`
Counts PageCounts `json:"counts"`
}
PageSaved is a saved version.
type PageSettings ¶
type PageSettings struct {
SEOTitle string `json:"seoTitle"`
SEODescription string `json:"seoDescription"`
SocialImage string `json:"socialImage"`
Visibility string `json:"visibility" enum:"public,members,paid"`
Tiers []string `json:"tiers" doc:"Paid pages: the tiers that may read it (empty: every paid tier)"`
HideHeader bool `json:"hideHeader" doc:"Focused landing pages: the site header shows the logo only"`
}
PageSettings are a page's settings (the builder's Page tab).
type PageSettingsInput ¶
type PageSettingsInput struct {
Name string `json:"name" minLength:"1" maxLength:"120"`
Slug string `json:"slug" minLength:"1" maxLength:"80"`
SEOTitle string `json:"seoTitle" maxLength:"120"`
SEODescription string `json:"seoDescription" maxLength:"300"`
SocialImage string `json:"socialImage" maxLength:"1000"`
Visibility string `json:"visibility" enum:"public,members,paid"`
Tiers []string `json:"tiers,omitempty" maxItems:"20"`
HideHeader bool `json:"hideHeader"`
}
PageSettingsInput saves the Page tab.
type PageTemplateCount ¶
PageTemplateCount is a template filter chip ("Sales page 1").
type PageUnpublishInput ¶
type PageUnpublishInput struct {
Reason string `json:"reason,omitempty" maxLength:"300"`
// RedirectTo is a path on the site readers are sent to; empty answers 410.
RedirectTo string `json:"redirectTo,omitempty" maxLength:"300"`
}
PageUnpublishInput takes a page off the site.
type PageVersionDetail ¶
type PageVersionDetail struct {
PageVersionItem
Slug string `json:"slug"`
HTML string `json:"html"`
Project json.RawMessage `json:"project"`
Settings PageSettings `json:"settings"`
}
PageVersionDetail is one version's content.
type PageVersionItem ¶
type PageVersionItem struct {
Version int32 `json:"version"`
Name string `json:"name"`
Label string `json:"label" doc:"created, autosave, saved, settings, kept, restored, published"`
SavedAt time.Time `json:"savedAt"`
SavedBy *PagePerson `json:"savedBy,omitempty"`
PublishedAt *time.Time `json:"publishedAt,omitempty"`
PublishedBy string `json:"publishedBy,omitempty"`
Live bool `json:"live"`
Current bool `json:"current"`
}
PageVersionItem is a row of Version history.
type PageVersionList ¶
type PageVersionList struct {
Items []PageVersionItem `json:"items"`
}
PageVersionList is Version history.
type PagesOverview ¶
type PagesOverview struct {
Period string `json:"period"`
From time.Time `json:"from"`
Until time.Time `json:"until"`
Stats PagesStats `json:"stats"`
Pages []PageListItem `json:"pages"`
Templates []PageTemplateCount `json:"templates"`
Shop PagesShop `json:"shop"`
Host string `json:"host"`
Theme PagesTheme `json:"theme"`
WebsiteOn bool `json:"websiteOn"`
// Editors and Publishers are who to ask (a Viewer's note).
Editors []string `json:"editors"`
Publishers []string `json:"publishers"`
CanEdit bool `json:"canEdit"`
CanPublish bool `json:"canPublish"`
}
PagesOverview is Forms & public pages › Pages.
type PagesShop ¶
type PagesShop struct {
On bool `json:"on"`
Products int64 `json:"products"`
Path string `json:"path"`
URL string `json:"url"`
CanToggle bool `json:"canToggle"`
}
PagesShop is the shop's row of Built-in pages.
type PagesStats ¶
type PagesStats struct {
Views int64 `json:"views"`
// ViewedPages counts the pages viewed; ShopViewed whether the shop was.
ViewedPages int `json:"viewedPages"`
ShopViewed bool `json:"shopViewed"`
Signups int64 `json:"signups"`
SignupPages []string `json:"signupPages"`
Registrations int64 `json:"registrations"`
RegistrationPages []string `json:"registrationPages"`
Sales int64 `json:"sales"`
SalesCents int64 `json:"salesCents"`
Currency string `json:"currency"`
SalesPages int `json:"salesPages"`
ShopSales bool `json:"shopSales"`
}
PagesStats are the four cards over the list.
type PagesTheme ¶
type PagesTheme struct {
Publisher string `json:"publisher"`
Logo bool `json:"logo"`
Accent string `json:"accent"`
Ground string `json:"ground"`
Font string `json:"font"`
}
PagesTheme is the note under the lists: the theme pages use.
type ReminderRequest ¶
type ReminderRequest struct {
Name, Title, Field, At, Link, When string
}
ReminderRequest is the flow to make (internal/automations makes it).
type Resolved ¶
type Resolved struct {
Page *LivePage
// MovedTo is the address of a page that moved (a redirect).
MovedTo string
// RedirectTo is where an unpublished page sends readers.
RedirectTo string
// Gone: the page was taken off the site or deleted.
Gone bool
}
Resolved is what an address on the site holds.
type Service ¶
type Service struct {
Pool *pgxpool.Pool
Q *store.Queries
Audit *audit.Logger
Log *slog.Logger
Now func() time.Time
// Forms gives the site's addresses (the custom domain once verified)
// and the branding pages use.
Forms *forms.Service
// Website keeps "Show in navigation" header links and says whether the
// website is on (nil: pages stand alone).
Website *website.Service
// Selling is the payment connection Buy buttons need (nil: none).
Selling func(ctx context.Context, ws *store.Workspace) (Selling, bool, error)
// Approvals applies the workspace's approval rules to publishing (nil:
// website:publish decides).
Approvals Approvals
// Probe checks a link of a page (the "A link doesn't work" warning):
// its HTTP status (nil: links aren't checked).
Probe func(ctx context.Context, url string) (int, error)
// ReminderFlow makes a webinar's reminder automation (nil: none).
ReminderFlow func(ctx context.Context, ws *store.Workspace, by *uuid.UUID, r ReminderRequest) (uuid.UUID, error)
}
Service holds the pages domain.
func (*Service) Conversion ¶
func (s *Service) Conversion(ctx context.Context, ws *store.Workspace, page uuid.UUID, kind string, contact *uuid.UUID) error
Conversion records what a page brought in: a signup, a registration.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, ws *store.Workspace, p *authz.Principal, in PageCreate) (PageDetail, error)
Create starts a page from a template, as a draft.
func (*Service) CreateReminders ¶
func (s *Service) CreateReminders(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (PageReminders, error)
CreateReminders makes the reminder automation, as a draft.
func (*Service) Delete ¶
func (s *Service) Delete(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
Delete deletes a page. A page that was published answers 410 at its address; its header link goes.
func (*Service) Detail ¶
func (s *Service) Detail(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (PageDetail, error)
Detail reads a page for the builder.
func (*Service) Overview ¶
func (s *Service) Overview(ctx context.Context, ws *store.Workspace, p *authz.Principal, period string) (PagesOverview, error)
Overview is Forms & public pages › Pages: the numbers, the pages and the shop.
func (*Service) PagesUsingForm ¶
func (s *Service) PagesUsingForm(ctx context.Context, ws *store.Workspace, formID uuid.UUID) (FormPages, error)
PagesUsingForm lists the pages whose blocks use a form.
func (*Service) Publish ¶
func (s *Service) Publish(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in PagePublishInput) (PageDetail, error)
Publish publishes a page's draft now, or schedules it.
func (*Service) PublishApproved ¶
func (s *Service) PublishApproved(ctx context.Context, ws *store.Workspace, id uuid.UUID, approvalID, approver, hash string) error
PublishApproved publishes a page once its approval came (the approvals domain calls it), unless it changed since (hash is the page as approved) or a blocking check fails now.
func (*Service) PublishDue ¶
PublishDue publishes the scheduled pages whose time came.
func (*Service) RecordEventDate ¶
func (s *Service) RecordEventDate(ctx context.Context, ws *store.Workspace, contact uuid.UUID, ev EventInfo) error
RecordEventDate writes a webinar's date to a registrant's date field (dmarc_live_at), when the workspace has that date field. The date is the session's start in the workspace's time zone: the reminder automation's date-field trigger counts days and times there.
func (*Service) Reminders ¶
func (s *Service) Reminders(ctx context.Context, ws *store.Workspace, id uuid.UUID) (PageReminders, error)
Reminders reads a page's reminder offer.
func (*Service) RequestApproval ¶
func (s *Service) RequestApproval(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in PageApprovalInput) (PageDetail, error)
RequestApproval asks the workspace's approvers to approve publishing the page as it is.
func (*Service) Restore ¶
func (s *Service) Restore(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, version int32) (PageDetail, error)
Restore makes an earlier version the draft again, as a new version.
func (*Service) SaveContent ¶
func (s *Service) SaveContent(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in PageContentInput) (PageSaved, error)
SaveContent saves the draft's blocks: a new version, the live page unchanged.
func (*Service) SaveSettings ¶
func (s *Service) SaveSettings(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in PageSettingsInput) (PageDetail, error)
SaveSettings saves the Page tab: a new version, the live page unchanged until it's published. Visibility and navigation need website:manage.
func (*Service) SetShop ¶
func (s *Service) SetShop(ctx context.Context, ws *store.Workspace, p *authz.Principal, on bool) (PagesShop, error)
SetShop turns the shop on or off.
func (*Service) Undo ¶
func (s *Service) Undo(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (PageDetail, error)
Undo takes a publish back within ten seconds ("Undo" on the toast): the version live before comes back, or the page goes back to its draft.
func (*Service) Unpublish ¶
func (s *Service) Unpublish(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in PageUnpublishInput) (PageDetail, error)
Unpublish takes a page off the site.
type TemplateOptions ¶
type TemplateOptions struct {
Name string
Publisher string
// FormID is the form signup blocks start with ("" for none yet).
FormID string
// ProductID is the product a product block starts with.
ProductID string
// TZ is the workspace's time zone (countdowns and events).
TZ string
// Today is the date a countdown or an event starts from ("2026-10-15").
Date string
}
TemplateOptions fill a template in: the page's name, the publisher, the workspace's signup form, product and timezone when it has them.
type Usage ¶
type Usage struct {
Blocks int
Products []uuid.UUID
// BuyButtons counts the product blocks and grids (they need Stripe).
BuyButtons int
Forms []uuid.UUID
Countdowns []Moment
Events []Moment
Images int
// ImagesNoAlt are the images without alt text, by their address.
ImagesNoAlt []string
Links []Link
// FirstHeading is the first block's top heading level (1 for an h1), 0
// without a heading.
FirstHeading int
Stores int
Tiers int
Videos int
// EmptyProducts and EmptyForms are product and signup blocks with
// nothing picked yet.
EmptyProducts int
EmptyForms int
}
Usage is what a page's blocks refer to and contain: the publish checks, the status bar's counts and the forms' "Used on pages".