feature

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 38 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyStubsInStubs added in v0.4.0

func AnyStubsInStubs(src, tgt PageStubs) (found bool)

func AsTyped added in v0.2.15

func AsTyped[T interface{}](f Feature) (t T, ok bool)

func FilterTyped added in v0.2.15

func FilterTyped[T interface{}](list Features) (found []T)

func FirstTyped added in v0.2.15

func FirstTyped[T interface{}](list Features) (found T)

func MustTyped added in v0.2.15

func MustTyped[T interface{}](f Feature) (t T)

func RegisterPageMatcherFuncs added in v0.4.0

func RegisterPageMatcherFuncs(matchers ...MatcherFn)

Types

type Action added in v0.4.0

type Action string

Action is a kebab-cased name consisting of a verb, a subject (feature.Tag) and one or more additional details, separated by periods. For example: the action `view_fs-content_page` has a verb of "view", a subject of "fs-content" and one additional detail of "page". Details are individually converted to kebab-case and joined with hyphens, ie: `view_fs-content_page.search`

func NewAction added in v0.4.0

func NewAction(subject string, verb string, details ...string) Action

func ParseAction added in v0.4.0

func ParseAction(line string) (action Action)

func (Action) Details added in v0.4.0

func (a Action) Details() (details []string)

func (Action) String added in v0.4.0

func (a Action) String() string

func (Action) Subject added in v0.4.0

func (a Action) Subject() string

func (Action) Verb added in v0.4.0

func (a Action) Verb() string

type Actions added in v0.4.0

type Actions []Action

Actions are the collection of one or more groups

func NewActionsFromStringNL added in v0.4.0

func NewActionsFromStringNL(newlines string) (actions Actions)

func NewActionsFromStrings added in v0.4.0

func NewActionsFromStrings(slice ...string) (actions Actions)

func ParseActions added in v0.4.0

func ParseActions(lines string) (actions Actions, err error)

func (Actions) Append added in v0.4.0

func (a Actions) Append(actions ...Action) (modified Actions)

func (Actions) AsNewlines added in v0.4.0

func (a Actions) AsNewlines() (newlines string)

func (Actions) FilterKnown added in v0.4.0

func (a Actions) FilterKnown(other Actions) (known Actions)

func (Actions) FilterUnknown added in v0.4.0

func (a Actions) FilterUnknown(other Actions) (unknown Actions)

func (Actions) Has added in v0.4.0

func (a Actions) Has(action Action) (present bool)

func (Actions) HasSubject added in v0.4.0

func (a Actions) HasSubject(subject string) (present bool)

func (Actions) HasVerb added in v0.4.0

func (a Actions) HasVerb(verb string) (present bool)

func (Actions) Len added in v0.4.0

func (a Actions) Len() int

func (Actions) String added in v0.4.0

func (a Actions) String() (s string)

type ApplyMiddleware added in v0.1.0

type ApplyMiddleware interface {
	Feature
	Apply(s System) (err error)
}

type Author added in v0.4.0

type Author struct {
	Name     string
	Homepage string
}

type BaseMakePreset added in v0.4.0

type BaseMakePreset[MakeTypedPreset interface{}] interface {
	// Include specifies additional features to be included during the build phase
	Include(features ...Feature) MakeTypedPreset

	// Prepend includes the specified features before all other features within the preset
	Prepend(features ...Feature) MakeTypedPreset

	// OmitTags specifies preset Feature.Tag()s to be omitted during the build phase
	OmitTags(features ...Tag) MakeTypedPreset

	// Overload provides a replacement for an existing feature (by tag)
	// Note: panics if tag specified is not found
	Overload(tag Tag, feature Feature) MakeTypedPreset
}

type Buildable

type Buildable interface {
	Builder

	// MakeEnvKey returns name with EnvPrefix (SCREAMING_SNAKE formatted)
	MakeEnvKey(name string) (key string)

	// MakeEnvKeys returns name with EnvPrefix (SCREAMING_SNAKE formatted)
	MakeEnvKeys(names ...string) (key []string)

	// RegisterPublicFileSystem mounts the given static FileSystems
	RegisterPublicFileSystem(mount string, filesystems ...fs.FileSystem)

	// RegisterTemplatePartial sets the named go-template content for inclusion at the specified block and position
	// Notes:
	//    * "block" must be one of "head" or "body"
	//    * position must be one of "head" or "tail"
	//    * adds the given name tmpl to the first feature.TemplatePartialsProvider
	//    * auto-adds a feature.TemplatePartialsProvider if none are present
	RegisterTemplatePartial(block, position, name, tmpl string) (err error)
}

type Builder

