contentpage

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHashFromURL

func ExtractHashFromURL(rawURL string) string

Types

type ContentPageHandler

type ContentPageHandler struct {
	// contains filtered or unexported fields
}

func NewContentPageHandler

func NewContentPageHandler(
	contentService ContentService,
	postTypeResolver PostTypeResolver,
	userFieldResolver UserFieldResolver,
	userProvider UserProvider,
	templates *tpl.Templates,
	renderer tiptap.Renderer,
	mediaRepo mediadomain.Repository,
	languages []string,
	homepageSections []config.HomepageSection,
	siteConfig config.SiteConfig,
	postsPerPage int,
) *ContentPageHandler

func (*ContentPageHandler) Assembler added in v0.8.0

func (h *ContentPageHandler) Assembler() *DataAssembler

func (*ContentPageHandler) ServeHTTP

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

func (*ContentPageHandler) WithPublicFieldRegistry added in v0.7.0

func (h *ContentPageHandler) WithPublicFieldRegistry(registry PublicFieldLookup) *ContentPageHandler

WithPublicFieldRegistry attaches a [[public_field]] registry to the handler so the author HTML page can discover which user system fields are allowlisted with the "expose" operation and render them. When not called (or called with nil), no system fields appear — the safe default. Returns the receiver for chaining at construction time.

type ContentService

type ContentService interface {
	GetPublished(ctx context.Context, limit int, offset int) ([]*contentdomain.Content, error)
	GetPublishedBySlugAny(ctx context.Context, slug string) (*contentdomain.Content, error)
	GetPublishedByID(ctx context.Context, id int) (*contentdomain.Content, error)
	GetPublishedByAuthorUsername(ctx context.Context, username string, language string, limit int, offset int) ([]*contentdomain.Content, error)
	AuthorExists(ctx context.Context, username string) (bool, error)
	GetPublishedPages(ctx context.Context) ([]*contentdomain.Content, error)
	GetPublishedCustomPostTypes(ctx context.Context) ([]string, error)
	GetPublishedByPostType(ctx context.Context, postType string, language string, year int, month int, limit int, offset int) ([]*contentdomain.Content, error)
	GetPublishedByTag(ctx context.Context, tag string, language string, year int, month int, limit int, offset int) ([]*contentdomain.Content, error)
	GetPublishedTags(ctx context.Context) ([]string, error)
	GetCommentsForContent(ctx context.Context, contentID int) ([]*contentdomain.Comment, error)
	GetTranslations(ctx context.Context, translationGroupID int, excludeID int) ([]*contentdomain.Content, error)
	GetRelated(ctx context.Context, id int, limit int) ([]*contentdomain.Content, error)
}

type DataAssembler added in v0.8.0

type DataAssembler struct {
	// contains filtered or unexported fields
}

func NewDataAssembler added in v0.8.0

func NewDataAssembler(
	contentService ContentService,
	postTypeResolver PostTypeResolver,
	userFieldResolver UserFieldResolver,
	userProvider UserProvider,
	renderer tiptap.Renderer,
	mediaRepo mediadomain.Repository,
	languages []string,
	homepageSections []config.HomepageSection,
	siteConfig config.SiteConfig,
	postsPerPage int,
) *DataAssembler

func (*DataAssembler) BuildAuthorData added in v0.8.0

func (a *DataAssembler) BuildAuthorData(ctx context.Context, username string, page int) (tpl.AuthorData, error)

func (*DataAssembler) BuildContentData added in v0.8.0

func (a *DataAssembler) BuildContentData(ctx context.Context, slug string) (tpl.ContentData, error)

func (*DataAssembler) BuildHomeData added in v0.8.0

func (a *DataAssembler) BuildHomeData(ctx context.Context, page, year, month int) (tpl.IndexData, error)

func (*DataAssembler) BuildIndexData added in v0.8.0

func (a *DataAssembler) BuildIndexData(ctx context.Context, postTypeSlug string, page, year, month int) (tpl.IndexData, error)

func (*DataAssembler) BuildNotFoundData added in v0.8.0

func (a *DataAssembler) BuildNotFoundData(ctx context.Context, currentPath string) tpl.NotFoundData

func (*DataAssembler) BuildTagData added in v0.8.0

func (a *DataAssembler) BuildTagData(ctx context.Context, tag string, page, year, month int) (tpl.TagData, error)

func (*DataAssembler) ContentService added in v0.8.0

func (a *DataAssembler) ContentService() ContentService

func (*DataAssembler) Languages added in v0.8.0

func (a *DataAssembler) Languages() []string

func (*DataAssembler) PostsPerPage added in v0.8.0

func (a *DataAssembler) PostsPerPage() int

func (*DataAssembler) PrimaryLanguage added in v0.8.0

func (a *DataAssembler) PrimaryLanguage() string

func (*DataAssembler) Renderer added in v0.8.0

func (a *DataAssembler) Renderer() tiptap.Renderer

func (*DataAssembler) SiteConfig added in v0.8.0

func (a *DataAssembler) SiteConfig() tpl.SiteConfig

func (*DataAssembler) WithPublicFieldRegistry added in v0.8.0

func (a *DataAssembler) WithPublicFieldRegistry(registry PublicFieldLookup) *DataAssembler

type PostTypeResolver

type PostTypeResolver interface {
	GetBySlug(slug string) (posttype.PostType, error)
}

type PublicFieldLookup added in v0.7.0

type PublicFieldLookup interface {
	ExposedFields(resource, postType string) []string
}

PublicFieldLookup is the interface the ContentPageHandler uses to discover which user custom/system field slugs are allowlisted with the "expose" operation in the [[public_field]] config. Defining it locally keeps the contentpage package decoupled from the config package and testable with a stub.

type UserBasicInfo

type UserBasicInfo struct {
	Name           string
	Username       string
	CustomFields   map[string]any
	ProfilePicture string
}

type UserFieldResolver

type UserFieldResolver interface {
	GetUserFields() []customfield.FieldSchema
	GetUserSystemFields() []customfield.FieldSchema
}

type UserProvider

type UserProvider interface {
	GetUserByUsername(ctx context.Context, username string) (*UserBasicInfo, error)
}

func NewUserRepoAdapter

func NewUserRepoAdapter(getUser func(ctx context.Context, username string) (*UserBasicInfo, error)) UserProvider

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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