Documentation
¶
Index ¶
- Constants
- func ServeCGI(h http.Handler) error
- type AnfrageResponse
- type AuthRuntime
- type BlogRuntime
- type CoursesRuntime
- type EventsRuntime
- type FeaturesRuntime
- type Handler
- func (h *Handler) FulfilOrder(id string) error
- func (h *Handler) MarketPaymentTick(ctx context.Context) error
- func (h *Handler) MarketTick(ctx context.Context)
- func (h *Handler) RegisterCoursePayments()
- func (h *Handler) RegisterShopPayments()
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *Handler) StartMarket(ctx context.Context)
- func (h *Handler) StartMarketPayments(ctx context.Context)
- func (h *Handler) StartNewsletter(ctx context.Context)
- func (h *Handler) StartShopWatcher(ctx context.Context)
- type LangOption
- type MarketRuntime
- type MultiHandler
- type NewsletterRuntime
- type PageData
- type PageResponse
- type ShopRuntime
- type StripeRuntime
- type ThumbStore
Constants ¶
const DefaultCSSPath = "/_forgecms/default.css"
DefaultCSSPath serves the built-in stylesheet. A site opts in with default_css: true in app.sml; its own static/style.css is linked after it and can override everything.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnfrageResponse ¶
AnfrageResponse is returned to the frontend after form submission.
type AuthRuntime ¶
type AuthRuntime struct {
Service *auth.Service
LoginIP *shop.Limiter // login mails per client IP
LoginEmail *shop.Limiter // login mails per (normalised) address
}
AuthRuntime is the per-site visitor login (magic links).
func NewAuthRuntime ¶
func NewAuthRuntime(dataDir, domain string, cfg *config.Config) (*AuthRuntime, error)
NewAuthRuntime opens the visitor login of a site (<data>/<domain>/auth), shared by all modules that need it (feature requests, newsletter admin).
type BlogRuntime ¶
type BlogRuntime struct {
*ThumbStore
Loc *time.Location
Now func() time.Time // tests set a fixed clock
}
BlogRuntime is the per-site state of the blog module. The posts live in the content repo; only thumbnails are stored locally.
func NewBlogRuntime ¶
func NewBlogRuntime(cfg config.BlogConfig, thumbs *ThumbStore, thumbDir string) (*BlogRuntime, error)
NewBlogRuntime prepares the blog module of a site. thumbs may be shared with the events module; nil makes a store in thumbDir.
type CoursesRuntime ¶
type CoursesRuntime struct {
Store *courses.Store
Buy *shop.Limiter // checkout starts per user
Grants *shop.Limiter // admin grants per admin
}
CoursesRuntime is the per-site state of the course module.
func NewCoursesRuntime ¶
func NewCoursesRuntime(dataDir, domain string) (*CoursesRuntime, error)
NewCoursesRuntime opens <data>/<domain>/courses.
type EventsRuntime ¶
type EventsRuntime struct {
*ThumbStore
Loc *time.Location
Now func() time.Time // tests set a fixed clock
}
EventsRuntime is the per-site state of the events module. The events themselves live in the content repo; only thumbnails are stored locally.
func NewEventsRuntime ¶
func NewEventsRuntime(cfg config.EventsConfig, thumbDir string) (*EventsRuntime, error)
NewEventsRuntime prepares the events module of a site.
type FeaturesRuntime ¶
type FeaturesRuntime struct {
Store *features.Store
Propose *shop.Limiter // new requests per user
Votes *shop.Limiter // votes per user
}
FeaturesRuntime is the per-site state of the feature request module.
func NewFeaturesRuntime ¶
func NewFeaturesRuntime(dataDir, domain string, cfg *config.Config) (*FeaturesRuntime, error)
NewFeaturesRuntime opens the feature requests of a site (<data>/<domain>/features). It needs the site's AuthRuntime.
type Handler ¶
type Handler struct {
Config *config.Config
Cache *content.CacheManager
Templates *template.Template
Assets assets.AssetMap
StaticDir string
ThemeVars template.CSS
Favicon string
Logo string
Mailer *mailer.ContactMailer
Shop *ShopRuntime // nil when the site has no (usable) Shop{}
Auth *AuthRuntime // visitor login; nil unless a module needs it
Features *FeaturesRuntime // nil when the site has no (usable) Features{}
Events *EventsRuntime // nil when the site has no (usable) Events{}
Blog *BlogRuntime // nil when the site has no (usable) Blog{}
// Newsletter is nil when the site has no (usable) Newsletter{}.
Newsletter *NewsletterRuntime
Market *MarketRuntime // nil when the site has no (usable) Market{}
Stripe *StripeRuntime // nil when the site has no Stripe{}
Courses *CoursesRuntime // nil when the site has no (usable) Courses{}
// contains filtered or unexported fields
}
func (*Handler) FulfilOrder ¶
FulfilOrder is called once an order is paid (by the payment watcher, or by the seller to re-send a lost download link). Digital orders get a license key and a fresh download link; buyer and seller are emailed.
func (*Handler) MarketPaymentTick ¶
MarketPaymentTick reads the transfers of the confirmed blocks since the last run to the wallets that may receive a market payment, books them and sends the mails of paid orders.
func (*Handler) MarketTick ¶
MarketTick expires old listings, mails expiry reminders and refreshes the member badges that are older than a day (a few per run).
func (*Handler) RegisterCoursePayments ¶
func (h *Handler) RegisterCoursePayments()
RegisterCoursePayments connects the course module to Stripe.
func (*Handler) RegisterShopPayments ¶
func (h *Handler) RegisterShopPayments()
RegisterShopPayments connects the shop to Stripe.
func (*Handler) StartMarket ¶
StartMarket runs the hourly market job (expiry, reminders, member badges) until ctx ends.
func (*Handler) StartMarketPayments ¶
StartMarketPayments polls the indexer once a minute (with backoff after errors) until ctx ends.
func (*Handler) StartNewsletter ¶
StartNewsletter runs the mailing sender and drops stale unconfirmed addresses once a day, until ctx ends.
func (*Handler) StartShopWatcher ¶
StartShopWatcher starts the payment watcher of this site in the background; it stops when ctx is cancelled.
type LangOption ¶
LangOption is one entry in the language switcher menu.
type MarketRuntime ¶
type MarketRuntime struct {
Store *market.Store
Indexer *shop.Indexer
Contact *shop.Limiter // contact mails per client IP
Reports *shop.Limiter // reports per client IP
Create *shop.Limiter // new listings per user
Uploads *shop.Limiter // photo uploads per user
Wallets *shop.Limiter // wallet confirmation mails per user
Now func() time.Time
}
MarketRuntime is the per-site state of the market module.
func NewMarketRuntime ¶
func NewMarketRuntime(dataDir, domain string, cfg *config.Config) (*MarketRuntime, error)
NewMarketRuntime opens the market of a site (<data>/<domain>/market). It needs the site's AuthRuntime.
type MultiHandler ¶
MultiHandler dispatches requests to site-specific handlers based on the Host header. Falls back to the first registered site (enables plain localhost access).
func (*MultiHandler) ServeHTTP ¶
func (m *MultiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type NewsletterRuntime ¶
type NewsletterRuntime struct {
Store *newsletter.Store
SignupIP *shop.Limiter // sign-ups per client IP
SignupEmail *shop.Limiter // confirm mails per (normalised) address
}
NewsletterRuntime is the per-site state of the newsletter module.
func NewNewsletterRuntime ¶
func NewNewsletterRuntime(dataDir, domain string) (*NewsletterRuntime, error)
NewNewsletterRuntime opens the mailing list of a site (<data>/<domain>/newsletter). It needs the site's AuthRuntime for the admin login and the link signatures.
type PageData ¶
type PageData struct {
Title string
Description string
Lang string
LangOptions []LangOption
Content template.HTML
Assets assets.AssetMap
SiteName string
CanonicalURL string
ThemeVars template.CSS
Favicon string
Logo string
StyleCSS string
DefaultCSS bool // link /_forgecms/default.css (app.sml default_css: true)
RepoURL string
CommitHash string
UmamiSrc string
UmamiID string
OGImage string
FeedURL string // Atom feed of the blog module, for <link rel="alternate">
Refresh int // seconds; >0 adds a meta refresh (shop pay page)
NoIndex bool // adds robots noindex (shop pages)
}
type PageResponse ¶
type PageResponse struct {
Title string `json:"title"`
Description string `json:"description"`
Lang string `json:"lang"`
Content string `json:"content"`
ETag string `json:"etag"`
}
PageResponse is the JSON payload returned by GET /api/pages?path=<route>. It contains the rendered HTML fragment (without the base template) so that a WebApp can wrap it in its own layout.
type ShopRuntime ¶
type ShopRuntime struct {
Store *shop.Store
Limiter *shop.Limiter
DataDir string // <data dir>/<domain>; Delivery files live below it
}
ShopRuntime is the per-site state of the Ğ1 shop.
func NewShopRuntime ¶
func NewShopRuntime(dataDir, domain string) (*ShopRuntime, error)
NewShopRuntime opens the order store below dataDir/domain.
type StripeRuntime ¶
StripeRuntime is the per-site Stripe module.
func NewStripeRuntime ¶
func NewStripeRuntime(dataDir, domain string, cfg *config.Config) (*StripeRuntime, error)
NewStripeRuntime opens <data>/<domain>/stripe.sml (created from a template on first start) and prepares the module.
type ThumbStore ¶
type ThumbStore struct {
ThumbDir string // generated list images, keyed by source hash
// contains filtered or unexported fields
}
ThumbStore holds the list images (thumbnails) of the events and blog modules, served at /_thumb/<file>.
func NewThumbStore ¶
func NewThumbStore(dir string) (*ThumbStore, error)
NewThumbStore prepares the thumbnail directory.