type Builder interface {
	SiteTag(key string) Builder
	SiteName(name string) Builder
	SiteTagLine(title string) Builder

	SiteCopyrightName(name string) Builder
	SiteCopyrightNotice(notice string) Builder

	SiteLanguageMode(mode lang.Mode) Builder
	SiteDefaultLanguage(tag language.Tag) Builder
	SiteSupportedLanguages(tags ...language.Tag) Builder
	SiteLanguageDisplayNames(names map[language.Tag]string) Builder

	// Set a custom context key with value
	Set(key string, value interface{}) Builder

	// AddPreset includes the given presets just before the normal enjin Build() phase, presets are added in the same
	// order given and any features added will be inserted before all other enjin features present
	AddPreset(presets ...Preset) Builder

	// AddHtmlHeadTag adds a custom (singleton) HTML tag to the <head> section
	// of the page output, example meta tag:
	//   AddHtmlHeadTag("meta",map[string]string{"name":"og:thing","content":"stuff"})
	AddHtmlHeadTag(name string, attr map[string]string) Builder

	// AddDomains restricts inbound requests to only the domain names given
	AddDomains(domains ...string) Builder

	// AddFlags adds custom command line flags
	AddFlags(flags ...cli.Flag) Builder

	// AddCommands adds custom command line commands
	AddCommands(commands ...*cli.Command) Builder

	// AddConsole adds custom command line go-curses consoles (ctk.Window)
	AddConsole(c Console) Builder

	// AddFeature appends the given feature within the built Enjin (appends it to the end of the list of features
	// included)
	AddFeature(f Feature) Builder

	// PrependFeature prepends the given feature within the built Enjin (inserts it at the start of the list of
	// features included)
	PrependFeature(f Feature) Builder

	// AddRouteProcessor adds the given route processor to the Enjin route
	// processing middleware
	AddRouteProcessor(route string, processor ReqProcessFn) Builder

	// AddOutputTranslator adds the given output filter (for the given mime type)
	AddOutputTranslator(mime string, filter TranslateOutputFn) Builder

	// AddModifyHeadersFn adds the given headers.ModifyHeadersFn function to the
	// default headers enjin middleware layer
	AddModifyHeadersFn(fn headers.ModifyHeadersFn) Builder

	AddNotifyHook(name string, hook NotifyHook) Builder

	// AddPageFromString is a convenience wrapper around AddPage
	AddPageFromString(path, raw string) Builder

	// SetStatusPage overrides specific HTTP error pages, ie: 404
	SetStatusPage(status int, path string) Builder

	// AddTheme includes the given theme within the built Enjin
	AddTheme(t Theme) Builder

	// SetTheme configures the default theme
	SetTheme(name string) Builder

	// HotReload enables or disables hot-reloading theme templates and content files
	HotReload(enabled bool) Builder

	// SetPublicAccess specifies the list of actions unauthorized visitors have
	//
	// Note: not specifying any public access results in no public access given
	SetPublicAccess(actions ...Action) Builder

	// AddUserAction adds the given actions to the overall known list of
	// registered user actions across all features
	AddUserAction(actions ...Action) Builder

	// Build constructs an Enjin Runner from the Builder configuration
	Build() Runner
}

type CConsole

type CConsole struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*CConsole) Build

func (c *CConsole) Build(b Buildable) (err error)

func (*CConsole) Depends

func (c *CConsole) Depends() (deps Tags)

func (*CConsole) Init

func (c *CConsole) Init(this interface{})

func (*CConsole) Make

func (c *CConsole) Make() Console

func (*CConsole) Self

func (c *CConsole) Self() (self Console)

func (*CConsole) Tag

func (c *CConsole) Tag() (tag Tag)

func (*CConsole) This

func (c *CConsole) This() (this interface{})

type CEnjinBlock

type CEnjinBlock struct {
	CEnjinFeature
}

type CEnjinFeature

type CEnjinFeature struct {
	CFeature
}

func (*CEnjinFeature) NjnCheckClass

func (f *CEnjinFeature) NjnCheckClass(tagClass NjnClass) (allow bool)

func (*CEnjinFeature) NjnCheckTag

func (f *CEnjinFeature) NjnCheckTag(tagName string) (allow bool)

func (*CEnjinFeature) NjnClassAllowed

func (f *CEnjinFeature) NjnClassAllowed() (allowed NjnClass, ok bool)

func (*CEnjinFeature) NjnTagsAllowed

func (f *CEnjinFeature) NjnTagsAllowed() (allowed []string, ok bool)

func (*CEnjinFeature) NjnTagsDenied

func (f *CEnjinFeature) NjnTagsDenied() (denied []string, ok bool)

type CEnjinField

type CEnjinField struct {
	CEnjinFeature
}

type CFeature

type CFeature struct {
	PackageTag Tag
	FeatureTag Tag

	Enjin Internals

	sync.RWMutex
	// contains filtered or unexported fields
}

func (*CFeature) BaseTag added in v0.4.0

func (f *CFeature) BaseTag() (pkg Tag)

func (*CFeature) Build

func (f *CFeature) Build(b Buildable) (err error)

func (*CFeature) CloneBaseFeature added in v0.2.5

func (f *CFeature) CloneBaseFeature() (cloned CFeature)

func (*CFeature) Depends

func (f *CFeature) Depends() (deps Tags)

func (*CFeature) Init

func (f *CFeature) Init(this interface{})

func (*CFeature) Make

func (f *CFeature) Make() Feature

func (*CFeature) Self

func (f *CFeature) Self() (self Feature)

func (*CFeature) Setup

func (f *CFeature) Setup(enjin Internals)

func (*CFeature) Shutdown

func (f *CFeature) Shutdown()

func (*CFeature) Startup

func (f *CFeature) Startup(ctx *cli.Context) (err error)

func (*CFeature) Tag

func (f *CFeature) Tag() (tag Tag)

func (*CFeature) This

func (f *CFeature) This() (this interface{})

func (*CFeature) UsageNotes added in v0.4.0

func (f *CFeature) UsageNotes() (notes []string)

type CPreset added in v0.4.0

type CPreset[MakeTypedPreset interface{}] struct {
	Name     string
	Features Features
	// contains filtered or unexported fields
}

func (*CPreset[MakeTypedPreset]) Include added in v0.4.0

func (p *CPreset[MakeTypedPreset]) Include(features ...Feature) MakeTypedPreset

func (*CPreset[MakeTypedPreset]) IncludeFeature added in v0.4.0

func (p *CPreset[MakeTypedPreset]) IncludeFeature(b Builder, f Feature)

IncludeFeature will prepend the given feature to the Builder enjin, taking into account omissions and overloads

func (*CPreset[MakeTypedPreset]) Init added in v0.4.0

func (p *CPreset[MakeTypedPreset]) Init(this interface{})

func (*CPreset[MakeTypedPreset]) Label added in v0.4.0

func (p *CPreset[MakeTypedPreset]) Label() (name string)

