publicpages

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Overview

Package publicpages serves the pages subscribers see (spec 5.12, 7.12), server-rendered with html/template under the layout of internal/publicurl:

/p/{workspace}/subscribe[/{form}]      hosted subscribe page (GET, POST)
/p/{workspace}/confirm/{token}         double opt-in confirmation
/p/{workspace}/preferences[/{token}]   preference center (or ask for a link)
/p/{workspace}/unsubscribe/{token}     unsubscribe page; POST is RFC 8058 one-click
/p/{workspace}/view/{token}            an email in the browser
/p/{workspace}/archive[/{issue}]       public archive, archive.rss, sitemap.xml
/p/{workspace}/forms/{id}.js           embed script, /session and /submit
/p/_/…                                 stylesheet, fonts, scripts

A workspace's verified custom domain serves the same pages at its root (news.acme.io/subscribe). The pages work without JavaScript and cookies, load no third-party code (Cloudflare Turnstile only on a challenge page), run under a strict CSP without inline scripts or styles, and carry full metadata; every page reached through a signed link is noindex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAPI

func RegisterAPI(h huma.API, p *Handler)

RegisterAPI adds the preview operation.

Types

type Handler

type Handler struct {
	Pool     *pgxpool.Pool
	Q        *store.Queries
	Forms    *forms.Service
	Audience *audience.Service
	Tokens   *linktoken.Signer
	URLs     publicurl.Builder
	Log      *slog.Logger
	// SPA answers root paths on hosts that aren't a custom domain.
	SPA http.Handler
	// LandingURL is where "Sent with ReputeCast" points.
	LandingURL string
	Now        func() time.Time
	// contains filtered or unexported fields
}

func (*Handler) Init

func (h *Handler) Init() error

Init parses the templates; Routes calls it.

func (*Handler) Preview

func (h *Handler) Preview(ctx context.Context, ws *store.Workspace, page, form, draft, contact string) (PublicPagePreview, error)

Preview renders one public page for the app.

func (*Handler) Routes

func (h *Handler) Routes(r chi.Router)

Routes mounts the public pages, their assets and the custom-domain root.

type PublicPagePreview

type PublicPagePreview struct {
	// HTML is the page as subscribers see it; links and buttons are inert.
	HTML string `json:"html"`
	// URL is where the page lives (the custom domain once verified); empty
	// for pages only signed links open (confirmation, unsubscribe).
	URL string `json:"url"`
	// Contact is whose page it is: the subscriber who confirmed last, or an example address.
	Contact string `json:"contact"`
}

PublicPagePreview is a public page rendered for the app.

Jump to

Keyboard shortcuts

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