Documentation
¶
Index ¶
- Constants
- func LoadLanguages(cfg *Config) ([]string, error)
- func LoadPostTypes(cfg *Config) (*posttype.Service, error)
- func LoadRoles(cfg *Config, postTypes []string) (*role.Service, error)
- func LoadThumbnails(cfg *Config) (*thumbnail.Service, error)
- func ParsePIIMasterKey(raw string) ([]byte, error)
- func PrimaryLanguage(languages []string) string
- func SaveInvoice(cfg *Config, settings InvoiceConfig) error
- func SaveTheme(cfg *Config, active string) error
- type CSPConfig
- type CatalogConfig
- type CommentsConfig
- type Config
- func (c *Config) EffectiveThemGenBaseURL() string
- func (c *Config) EffectiveThemGenModel() string
- func (c *Config) ImportMaxSize() int64
- func (c *Config) IsImageGenerationEnabled() bool
- func (c *Config) IsSamEnabled() bool
- func (c *Config) IsSpeechToTextEnabled() bool
- func (c *Config) IsTextGenerationEnabled() bool
- func (c *Config) IsThemeGenerationEnabled() bool
- func (c *Config) ParseCORSOrigins() []string
- func (c *Config) ThemesRoot() string
- type DisplayCurrency
- type HeadlessConfig
- type HomepageSection
- type InvoiceConfig
- type LegalConfig
- type MCPConfig
- type ManualPayee
- type ModulesConfig
- type OrdersConfig
- type PaymentsConfig
- type PublicField
- type PublicFieldRegistry
- type RegistrationConfig
- type SiteConfig
- type ThemeConfig
Constants ¶
const ( // SpeechToTextProviderMeta selects Meta Model API (Muse Voice // Transcribe) as the speech-to-text provider. Read via // AI_SPEECH_TO_TEXT_PROVIDER. SpeechToTextProviderMeta = "meta" // SpeechToTextProviderOpenAI selects an OpenAI-compatible audio // transcription endpoint (POST /v1/audio/transcriptions) as the // speech-to-text provider. Read via AI_SPEECH_TO_TEXT_PROVIDER. SpeechToTextProviderOpenAI = "openai" )
const ( // PublicFieldResourceUser and PublicFieldResourceContent are the two supported // values for PublicField.Resource. They map to the two public query endpoints: // the authors endpoint (users) and the content_items endpoint (content). PublicFieldResourceUser = "user" PublicFieldResourceContent = "content" // PublicFieldOperationSort, PublicFieldOperationFilter, and // PublicFieldOperationExpose are the supported values for PublicField.Operations. // A field can be allowlisted for any combination. PublicFieldOperationSort = "sort" PublicFieldOperationFilter = "filter" PublicFieldOperationExpose = "expose" )
Variables ¶
This section is empty.
Functions ¶
func LoadLanguages ¶
LoadLanguages loads the supported languages from the config.toml file. Returns at least ["en"] — if the config file is missing or has no languages defined, "en" is used as the primary language.
func LoadPostTypes ¶
LoadPostTypes loads custom post types from the config directory If the config file doesn't exist, it returns a service with default post types
func LoadRoles ¶ added in v0.10.0
LoadRoles loads custom [role] definitions from the same config.toml that supplies post types. The built-in roles (Admin, Contributor, Commentator) are always present; a same-name [role] entry overrides a built-in (except Admin). postTypes must list every registered post-type slug — custom entries may only reference existing types, so a typo fails closed at startup instead of silently granting a role an unregistered type. A missing config file or directory yields a service with only the built-in roles.
func LoadThumbnails ¶
LoadThumbnails loads thumbnail configurations from the config file (config.toml). If the file does not exist, it returns a service with default configs.
func ParsePIIMasterKey ¶ added in v1.1.0
ParsePIIMasterKey decodes the PII_MASTER_KEY value into the 32-byte master key the commerce PII cipher needs: standard-base64 of exactly 32 random bytes (generate with `openssl rand -base64 32`). A missing value or anything that is not 32 bytes fails closed — the commerce edition aborts startup instead of serving customer PII in plaintext.
func PrimaryLanguage ¶
PrimaryLanguage returns the first language in the slice, or "en" if empty.
func SaveInvoice ¶ added in v1.1.0
func SaveInvoice(cfg *Config, settings InvoiceConfig) error
SaveInvoice rewrites only the [invoice] block of config.toml, preserving every other line verbatim. The block itself is regenerated, so comments inside it do not survive; comments elsewhere in the file stay intact. The write is atomic — a temp file in the same directory renames over the original — and an explicit zero rate is written back as zero.
Types ¶
type CSPConfig ¶ added in v0.7.0
type CSPConfig struct {
Disable bool `toml:"disable"`
ReportOnly bool `toml:"report_only"`
ScriptSrc []string `toml:"script_src"`
StyleSrc []string `toml:"style_src"`
ImgSrc []string `toml:"img_src"`
FontSrc []string `toml:"font_src"`
ConnectSrc []string `toml:"connect_src"`
FrameSrc []string `toml:"frame_src"`
MediaSrc []string `toml:"media_src"`
ObjectSrc []string `toml:"object_src"`
WorkerSrc []string `toml:"worker_src"`
FrameAncestors []string `toml:"frame_ancestors"`
ExtraDirectives map[string]string `toml:"extra_directives"`
Policy string `toml:"policy"`
}
CSPConfig holds the optional [csp] block from config.toml. All fields have zero-value defaults that are backward compatible. Operators append sources to individual directives; they never replace. The exceptions are `policy` (full replacement) and `frame_ancestors` (replaces the `frame-ancestors` directive — appending to the default `'none'` is meaningless per the CSP spec, so this directive is a dedicated opt-in knob; it also drives the X-Frame-Options header, see XFrameOptions).
func LoadCSPConfig ¶ added in v0.7.0
LoadCSPConfig reads the optional [csp] block from config.toml. When the file, section, or directory is missing it returns a zero-value CSPConfig (fully backward compatible — Build() returns the default policy).
func (CSPConfig) Build ¶ added in v0.7.0
Build returns the CSP header name and value for this configuration. Empty header value means "do not emit a CSP header".
func (CSPConfig) IFrameHosts ¶ added in v0.10.0
IFrameHosts derives the HTML sanitizer's iframe host allowlist from the frame-src directive: the built-in default sources plus operator appends. A full [csp] policy override replaces the defaults: the frame-src sources are parsed from that policy and used instead, mirroring the emitted header — an override without frame-src leaves the allowlist empty so iframes stay stripped. disable and report_only keep the default-based allowlist so the sanitizer stays a restrictive safety net even when the browser gate is off. Non-host sources ("'self'", bare schemes) are skipped; "*.host" entries keep their wildcard prefix so the sanitizer allows only subdomains. The result feeds sanitize.SanitizeHTMLDocument so embeds the CSP allows to be framed are also allowed through the sanitizer.
func (CSPConfig) XFrameOptions ¶ added in v0.10.0
XFrameOptions derives the X-Frame-Options header value from the framing configuration so the legacy header can never contradict the CSP. A policy override owns the framing story when set (mirroring Build — the knob only applies without a policy). Rules:
- a frame-ancestors source list that is exactly "'self'" → "SAMEORIGIN" (duplicates and case variants included; "'self'" is the only keyword X-Frame-Options can express)
- any "'none'" source → "DENY" (even in a mixed list, which browsers discard — the legacy header then holds the line)
- a host source list → "" (the header is omitted; frame-ancestors is the control). Exception: under report_only the CSP is not enforced, so a host list floors to "DENY" to keep a restriction in place during rollout trials; under disable the operator manages CSP at the edge and the omission stands (documented).
type CatalogConfig ¶ added in v1.1.0
type CatalogConfig struct {
PostType string `toml:"post_type"`
Currency string `toml:"currency"`
NotifyEmail string `toml:"notify_email"`
DisplayCurrencies []DisplayCurrency `toml:"display_currency"`
}
func LoadCatalog ¶ added in v1.1.0
func LoadCatalog(cfg *Config) (CatalogConfig, error)
LoadCatalog reads the optional [catalog] block from the same config.toml that supplies post types and the [modules] list. An absent block or file yields defaults ("product" / "IDR") — backward compatible, and the commerce edition works out of the box with the documented config.
type CommentsConfig ¶ added in v0.9.0
type CommentsConfig struct {
Enabled *bool `toml:"enabled"`
}
CommentsConfig is the optional [comments] block from config.toml. When disabled, the comment system is hard-disabled: comment routes are not mounted, the admin UI hides all comment surfaces, new content defaults to allowComments=false, and self-registration (which creates Commentator users) is blocked. An absent block yields a zero-value CommentsConfig, which IsEnabled treats as enabled — the backward-compatible default.
func LoadComments ¶ added in v0.9.0
func LoadComments(cfg *Config) (CommentsConfig, error)
LoadComments reads the optional [comments] block from the same config.toml that supplies post types and homepage sections. It mirrors LoadHomepageSections: a missing config directory or file yields a zero-value CommentsConfig (which IsEnabled reports as enabled — fully backward compatible).
func (CommentsConfig) IsEnabled ¶ added in v0.9.0
func (c CommentsConfig) IsEnabled() bool
IsEnabled reports whether comments are enabled. The zero value (absent block or absent key) means enabled, so existing deployments without a [comments] block keep their comment system.
type Config ¶
type Config struct {
Host string
Port int
DBPath string
DBDriver string
DBDSN string
DBPoolMaxConns int
// StorageDriver selects the file storage backend: "local" (default) or "s3".
// The "s3" driver works against AWS S3 AND MinIO (both speak the S3 API).
// Read via STORAGE_DRIVER.
StorageDriver string
// StorageS3Endpoint is the S3-compatible endpoint URL (e.g. "http://minio:9000").
// Leave empty to use the default AWS endpoints. Read via STORAGE_S3_ENDPOINT.
StorageS3Endpoint string
// StorageS3Region is the AWS region or MinIO region (MinIO uses "us-east-1" by
// default). Read via STORAGE_S3_REGION.
StorageS3Region string
// StorageS3Bucket is the bucket media and profile pictures are stored in.
// Read via STORAGE_S3_BUCKET.
StorageS3Bucket string
// StorageS3AccessKeyID is the access key for the S3-compatible backend.
// Read via STORAGE_S3_ACCESS_KEY_ID.
StorageS3AccessKeyID string
// StorageS3SecretAccessKey is the secret key for the S3-compatible backend.
// Read via STORAGE_S3_SECRET_ACCESS_KEY.
StorageS3SecretAccessKey string
// StorageS3UsePathStyle forces path-style addressing ("bucket.example.com/key"
// vs "example.com/bucket/key"). Required for most MinIO deployments.
// Read via STORAGE_S3_USE_PATH_STYLE.
StorageS3UsePathStyle bool
// StorageS3PublicBaseURL is the base URL served to clients (the bucket's public
// URL or a CDN/CloudFront distribution, e.g. "https://cdn.example.com").
// GetURL returns this prefix + object key. Read via STORAGE_S3_PUBLIC_BASE_URL.
StorageS3PublicBaseURL string
JWTSecret string
LogLevel string
// PIIMasterKey is the base64-encoded 32-byte master key for
// application-level commerce PII encryption (orders and payments
// customer fields). Read via PII_MASTER_KEY. Only the commerce
// edition requires it — wireOrders/wirePayments fail closed when it
// is missing or invalid — every other edition ignores it.
PIIMasterKey string
SMTPHost string
SMTPPort int
SMTPUser string
SMTPPassword string
SMTPFrom string
ConfigDir string
ConfigFile string
CORSAllowedOrigins string
SiteURL string
DevMode bool
AdminDevURL string
ThemeDir string
PostPerPage int
// ServerReadHeaderTimeout is the maximum duration to read request headers
// (Slowloris protection). Read via SERVER_READ_HEADER_TIMEOUT.
ServerReadHeaderTimeout time.Duration
// ServerReadTimeout is the maximum duration to read the entire request
// including the body. A zero value means no timeout — body size is capped
// per-handler via MaxBytesReader / maxBodySizeMiddleware. Read via
// SERVER_READ_TIMEOUT.
ServerReadTimeout time.Duration
// ServerWriteTimeout is the maximum duration to write the response after
// the request headers have been read. A zero value means no timeout. Read
// via SERVER_WRITE_TIMEOUT.
ServerWriteTimeout time.Duration
RateLimitEnabled bool
RateLimitAuthPerMinute int
RateLimitAPIPerMinute int
RateLimitPublicPerMinute int
// AgentFailuresPerMinute is the per-IP budget of Bearer 401 responses
// before the outcome-based limiter refuses further Bearer requests
// with 429. Low enough to stop fake-key rotation, high enough to
// never touch legitimate use. Read via
// RATE_LIMIT_AGENT_FAILURES_PER_MINUTE.
AgentFailuresPerMinute int
// HSTSMaxAge is the Strict-Transport-Security max-age in seconds. It
// defaults to one year when SITE_URL is https:// and to 0 (header
// omitted) otherwise, so plain-HTTP local deployments keep working.
// Read via HSTS_MAX_AGE_SECONDS; set it to 0 to disable the header
// explicitly on an HTTPS origin.
HSTSMaxAge int
AIImageGenerationAPIKey string
AIImageGenerationBaseURL string
AIImageGenerationModel string
AIImageGenerationSize string
AIImageGenerationAspectRatio string
AITextGenerationAPIKey string
AITextGenerationBaseURL string
AITextGenerationModel string
// AIThemGenAPIKey enables the AI theme generator: a dedicated key for
// theme CSS generation. Empty falls back to AITextGenerationAPIKey.
// Read via AI_THEMGEN_API_KEY.
AIThemGenAPIKey string
// AIThemGenBaseURL is the OpenAI-compatible base URL for theme
// generation. Empty falls back to AITextGenerationBaseURL.
// Read via AI_THEMGEN_BASE_URL.
AIThemGenBaseURL string
// AIThemGenModel is the chat model for theme generation. Empty falls
// back to AITextGenerationModel, then to gpt-5-mini.
// Read via AI_THEMGEN_MODEL.
AIThemGenModel string
// ThemesDir is the filesystem root for installed (generated or manual)
// themes: one directory per theme. Read via THEMES_DIR.
ThemesDir string
// AISamAPIKey enables the privacy redaction pass: when set, every
// media and profile-picture upload is scanned with SAM 3.1 and
// sensitive regions are blurred before anything is stored. Empty
// keeps the legacy pipeline byte-identical. Read via AI_SAM_API_KEY.
AISamAPIKey string
// AISamModel is the SAM model name sent to the Model API.
// Read via AI_SAM_MODEL.
AISamModel string
// AISamConcepts is the comma-separated scan vocabulary, e.g.
// "face,license plate,nudity" (plain noun phrases — the Model API
// matches concrete nouns best). Read via AI_SAM_CONCEPTS.
AISamConcepts string
AISpeechToTextAPIKey string
AISpeechToTextBaseURL string
AISpeechToTextModel string
AISpeechToTextProvider string
APIKeyPepper string
// ImportMaxSizeMB is the ceiling (in megabytes) for any importer upload
// (WordPress WXR now; future importers reuse the same cap). Read via
// IMPORT_MAX_SIZE_MB. Use ImportMaxSize() for the byte value.
ImportMaxSizeMB int
// WordPressImportTimeout is the maximum duration a WordPress import job may
// run after the HTTP response has been sent (the job runs in a background
// goroutine). Read via WORDPRESS_IMPORT_TIMEOUT.
WordPressImportTimeout time.Duration
// HugoImportTimeout is the maximum duration a Hugo import job may run after
// the HTTP response has been sent (the job runs in a background goroutine).
// Read via HUGO_IMPORT_TIMEOUT.
HugoImportTimeout time.Duration
}
Config holds all application configuration
func Load ¶
Load loads configuration from environment variables It tries to load .env file first, then reads from actual environment
func (*Config) EffectiveThemGenBaseURL ¶ added in v1.5.0
EffectiveThemGenBaseURL resolves the theme generation base URL: the dedicated value when set, otherwise the shared text-generation URL.
func (*Config) EffectiveThemGenModel ¶ added in v1.5.0
EffectiveThemGenModel resolves the theme generation model: the dedicated value when set, otherwise the shared text-generation model, then gpt-5-mini.
func (*Config) ImportMaxSize ¶ added in v0.5.0
ImportMaxSize returns the importer upload ceiling in bytes.
func (*Config) IsImageGenerationEnabled ¶
IsImageGenerationEnabled returns true if the Google Imagen API key is configured
func (*Config) IsSamEnabled ¶ added in v1.2.1
IsSamEnabled returns true when the SAM API key is configured. The privacy redaction pass runs only then; otherwise uploads use the legacy pipeline. A whitespace-only key counts as unset so a pasted blank cannot brick every upload fail-closed.
func (*Config) IsSpeechToTextEnabled ¶ added in v1.2.1
IsSpeechToTextEnabled returns true if the speech-to-text API key is configured. The provider value itself is validated at Load, so presence of the key is the only runtime gate. Voice dictation additionally requires text generation (the transcription is enhanced into TipTap content), which callers compose as IsSpeechToTextEnabled() && IsTextGenerationEnabled().
func (*Config) IsTextGenerationEnabled ¶
IsTextGenerationEnabled returns true if the AI text generation API key is configured
func (*Config) IsThemeGenerationEnabled ¶ added in v1.5.0
IsThemeGenerationEnabled returns true when the theme generator can run: a dedicated AI_THEMGEN_API_KEY or the shared text-generation key.
func (*Config) ParseCORSOrigins ¶
ParseCORSOrigins parses the comma-separated CORS origins string into a slice It handles whitespace trimming and validates that each origin has a valid http/https scheme
func (*Config) ThemesRoot ¶ added in v1.5.0
ThemesRoot returns the configured themes directory, defaulting to "themes/" when THEMES_DIR is unset or blank.
type DisplayCurrency ¶ added in v1.1.0
DisplayCurrency is one display-only currency for the storefront toggle: the ISO code the visitor picks and the conversion rate (display-major per base-minor, applied with cents scaling for two-decimal display currencies in storefront.js). Checkout stays in the base currency.
type HeadlessConfig ¶ added in v0.9.0
type HeadlessConfig struct {
Enabled bool `toml:"enabled"`
}
HeadlessConfig is the optional [headless] block from config.toml. When Enabled is true, the server-rendered content site (the /* catch-all) is not mounted — the instance serves only the admin panel and the REST API, for headless CMS use. An absent block yields a zero-value HeadlessConfig (Enabled=false — the content site renders as before).
func LoadHeadless ¶ added in v0.9.0
func LoadHeadless(cfg *Config) (HeadlessConfig, error)
LoadHeadless reads the optional [headless] block from the same config.toml that supplies post types and homepage sections. It mirrors LoadHomepageSections: a missing config directory or file yields a zero-value HeadlessConfig (fully backward compatible).
type HomepageSection ¶ added in v0.5.0
type HomepageSection struct {
PostType string `toml:"post_type"`
Limit int `toml:"limit"`
Offset int `toml:"offset"`
Title string `toml:"title"`
TitleID string `toml:"title_id"`
Description string `toml:"description"`
DescriptionID string `toml:"description_id"`
}
HomepageSection is one [[homepage_section]] block from config.toml. It tells the public homepage to render a per-post-type grouping in addition to (or instead of relying on) the flat latest-posts list. PostType is the only required field; Limit, Offset, and Title are optional overrides. TitleID and DescriptionID carry the optional Indonesian display strings: when the negotiated language is Indonesian they win, otherwise the base values apply.
func LoadHomepageSections ¶ added in v0.5.0
func LoadHomepageSections(cfg *Config) ([]HomepageSection, error)
LoadHomepageSections reads the [[homepage_section]] blocks from the same config.toml that supplies post types. It mirrors LoadPostTypes: a missing config directory or file yields an empty slice (the homepage then renders the flat latest-posts list — fully backward compatible).
type InvoiceConfig ¶ added in v1.1.0
type InvoiceConfig struct {
SellerName string `toml:"seller_name"`
SellerAddress string `toml:"seller_address"`
SellerTaxID string `toml:"seller_tax_id"`
TaxRate float64 `toml:"tax_rate"`
}
InvoiceConfig is the optional [invoice] block from config.toml: the seller identity stamped on every invoice and the PPN rate applied as a display-only breakdown. Loaded by the composition root and mapped into the orders module's options.
func LoadInvoice ¶ added in v1.1.0
func LoadInvoice(cfg *Config) (InvoiceConfig, error)
LoadInvoice reads the optional [invoice] block from the same config.toml that supplies post types and the [modules] list. An absent block or file yields blank seller identity with the statutory PPN default — backward compatible, and invoices render out of the box.
type LegalConfig ¶ added in v1.1.0
type LegalConfig struct {
CheckoutConsent *bool
RegistrationConsent *bool
CookiePolicyURL string
PrivacyPolicyURL string
TermsOfServiceURL string
ReturnsPolicyURL string
}
LegalConfig is the optional legal block from config.toml. Legal pages stay ordinary bilingual page content: the platform resolves them by conventional slug and this block carries only behavior overrides.
Absent block behavior (backward compatible):
- CheckoutConsent / RegistrationConsent: required when both the terms and privacy documents resolve; the checkout and registration flows are unchanged when they do not.
- LegalNav: legal pages are listed in the footer only.
- URL overrides: empty, so conventional slug resolution applies.
func LoadLegal ¶ added in v1.1.0
func LoadLegal(cfg *Config) (LegalConfig, error)
LoadLegal reads the optional legal block from the same config.toml that supplies the site config. A missing config directory or file yields a zero-value LegalConfig: conventional resolution applies and consent follows whether the documents exist.
func (LegalConfig) CheckoutConsentEnabled ¶ added in v1.1.0
func (c LegalConfig) CheckoutConsentEnabled(documentsPresent bool) bool
CheckoutConsentEnabled reports whether checkout must demand an affirmative consent act. An explicit key wins; otherwise consent is required exactly when the terms and privacy documents both resolve.
func (LegalConfig) Nav ¶ added in v1.1.0
func (c LegalConfig) Nav() legal.NavPlacement
Nav returns the configured placement, defaulting to footer for the zero-value config a missing block produces.
func (LegalConfig) Overrides ¶ added in v1.1.0
func (c LegalConfig) Overrides() map[legal.Page]string
Overrides maps the configured explicit URL overrides onto their conventional pages. Empty entries are dropped: they mean "resolve the conventional slug".
func (LegalConfig) RegistrationConsentEnabled ¶ added in v1.1.0
func (c LegalConfig) RegistrationConsentEnabled(documentsPresent bool) bool
RegistrationConsentEnabled reports whether registration must demand an affirmative consent act. An explicit key wins; otherwise consent is required exactly when the terms and privacy documents both resolve.
type MCPConfig ¶ added in v1.4.0
type MCPConfig struct {
Enabled bool `toml:"enabled"`
}
MCPConfig is the optional [mcp] block from config.toml. When Enabled is true, the server mounts the Streamable HTTP MCP endpoint at POST /mcp, so a remote host can drive the /api/v1 surface with a Bearer API key without a local binary. An absent block yields a zero-value MCPConfig (disabled — the new network surface is opt-in).
type ManualPayee ¶ added in v1.1.0
type ManualPayee struct {
Bank string `toml:"bank"`
Account string `toml:"account"`
Name string `toml:"name"`
}
ManualPayee is the optional [payments.manual] block from config.toml: the destination account shown on the confirmation email ("How to pay") and the guest tracking panel for manual bank transfers. All-or-nothing: either all three fields are set or none is — a partial block fails startup naming the missing field, so operators never ship a payee panel missing the account number.
type ModulesConfig ¶ added in v1.0.0
type ModulesConfig struct {
Disabled []string `toml:"disabled"`
}
ModulesConfig is the optional [modules] block from config.toml. Disabled names modules the composition root must not register: kernel.Prune drops them plus every transitive Requires dependent (cascade) before InitAll. Unknown names are warned about and ignored so configs stay portable across editions. An absent block yields a zero-value ModulesConfig (nothing disabled — the backward-compatible default). Headless mode is NOT expressed here: [headless] only suppresses public-surface mounting while the site-ssr engine stays registered for SSG/export.
func LoadModules ¶ added in v1.0.0
func LoadModules(cfg *Config) (ModulesConfig, error)
LoadModules reads the optional [modules] block from the same config.toml that supplies post types and homepage sections. It mirrors LoadHeadless: a missing config directory or file yields a zero-value ModulesConfig (fully backward compatible).
func (ModulesConfig) IsDisabled ¶ added in v1.0.0
func (c ModulesConfig) IsDisabled(name string) bool
IsDisabled reports whether the named module is disabled.
type OrdersConfig ¶ added in v1.1.0
type OrdersConfig struct {
PendingExpiry string `toml:"pending_expiry"`
}
OrdersConfig is the optional [orders] block from config.toml: how long a pending order stays payable before the sweeper expires it. The same value mirrors into the Midtrans Snap session expiry, so a hosted checkout cannot outlive its order.
func LoadOrders ¶ added in v1.1.0
func LoadOrders(cfg *Config) (OrdersConfig, error)
LoadOrders reads the optional [orders] block from the same config.toml that supplies post types and the [modules] list. An absent block or file yields the default — 24 hours, backward compatible with every existing deployment.
func (OrdersConfig) PendingExpiryDuration ¶ added in v1.1.0
func (o OrdersConfig) PendingExpiryDuration() (time.Duration, error)
PendingExpiryDuration renders the configured window as a duration.
type PaymentsConfig ¶ added in v1.1.0
type PaymentsConfig struct {
Methods []string `toml:"methods"`
Manual ManualPayee `toml:"manual"`
MidtransServerKey string
MidtransIsProduction bool
}
PaymentsConfig is the optional [payments] block from config.toml: the offered payment methods, in the order the client presents them, plus the Midtrans gateway credentials read from the environment (secrets never ride config.toml). Loaded by the composition root and mapped into the payments module's options.
func LoadPayments ¶ added in v1.1.0
func LoadPayments(cfg *Config) (PaymentsConfig, error)
LoadPayments reads the optional [payments] block from the same config.toml that supplies post types and the [modules] list. An absent block or file yields the default method list — manual transfer first, so the commerce edition works out of the box with the documented config. Unknown values ride through: the composition root drops any method its drivers do not know, so newer configs can pre-list gateways before their drivers exist.
type PublicField ¶ added in v0.7.0
type PublicField struct {
Resource string `toml:"resource"`
Field string `toml:"field"`
PostType string `toml:"post_type"`
Operations []string `toml:"operations"`
}
PublicField is one [[public_field]] block from config.toml. It declares that a specific custom-field or system-field slug may be used in a public query (filter, sort, or expose) against one of the public query endpoints. Without an entry here, the public endpoints reject any cf_<field> / cf_<field>_min / cf_<field>_max / sort_by=cf:<field> parameter that references the field with a 400 field_not_queryable error. Fields with the "expose" operation are included in the response body (e.g. in the publicAuthors[:].publicFields map).
Admin endpoints (e.g. /api/v1/content_items) are NOT gated by this allowlist — they remain unrestricted, matching pre-existing behaviour.
type PublicFieldRegistry ¶ added in v0.7.0
type PublicFieldRegistry struct {
// contains filtered or unexported fields
}
PublicFieldRegistry is the immutable, lookup-optimised form of a slice of PublicField entries. Hand one of these to a handler and call IsQueryable to enforce the allowlist on incoming public queries.
func LoadPublicFields ¶ added in v0.7.0
func LoadPublicFields(cfg *Config) (*PublicFieldRegistry, error)
LoadPublicFields reads the [[public_field]] blocks from the same config.toml that supplies post types and homepage sections. It mirrors LoadSiteConfig: a missing config directory or file yields an empty registry (fully backward compatible — every public cf_*/sort_by=cf:* query is then rejected).
func (*PublicFieldRegistry) ExposedFields ¶ added in v0.7.0
func (r *PublicFieldRegistry) ExposedFields(resource, postType string) []string
ExposedFields returns the field slugs that are allowlisted with the "expose" operation for the given resource (and optionally postType). When resource is "content", postType is matched against the entry's PostType; an entry with an empty PostType matches every post type. When resource is "user", postType is ignored. An empty registry returns nil.
func (*PublicFieldRegistry) IsQueryable ¶ added in v0.7.0
func (r *PublicFieldRegistry) IsQueryable(resource, postType, field, operation string) bool
IsQueryable reports whether the named field may be used with the given operation against the named resource. When resource is "content", postType is matched against the entry's PostType; an entry with an empty PostType matches every post type. When resource is "user", postType is ignored.
An empty registry (no [[public_field]] blocks configured) returns false for every query — the public endpoints then reject every cf_*/sort_by=cf:* parameter. This is the safe default.
type RegistrationConfig ¶ added in v0.10.0
RegistrationConfig is the optional [registration] block from config.toml. It decouples self-registration from the comment system: today registration is enabled iff comments are enabled (because the only self-registerable role, Commentator, was meaningless without them). With custom [role] entries a site may want public registration for a non-comment role (e.g. a journalist role), so this block overrides the default coupling.
Email verification is always mandatory: registrants are always created "pending" and must verify their email address. AdminApproval adds a second activation layer on top of the email proof.
Absent block behavior (backward compatible):
- Enabled: follows the comment system (comments enabled ⇒ registration on).
- DefaultRole: "Commentator".
- AdminApproval: false (email verification activates the account).
func LoadRegistration ¶ added in v0.10.0
func LoadRegistration(cfg *Config) (RegistrationConfig, error)
LoadRegistration reads the optional [registration] block from the same config.toml that supplies post types. It mirrors LoadComments: a missing config directory or file yields a zero-value RegistrationConfig, whose IsEnabled(commentsEnabled) reproduces the legacy coupling.
func (RegistrationConfig) IsEnabled ¶ added in v0.10.0
func (c RegistrationConfig) IsEnabled(commentsEnabled bool) bool
IsEnabled reports whether self-registration is allowed. An explicit enabled key wins; otherwise it falls back to the comment system's state.
type SiteConfig ¶ added in v0.5.0
type SiteConfig struct {
Name string `toml:"name"`
Logo string `toml:"logo"`
Favicon string `toml:"favicon"`
ProductImageRatio string `toml:"product_image_ratio"`
HeroImage string `toml:"hero_image"`
HeroTitle string `toml:"hero_title"`
HeroSubtitle string `toml:"hero_subtitle"`
}
SiteConfig is the optional [site_config] block from config.toml. It carries the site's text and visual identity — the values that appear on every public page and that the handler otherwise bakes into the binary (notably the PageTitle suffix and the og:site_name). All fields are optional; an absent block yields a zero-value SiteConfig, and the caller is expected to default Name to the application name when empty.
func LoadSiteConfig ¶ added in v0.5.0
func LoadSiteConfig(cfg *Config) (SiteConfig, error)
LoadSiteConfig reads the optional [site_config] block from the same config.toml that supplies post types and homepage sections. It mirrors LoadHomepageSections: a missing config directory or file yields a zero-value SiteConfig (fully backward compatible).
type ThemeConfig ¶ added in v1.5.0
type ThemeConfig struct {
Active string `toml:"active"`
}
ThemeConfig is the optional [theme] block from config.toml: the installed theme the content site layers over the embedded default. An empty Active means the embedded theme renders alone (unless THEME_DIR overrides it).
func LoadTheme ¶ added in v1.5.0
func LoadTheme(cfg *Config) (ThemeConfig, error)
LoadTheme reads the optional [theme] block from the same config.toml that supplies post types and the [modules] list. An absent block or file yields an empty Active — the embedded default renders.