feature

package
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 50 Imported by: 15

Documentation

Index

Constants

View Source
const (
	PreLockFileSignal            signaling.Signal = "pre-lock-file"
	LockFileSignal               signaling.Signal = "lock-file"
	PreUnlockFileSignal          signaling.Signal = "pre-unlock-file"
	UnlockFileSignal             signaling.Signal = "unlock-file"
	PreMoveFileSignal            signaling.Signal = "pre-move-file"
	MoveFileSignal               signaling.Signal = "move-file"
	PreCopyFileSignal            signaling.Signal = "pre-copy-file"
	CopyFileSignal               signaling.Signal = "copy-file"
	PrePublishFileSignal         signaling.Signal = "pre-publish-file"
	PublishFileSignal            signaling.Signal = "publish-file"
	PreRepublishFileSignal       signaling.Signal = "pre-republish-file"
	RepublishFileSignal          signaling.Signal = "republish-file"
	PreDeleteFileSignal          signaling.Signal = "pre-delete-file"
	DeleteFileSignal             signaling.Signal = "delete-file"
	PreDeletePathSignal          signaling.Signal = "pre-delete-path"
	DeletePathSignal             signaling.Signal = "delete-path"
	PreRetakeFileSignal          signaling.Signal = "pre-retake-file"
	RetakeFileSignal             signaling.Signal = "retake-file"
	PreCommitFileSignal          signaling.Signal = "pre-commit-file"
	CommitFileSignal             signaling.Signal = "commit-file"
	FileNameRequiredSignal       signaling.Signal = "file-name-required"
	PreTranslateFileActionSignal signaling.Signal = "pre-translate-file"
	TranslateFileActionSignal    signaling.Signal = "translate-file"
	PreChangeActionSignal        signaling.Signal = "pre-change-action"
	ChangeActionSignal           signaling.Signal = "change-action"
)
View Source
const (
	UserNoticesRequestKey request.Key = "user-notices"
)

Variables

This section is empty.

Functions

func AddErrorNotice added in v0.5.0

func AddErrorNotice(r *http.Request, dismiss bool, message string, argv ...interface{}) (modified *http.Request)

func AddImportantNotice added in v0.5.0

func AddImportantNotice(r *http.Request, dismiss bool, message string, argv ...interface{}) (modified *http.Request)

func AddInfoNotice added in v0.5.0

func AddInfoNotice(r *http.Request, dismiss bool, message string, argv ...interface{}) (modified *http.Request)

func AddUserNotices added in v0.5.0

func AddUserNotices(r *http.Request, notes ...*UserNotice) (modified *http.Request)

func AddWarnNotice added in v0.5.0

func AddWarnNotice(r *http.Request, dismiss bool, message string, argv ...interface{}) (modified *http.Request)

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 FilterUserNotices added in v0.5.0

func FilterUserNotices(r *http.Request, fn func(notice *UserNotice) (keep bool)) (m *http.Request)

func FirstTyped added in v0.2.15

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

func GetTyped added in v0.5.0

func GetTyped[T interface{}](tag Tag, list Features) (f T, err error)

func MakeRawPage added in v0.5.0

func MakeRawPage(matter context.Context, content string) (raw string)

func MustTyped added in v0.2.15

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

func ParseEditorOpKey added in v0.5.0

func ParseEditorOpKey(action string) (op, tgt string)

func ParseEditorOpTargetValue added in v0.5.0

func ParseEditorOpTargetValue(target string) (tgt, value string)

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 periods, 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) IsNil added in v0.5.0

func (a Action) IsNil() (empty bool)

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 user Action permissions

func ParseActions added in v0.4.0

func ParseActions(lines ...string) (actions Actions)

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) Bytes added in v0.5.0

func (a Actions) Bytes() (data []byte)

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) HasAllOf added in v0.5.0

func (a Actions) HasAllOf(actions Actions) (present bool)

func (Actions) HasOneOf added in v0.5.0

func (a Actions) HasOneOf(actions Actions) (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 AuthProvider added in v0.5.0

type AuthProvider interface {
	Feature

	AuthenticateRequest(w http.ResponseWriter, r *http.Request) (handled bool, modified *http.Request)
}

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
	signaling.SignalSupport

	// 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)

	// Features provides access to the cache of enjin features
	Features() (cache *FeaturesCache)
}

type Builder

type Builder interface {
	// SiteTag is the programmatic tag for identifying this particular enjin
	SiteTag(key string) Builder
	// SiteName is the name of the site, typically used in the branding header and browser tab titles
	SiteName(name string) Builder
	// SiteTagLine is an optional bit of text to display under the site name in the branding header
	SiteTagLine(title string) Builder

	// SiteCopyrightName specifies the first component of a standard copyright declaration for the site
	SiteCopyrightName(name string) Builder
	// SiteCopyrightYear specifies the year component of a standard copyright declaration and if left empty, the current
	// year is used in its place
	SiteCopyrightYear(year string) Builder
	// SiteCopyrightNotice specifies the last component of a standard copyright declaration and if left empty, the
	// phrase "All rights reserved" is used in its place
	SiteCopyrightNotice(notice string) Builder

	// SetEnjinTextFn is the means for translating the site name, tag line and copyright components at runtime using a
	// language printer for every request to the site
	SetEnjinTextFn(fn EnjinTextFn) 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

	// SetAlwaysHtmlRedirect configures the enjin to always use the HTML meta tag http-equiv=refresh method of
	// redirecting visitors to another page, the default is to use HTTP status 303 (See other) header redirections
	// unless explicitly calling the enjin ServeHtmlRedirect method
	SetAlwaysHtmlRedirect(always bool) Builder

	// SetHtmlRedirectDelay specifies the number of seconds to delay visitors when performing ServeHtmlRedirect calls,
	// the default is 0 seconds (immediately on load)
	SetHtmlRedirectDelay(seconds int) 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

	// AddModifyContentSecurityPolicyFn includes the given CSP modifier function with each request
	AddCspModifierFn(tag string, fn CspModifierFn) 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 {
	CNjnFeature
}

type CEnjinField

type CEnjinField struct {
	CNjnFeature
}

type CFeature

type CFeature struct {
	KebabTag   string
	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) Construct added in v0.5.0

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

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) SetState added in v0.5.6

func (f *CFeature) SetState(state LifeCycleState)

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) State added in v0.5.6

func (f *CFeature) State() (state LifeCycleState)

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 CMountPoint added in v0.5.0

type CMountPoint struct {
	// Path is the actual filesystem path
	Path string
	// Mount is the URL path prefix
	Mount string
	// ROFS is the read-only filesystem, always non-nil
	ROFS fs.FileSystem
	// RWFS is the write-only filesystem, nil when fs is read-only
	RWFS fs.RWFileSystem
}

type CNjnFeature added in v0.5.0

type CNjnFeature struct {
	CFeature
}

func (*CNjnFeature) NjnCheckClass added in v0.5.0

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

func (*CNjnFeature) NjnCheckTag added in v0.5.0

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

func (*CNjnFeature) NjnClassAllowed added in v0.5.0

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

func (*CNjnFeature) NjnTagsAllowed added in v0.5.0

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

func (*CNjnFeature) NjnTagsDenied added in v0.5.0

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

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 CSiteAuthClaims added in v0.5.0

type CSiteAuthClaims struct {
	// RID is the Real ID of the user
	RID string
	// EID is the Enjin ID of the user
	EID string
	// Email is the email address of the user
	Email string
	// Context is the variable metadata related to the user
	Context beContext.Context

	jwt.RegisteredClaims
}

