Adds content.published_block_configs: the host returns the stored content JSON of every block with a given key inside currently published page snapshots. Restores server-authoritative per-block enforcement for sandboxed guests (calcomblock's captcha requirement was inert under wasm — blockConfig hardcoded nil because no capability exposed published block content). Breaking: content.Content gains a method; the cms adapter implements it in the paired bump. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
75 lines
2.7 KiB
Go
75 lines
2.7 KiB
Go
package content
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AuthorProfile is a simplified author representation for plugins.
|
|
type AuthorProfile struct {
|
|
ID uuid.UUID
|
|
Name string
|
|
Slug string
|
|
Bio string
|
|
AvatarURL string
|
|
Website string
|
|
SocialLinks map[string]string
|
|
}
|
|
|
|
// PageInfo is a simplified page representation for plugins.
|
|
type PageInfo struct {
|
|
ID uuid.UUID
|
|
Slug string
|
|
Title string
|
|
}
|
|
|
|
// PostInfo is a simplified post representation for plugins. It carries enough
|
|
// for both a blog index (title/slug/excerpt/author/date/featured image) and a
|
|
// post detail view (Body — the rendered HTML). Body is populated by GetPost and
|
|
// by ListPosts when ListPostsParams.IncludeBody is set; it is empty otherwise.
|
|
type PostInfo struct {
|
|
ID uuid.UUID
|
|
Slug string
|
|
Title string
|
|
Excerpt string
|
|
Body string // rendered HTML; populated by GetPost / ListPosts(IncludeBody)
|
|
FeaturedImageURL string
|
|
AuthorID uuid.UUID
|
|
AuthorName string
|
|
AuthorSlug string
|
|
PublishedAt time.Time
|
|
}
|
|
|
|
// ListPostsParams filters and shapes a ListPosts query. The zero value lists
|
|
// published posts from the start with no category filter, excerpts included and
|
|
// bodies omitted (the cheap blog-index shape).
|
|
type ListPostsParams struct {
|
|
Limit int // 0 = host default
|
|
Offset int // pagination offset
|
|
Category string // optional category slug filter ("" = all)
|
|
PublishedOnly bool // reserved: plugins only ever see published posts
|
|
IncludeBody bool // render each post's body to HTML (expensive)
|
|
IncludeExcerpt bool // include the post excerpt
|
|
}
|
|
|
|
// Content provides content access for plugins.
|
|
// The CMS implements this interface and wires it into CoreServices.
|
|
type Content interface {
|
|
GetAuthorProfile(ctx context.Context, id uuid.UUID) (*AuthorProfile, error)
|
|
GetPage(ctx context.Context, slug string) (*PageInfo, error)
|
|
// PublishedBlockConfigs returns the stored content (config) of every block
|
|
// with the given key inside a currently published page snapshot. This is
|
|
// the server-authoritative source for per-block settings a sandboxed guest
|
|
// cannot query itself (e.g. whether any published booking block demands
|
|
// captcha) — never trust the same flags from the client request.
|
|
PublishedBlockConfigs(ctx context.Context, blockKey string) ([]map[string]any, error)
|
|
GetPost(ctx context.Context, slug string) (*PostInfo, error)
|
|
ListPosts(ctx context.Context, params ListPostsParams) ([]PostInfo, error)
|
|
Slugify(text string) string
|
|
BlockNoteToHTML(ctx context.Context, doc map[string]any) string
|
|
GenerateExcerpt(html string, maxLen int) string
|
|
StripHTML(s string) string
|
|
}
|