func (*CPreset[MakeTypedPreset]) Make added in v0.4.0

func (p *CPreset[MakeTypedPreset]) Make() Preset

func (*CPreset[MakeTypedPreset]) OmitTags added in v0.4.0

func (p *CPreset[MakeTypedPreset]) OmitTags(features ...Tag) MakeTypedPreset

func (*CPreset[MakeTypedPreset]) Overload added in v0.4.0

func (p *CPreset[MakeTypedPreset]) Overload(tag Tag, feature Feature) MakeTypedPreset

func (*CPreset[MakeTypedPreset]) Prepend added in v0.4.0

func (p *CPreset[MakeTypedPreset]) Prepend(features ...Feature) MakeTypedPreset

func (*CPreset[MakeTypedPreset]) Preset added in v0.4.0

func (p *CPreset[MakeTypedPreset]) Preset(b Builder) (err error)

type CacheEnjinFeature added in v0.4.0

type CacheEnjinFeature interface {
	NewCache(bucket string) (err error)
	Mounted(bucket, path string) (ok bool)
	Mount(bucket, mount, path string, mfs fs.FileSystem)
	Rebuild(bucket string) (ok bool)
	Lookup(bucket string, tag language.Tag, url string) (mount, path string, p Page, err error)
	LookupTranslations(bucket, url string) (pgs []Page)
	LookupRedirect(bucket, url string) (p Page, ok bool)
	LookupPrefix(bucket, prefix string) (found []Page)
	TotalCached(bucket string) (count uint64)
}

type CanSetupInternals

type CanSetupInternals interface {
	Setup(enjin Internals)
}

type Console

type Console interface {
	Tag() (tag Tag)
	Init(this interface{})
	This() (this interface{})
	Self() (self Console)
	Build(c Buildable) (err error)
	Depends() (deps Tags)
}

type ContentSecurityPolicyModifier

type ContentSecurityPolicyModifier interface {
	Feature
	ModifyContentSecurityPolicy(policy csp.Policy, r *http.Request) (modified csp.Policy)
}

type DataRestrictionHandler

type DataRestrictionHandler interface {
	Feature
	RestrictServeData(data []byte, mime string, w http.ResponseWriter, r *http.Request) (modReq *http.Request, allow bool)
}

type Database

type Database interface {
	Feature

	// ListDB returns a sorted list of connected db tags for use with DB and
	// MustDB
	ListDB() (tags []string)

	// DB returns the database connection or an error
	DB(tag string) (db interface{}, err error)

	// MustDB returns the database connection or panics on error
	MustDB(tag string) (db interface{})
}

type EmailProvider added in v0.1.0

type EmailProvider interface {
	Feature
	NewEmail(basename string, bodyCtx beContext.Context) (message *gomail.Message, err error)
	MakeEmailBody(path string, ctx beContext.Context) (matter beContext.Context, body string, err error)
}

type EmailSender added in v0.1.0

type EmailSender interface {
	Feature
	HasEmailAccount(account string) (present bool)
	SendEmail(account string, message *gomail.Message) (err error)
}

type EnjinBlock

type EnjinBlock interface {
	EnjinFeature

	NjnBlockType() (name string)

	ProcessBlock(re EnjinRenderer, blockType string, data map[string]interface{}) (html template.HTML, redirect string, err error)

	PrepareBlock(re EnjinRenderer, blockType string, data map[string]interface{}) (block map[string]interface{}, redirect string, err error)
	RenderPreparedBlock(re EnjinRenderer, block map[string]interface{}) (html template.HTML, err error)
}

type EnjinContextProvider added in v0.4.0

type EnjinContextProvider interface {
	Feature
	EnjinContext() (ctx context.Context)
}

type EnjinFeature

type EnjinFeature interface {
	Feature

	NjnClass() (tagClass NjnClass)
	NjnCheckTag(tagName string) (allow bool)
	NjnCheckClass(tagClass NjnClass) (allow bool)
	NjnTagsAllowed() (allowed []string, ok bool)
	NjnTagsDenied() (denied []string, ok bool)
	NjnClassAllowed() (allowed NjnClass, ok bool)
}

type EnjinField

type EnjinField interface {
	EnjinFeature

	NjnFieldNames() (tagNames []string)

	PrepareNjnData(re EnjinRenderer, tagName string, field map[string]interface{}) (data map[string]interface{}, err error)
}

type EnjinRenderer

