Versions in this module Expand all Collapse all v0 v0.1.0 Oct 17, 2026 Changes in this version + var ErrConflict = errors.New("cms: record changed or key already exists") + var ErrForbidden = errors.New("cms: permission denied") + var ErrInvalid = errors.New("cms: invalid input") + var ErrNotFound = errors.New("cms: not found") + var ErrRateLimited = errors.New("cms: too many login attempts") + var ErrTooLarge = errors.New("cms: payload too large") + var ErrUnauthenticated = errors.New("cms: authentication required") + func RenderRichText(source string) (template.HTML, error) + type Action string + const Create + const Delete + const ManageUsers + const Read + const Update + const Upload + type CMS struct + func New(cfg Config) (*CMS, error) + func (c *CMS) BasePath() string + func (c *CMS) BootstrapAdmin(ctx context.Context, username, password string) error + func (c *CMS) CheckSchema(ctx context.Context) error + func (c *CMS) CleanExpiredSessions(ctx context.Context) error + func (c *CMS) Create(ctx context.Context, actor Principal, model string, input Values) (Record, error) + func (c *CMS) CreateUser(ctx context.Context, actor Principal, username, password, role string) (string, error) + func (c *CMS) Delete(ctx context.Context, actor Principal, model, id string, expected int64) error + func (c *CMS) DisableUser(ctx context.Context, actor Principal, id string, disabled bool) error + func (c *CMS) Get(ctx context.Context, model, id string) (Record, error) + func (c *CMS) GetBySlug(ctx context.Context, model, slug string) (Record, error) + func (c *CMS) ImageURL(id string) string + func (c *CMS) List(ctx context.Context, model string, q Query) (Page, error) + func (c *CMS) MediaHandler() http.Handler + func (c *CMS) Migrate(ctx context.Context) error + func (c *CMS) Mount(mux *http.ServeMux) + func (c *CMS) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (c *CMS) SetPassword(ctx context.Context, actor Principal, id, password string) error + func (c *CMS) SetRole(ctx context.Context, actor Principal, id, role string) error + func (c *CMS) Singleton(ctx context.Context, model string) (Record, error) + func (c *CMS) Update(ctx context.Context, actor Principal, model, id string, expected int64, ...) (Record, error) + type Config struct + Authenticate func(*http.Request) (Principal, error) + Authorize func(context.Context, Principal, Action, Resource) error + BasePath string + CSRFKey []byte + DB *sql.DB + DBTimeout time.Duration + Dialect Dialect + InsecureCookies bool + Logger *slog.Logger + Media MediaStorage + MediaBasePath string + Models []Model + Repository Repository + SessionTTL time.Duration + type Dialect string + const Postgres + const SQLite + type Field struct + Choices []string + Default any + Help string + Label string + Max *int64 + MaxLength int + Min *int64 + Name string + Required bool + Type FieldType + type FieldType string + const Boolean + const Date + const DateTime + const Decimal + const Image + const Integer + const RichText + const Select + const Slug + const Text + const Textarea + const URL + type ImageValue struct + Alt string + ID string + type ListOptions struct + AllFields bool + BeforeID string + BeforeTime int64 + Fields []string + Limit int + type Media struct + ContentType string + CreatedAt time.Time + Height int + ID string + Key string + Size int64 + Width int + type MediaStorage interface + Delete func(context.Context, string) error + Open func(context.Context, string) (io.ReadCloser, error) + Put func(context.Context, string, io.Reader) error + type Model struct + Fields []Field + Label string + Name string + Singleton bool + SlugField string + TitleField string + Validate func(Values) error + type Page struct + Items []Record + NextCursor string + type Principal struct + ID string + Name string + Roles []string + type Query struct + After string + AllFields bool + Fields []string + Limit int + type Record struct + CreatedAt time.Time + ID string + Revision int64 + Slug string + Title string + UpdatedAt time.Time + Values Values + func (r Record) Decode(dst any) error + type Repository interface + Create func(ctx context.Context, model string, record Record) error + Delete func(ctx context.Context, model, id string, expectedRevision int64) error + Get func(ctx context.Context, model, id string) (Record, error) + GetBySlug func(ctx context.Context, model, slug string) (Record, error) + List func(ctx context.Context, model string, options ListOptions) ([]Record, error) + Update func(ctx context.Context, model string, record Record, expectedRevision int64) error + type Resource struct + ID string + Model string + type ValidationErrors map[string]string + func (e ValidationErrors) Error() string + func (e ValidationErrors) Unwrap() error + type Values map[string]any