server

package
v0.0.0-...-963cf5d Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: GPL-3.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
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

func ServeCGI

func ServeCGI(h http.Handler) error

Types

type AnfrageResponse

type AnfrageResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

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
	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

func (h *Handler) FulfilOrder(id string) error

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

func (h *Handler) MarketPaymentTick(ctx context.Context) error

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

func (h *Handler) MarketTick(ctx context.Context)

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) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Handler) StartMarket

func (h *Handler) StartMarket(ctx context.Context)

StartMarket runs the hourly market job (expiry, reminders, member badges) until ctx ends.

func (*Handler) StartMarketPayments

func (h *Handler) StartMarketPayments(ctx context.Context)

StartMarketPayments polls the indexer once a minute (with backoff after errors) until ctx ends.

func (*Handler) StartNewsletter

func (h *Handler) StartNewsletter(ctx context.Context)

StartNewsletter runs the mailing sender and drops stale unconfirmed addresses once a day, until ctx ends.

func (*Handler) StartShopWatcher

func (h *Handler) StartShopWatcher(ctx context.Context)

StartShopWatcher starts the payment watcher of this site in the background; it stops when ctx is cancelled.

type LangOption

type LangOption struct {
	Code  string
	Label string
	Flag  string
}

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

type MultiHandler struct {
	Sites    map[string]*Handler
	Fallback *Handler
}

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
	NavItems     []config.MenuItem
	FooterText   template.HTML
	FooterLinks  []config.MenuItem
	Content      template.HTML
	Assets       assets.AssetMap
	SiteName     string
	CanonicalURL string
	ThemeVars    template.CSS
	Favicon      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

type StripeRuntime struct {
	Service *stripe.Service
}

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.

Jump to

Keyboard shortcuts

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