func (*CSiteAuthClaims) GetAllFactors added in v0.5.0

func (c *CSiteAuthClaims) GetAllFactors() (factors SiteAuthClaimsFactors)

func (*CSiteAuthClaims) GetAudience added in v0.5.0

func (c *CSiteAuthClaims) GetAudience() (name string)

GetAudience returns the first name in the .Audience ClaimStrings list

func (*CSiteAuthClaims) GetFactor added in v0.5.0

func (c *CSiteAuthClaims) GetFactor(kebab, name string) (factor *CSiteAuthClaimsFactor, ok bool)

func (*CSiteAuthClaims) GetFactors added in v0.5.0

func (c *CSiteAuthClaims) GetFactors(kebab string) (factors SiteAuthClaimsFactors)

func (*CSiteAuthClaims) GetVerifiedFactor added in v0.5.0

func (c *CSiteAuthClaims) GetVerifiedFactor(target string) (factor *CSiteAuthClaimsFactor, ok bool)

func (*CSiteAuthClaims) ResetFactorValueTypes added in v0.5.0

func (c *CSiteAuthClaims) ResetFactorValueTypes()

ResetFactorValueTypes will check all factors and verifications for factors-as-maps and convert them to their proper concrete types

func (*CSiteAuthClaims) RevokeFactor added in v0.5.0

func (c *CSiteAuthClaims) RevokeFactor(kebab, name string)

func (*CSiteAuthClaims) RevokeFactors added in v0.5.0

func (c *CSiteAuthClaims) RevokeFactors(kebab string)

func (*CSiteAuthClaims) RevokeVerifiedFactor added in v0.5.0

func (c *CSiteAuthClaims) RevokeVerifiedFactor(target string)

func (*CSiteAuthClaims) SetFactor added in v0.5.0

func (c *CSiteAuthClaims) SetFactor(factor *CSiteAuthClaimsFactor)

func (*CSiteAuthClaims) SetVerifiedFactor added in v0.5.0

func (c *CSiteAuthClaims) SetVerifiedFactor(target string, factor *CSiteAuthClaimsFactor)

type CSiteAuthClaimsFactor added in v0.5.0

type CSiteAuthClaimsFactor struct {
	// K is a kebab-cased feature.Tag
	K string `json:"k"`
	// N is a user-provided label for this factor
	N string `json:"n"`
	// E is an expiration unix epoch
	E int64 `json:"e"`
	// T is a timestamp unix epoch
	T int64 `json:"t"`
	// C is the challenge provided by the user
	C string `json:"c"`
}

func NewSiteAuthClaimsFactor added in v0.5.0

func NewSiteAuthClaimsFactor(k, n string, e, t int64, c string) (p *CSiteAuthClaimsFactor)

func ParseSiteAuthClaimsFactor added in v0.5.0

func ParseSiteAuthClaimsFactor(m map[string]interface{}) (p *CSiteAuthClaimsFactor, ok bool)

func (CSiteAuthClaimsFactor) ToMap added in v0.5.0

func (p CSiteAuthClaimsFactor) ToMap() (m map[string]interface{})

type CSiteAuthMultiFactorInfo added in v0.5.0

type CSiteAuthMultiFactorInfo struct {
	CSiteFeatureInfo
	// Ready is true when the current user has at least one provisioned factor of this type
	Ready bool `json:"ready"`
	// Factors is the list of provisioned factors, of this type, ready for challenging the current user
	Factors []string `json:"factors"`
	// Claimed is the list of provisioned factors which are present in the current user's claims
	Claimed []string `json:"claimed"`
	// Submit indicates whether to submit the feature.Tag in order to initiate the challenge process
	Submit bool `json:"submit"`
}

func NewSiteAuthMultiFactorInfo added in v0.5.0

func NewSiteAuthMultiFactorInfo(tag, key, icon, label string, factors ...string) (info *CSiteAuthMultiFactorInfo)

type CSiteFeatureInfo added in v0.5.0

type CSiteFeatureInfo struct {
	// Tag is the kebab-cased feature.Tag
	Tag string `json:"tag"`
	// Key is a different kebab-cased tag than Tag
	Key string `json:"key"`
	// Icon is a font-awesome icon class
	Icon string `json:"icon"`
	// Label is a translated string label
	Label string `json:"label"`
	// Usage is a sentence or two describing how to use this feature
	Usage string `json:"usage"`
	// Hint is used in multiple-step authentications, typically as a button's title attribute
	Hint string `json:"hint"`
	// Placeholder is the string of text displayed in the challenge form input tag
	Placeholder string `json:"placeholder"`
	// Backup indicates whether this feature is a backup feature or not
	Backup bool `json:"backup"`
}

func NewSiteFeatureInfo added in v0.5.0

func NewSiteFeatureInfo(tag, key, icon, label string) (info *CSiteFeatureInfo)

type CanSetupInternals

type CanSetupInternals interface {
	Setup(enjin Internals)
}

type CloudTag added in v0.5.11

type CloudTag struct {
	Word   string
	Link   string
	Count  int
	Weight int
}

type CloudTagPage added in v0.5.11

type CloudTagPage struct {
	Title   string
	Url     string
	Created time.Time
	Updated time.Time
	Tags    TagCloud
}

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 CspModifierFn added in v0.5.1

type CspModifierFn func(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 EditorFeature added in v0.5.0

type EditorFeature interface {
	SiteFeature
	signaling.Signaling
	UserActionsProvider

	SelfEditor() (self EditorFeature)
	SetupEditor(editor EditorSite)
	SetupEditorRoute(r chi.Router)
	EditorMenu(r *http.Request) (m menu.Menu)

	GetEditorKey() (name string)
	GetEditorPath() (path string)
	GetEditorMenu() (m menu.Menu)

	PrepareEditPage(pageType, editorType string, r *http.Request) (pg Page, ctx beContext.Context, err error)
	ParseEditorUrlParams(r *http.Request) (fsid, code, file string, locale *language.Tag)
	ServePreparedEditPage(pg Page, ctx beContext.Context, w http.ResponseWriter, r *http.Request)

	UpdatePathInfo(info *editor.File, r *http.Request)
	UpdateFileInfo(info *editor.File, r *http.Request)
	UpdateFileInfoForEditing(info *editor.File, r *http.Request)
	PrepareEditableFile(r *http.Request, info *editor.File) (editFile *editor.File)

	ListFileSystems() (list editor.Files)
	ListFileSystemLocales(fsid string) (list editor.Files)
	ListFileSystemDirectories(r *http.Request, fsid, code, dirs string) (list editor.Files)
	ListFileSystemFiles(r *http.Request, fsid, code, dirs string) (list editor.Files)
	ProcessMountPointFile(r *http.Request, printer *message.Printer, eid, mpfBTag, mpfTag, code, dirs, file string, mountPoint *CMountPoint, draftWork bool) (ef *editor.File, ignored bool)

	LockEditorFile(eid, fsid, filePath string) (err error)
	IsEditorFileLocked(fsid, filePath string) (eid string, locked bool)
	UnLockEditorFile(fsid, filePath string) (err error)

	FileExists(info *editor.File) (exists bool)
	ReadFile(info *editor.File) (data []byte, err error)
	WriteFile(info *editor.File, data []byte) (err error)
	RemoveFile(info *editor.File) (err error)
	RemoveDirectory(info *editor.File) (err error)

	DraftExists(info *editor.File) (present bool)
	ReadDraft(info *editor.File) (contents []byte, err error)
	ReadDraftMatter(info *editor.File) (pm *matter.PageMatter, err error)
	WriteDraft(info *editor.File, contents []byte) (err error)
	RemoveDraft(info *editor.File) (err error)
	PublishDraft(info *editor.File) (err error)

	RenderFileBrowser(w http.ResponseWriter, r *http.Request)
	RenderFileEditor(w http.ResponseWriter, r *http.Request)
	ReceiveFileEditorChanges(w http.ResponseWriter, r *http.Request)

	OpFileUnlockHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
	OpFileRetakeHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
	OpFileDeleteValidate(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)
	OpFileDeleteHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
	OpFileCommitValidate(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)
	OpFileCommitHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
	OpFilePublishValidate(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)
	OpFilePublishHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
	OpFileCancelValidate(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)
	OpFileCancelHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
	OpFileMoveValidate(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)
	OpFileMoveHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
	OpFileCopyValidate(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)
	OpFileCopyHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
	OpFileTranslateValidate(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)
	OpFileTranslateHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)

	OpPathDeleteValidate(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)
	OpPathDeleteHandler(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)
}