type EnjinRenderer interface {
	RequestArgv() (reqArgv *argv.RequestArgv)
	RequestContext() (ctx context.Context)

	RenderNjnTemplate(tag string, data map[string]interface{}) (html template.HTML, err error)

	ProcessBlock(data map[string]interface{}) (html template.HTML, redirect string, err error)

	PrepareBlock(data map[string]interface{}) (block map[string]interface{}, redirect string, err error)
	RenderPreparedBlock(block map[string]interface{}) (html template.HTML, err error)

	PrepareGenericBlockData(contentData interface{}) (blockDataContent map[string]interface{}, err error)
	PrepareGenericBlock(typeName string, data map[string]interface{}) (preparedData map[string]interface{})

	GetData() (data interface{})
	GetBlockIndex() (index int)

	GetWithinAside() (within bool)
	SetWithinAside(within bool)

	GetCurrentDepth() (depth int)
	IncCurrentDepth() (depth int)
	DecCurrentDepth() (depth int)

	GetHeadingCount() (count int)
	SetHeadingCount(count int)
	IncHeadingCount()

	GetHeadingLevel() (level int)
	SetHeadingLevel(level int)
	IncHeadingLevel()
	DecHeadingLevel()

	AddFootnote(blockIndex int, field map[string]interface{}) (index int)
	PrepareFootnotes(blockIndex int) (footnotes []map[string]interface{}, err error)

	ParseTypeName(data map[string]interface{}) (name string, ok bool)
	ParseFieldAndTypeName(data interface{}) (field map[string]interface{}, name string, ok bool)

	PrepareStringTags(text string) (data []interface{}, err error)
	WalkStringTags(doc *html.Node) (prepared []interface{})

	PrepareBlockHeader(content map[string]interface{}) (combined []interface{}, ok bool)
	PrepareBlockFooter(content map[string]interface{}) (combined []interface{}, ok bool)

	ParseBlockHeadingLevel(count, current int, blockData map[string]interface{}) (level, headingReset, headingLevel int)
	RenderBlockHeader(content map[string]interface{}) (html template.HTML, ok bool)
	RenderBlockFooter(content map[string]interface{}) (html template.HTML, ok bool)

	PrepareInlineFieldText(field map[string]interface{}) (combined []interface{}, err error)
	PrepareInlineFieldList(list []interface{}) (combined []interface{}, err error)
	PrepareInlineFields(fields []interface{}) (combined []interface{}, err error)
	PrepareInlineField(field map[string]interface{}) (prepared map[string]interface{}, err error)

	PrepareContainerFieldText(field map[string]interface{}) (fields []interface{}, err error)
	PrepareContainerFieldList(list []interface{}) (fields []interface{}, err error)
	PrepareContainerFields(fields []interface{}) (combined []map[string]interface{}, err error)
	PrepareContainerField(field map[string]interface{}) (prepared map[string]interface{}, err error)

	RenderInlineField(field map[string]interface{}) (combined []template.HTML, err error)
	RenderInlineFields(fields []interface{}) (combined []template.HTML, err error)
	RenderInlineFieldList(list []interface{}) (html template.HTML, err error)
	RenderInlineFieldText(field map[string]interface{}) (text template.HTML, err error)

	RenderContainerField(field map[string]interface{}) (combined []template.HTML, err error)
	RenderContainerFields(fields []interface{}) (combined []template.HTML, err error)
	RenderContainerFieldList(list []interface{}) (html template.HTML, err error)
	RenderContainerFieldText(field map[string]interface{}) (text template.HTML, err error)
}

type EnjinRunner

type EnjinRunner interface {
	Runner

	StartupString() (info string)

	Shutdown()

	Notify(tag string)
	NotifyF(tag, format string, argv ...interface{})
}

type EnjinSystem

type EnjinSystem interface {
	InlineFields() (field map[string]EnjinField)
	ContainerFields() (field map[string]EnjinField)
	InlineBlocks() (field map[string]EnjinBlock)
	ContainerBlocks() (field map[string]EnjinBlock)
	StringTags() (names []string)
	FindField(tagClass NjnClass, fieldType string) (field EnjinField, ok bool)
	FindBlock(tagClass NjnClass, blockType string) (block EnjinBlock, ok bool)
}

type Feature

type Feature interface {
	Init(this interface{})
	Tag() (tag Tag)
	BaseTag() (pkg Tag)
	This() (this interface{})
	Self() (f Feature)
	Depends() (deps Tags)
	UsageNotes() (notes []string)
	Build(c Buildable) (err error)
	Setup(enjin Internals)
	Startup(ctx *cli.Context) (err error)
	Shutdown()
}

type Features added in v0.2.0

type Features []Feature

func (Features) Find added in v0.2.0

func (f Features) Find(tag Tag) (found Feature)

func (Features) Len added in v0.2.15

func (f Features) Len() (count int)

type FeaturesCache added in v0.2.15

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

func NewFeaturesCache added in v0.2.15

func NewFeaturesCache() (cache *FeaturesCache)

func (*FeaturesCache) Add added in v0.2.15

func (c *FeaturesCache) Add(f Feature) (err error)

func (*FeaturesCache) Get added in v0.2.15

func (c *FeaturesCache) Get(tag Tag) (f Feature, ok bool)

func (*FeaturesCache) List added in v0.2.15

func (c *FeaturesCache) List() (list Features)

func (*FeaturesCache) MustGet added in v0.2.15

func (c *FeaturesCache) MustGet(tag Tag) (f Feature)

func (*FeaturesCache) Prepend added in v0.4.0

func (c *FeaturesCache) Prepend(f Feature) (err error)

func (*FeaturesCache) Tags added in v0.2.15

func (c *FeaturesCache) Tags() (list Tags)

type FileProvider added in v0.1.0

type FileProvider interface {
	Feature
	FindFile(url string) (data []byte, mime string, err error)
}

type FuncMap added in v0.4.0

type FuncMap textTemplate.FuncMap

func (FuncMap) Apply added in v0.4.0

func (fm FuncMap) Apply(other FuncMap)

func (FuncMap) AsHTML added in v0.4.0

func (fm FuncMap) AsHTML() htmlTemplate.FuncMap

func (FuncMap) AsTEXT added in v0.4.0

func (fm FuncMap) AsTEXT() textTemplate.FuncMap

type FuncMapProvider added in v0.4.0

type FuncMapProvider interface {
	Feature

	MakeFuncMap(ctx context.Context) (fm FuncMap)
}

type HeadersModifier

type HeadersModifier interface {
	Feature
	ModifyHeaders(w http.ResponseWriter, r *http.Request)
}

type Internals

type Internals interface {
	Service
	signaling.SignalsSupport
	SiteEnjin

	Self() (self interface{})

	Features() (cache *FeaturesCache)

	Pages() (pages map[string]Page)
	Theme() (theme string)
	Theming() (theming map[string]Theme)
	Headers() (headers []headers.ModifyHeadersFn)
	Domains() (domains []string)
	Consoles() (consoles map[Tag]Console)
	Processors() (processors map[string]ReqProcessFn)
	Translators() (translators map[string]TranslateOutputFn)
	Transformers() (transformers map[string]TransformOutputFn)
	Slugsums() (enabled bool)

	DB(tag string) (db interface{}, err error)
	MustDB(tag string) (db interface{})
	SpecificDB(fTag Tag, tag string) (db interface{}, err error)
	MustSpecificDB(fTag Tag, tag string) (db interface{})

	MakeFuncMap(ctx context.Context) (fm FuncMap)

	PublicFileSystems() (registry fs.Registry)

	ListTemplatePartials(block, position string) (names []string)
	GetTemplatePartial(block, position, name string) (tmpl string, ok bool)
}

