Documentation
¶
Overview ¶
Package theme resolves the active theme for a tenant page render.
Per gocodealone-multisite SPEC.md:
C11: Theming — default theme bundled with host for sites lacking own
template; per-site theme is expected.
V23: bundle's `multisite.yaml.theme` → first try tenant theme record;
on miss + `use_host_default=true` → host default theme; on miss +
`use_host_default=false` → 503 (config error, ⊥ silent fallback).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("theme not found")
ErrNotFound — same semantic as store.ErrNotFound to keep callers indifferent to source.
var ErrThemeMissingNoFallback = errors.New("theme missing and use_host_default=false (V23)")
ErrThemeMissingNoFallback is returned when the requested theme is not found AND `use_host_default` is false (V23: hard 503 — never silent fallback).
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory Store for tests + local dev.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) GetHostDefault ¶
func (m *MemoryStore) GetHostDefault(_ context.Context) (*Theme, error)
type Store ¶
type Store interface {
// Get fetches a theme by id, scoped to the tenant. tenant_id mismatch
// → ErrNotFound (V12 multi-tenancy guard).
Get(ctx context.Context, tenantID, themeID int64) (*Theme, error)
// GetHostDefault returns the bundled host-default theme.
GetHostDefault(ctx context.Context) (*Theme, error)
}
Store provides theme lookup by id + by-tenant-default + host-default.
type Theme ¶
type Theme struct {
ID int64
TenantID int64 // 0 = host default
Name string
TemplateArchivePath string
IsDefault bool
}
Theme is the persistent representation of a renderable theme.
Production wires a postgres-backed Store; the in-memory implementation here suits tests + local dev. TenantID == 0 means a host-default theme (shared across tenants).
func Resolve ¶
Resolve returns the theme to render with, following the V23 ladder:
- spec.ID → store.Get → return
- miss + spec.UseHostDefault=true → store.GetHostDefault → return
- miss + spec.UseHostDefault=false → ErrThemeMissingNoFallback
Calls Get with tenantID; the tenant-scoping guard lives in the Store impl.