type EditorMakeFeature added in v0.5.0

type EditorMakeFeature[MakeTypedFeature interface{}] interface {
	SiteMakeFeature[MakeTypedFeature]

	SetEditorName(name string) MakeTypedFeature
	SetEditorType(editorType string) MakeTypedFeature
	SetEditingTags(tags ...Tag) MakeTypedFeature
}

type EditorOperation added in v0.5.0

type EditorOperation struct {
	// Key is the submit button kebab-cased value
	Key string `json:"key"`
	// Confirm is the confirmation form parameter, leave empty for no confirmation step
	Confirm string `json:"confirm,omitempty"`
	// Action is the permission users are required to have in order to perform the operation
	Action Action
	// Validate is the handler called to sanitize the form ctx
	Validate EditorValidateFn
	// Operation is the handler called to perform the operation
	Operation EditorOperationFn
}

type EditorOperationFn added in v0.5.0

type EditorOperationFn = func(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (redirect string)

type EditorSite added in v0.5.0

type EditorSite interface {
	SiteFeature

	ListPageTypes() (values []string)
	ListPageLayouts() (names []string)
}

type EditorValidateFn added in v0.5.0

type EditorValidateFn = func(r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string) (err error)

type EmailProvider added in v0.1.0

type EmailProvider interface {
	Feature

	NewEmail(path string, bodyCtx beContext.Context) (message *gomail.Message, err error)
	MakeEmailBody(path string, ctx beContext.Context) (matter beContext.Context, body string, err error)

	ListTemplates() (names []string)
	HasTemplate(name string) (present bool)
}

type EmailSender added in v0.1.0

type EmailSender interface {
	Feature

	HasEmailAccount(account string) (present bool)
	SendEmail(r *http.Request, account string, message *gomail.Message) (err error)
}

type EnjinBase added in v0.5.0

type EnjinBase interface {
	SiteTag() (key string)
	SiteName() (name string)
	SiteTagLine() (tagLine string)

	SiteCopyrightName() (name string)
	SiteCopyrightYear() (year string)
	SiteCopyrightNotice() (notice string)

	SiteLocales() (locales cllang.Tags)
	SiteLanguageMode() (mode lang.Mode)
	SiteLanguageCatalog() (c catalog.Catalog)
	SiteDefaultLanguage() (tag language.Tag)
	SiteSupportsLanguage(tag language.Tag) (supported bool)
	SiteLanguageDisplayName(tag language.Tag) (name string, ok bool)

	FindTranslations(url string) (pages Pages)
	FindTranslationUrls(url string) (pages map[language.Tag]string)
	FindPage(r *http.Request, tag language.Tag, url string) (p Page)
	FindPages(prefix string) (pages []Page)
}

type EnjinBlock

type EnjinBlock interface {
	NjnFeature

	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(r *http.Request) (ctx context.Context)
}

type EnjinField

type EnjinField interface {
	NjnFeature

	NjnFieldNames() (tagNames []string)

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

type EnjinInfo added in v0.5.0

type EnjinInfo struct {
	Tag string
	EnjinText
	Locales     []language.Tag
	LangMode    lang.Mode
	DefaultLang language.Tag
}

func MakeEnjinInfo added in v0.5.0

func MakeEnjinInfo(e EnjinBase) (info EnjinInfo)

type EnjinRenderer

type EnjinRenderer interface {
	RequestArgv() (reqArgv *argv.Argv)
	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 EnjinText added in v0.5.1

type EnjinText struct {
	Name            string
	TagLine         string
	CopyrightName   string
	CopyrightYear   string
	CopyrightNotice string
}

type EnjinTextFn added in v0.5.1

type EnjinTextFn func(printer *message.Printer) (text EnjinText)

type ExtendedKeyValueStore added in v0.5.6

type ExtendedKeyValueStore interface {
	KeyValueStore

	Size() (count int)
	Keys(prefix string) (keys []string)
	Range(prefix string, fn KeyValueStoreRangeFn)
	StreamKeys(prefix string, ctx context.Context) (keys chan string)
}

type Feature

type Feature interface {
	// Construct is used as the last call within the standard NewTagged(tag) constructor and is used by extended types
	// to perform initializations which require the .FeatureTag set
	Construct(this interface{})
	// Init is used as the first call within the standard NewTagged(tag) constructor to perform initializations which
	// do not require the .FeatureTag set
	Init(this interface{})
	// Tag is the feature.Tag for this particular feature instance
	Tag() (tag Tag)
	// BaseTag is the stock tag common to all feature instances of this type
	BaseTag() (pkg Tag)
	// This returns an interface{} reference to the underlying structure instance
	This() (this interface{})
	// Self returns f.this, typed as a Feature, in such a way that calling f.Self().Thing() from a base type will invoke
	// the type's overloaded method; for example:
	//  - feature A implements `.Thing()` method and calls `f.Thing()` from some `.OtherThing()` method
	//  - feature B embeds feature A and overloads the `.Thing()` method
	//  - when feature A calls `f.Thing()` within `.OtherThing()`, feature A's method is invoked
	//  - if feature A instead calls `f.Self().Thing()` instead, feature B's method is invoked
	//
	// The example above is of course contrived as this only works with Feature methods, however, the design pattern can
	// be re-used in other systems to achieve the same effect, see EditorFeature.SelfEditor for another example.
	Self() (f Feature)
	State() (state LifeCycleState)
	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) Get added in v0.5.0

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

func (Features) Has added in v0.5.0

func (f Features) Has(tag Tag) (present bool)

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 FileSystemFeature added in v0.5.0

type FileSystemFeature interface {
	Feature
	IsLocalized() (supported bool)
	MountPathROFS(path string, point string, rofs fs.FileSystem)
	MountPathRWFS(path string, point string, rwfs fs.RWFileSystem)
	FindPathMountPoint(path string) (mps MountPoints)
	Exists(path string) (present bool)
	FindPageMatterPath(prefix string) (path string, err error)
	FindReadPageMatter(path string) (pm *matter.PageMatter, err error)
	ReadPageMatter(path string) (pm *matter.PageMatter, err error)
	WritePageMatter(pm *matter.PageMatter) (err error)
	GetMountedPoints() (mountPoints MountedPoints)
}

type FinalizeServeRequestFeature added in v0.5.0

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

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 Group added in v0.5.0

type Group string

Group is the kebab-cased name of a user Group

func NewGroup added in v0.5.0

func NewGroup(group string) Group

func (Group) String added in v0.5.0

func (g Group) String() string

type Groups added in v0.5.0

type Groups []Group

Groups are the collection of one or more groups

func NewGroupsFromStringNL added in v0.5.0

func NewGroupsFromStringNL(newlines string) (groups Groups)

func NewGroupsFromStrings added in v0.5.0

func NewGroupsFromStrings(slice ...string) (groups Groups)

func (Groups) Append added in v0.5.0

func (g Groups) Append(groups ...Group) (modified Groups)

func (Groups) AppendString added in v0.5.0

func (g Groups) AppendString(names ...string) (modified Groups)

func (Groups) AsNewlines added in v0.5.0

func (g Groups) AsNewlines() (newlines string)

func (Groups) Has added in v0.5.0

func (g Groups) Has(group Group) (present bool)

func (Groups) Len added in v0.5.0

func (g Groups) Len() int

func (Groups) Remove added in v0.5.0

func (g Groups) Remove(groups ...Group) (modified Groups)

func (Groups) String added in v0.5.0

func (g Groups) String() (s string)

type GroupsProvider added in v0.5.0

type GroupsProvider interface {
	Feature

	// IsUserInGroup returns true if the user is in the given group
	IsUserInGroup(eid string, group Group) (present bool)

	// GetUserGroups returns the user's list of groups
	GetUserGroups(eid string) (groups Groups)
}

type HeadersModifier

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

type HotReloadableFeature added in v0.5.0

type HotReloadableFeature interface {
	Feature
	HotReload() (err error)
}

type Internals

type Internals interface {
	Service
	signaling.Signaling
	EnjinBase

	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)

	ReloadLocales()
	HotReloading() (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)

	MakeLanguagePrinter(requested string) (tag language.Tag, printer *message.Printer)

	PublicUserActions() (actions Actions)
	ValidateUserRequest(action Action, w http.ResponseWriter, r *http.Request) (valid bool)

	PageContextParsers() (parsers context.Parsers)
	MakePageContextField(key string, r *http.Request) (field *context.Field, ok bool)
	MakePageContextFields(r *http.Request) (fields context.Fields)
	ApplyPageContextUpdaters(r *http.Request, pages ...Page)

	GetFormatProviders() []PageFormatProvider
	GetRequestFilters() []RequestFilter
	GetPageContextModifiers() []PageContextModifier
	GetPageContextUpdaters() []PageContextUpdater
	GetPageRestrictionHandlers() []PageRestrictionHandler
	GetMenuProviders() []MenuProvider
	GetDataRestrictionHandlers() []DataRestrictionHandler
	GetOutputTranslators() []OutputTranslator
	GetOutputTransformers() []OutputTransformer
	GetPageTypeProcessors() []PageTypeProcessor
	GetServePathFeatures() []ServePathFeature
	GetDatabases() []Database
	GetEmailSenders() []EmailSender
	GetRequestModifiers() []RequestModifier
	GetRequestRewriters() []RequestRewriter
	GetPermissionsPolicyModifiers() []PermissionsPolicyModifier
	GetContentSecurityPolicyModifiers() []ContentSecurityPolicyModifier
	GetUseMiddlewares() []UseMiddleware
	GetHeadersModifiers() []HeadersModifier
	GetProcessors() []Processor
	GetApplyMiddlewares() []ApplyMiddleware
	GetPageProviders() []PageProvider
	GetFileProviders() []FileProvider
	GetQueryIndexFeatures() []QueryIndexFeature
	GetPageContextProviders() []PageContextProvider
	GetAuthProviders() []AuthProvider
	GetUserActionsProviders() []UserActionsProvider
	GetEnjinContextProvider() []EnjinContextProvider
	GetPageShortcodeProcessors() []PageShortcodeProcessor
	GetFuncMapProviders() []FuncMapProvider
	GetTemplatePartialsProvider() []TemplatePartialsProvider
	GetThemeRenderers() []ThemeRenderer
	GetServiceLoggers() []ServiceLogger
	GetLocalesProviders() []LocalesProvider
	GetPrepareServePagesFeatures() []PrepareServePagesFeature
	GetFinalizeServePagesFeatures() []FinalizeServeRequestFeature
	GetPageContextFieldsProviders() []PageContextFieldsProvider
	GetPageContextParsersProviders() []PageContextParsersProvider
	GetPanicHandler() PanicHandler
	GetLocaleHandler() LocaleHandler
	GetServiceListener() ServiceListener
	GetRoutePagesHandler() RoutePagesHandler
	GetServePagesHandler() ServePagesHandler
	GetServiceLogHandler() ServiceLogHandler
}

type KeyValueCache added in v0.5.0

type KeyValueCache interface {
	// ListBuckets returns the names of all buckets
	ListBuckets() (names []string)
	// Bucket returns the named bucket or adds a new bucket and returns that
	Bucket(name string) (kvs KeyValueStore, err error)
	// MustBucket uses Bucket and on error will log.ErrorDF and panic
	MustBucket(name string) (kvs KeyValueStore)
	// AddBucket adds and returns a new bucket, errors if already exists
	AddBucket(name string) (kvs KeyValueStore, err error)
	// GetBucket returns a new bucket, errors if not found
	GetBucket(name string) (kvs KeyValueStore, err error)
	// GetBucketSource returns the underlying cache object, or nil if not found
	GetBucketSource(name string) (src interface{})
}

type KeyValueCacheFeature added in v0.5.6

type KeyValueCacheFeature interface {
	Build(b Buildable) (err error)
	Startup(ctx *cli.Context) (err error)
	Shutdown()
}

type KeyValueCaches added in v0.5.0

type KeyValueCaches interface {
	Feature

	Get(name string) (kvs KeyValueCache, err error)
}

type KeyValueStore added in v0.5.0

type KeyValueStore interface {
	Get(key string) (value []byte, err error)
	Set(key string, value []byte) (err error)
	Delete(key string) (err error)
}

type KeyValueStoreRangeFn added in v0.5.6

type KeyValueStoreRangeFn func(key string, value []byte) (stop bool)

type KeywordProvider added in v0.4.0

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

type LifeCycleState added in v0.5.6

type LifeCycleState uint8
const (
	StateCreated LifeCycleState = iota
	StateConstructed
	StateInitialized
	StateMade
	StateBuilt
	StateSetup
	StateStarted
	StatePostStarted
	StateShutdown
	EndLifeCycleStates
)

func (LifeCycleState) String added in v0.5.6

func (l LifeCycleState) String() (name string)

func (LifeCycleState) Valid added in v0.5.6

func (l LifeCycleState) Valid() (valid bool)

type LocaleHandler added in v0.5.0

type LocaleHandler interface {
	Feature
	LocaleHandler(next http.Handler) http.Handler
}

type LocalesProvider added in v0.5.0

type LocalesProvider interface {
	Feature

	AddLocales(c beCatalog.Catalog)
}

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)
	GetAllMenus() (menus map[language.Tag]map[string]menu.Menu)
}
type MenuSupport struct {
	Key  string `json:"key"`
	Name string `json:"name"`
	Area string `json:"area"`
}
type MenuSupports []MenuSupport