type KeywordProvider added in v0.4.0

type KeywordProvider interface {
	Size() (count int)
	KnownKeywords() (keywords []string)
	KeywordStubs(keyword string) (stubs PageStubs)
	Range(fn func(key string, value []string) (proceed bool))
}

type LoggerContext added in v0.4.0

type LoggerContext interface {
	// URL is the parsed request URL
	URL() (parsed *url.URL)
	// Size is the number of response bytes
	Size() (size int)
	// StatusCode is the HTTP status code of the response
	StatusCode() (status int)
	// TimeStamp returns when the request was first received
	TimeStamp() (when time.Time)
	// Duration returns the total time taken to complete the request
	Duration() (duration time.Duration)
	// Request returns the request object
	Request() (r *http.Request)
}

LoggerContext is a per-request context used with ServiceLogger implementations

type MakeConsole

type MakeConsole interface {
	Make() Console
}

type MakeFeature

type MakeFeature interface {
	Make() Feature
}

type MakePreset added in v0.4.0

type MakePreset interface {
	Make() Preset

	BaseMakePreset[MakePreset]
}

func NewPresetWith added in v0.4.0

func NewPresetWith(name string, features ...Feature) MakePreset

type MatcherFn added in v0.4.0

type MatcherFn func(path string, pg Page) (found string, ok bool)

func GetPageMatcherFuncs added in v0.4.0

func GetPageMatcherFuncs() (funcs []MatcherFn)
type MenuProvider interface {
	Feature

	GetMenus(tag language.Tag) (found map[string]menu.Menu)
}

type MiddlewareFn

type MiddlewareFn = func(next http.Handler) (this http.Handler)

type NjnClass

type NjnClass uint
const (
	InlineNjnClass NjnClass = iota
	ContainerNjnClass
	AnyNjnClass
)

func (NjnClass) String

func (nc NjnClass) String() string

type NotifyHook

type NotifyHook = func(format string, argv ...interface{})

type OutputTransformer

type OutputTransformer interface {
	Feature
	CanTransform(mime string, r *http.Request) (ok bool)
	TransformOutput(mime string, input []byte) (output []byte)
}

type OutputTranslator

type OutputTranslator interface {
	Feature
	CanTranslate(mime string) (ok bool)
	TranslateOutput(s Service, input []byte, inputMime string) (output []byte, mime string, err error)
}

type Page added in v0.4.0

type Page interface {
	Type() (pageType string)
	Format() (pageFormat string)
	Url() (url string)
	Slug() (slug string)
	Path() (path string)

	Title() (title string)
	Summary() (summary string)
	Description() (description string)

	Layout() (layoutName string)
	Section() (section string)
	Archetype() (archetype string)

	Permalink() (id uuid.UUID)
	PermalinkSha() (shasum string)

	Language() (code string)
	LanguageTag() (tag language.Tag)
	Translates() (url string)

	Shasum() (shasum string)
	Content() (content string)
	FrontMatter() (frontMatter string)
	FrontMatterType() (frontMatterType matter.FrontMatterType)
	PageMatter() (pageMatter *matter.PageMatter)

	CreatedAt() (at time.Time)
	UpdatedAt() (at time.Time)
	DeletedAt() (at sql.NullTime)

	Context() (ctx beContext.Context)

	String() (jsonPage string)

	Match(path string) (found string, ok bool)
	MatchQL(query string) (ok bool, err error)
	MatchPrefix(prefix string) (found string, ok bool)
	Redirections() (redirects []string)
	IsRedirection(path string) (ok bool)
	IsTranslation(path string) (ok bool)
	HasTranslation() (ok bool)

	SetType(pageType string)
	SetFormat(pageFormat string) (path string)
	SetSlugUrl(url string)

	SetTitle(title string)
	SetSummary(summary string)
	SetDescription(description string)

	SetLayout(layoutName string)
	SetArchetype(archetype string)

	SetPermalink(value string) (err error)

	SetLanguage(tag language.Tag)
	SetTranslates(url string)

	SetContent(content string)

	SetFrontMatter(frontMatter string)
	SetFrontMatterType(frontMatterType matter.FrontMatterType)

	SetCreatedAt(at time.Time)
	SetUpdatedAt(at time.Time)
	SetDeletedAt(at sql.NullTime)

	Copy() (copy Page)
}

type PageContextFilterFn

type PageContextFilterFn = func(ctx context.Context, r *http.Request) (modCtx context.Context)

type PageContextModifier

type PageContextModifier interface {
	Feature
	FilterPageContext(themeCtx, pageCtx context.Context, r *http.Request) (themeOut context.Context)
}

type PageContextProvider added in v0.4.0

type PageContextProvider interface {
	FindPageStub(shasum string) (stub *PageStub)
	PageContextValuesCount(key string) (count uint64)
	PageContextValueCounts(key string) (counts map[interface{}]uint64)
	YieldPageContextValues(key string) (values chan interface{})
	YieldPageContextValueStubs(key string) (pairs chan *ValueStubPair)
	YieldFilterPageContextValueStubs(include bool, key string, value interface{}) (pairs chan *ValueStubPair)
	FilterPageContextValueStubs(include bool, key string, value interface{}) (stubs PageStubs)
}

type PageFormat added in v0.4.0

