contentpage

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 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) 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 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