func ParseMenuSupports added in v0.5.0

func ParseMenuSupports(input interface{}) (supports MenuSupports)
func (m MenuSupports) Append(others MenuSupports) (merged MenuSupports)
func (m MenuSupports) Has(key string) (supported bool)
func (m MenuSupports) Keys() (keys []string)

type MessagePrinterFn added in v0.5.0

type MessagePrinterFn func(printer *message.Printer) (text string)

type MiddlewareFn

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

type MountPoints added in v0.5.0

type MountPoints []*CMountPoint

func (MountPoints) Append added in v0.5.0

func (m MountPoints) Append(mountPoint *CMountPoint) (modified MountPoints)

func (MountPoints) HasRWFS added in v0.5.0

func (m MountPoints) HasRWFS() (rw bool)

func (MountPoints) Len added in v0.5.0

func (m MountPoints) Len() (count int)

type MountedPoints added in v0.5.0

type MountedPoints map[string]MountPoints

func (MountedPoints) Exists added in v0.5.0

func (m MountedPoints) Exists(path string) (present bool)

func (MountedPoints) FindPathPoints added in v0.5.0

func (m MountedPoints) FindPathPoints(path string) (mountPoints MountPoints)

FindPathPoints returns a list of MountPoints which prefix match the given path

func (MountedPoints) FindRWPathPoint added in v0.5.0