type PageFormat interface {
	Feature
	Name() (name string)
	Label() (label string)
	Extensions() (extensions []string)
	Prepare(ctx context.Context, content string) (out context.Context, err error)
	Process(ctx context.Context, content string) (html template.HTML, redirect string, err error)
	IndexDocument(pg Page) (doc interface{}, err error)
	NewDocumentMapping(tag language.Tag) (doctype, analyzer string, dm *mapping.DocumentMapping)
}

type PageFormatProvider added in v0.4.0

type PageFormatProvider interface {
	ListFormats() (names []string)
	GetFormat(name string) (format PageFormat)
	MatchFormat(filename string) (format PageFormat, match string)
}

type PageIndexFeature added in v0.4.0

type PageIndexFeature interface {
	AddToIndex(stub *PageStub, p Page) (err error)
	RemoveFromIndex(tag language.Tag, file, shasum string)
}

type PageProvider

type PageProvider interface {
	Feature
	FindRedirection(url string) (p Page)
	FindTranslations(url string) (pages []Page)
	FindPage(tag language.Tag, url string) (p Page)
	LookupPrefixed(prefix string) (pages []Page)
}

type PageRestrictionHandler

type PageRestrictionHandler interface {
	Feature
	RestrictServePage(ctx context.Context, w http.ResponseWriter, r *http.Request) (modCtx context.Context, modReq *http.Request, allow bool)
}

type PageShortcodeProcessor added in v0.4.0

type PageShortcodeProcessor interface {
	Feature
	TranslateShortcodes(content string, ctx context.Context) (modified string)
}

type PageStub added in v0.4.0

type PageStub struct {
	Origin   string
	FS       fs.FileSystem
	Point    string
	Shasum   string
	Source   string
	Language language.Tag
	Fallback language.Tag
	EnjinCtx beContext.Context
}

func NewPageStub added in v0.4.0

func NewPageStub(origin string, enjin beContext.Context, bfs fs.FileSystem, point, source, shasum string, fallback language.Tag) (s *PageStub)

func (*PageStub) GobDecode added in v0.4.0

func (ps *PageStub) GobDecode(data []byte) (err error)

func (*PageStub) GobEncode added in v0.4.0

func (ps *PageStub) GobEncode() (data []byte, err error)

func (*PageStub) MarshalBinary added in v0.4.0

func (ps *PageStub) MarshalBinary() (data []byte, err error)

func (*PageStub) UnmarshalBinary added in v0.4.0

func (ps *PageStub) UnmarshalBinary(data []byte) (err error)

type PageStubs added in v0.4.0

type PageStubs []*PageStub

func (PageStubs) GetShasum added in v0.4.0

func (s PageStubs) GetShasum(shasum string) (found *PageStub)

func (PageStubs) GetSource added in v0.4.0

func (s PageStubs) GetSource(source string) (found *PageStub)

func (PageStubs) HasShasum added in v0.4.0

func (s PageStubs) HasShasum(shasum string) (found bool)

func (PageStubs) Random added in v0.4.0

func (s PageStubs) Random() (stub *PageStub)

type PageTypeProcessor

type PageTypeProcessor interface {
	Feature
	ProcessRequestPageType(r *http.Request, p Page) (pg Page, redirect string, processed bool, err error)
}

type PermissionsPolicyModifier

type PermissionsPolicyModifier interface {
	Feature
	ModifyPermissionsPolicy(policy permissions.Policy, r *http.Request) (modified permissions.Policy)
}

type Preset added in v0.4.0

type Preset interface {
	Label() (name string)
	Preset(b Builder) (err error)
}

type Processor

type Processor interface {
	Feature
	Process(s Service, next http.Handler, w http.ResponseWriter, r *http.Request)
}

type QueryIndexFeature added in v0.4.0

type QueryIndexFeature interface {
	PerformQuery(input string) (stubs []*PageStub, err error)
	PerformSelect(input string) (selected map[string]interface{}, err error)
}

type ReqProcessFn

type ReqProcessFn = func(s Service, w http.ResponseWriter, r *http.Request) (ok bool)

type RequestFilter

type RequestFilter interface {
	Feature
	FilterRequest(r *http.Request) (err error)
}

type RequestFilterFn

type RequestFilterFn = func(r *http.Request) (err error)

type RequestModifier

type RequestModifier interface {
	Feature
	ModifyRequest(w http.ResponseWriter, r *http.Request)
}

type RequestRewriter

type RequestRewriter interface {
	Feature
	RewriteRequest(w http.ResponseWriter, r *http.Request) (modified *http.Request)
}

type RootInternals

type RootInternals interface {
	Internals

	SetupRootEnjin(ctx *cli.Context) (err error)
}

type RoutePagesHandler added in v0.4.0

type RoutePagesHandler interface {
	Feature
	RoutePage(w http.ResponseWriter, r *http.Request)
}

type Runner

type Runner interface {
	String() string
	Run(argv []string) (err error)
}

type SearchDocumentMapperFeature added in v0.4.0

type SearchDocumentMapperFeature interface {
	SearchDocumentMapping(tag language.Tag) (doctype string, dm *mapping.DocumentMapping)
	AddSearchDocumentMapping(tag language.Tag, indexMapping *mapping.IndexMappingImpl)
}

type SearchEnjinFeature added in v0.4.0

type SearchEnjinFeature interface {
	PrepareSearch(tag language.Tag, input string) (query string)
	PerformSearch(tag language.Tag, input string, size, pg int) (results *bleve.SearchResult, err error)
	AddToSearchIndex(stub *PageStub, p Page) (err error)
	RemoveFromSearchIndex(tag language.Tag, file, shasum string)
}

type ServePathFeature added in v0.1.0

type ServePathFeature interface {
	Feature
	ServePath(path string, s System, w http.ResponseWriter, r *http.Request) (err error)
}

type Service

type Service interface {
	Prefix() (prefix string)
	Context() (ctx context.Context)
	GetTheme() (t Theme, err error)
	MustGetTheme() (t Theme)
	ThemeNames() (names []string)
	ServerName() (name string)
	ServiceInfo() (scheme, listen string, port int)

	ContentSecurityPolicy() (handler *csp.PolicyHandler)
	PermissionsPolicy() (handler *permissions.PolicyHandler)

	ServeRedirect(destination string, w http.ResponseWriter, r *http.Request)

	Serve204(w http.ResponseWriter, r *http.Request)
	Serve400(w http.ResponseWriter, r *http.Request)
	Serve401(w http.ResponseWriter, r *http.Request)
	ServeBasic401(w http.ResponseWriter, r *http.Request)
	Serve403(w http.ResponseWriter, r *http.Request)
	Serve404(w http.ResponseWriter, r *http.Request)
	Serve405(w http.ResponseWriter, r *http.Request)
	Serve500(w http.ResponseWriter, r *http.Request)

	ServeNotFound(w http.ResponseWriter, r *http.Request)
	ServeInternalServerError(w http.ResponseWriter, r *http.Request)

	ServeStatusPage(status int, w http.ResponseWriter, r *http.Request)
	ServePage(p Page, w http.ResponseWriter, r *http.Request) (err error)
	ServePath(urlPath string, w http.ResponseWriter, r *http.Request) (err error)
	ServeJSON(v interface{}, w http.ResponseWriter, r *http.Request) (err error)
	ServeStatusJSON(status int, v interface{}, w http.ResponseWriter, r *http.Request) (err error)
	ServeData(data []byte, mime string, w http.ResponseWriter, r *http.Request)

	MatchQL(query string) (pages []Page)
	MatchStubsQL(query string) (stubs []*PageStub)
	SelectQL(query string) (selected map[string]interface{})

	CheckMatchQL(query string) (pages []Page, err error)
	CheckMatchStubsQL(query string) (stubs []*PageStub, err error)
	CheckSelectQL(query string) (selected map[string]interface{}, err error)

	FindPageStub(shasum string) (stub *PageStub)
	FindPage(tag language.Tag, url string) (p Page)
	FindFile(path string) (data []byte, mime string, err error)

	FindEmailAccount(account string) (emailSender EmailSender)
	SendEmail(account string, message *gomail.Message) (err error)

	GetPublicAccess() (actions Actions)
	FindAllUserActions() (list Actions)

	Notify(tag string)
	NotifyF(tag, format string, argv ...interface{})

	TranslateShortcodes(content string, ctx context.Context) (modified string)

	GetThemeRenderer(ctx context.Context) (renderer ThemeRenderer)

	signaling.EmitterSupport
}

type ServiceListener added in v0.4.0

type ServiceListener interface {
	Feature
	ServiceInfo() (scheme, listen string, port int)
	StopListening() (err error)
	StartListening(router *chi.Mux, e EnjinRunner) (err error)
}

type ServiceLogHandler added in v0.4.0

type ServiceLogHandler interface {
	Feature

	LogHandler(next http.Handler) (this http.Handler)
}

type ServiceLogger added in v0.4.0

type ServiceLogger interface {
	Feature

	RequestLogger(ctx LoggerContext) (err error)
}

type ServiceResponseLogger added in v0.4.0

type ServiceResponseLogger interface {
	Size() int
	Status() int
}

type SiteEnjin added in v0.4.0

type SiteEnjin interface {
	SiteTag() (key string)
	SiteName() (name string)
	SiteTagLine() (tagLine string)
	SiteLocales() (locales []language.Tag)
	SiteLangCatalog() (c *catalog.Catalog)
	SiteLanguageMode() (mode lang.Mode)
	SiteLanguageCatalog() (c catalog2.Catalog)
	SiteDefaultLanguage() (tag language.Tag)
	SiteSupportsLanguage(tag language.Tag) (supported bool)
	SiteLanguageDisplayName(tag language.Tag) (name string, ok bool)

	FindTranslations(url string) (pages []Page)
	FindPage(tag language.Tag, url string) (p Page)
	FindPages(prefix string) (pages []Page)
}

type SiteInfo added in v0.4.0

type SiteInfo struct {
	Tag         string
	Name        string
	TagLine     string
	Locales     []language.Tag
	LangMode    lang.Mode
	DefaultLang language.Tag
}

func MakeSiteInfo added in v0.4.0

func MakeSiteInfo(e SiteEnjin) (info SiteInfo)

type System

type System interface {
	Service
	signaling.SignalsSupport

	Router() (router *chi.Mux)
}

type Tag

type Tag string

Tag is the primary identifier type for enjin Feature implementations

const (
	NilTag   Tag = ""
	EnjinTag Tag = "enjin"
)
const NotImplemented Tag = "not-implemented"

func (Tag) Camel added in v0.1.0

func (t Tag) Camel() string

Camel returns the Tag as a CamelCased string

func (Tag) Equal added in v0.4.0

func (t Tag) Equal(other Tag) (same bool)

Equal returns true if the kebab-case of this Tag is the same as the kebab-case of the other Tag

func (Tag) IsNil added in v0.4.0

func (t Tag) IsNil() (empty bool)

IsNil returns true if the tag is empty

func (Tag) Kebab added in v0.1.0

func (t Tag) Kebab() string

Kebab returns the Tag as a kebab-cased string

func (Tag) ScreamingKebab added in v0.1.0

func (t Tag) ScreamingKebab() string

ScreamingKebab returns the Tag as a SCREAMING-KEBAB-CASED string

func (Tag) ScreamingSnake added in v0.1.0

func (t Tag) ScreamingSnake() string

ScreamingSnake returns the Tag as a SCREAMING_SNAKE_CASED string