func (m MountedPoints) FindRWPathPoint(path string) (readWrite *CMountPoint)

FindRWPathPoint finds the first read-write MountPoint matching the path given

func (MountedPoints) HasRWFS added in v0.5.0

func (m MountedPoints) HasRWFS() (rw bool)

func (MountedPoints) HasRootOrAllOf added in v0.5.0

func (m MountedPoints) HasRootOrAllOf(mounts ...string) (present bool)

func (MountedPoints) IsReadOnly added in v0.5.0

func (m MountedPoints) IsReadOnly(path string) (readOnly bool)

func (MountedPoints) ListDirs added in v0.5.0

func (m MountedPoints) ListDirs(path string) (dirs []string)

func (MountedPoints) ListFiles added in v0.5.0

func (m MountedPoints) ListFiles(path string) (files []string)

func (MountedPoints) ListMounts added in v0.5.0

func (m MountedPoints) ListMounts() (mounts []string)

func (MountedPoints) ReadFile added in v0.5.0

func (m MountedPoints) ReadFile(path string) (data []byte, err error)

func (MountedPoints) RemoveFile added in v0.5.0

func (m MountedPoints) RemoveFile(path string) (err error)

func (MountedPoints) WriteFile added in v0.5.0

func (m MountedPoints) WriteFile(path string, data []byte) (err error)

type NjnClass

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

func (NjnClass) String

func (nc NjnClass) String() string

type NjnFeature added in v0.5.0

type NjnFeature 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 Nonce added in v0.5.0

type Nonce struct {
	// Key is the string to use with nonce factories
	Key string `json:"key"`
	// Name is the form hidden input name
	Name string `json:"name"`
	// Value is the actual nonce to be used with this key/name combination; Value may be omitted in which case the theme
	// must call `Nonce $nonce.Key` to get the correct nonce value to use
	Value string `json:"-"`
}

type NonceFactory added in v0.5.0

type NonceFactory interface {
	CreateNonce(key string) (value string)
	VerifyNonce(key, value string) (valid bool)
}

type NonceFactoryFeature added in v0.5.0

type NonceFactoryFeature interface {
	Feature
	NonceFactory
}

type Nonces added in v0.5.0

type Nonces []Nonce

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)
	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)
	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)
}

func ParseSignalArgv added in v0.5.0

func ParseSignalArgv(argv []interface{}) (r *http.Request, pg Page, ctx, form beContext.Context, info *editor.File, eid string, redirect *string, ok bool)

ParseSignalArgv is a helper function for translating the emitted signal argv into concrete types

`r, pg, ctx, form, info, eid, file, redirect, ok := bePkgEditor.ParseSignalArgv(argv)`

type PageContextFieldsProvider added in v0.5.0

type PageContextFieldsProvider interface {
	Feature
	MakePageContextFields(r *http.Request) (fields context.Fields)
}

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 PageContextParsersProvider added in v0.5.0

type PageContextParsersProvider interface {
	Feature
	PageContextParsers() (fields context.Parsers)
}

type PageContextProvider added in v0.4.0

type PageContextProvider interface {
	Feature
	FindPageStub(shasum string) (stub *PageStub)
	PageContextValuesCount(key string) (count uint64)
	PageContextValueCounts(key string) (counts map[interface{}]uint64)
	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 PageContextUpdater added in v0.5.0

type PageContextUpdater interface {
	Feature
	UpdatePageContext(pageCtx context.Context, r *http.Request) (additions context.Context)
}

type PageFileSystemFeature added in v0.5.0

type PageFileSystemFeature interface {
	FileSystemFeature

	AddIndexing(filePath string)
	RemoveIndexing(filePath string)
}

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 {
	Feature
	AddToIndex(stub *PageStub, p Page) (err error)
	RemoveFromIndex(stub *PageStub, p Page) (err error)
}

type PageProvider

type PageProvider interface {
	Feature
	FindRedirection(url string) (p Page)
	FindTranslations(url string) (pages []Page)
	FindTranslationUrls(url string) (pages map[language.Tag]string)
	FindPage(r *http.Request, 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            `json:"origin"`
	FS       fs.FileSystem     `json:"fs"`
	Point    string            `json:"point"`
	Shasum   string            `json:"shasum"`
	Source   string            `json:"source"`
	Language language.Tag      `json:"language"`
	Fallback language.Tag      `json:"fallback"`
	EnjinCtx beContext.Context `json:"enjin-ctx"`
}

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) 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
	PageTypeNames() (names []string)
	ProcessRequestPageType(r *http.Request, p Page) (pg Page, redirect string, processed bool, err error)
}

type Pages added in v0.5.0

type Pages []Page

type PanicHandler added in v0.5.0

type PanicHandler interface {
	Feature
	PanicHandler(next http.Handler) http.Handler
}

type PermissionsPolicyModifier

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

type PostStartupFeature added in v0.5.0

type PostStartupFeature interface {
	Feature

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

type PrepareServePagesFeature added in v0.5.0

type PrepareServePagesFeature interface {
	Feature
	PrepareServePage(ctx context.Context, t Theme, p Page, w http.ResponseWriter, r *http.Request) (out context.Context, modified *http.Request, stop bool)
}

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 {
	Feature
	PerformQuery(input string) (stubs []*PageStub, err error)
	PerformSelect(input string) (selected map[string]interface{}, err error)
}

type ReloadableFeature added in v0.5.6

type ReloadableFeature interface {
	Reload()
}

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 {
	Feature
	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 {
	Feature
	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(stub *PageStub, p Page)
}

type SecretsProvider added in v0.5.0

type SecretsProvider interface {
	Feature

	// GetUserSecret returns the user's password hash, returns "" if the user
	// secret is not found
	GetUserSecret(id string) (hash string)
}

type ServePagesHandler added in v0.5.0

type ServePagesHandler interface {
	Feature
	ServePage(p Page, t Theme, ctx context.Context, w http.ResponseWriter, r *http.Request) (err error)
}

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(r *http.Request) (ctx context.Context)

	GetTheme() (t Theme, err error)
	MustGetTheme() (t Theme)
	ThemeNames() (names []string)
	GetThemeName() (name string)
	GetThemeNamed(name string) (t Theme, err error)
	MustGetThemeNamed(name string) (t Theme)

	ServerName() (name string)
	ServiceInfo() (scheme, listen string, port int)

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

	FinalizeServeRequest(w http.ResponseWriter, r *http.Request) (modified *http.Request)

	ServeRedirect(destination string, w http.ResponseWriter, r *http.Request)
	ServeRedirectHomePath(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)
	ServeForbidden(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(r *http.Request, tag language.Tag, url string) (p Page)
	FindFile(path string) (data []byte, mime string, err error)

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

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

	NonceFactory
	TokenFactory
	SyncLockerFactory

	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 Site added in v0.5.0

type Site interface {
	Feature
	signaling.Signaling

	SitePath() (path string)
	SiteMenu(r *http.Request) (siteMenu beContext.Context)
	SiteTheme() (t Theme)
	SiteUsers() (sup SiteUsersProvider)
	SiteAuth() (sup SiteAuthFeature)

	SiteFeatures() (list SiteFeatures)

	PushImportantNotice(eid string, dismiss bool, message string, argv ...interface{})
	PushInfoNotice(eid string, dismiss bool, message string, argv ...interface{})
	PushWarnNotice(eid string, dismiss bool, message string, argv ...interface{})
	PushErrorNotice(eid string, dismiss bool, message string, argv ...interface{})
	PushNotices(eid string, notices ...*UserNotice)
	PullNotices(eid string) (notices UserNotices)

	GetContext(eid string) (ctx beContext.Context)
	SetContext(eid string, ctx beContext.Context)
	ApplyContext(eid string, changes beContext.Context)
	DeleteContextKeys(eid string, keys ...string)

	PreparePage(layout, pageType, pagePath string, t Theme, r *http.Request) (pg Page, ctx beContext.Context, err error)
	ServePreparedPage(pg Page, ctx beContext.Context, t Theme, w http.ResponseWriter, r *http.Request)
	PrepareAndServePage(layout, pageType, pagePath string, t Theme, w http.ResponseWriter, r *http.Request, ctx beContext.Context) (err error)

	RequireVerification(path string, w http.ResponseWriter, r *http.Request) (allowed bool)
	MustRequireVerification(path string, w http.ResponseWriter, r *http.Request) (allowed bool)
}

type SiteAuthClaimsFactors added in v0.5.0

type SiteAuthClaimsFactors []*CSiteAuthClaimsFactor

func ParseSiteAuthClaimsFactors added in v0.5.0

func ParseSiteAuthClaimsFactors(v interface{}) (p SiteAuthClaimsFactors, ok bool)

func (SiteAuthClaimsFactors) Filter added in v0.5.0

func (f SiteAuthClaimsFactors) Filter(provision string) (modified SiteAuthClaimsFactors)

Filter returns the same list of factors, without the provision given

func (SiteAuthClaimsFactors) Find added in v0.5.0

func (f SiteAuthClaimsFactors) Find(provision string) (found *CSiteAuthClaimsFactor, ok bool)

Find returns the first factor that matches the "kebab;name" provision string given

func (SiteAuthClaimsFactors) Len added in v0.5.0

func (f SiteAuthClaimsFactors) Len() (count int)

type SiteAuthFeature added in v0.5.0

type SiteAuthFeature interface {
	Feature

	Site() Site
	SiteFeatureKey() (name string)
	SiteFeaturePath() (path string)
	SiteFeatureTheme() (t Theme)

	SiteAuthSignInPath() (url string)
	SiteAuthSignOutPath() (url string)
	SiteAuthChallengePath() (path string)

	NumFactorsPresent() (count int)
	NumFactorsRequired() (count int)

	IsUserAllowed(email string) (allowed bool)
	GetSignUpsAllowed() (allowed bool)
	GetSessionDuration() (duration time.Duration)
	GetVerifiedDuration() (duration time.Duration)

	MakeAuthClaims(aud, email string, ctx context.Context) (claims *CSiteAuthClaims)
	GenerateJWT(claims *CSiteAuthClaims) (token string, err error)
	VerifyJWT(r *http.Request) (claims *CSiteAuthClaims, err error)
	ResetUserFactors(r *http.Request, eid string) (err error)
	SetUserFactor(r *http.Request, claim *CSiteAuthClaimsFactor)

	AuthorizeUserSignIn(w http.ResponseWriter, r *http.Request, claims *CSiteAuthClaims) (handled bool, modified *http.Request)

	SiteAuthRequestHandler

	ServeSignInPage(w http.ResponseWriter, r *http.Request)
	ServeSignOutPage(w http.ResponseWriter, r *http.Request)
	ServeChallengeRequest(w http.ResponseWriter, r *http.Request)

	ServeVerificationRequest(verifyTarget string, w http.ResponseWriter, r *http.Request) (handled bool, redirect string)
	RequireVerification(path string, w http.ResponseWriter, r *http.Request) (handled bool, redirect string)
}

type SiteAuthProvider added in v0.5.0

type SiteAuthProvider interface {
	SiteFeature

	IsBackupProvider() (backup bool)

	SiteAuthLoginCallback(w http.ResponseWriter, r *http.Request, saf SiteAuthFeature) (err error)
	SiteAuthSignInHandler(w http.ResponseWriter, r *http.Request, saf SiteAuthFeature) (claims *CSiteAuthClaims, redirect string, err error)
	SiteAuthSignOutHandler(w http.ResponseWriter, r *http.Request, saf SiteAuthFeature) (handled bool, redirect string, err error)
}

type SiteAuthRequestHandler added in v0.5.0

type SiteAuthRequestHandler interface {
	SiteFeature

	AuthenticateSiteRequest(w http.ResponseWriter, r *http.Request) (handled bool, modified *http.Request)
	FinalizeSiteRequest(w http.ResponseWriter, r *http.Request) (modified *http.Request)
}

type SiteAuthSettingsPanel added in v0.5.0

type SiteAuthSettingsPanel interface {
	SiteFeature

	SiteAuthSettingsPanel(settingsPath string, saf SiteAuthFeature) (serve, handle http.HandlerFunc)
}

type SiteFeature added in v0.5.0

type SiteFeature interface {
	Feature
	UserActionsProvider
	signaling.Signaling

	Site() (s Site)

	Action(verb string, details ...string) (action Action)

	SiteFeatureInfo(r *http.Request) (info *CSiteFeatureInfo)

	SiteFeatureKey() (name string)
	SiteFeatureIcon() (icon string)
	SiteFeaturePath() (path string)
	SiteFeatureMenu(r *http.Request) (m menu.Menu)
	SiteFeatureTheme() (t Theme)
	SiteFeatureLabel(printer *message.Printer) (label string)

	SetupSiteFeature(s Site) (err error)
	RouteSiteFeature(r chi.Router)

	SiteSettingsFields(r *http.Request) (fields beContext.Fields)
	SiteSettingsPanel(settingsPath string) (serve, handle http.HandlerFunc)
}

type SiteFeatureLabelFn added in v0.5.0

type SiteFeatureLabelFn func(printer *message.Printer) (label string)

type SiteFeatures added in v0.5.0

type SiteFeatures TypedFeatures[SiteFeature]

type SiteInfosLookup added in v0.5.0

type SiteInfosLookup[T interface{}] struct {
	// contains filtered or unexported fields
}

func NewSiteInfosLookup added in v0.5.0

func NewSiteInfosLookup[T interface{}]() (lookup *SiteInfosLookup[T])

func (*SiteInfosLookup[T]) Get added in v0.5.0

func (l *SiteInfosLookup[T]) Get(key string) (info T)

func (*SiteInfosLookup[T]) Keys added in v0.5.0

func (l *SiteInfosLookup[T]) Keys() (keys []string)

func (*SiteInfosLookup[T]) Len added in v0.5.0

func (l *SiteInfosLookup[T]) Len() (count int)

func (*SiteInfosLookup[T]) Set added in v0.5.0

func (l *SiteInfosLookup[T]) Set(key string, info T)

type SiteMakeFeature added in v0.5.0

type SiteMakeFeature[MakeTypedFeature interface{}] interface {
	SetSiteFeatureKey(key string) MakeTypedFeature
	SetSiteFeatureIcon(icon string) MakeTypedFeature
	SetSiteFeatureTheme(name string) MakeTypedFeature
	SetSiteFeatureLabel(fn SiteFeatureLabelFn) MakeTypedFeature
}

type SiteMultiFactorProvider added in v0.5.0

type SiteMultiFactorProvider interface {
	SiteFeature
	SiteUserSetupStage

	SetupSiteAuthProvider(saf SiteAuthFeature)
	IsMultiFactorBackup() (backup bool)

	SiteMultiFactorKey() (key string)
	SiteMultiFactorInfo(r *http.Request) (info *CSiteAuthMultiFactorInfo)
	SiteMultiFactorLabel(printer *message.Printer) (label string)
	CurrentUserFactorsReady(r *http.Request) (names []string)
	CurrentUserFactorsReadyCount(r *http.Request) (count int)

	ResetUserFactors(r *http.Request, eid string) (err error)

	ProcessSetupPage(saf SiteAuthFeature, w http.ResponseWriter, r *http.Request) (handled bool)

	ProcessChallenge(factor, challenge string, saf SiteAuthFeature, claims *CSiteAuthClaims, w http.ResponseWriter, r *http.Request) (handled bool, redirect string)

	VerifyClaimFactor(claim *CSiteAuthClaimsFactor, saf SiteAuthFeature, r *http.Request) (verified bool)
	ProcessVerification(verifyTarget, factor, challenge string, saf SiteAuthFeature, claims *CSiteAuthClaims, w http.ResponseWriter, r *http.Request) (handled bool, redirect string)
}

type SiteRootFeature added in v0.5.0

type SiteRootFeature interface {
	SiteFeature

	SiteRootHandler() (this http.Handler)
}

type SiteUserRequestModifier added in v0.5.1

type SiteUserRequestModifier interface {
	SiteFeature

	ModifyUserRequest(au User, r *http.Request) (modified *http.Request)
}

type SiteUserSetupStage added in v0.5.0

type SiteUserSetupStage interface {
	SiteFeature

	SiteUserSetupStageReady(eid string, r *http.Request) (ready bool)
	SiteUserSetupStageHandler(saf SiteAuthFeature, w http.ResponseWriter, r *http.Request)
}

type SiteUsersProvider added in v0.5.0

type SiteUsersProvider interface {
	Feature

	MakeRealID(email string) (rid string)
	MakeEnjinID(rid string) (eid string)

	GroupPresent(group Group) (present bool)
	CreateGroup(r *http.Request, group Group, permissions ...Action) (err error)
	RetrieveGroup(r *http.Request, group Group) (permissions Actions, err error)
	UpdateGroup(r *http.Request, group Group, permissions ...Action) (err error)
	DeleteGroup(r *http.Request, group Group) (err error)

	UserPresent(eid string) (present bool)

	IsUserLocked(r *http.Request, eid string) (locked bool)
	LockUser(r *http.Request, eid string)
	UnlockUser(r *http.Request, eid string)
	RLockUser(r *http.Request, eid string)
	RUnlockUser(r *http.Request, eid string)

	ListUsers(r *http.Request, pg, numPerPage int, sortDesc bool) (list []User, total int)
	SignUpUser(r *http.Request, claims *CSiteAuthClaims) (err error)
	CreateUser(r *http.Request, origin, rid, eid, email string) (err error)
	RetrieveUser(r *http.Request, eid string) (user User, err error)
	DeleteUser(r *http.Request, eid string) (err error)

	UpdateUserName(r *http.Request, eid string, name string) (err error)
	UpdateUserImage(r *http.Request, eid string, image string) (err error)
	UpdateUserContext(r *http.Request, eid string, ctx beContext.Context) (err error)
	UpdateUserGroups(r *http.Request, eid string, groups ...Group) (err error)
	UpdateUserPermissions(r *http.Request, eid string, permissions ...Action) (err error)

	SetUserName(r *http.Request, eid string, name string) (err error)
	SetUserImage(r *http.Request, eid string, image string) (err error)
	SetUserContext(r *http.Request, eid string, ctx beContext.Context) (err error)
	SetUserSetting(r *http.Request, eid string, key string, value interface{}) (err error)
	SetUserSettings(r *http.Request, eid string, ctx beContext.Context) (err error)
	SetUserGroups(r *http.Request, eid string, groups ...Group) (err error)
	SetUserPermissions(r *http.Request, eid string, permissions ...Action) (err error)

	UpdateUserActive(r *http.Request, eid string, active bool) (err error)
	UpdateUserAdminLocked(r *http.Request, eid string, active bool) (err error)
	SetUserActive(r *http.Request, eid string, active bool) (err error)
	SetUserAdminLocked(r *http.Request, eid string, active bool) (err error)

	GetUserStatus(r *http.Request, eid string) (active, locked, visitor bool, err error)
	GetUserActive(r *http.Request, eid string) (active bool, err error)
	GetUserAdminLocked(r *http.Request, eid string) (locked bool, err error)
}

type SyncLocker added in v0.5.0

type SyncLocker interface {
	IsLocked() (locked bool)
	Lock(key string)
	Unlock(key string)
}

type SyncLockerFactory added in v0.5.0

type SyncLockerFactory interface {
	NewSyncLocker(tag Tag, key string, store KeyValueStore) (l SyncLocker)
	NewSyncLockerWith(tag Tag, key string, store KeyValueStore, timeout, interval time.Duration) (l SyncLocker)
	NewSyncRWLocker(tag Tag, key string, readStore, writeStore KeyValueStore) (l SyncRWLocker)
	NewSyncRWLockerWith(tag Tag, key string, readStore, writeStore KeyValueStore, timeout, interval time.Duration) (l SyncRWLocker)
}

type SyncLockerFactoryFeature added in v0.5.0

type SyncLockerFactoryFeature interface {
	Feature
	SyncLockerFactory
}

type SyncRWLocker added in v0.5.0

type SyncRWLocker interface {
	SyncLocker
	RLock(key string)
	RUnlock(key string)
}

type System

type System interface {
	Service
	signaling.Signaling

	Router() (router *chi.Mux)
}

type Tag

type Tag string

Tag is the primary identifier type for enjin Feature implementations

const (
	EnjinTag        Tag = "enjin"
	EnjinLocalesTag Tag = "enjin-locales"
)
const (
	NilTag Tag = ""
)
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) Spaced added in v0.5.0

func (t Tag) Spaced() string

Spaced returns the tag as a space cased string (all lowercase, separated by spaces)

func (Tag) SpacedCamel added in v0.5.0

func (t Tag) SpacedCamel() string

SpacedCamel returns the tag as a Spaced Camel Cased string (first letters capitalized, separated by spaces)

func (Tag) String

func (t Tag) String() string

String returns the Tag as a string

type TagCloud added in v0.5.11

type TagCloud []*CloudTag

func (TagCloud) Rank added in v0.5.11

func (c TagCloud) Rank()

func (TagCloud) Sort added in v0.5.11

func (c TagCloud) Sort()

func (TagCloud) Update added in v0.5.11

func (c TagCloud) Update(baseurl string)

type TagCloudProvider added in v0.5.11

type TagCloudProvider interface {
	Feature
	GetTagCloud() (tc TagCloud)
	GetPageTagCloud(shasum string) (tags TagCloud)
}

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 natural.StringSlice 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(tags ...Tag) (list Tags)

Append returns a (unique) list with the given tags appended

func (Tags) Find added in v0.5.0

func (t Tags) Find(name string) (found Tag, ok bool)

Find returns the first tag matching the given name exactly, or matching by kebab-cased comparison

func (Tags) Has

func (t Tags) Has(tag Tag) (present 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)

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

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

	ReadStaticFile(path string) (data []byte, mime string, err error)

	GetConfig() (config *ThemeConfig)

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

	ListArchetypes() (names []string)
	MakeArchetype(enjin Internals, name string) (format string, data []byte, err error)

	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 ThemeAuthor added in v0.5.1

type ThemeAuthor struct {
	Name     string
	Homepage string
}

type ThemeConfig added in v0.4.0

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

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

	FontawesomeLinks   map[string]string
	FontawesomeClasses []string

	CacheControl string

	PermissionsPolicy     []permissions.Directive
	ContentSecurityPolicy csp.ContentSecurityPolicyConfig

	Supports ThemeSupports

	Context context.Context

	Err error
}

func (*ThemeConfig) Copy added in v0.5.1

func (tc *ThemeConfig) Copy() (config *ThemeConfig)

type ThemeLayout added in v0.4.0

type ThemeLayout interface {
	Name() (name string)

	Apply(other ThemeLayout)
	CacheKeys() (keys []string)
	CacheValue(key string) (value 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 {
	ListLayouts() (names []string)
	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(t Theme, view string, ctx context.Context) (data []byte, err error)
	RenderPage(t Theme, ctx context.Context, p Page) (data []byte, redirect string, err error)
	PrepareRenderPage(t Theme, ctx context.Context, p Page) (data htmlTemplate.HTML, redirect string, err error)

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

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

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

type ThemeSupports added in v0.5.0

type ThemeSupports struct {
	Menus      MenuSupports              `json:"menus,omitempty"`
	Layouts    []string                  `json:"layouts,omitempty"`
	Locales    []language.Tag            `json:"locales,omitempty"`
	Archetypes map[string]context.Fields `json:"archetypes,omitempty"`
}

type TokenFactory added in v0.5.0

type TokenFactory interface {
	CreateToken(key string) (value, shasum string)
	CreateTokenWith(key string, duration time.Duration) (value, shasum string)
	VerifyToken(key, value string) (valid bool)
}

type TokenFactoryFeature added in v0.5.0

type TokenFactoryFeature interface {
	Feature
	TokenFactory
}

type TransformOutputFn

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

type TranslateOutputFn

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

type TypedFeatures added in v0.5.0

type TypedFeatures[T interface{}] []T

func (TypedFeatures[T]) AsFeatures added in v0.5.0

func (tf TypedFeatures[T]) AsFeatures() (features Features)

func (TypedFeatures[T]) Find added in v0.5.0

func (tf TypedFeatures[T]) Find(name string) (tag Tag)

func (TypedFeatures[T]) Get added in v0.5.0

func (tf TypedFeatures[T]) Get(tag Tag) (found T)

func (TypedFeatures[T]) Has added in v0.5.0

func (tf TypedFeatures[T]) Has(tag Tag) (present bool)

func (TypedFeatures[T]) Len added in v0.5.0

func (tf TypedFeatures[T]) Len() (count int)

func (TypedFeatures[T]) Tags added in v0.5.0

func (tf TypedFeatures[T]) Tags() (tags Tags)

type UpdateSiteRoutesFeature added in v0.5.0

type UpdateSiteRoutesFeature interface {
	SiteFeature

	UpdateSiteRoutes(r chi.Router)
}

type UseMiddleware added in v0.1.0

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

type User added in v0.5.0

type User interface {
	GetRID() (rid string)
	GetEID() (eid string)
	GetName() (name string)
	GetEmail() (email string)
	GetImage() (image string)
	GetOrigin() (origin string)
	GetGroups() (groups Groups)
	GetActions() (groups Actions)

	GetActive() (active bool)
	GetAdminLocked() (locked bool)

	GetSetting(key string) (value interface{})
	GetSettings(includeKeys ...string) (settings context.Context)

	UnsafeContext() (ctx context.Context)
	SafeContext(includeKeys ...string) (ctx context.Context)

	Can(action ...Action) (allowed bool)
	CanAll(action ...Action) (allowed bool)

	IsVisitor() (visitor bool)

	Bytes() (data []byte)
}

type UserActionsProvider added in v0.5.0

type UserActionsProvider interface {
	Feature

	UserActions() (list Actions)
	Action(verb string, details ...string) (action Action)
}

type UserManager added in v0.5.0

type UserManager interface {
	Feature

	// NewUser constructs a new User instance and saves it to the userbase
	NewUser(rid, name, email, picture, audience string, attributes map[string]interface{}) (user User, err error)

	// SetUser writes the given User to the system
	SetUser(user User) (err error)

	// RemoveUser deletes a user from the system
	RemoveUser(eid string) (err error)
}

type UserNotice added in v0.5.0

type UserNotice struct {
	Type    string           `json:"type"`
	Dismiss bool             `json:"dismiss"`
	Summary string           `json:"summary"`
	Content []string         `json:"content"`
	Actions []UserNoticeLink `json:"actions"`
}

func MakeErrorNotice added in v0.5.0

func MakeErrorNotice(dismiss bool, message string, argv ...interface{}) (notice *UserNotice)

func MakeImportantNotice added in v0.5.0

func MakeImportantNotice(dismiss bool, message string, argv ...interface{}) (notice *UserNotice)

func MakeInfoNotice added in v0.5.0

func MakeInfoNotice(dismiss bool, message string, argv ...interface{}) (notice *UserNotice)

func MakeWarnNotice added in v0.5.0

func MakeWarnNotice(dismiss bool, message string, argv ...interface{}) (notice *UserNotice)

func NewNotice added in v0.5.0

func NewNotice(key string, dismiss bool, summary string, actions ...UserNoticeLink) (notice *UserNotice)
type UserNoticeLink struct {
	Text   string `json:"text"`
	Href   string `json:"href"`
	Target string `json:"target,omitempty"`
}

type UserNotices added in v0.5.0

type UserNotices []*UserNotice

func GetUserNotices added in v0.5.0

func GetUserNotices(r *http.Request) (notices UserNotices)

type UserProvider added in v0.5.0

type UserProvider interface {
	Feature

	// UserPresent returns true if a user with the EID given is present
	UserPresent(eid string) (present bool)

	// GetUser returns the user by user.EID
	GetUser(eid string) (user User, err error)
}

type ValueStubPair added in v0.4.0

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

Jump to

Keyboard shortcuts

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