func (Tag) Snake added in v0.1.0

func (t Tag) Snake() string

Snake returns the tag as a snake_cased string

func (Tag) String

func (t Tag) String() string

String returns the Tag as a string

type Tags

type Tags []Tag

func SortedFeatureTags added in v0.1.0

func SortedFeatureTags[V interface{}](data map[Tag]V) (tags Tags)

SortedFeatureTags returns a sortorder.Natural list of Tag keys

func StringsAsTags added in v0.1.0

func StringsAsTags(names []string) (tags Tags)

StringsAsTags returns a list of Tags based on the names given

func (Tags) Append

func (t Tags) Append(tag Tag) Tags

Append returns a list with the given tag appended

func (Tags) Has

func (t Tags) Has(tag Tag) bool

Has returns true if the list of Tags includes the given tag

func (Tags) Len

func (t Tags) Len() int

Len returns the number of tags

func (Tags) Strings added in v0.1.0

func (t Tags) Strings() (names []string)

Strings returns the list of Tags as a string slice

func (Tags) Unique added in v0.1.0

func (t Tags) Unique() (tags Tags)

Unique returns a list of unique tags, maintaining their original order

type TemplatePartialsProvider added in v0.4.0

type TemplatePartialsProvider interface {
	Feature
	RegisterTemplatePartial(block, position, name, tmpl string) (err error)
	ListTemplatePartials(block, position string) (names []string)
	GetTemplatePartial(block, position, name string) (tmpl string, ok bool)
}

type Theme added in v0.4.0

type Theme interface {
	Name() (name string)
	Reload() (err error)

	GetParent() (parent Theme)
	GetBlockThemeNames() (names []string)

	ThemeFS() fs.FileSystem
	StaticFS() fs.FileSystem
	Locales() (locales fs.FileSystem, ok bool)

	GetConfig() (config ThemeConfig)

	Layouts() ThemeLayouts
	FindLayout(named string) (layout ThemeLayout, name string, ok bool)

	AddFormatProvider(providers ...PageFormatProvider)
	PageFormatProvider

	Middleware(next http.Handler) http.Handler

	NewHtmlTemplate(enjin Internals, name string, ctx context.Context) (tmpl *htmlTemplate.Template, err error)
	NewTextTemplate(enjin Internals, name string, ctx context.Context) (tmpl *textTemplate.Template, err error)
}

type ThemeConfig added in v0.4.0

type ThemeConfig struct {
	Name        string
	Parent      string
	License     string
	LicenseLink string
	Description string
	Homepage    string
	Authors     []Author
	Extends     string

	RootStyles  []htmlTemplate.CSS
	BlockStyles map[string][]htmlTemplate.CSS
	BlockThemes map[string]map[string]interface{}

	FontawesomeLinks   map[string]string
	FontawesomeClasses []string

	CacheControl string

	PermissionsPolicy     []permissions.Directive
	ContentSecurityPolicy csp.ContentSecurityPolicyConfig

	Context context.Context
}

type ThemeLayout added in v0.4.0

type ThemeLayout interface {
	Name() (name string)

	NewHtmlTemplate(enjin Internals, ctx context.Context) (tmpl *htmlTemplate.Template, err error)
	NewTextTemplate(enjin Internals, ctx context.Context) (tmpl *textTemplate.Template, err error)

	NewHtmlTemplateFrom(enjin Internals, parent ThemeLayout, ctx context.Context) (tmpl *htmlTemplate.Template, err error)
	NewTextTemplateFrom(enjin Internals, parent ThemeLayout, ctx context.Context) (tmpl *textTemplate.Template, err error)

	ApplyHtmlTemplate(enjin Internals, tt *htmlTemplate.Template, ctx context.Context) (err error)
	ApplyTextTemplate(enjin Internals, tt *textTemplate.Template, ctx context.Context) (err error)
}

type ThemeLayouts added in v0.4.0

type ThemeLayouts interface {
	GetLayout(name string) (layout ThemeLayout)
	SetLayout(name string, layout ThemeLayout)

	NewHtmlTemplate(enjin Internals, name string, ctx context.Context) (tmpl *htmlTemplate.Template, err error)
	NewTextTemplate(enjin Internals, name string, ctx context.Context) (tmpl *textTemplate.Template, err error)

	ApplyHtmlTemplates(enjin Internals, tmpl *htmlTemplate.Template, ctx context.Context) (err error)
	ApplyTextTemplates(enjin Internals, tmpl *textTemplate.Template, ctx context.Context) (err error)
}

type ThemeRenderer added in v0.4.0

type ThemeRenderer interface {
	Feature
	Render(view string, ctx context.Context) (data []byte, err error)
	RenderPage(ctx context.Context, p Page) (data []byte, redirect string, err error)

	NewHtmlTemplateWith(name string, ctx context.Context) (tt *htmlTemplate.Template, err error)
	NewTextTemplateWith(name string, ctx context.Context) (tt *textTemplate.Template, err error)

	RenderHtmlTemplateContent(ctx context.Context, tmplContent string) (rendered string, err error)
	RenderTextTemplateContent(ctx context.Context, tmplContent string) (rendered string, err error)

	NewHtmlTemplateFromContext(view string, ctx context.Context) (tt *htmlTemplate.Template, err error)
	NewTextTemplateFromContext(view string, ctx context.Context) (tt *textTemplate.Template, err error)
}

type TransformOutputFn

type TransformOutputFn = func(input []byte) (output []byte)

type TranslateOutputFn

type TranslateOutputFn = func(input []byte) (output []byte, mime string)

type UseMiddleware added in v0.1.0

type UseMiddleware interface {
	Feature
	Use(s System) MiddlewareFn
}

type ValueStubPair added in v0.4.0

type ValueStubPair struct {
	Value interface{}
	Stub  *PageStub
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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