Documentation
¶
Overview ¶
Package modulekit - the module SDK: what the engine hands a module at startup (Deps) and what the module hands back (Parts), and everything else a module uses of the core: its controllers' base, the hooks, the core's types and helpers. A module's Wire builds its repositories, services and controllers from Deps and returns Parts - its routes, its content types' pages, its 404-path fallback, its uninstall step; the engine calls the Wire of each module it has (its own, and those registered with Register) and knows none by name.
A module from its own repository imports this package, its subpackages and the engine's pkg/*, nothing else of the engine. The data types are the core's own (type aliases), so a module and the core speak the same types; the services and repositories a module gets are interfaces with what a module needs. The SDK may change before the engine's 1.0 (the documentation's "The module SDK").
Index ¶
- Constants
- Variables
- func AbsoluteAssetURL(base, uri string) string
- func AddAccountSettingsSection(s AccountSettingsSection)
- func AddActionGroup(g ActionGroup)
- func AddActionType(t ActionType)
- func AddAdminMenuCount(module, path string, count func(ctx context.Context) (int, error), ...)
- func AddContentTypeSettings(s ContentTypeSettings)
- func AddCreateLinks(module string, ...)
- func AddDashboardBlock(b DashboardBlock)
- func AddEmbedKind(k EmbedKind)
- func AddFieldFormatter(f FieldFormatter)
- func AddFileStorage(d FileStorage)
- func AddFormSection(s FormSection)
- func AddJob(module string, j Job)
- func AddMail(d MailDef)
- func AddMailTransport(t MailTransport)
- func AddNodePage(module string, fn func(ctx context.Context, node Node) NodePageParts)
- func AddNodeSettings(s NodeSettings)
- func AddPageData(module string, fn func(r *http.Request, data map[string]any))
- func AddPathOwner(module string, answers func(ctx context.Context, path string) (bool, error))
- func AddProfileTab(t ProfileTab)
- func AddSitemapPaths(module string, fn func(ctx context.Context) ([]string, error))
- func AddTermPage(module string, fn func(ctx context.Context, term TaxonomyTerm) any)
- func AddTextFilter(f TextFilter)
- func AddUserMenuCount(data map[string]any, n int)
- func AddUserSettingsSection(s UserSettingsSection)
- func AddViewField(f ViewField)
- func AddViewFilter(f ViewFilter)
- func AddViewSort(s ViewSort)
- func ApplySiteLanguages(def string, others []SiteLanguage)
- func AsGuest(ctx context.Context) (context.Context, error)
- func AuthJSONMiddleware(store *sessions.CookieStore) func(http.Handler) http.Handler
- func AuthMiddleware(store *sessions.CookieStore) func(http.Handler) http.Handler
- func ChangeNode(ctx context.Context, nodeID int, user *User, ...) error
- func CheckBotTrap(r *http.Request) error
- func CommentReason(code, detail string) string
- func CommentsPerPage() int
- func ContextUserID(ctx context.Context) (int, bool)
- func CopyNode(ctx context.Context, nodeID int, user *User, title string) (int, error)
- func DBDialect() string
- func DocumentAllowed(name string, head []byte) bool
- func Driver(ctx context.Context, db *sql.DB) dialect.Driver
- func EmbedTemplate(ctx context.Context, templates TemplateService, define string, ...) (template.HTML, error)
- func EscapePathSegments(rel string) string
- func FileIDs(v any) []int
- func FirstFileID(v any) int
- func FormPreviewPath(contentType string, nodeID int) string
- func ImageFormatsLabel(mimes []string) string
- func ImageMIME(uri string) string
- func InTx(ctx context.Context, db *sql.DB, fn func(ctx context.Context) error) error
- func IsDuplicateKey(err error) bool
- func IsNotFound(err error) bool
- func IsValidCommentMode(s string) bool
- func LocalPath(code, path string) string
- func LogFallback(logger *slog.Logger, err error, msg string, args ...any)
- func MailBaseURL() string
- func MailTemplatePath(key string) string
- func ModuleEnabled(name string) bool
- func ModuleNodeData(ctx context.Context, node Node) map[string]any
- func ModuleNodeTypePathPrefix(nodeType string) string
- func NodeRelPath(nodeType ContentType, slug string) string
- func NodeTypeEnabled(nodeType string) bool
- func OnAction(module string, fn func(ctx context.Context, e ActionEvent))
- func OnNodeFormSaved(module string, fn func(ctx context.Context, node Node, isNew bool) error)
- func OnNodePublished(module string, fn func(ctx context.Context, node Node) error)
- func OnNotFound(module string, fn func(ctx context.Context, path, referrer string))
- func OptionalAuthMiddleware(store *sessions.CookieStore) func(http.Handler) http.Handler
- func OrderRandom(s *entsql.Selector)
- func PathOwner(ctx context.Context, path, module string) (string, error)
- func PermEditAny(nodeType string) string
- func PlainPreview(s string, limit int) string
- func PrivateFiles() filestore.Store
- func PublicBaseURL(r *http.Request) string
- func PublicFiles() filestore.Store
- func PublicFilesURL() string
- func RSSPostURL(base string, n Node) string
- func Rebind(query string) string
- func RecordAction(ctx context.Context, a Action)
- func RecordNodeCreated(ctx context.Context, n Node)
- func RecordNodeSaved(ctx context.Context, before, after Node)
- func Register(r Registration)
- func RequestTheme(ctx context.Context) string
- func SafeRedirectPath(destination string) string
- func SetContentListFilter(module string, fn func(ctx context.Context) func(*entsql.Selector))
- func SetLanguageVisibility(module string, fn func(kind, ref, lang string) bool)
- func SetLanguagesSwitch(module string)
- func SetNodeURLsInLanguage(module string, ...)
- func SetNodeWorkflow(w NodeWorkflow)
- func SetPluginBlockData(id PluginBlockID, ...)
- func SetPluginBlockSettings(id PluginBlockID, list func(ctx context.Context) ([]PluginBlockSetting, error))
- func SetPluginBlockTargets(id PluginBlockID, list func(ctx context.Context) ([]PluginBlockTarget, error))
- func SetTextTranslator(module string, fn func(lang, kind, ref string) (string, bool))
- func SiteDomain() string
- func TruncateMeta(s string, n int) string
- func UserMailTokens(baseURL string, site *SiteInformation, u *User) mailtemplate.TokenData
- func UserRoleNames(u *User) []string
- func WithContentVisitor(ctx context.Context, v ContentVisitor) context.Context
- type AccountSettings
- type AccountSettingsSection
- type Action
- type ActionActor
- type ActionChange
- type ActionEvent
- type ActionGroup
- type ActionObject
- type ActionType
- type AdminNodesFilter
- type AuthService
- type BaseController
- type BaseDeps
- type BlockPlacement
- type BreadcrumbItem
- type CaptchaService
- type Comment
- type CommentMode
- type Comments
- type CommentsService
- type ContentType
- type ContentTypeDef
- type ContentTypeDefs
- type ContentTypeFieldType
- type ContentTypeService
- type ContentTypeSettings
- type ContentVisitor
- type CreatableMaterialLink
- type DashboardBlock
- type Deps
- type DynamicContent
- type EmbedKind
- type EmbedOption
- type FeedNodeFilter
- type FieldFormatter
- type FieldInstanceDef
- type FieldInstanceDefs
- type FieldLayout
- type FieldUploadPolicy
- type File
- type FileRepository
- type FileStorage
- type FileStorageConfig
- type FileUploader
- type FormSection
- type ImageStyleDef
- type ImageStyleDefs
- type ImageStyleService
- type Job
- type Link
- type MailDef
- type MailSender
- type MailTemplate
- type MailTransport
- type MailTransportField
- type Mailer
- type Mux
- type Node
- type NodeDeleter
- type NodeFormPreviewer
- type NodeLink
- type NodeMetaFields
- type NodePageParts
- type NodeSettings
- type NodeTypeController
- type NodeWorkflow
- type Nodes
- type NodesRepository
- type NodesService
- type PageSEO
- type Parts
- type Picture
- type PluginBlockID
- type PluginBlockSetting
- type PluginBlockSettingType
- type PluginBlockTarget
- type ProfileTab
- type RSSChannel
- type RSSDoc
- type RSSEnclosure
- type RSSGUID
- type RSSItem
- type RedirectService
- type Region
- type Registration
- type Requirement
- type RequirementSeverity
- type Role
- type Roles
- type Routes
- type SiteInformation
- type SiteInformationRepository
- type SiteLanguage
- type StatusCheck
- type TaxonomyService
- type TaxonomyTerm
- type TaxonomyTerms
- type TaxonomyVocabularies
- type TaxonomyVocabulary
- type TeaserBuilder
- type TeaserItem
- type TemplateService
- type TextFilter
- type UnsavedPreview
- type UploadResult
- type UploadSettings
- type UploadSettingsRepository
- type User
- type UserContent
- type UserRepository
- type UserService
- type UserSettingsSection
- type ViewDisplayDef
- type ViewField
- type ViewFilter
- type ViewOption
- type ViewParam
- type ViewSort
Constants ¶
const ( FieldTypeText = entity.FieldTypeText FieldTypeTaxonomy = entity.FieldTypeTaxonomy FieldTypeImage = entity.FieldTypeImage FieldTypeLink = entity.FieldTypeLink )
The field types a module looks for (ContentTypeFieldType).
const ( FieldLayoutAll = entity.FieldLayoutAll FieldLayoutFeatured = entity.FieldLayoutFeatured FieldLayoutFirst = entity.FieldLayoutFirst )
The layouts of FieldLayout.
const ( PermAdministerContent = service.PermAdministerContent PermAccessAdmin = service.PermAccessAdmin PermViewUnpublished = service.PermViewUnpublished )
The core's permissions a module checks.
const ( CommentModeOpen = entity.CommentModeOpen CommentModeClosed = entity.CommentModeClosed CommentModeHidden = entity.CommentModeHidden )
The comment modes.
const ( BlockPlacementPlugin = entity.BlockPlacementPlugin BlockVisibilityAll = entity.BlockVisibilityAll )
A block placement's kind and visibility (BlockPlacement.PlacementType, VisibilityScope).
const ( PluginBlockSettingNumber = entity.PluginBlockSettingNumber PluginBlockSettingSelect = entity.PluginBlockSettingSelect PluginBlockSettingText = entity.PluginBlockSettingText )
The kinds of a plugin block's setting.
const ( RequirementOK = entity.RequirementOK RequirementWarning = entity.RequirementWarning RequirementError = entity.RequirementError )
The outcomes of a check.
const ( ActionToneCreate = audit.ToneCreate ActionToneChange = audit.ToneChange ActionToneDelete = audit.ToneDelete ActionToneAccess = audit.ToneAccess ActionToneLogin = audit.ToneLogin ActionToneFail = audit.ToneFail )
The tones of action types (ActionType.Tone).
const ( CommentPublished = entity.CommentPublished CommentPending = entity.CommentPending CommentSpam = entity.CommentSpam CommentReasonReported = entity.CommentReasonReported )
The comments' states (Comment.Status) and the reason of one held after visitors' complaints (Comments.Hold; CommentReason makes "reported:<count>").
const ( RequestThemeKey = service.RequestThemeKey RequestLanguageKey = service.RequestLanguageKey RequestLocationKey = service.RequestLocationKey )
RequestThemeKey - the data key of the theme a fragment renders in (RenderNamed), RequestTheme its value; RequestLanguageKey and RequestLocationKey - of its language and its page's address.
const ( FormMenuLink = interfaces.FormMenuLink FormBlock = interfaces.FormBlock FormBlockPlacement = interfaces.FormBlockPlacement FormTerm = interfaces.FormTerm FormSiteInformation = interfaces.FormSiteInformation FormView = interfaces.FormView FormField = interfaces.FormField )
The core's admin forms with module sections (FormSection.Form; ref - the thing's id): a menu link's, a custom block's, a block placement's.
const ( TextMenuLinkTitle = entity.TextMenuLinkTitle VisibilityMenuLink = entity.VisibilityMenuLink TextBlockTitle = entity.TextBlockTitle TextPlacementTitle = entity.TextPlacementTitle VisibilityBlockPlacement = entity.VisibilityBlockPlacement TextTermName = entity.TextTermName TextTermDescription = entity.TextTermDescription TextSiteName = entity.TextSiteName TextSiteSlogan = entity.TextSiteSlogan TextViewTitle = entity.TextViewTitle TextViewDescription = entity.TextViewDescription TextFieldLabel = entity.TextFieldLabel )
The kinds of the site's texts and things shown by language (SetTextTranslator, SetLanguageVisibility).
const ( RoleAnonymous = entity.RoleAnonymous RoleUser = entity.RoleUser )
RoleAnonymous - the guests' role; RoleUser - every signed-in user's.
const AdminNodesSortTitle = entity.AdminNodesSortTitle
AdminNodesSortTitle - AdminNodesFilter.SortBy: by title.
const MaxMetaDesc = entity.MaxMetaDesc
MaxMetaDesc - the longest meta description, in characters.
const PermAdministerComments = service.PermAdministerComments
PermAdministerComments - the core's permission to moderate comments.
const PermFullAccess = service.PermFullAccess
PermFullAccess - the permission of every permission (the administrator role's).
const SiteTextRef = entity.SiteTextRef
SiteTextRef - the ref of the site's own texts (TextSiteName…).
const UserStatusActive = entity.UserStatusActive
UserStatusActive - User.Status of an active account (not blocked, not awaiting approval).
Variables ¶
var ( MailSitePlaceholders = entity.MailSitePlaceholders MailUserPlaceholders = entity.MailUserPlaceholders )
MailSitePlaceholders and MailUserPlaceholders - the placeholders of every email and of an email about a user, for MailDef.Placeholders.
var ErrEntityNotFound = entity.ErrEntityNotFound
ErrEntityNotFound - a repository's answer for a missing record (IsNotFound; schemakit.ErrEntityNotFound for a module's generated ent).
var ErrNodeNotCopyable = interfaces.ErrNodeNotCopyable
ErrNodeNotCopyable - CopyNode's node can't be copied.
Functions ¶
func AbsoluteAssetURL ¶
AbsoluteAssetURL - uri (a file's address) absolute on base.
func AddAccountSettingsSection ¶
func AddAccountSettingsSection(s AccountSettingsSection)
AddAccountSettingsSection registers the module's section of the "Account settings" page, rendered by its template "account_settings_<module>": called once, from Wire.
func AddActionGroup ¶
func AddActionGroup(g ActionGroup)
AddActionGroup registers a group of the module's actions (Group.Module - the module) and AddActionType its actions. Called once, from Wire.
func AddAdminMenuCount ¶
func AddAdminMenuCount(module, path string, count func(ctx context.Context) (int, error), label ...string)
AddAdminMenuCount sets the number the module shows by the admin menu item at path (its own, its manifest's AdminMenu, or the core's - shown with the module off too, without the number then): what waits there, e.g. new reports; counted for each admin page while the item is shown, 0 - none; label (i18n.N, optional) - what it counts, where the admin's Overview lists it ("" - the item's label). Called once, from Wire.
func AddContentTypeSettings ¶
func AddContentTypeSettings(s ContentTypeSettings)
AddContentTypeSettings registers the module's section of the content type form: called once, from Wire.
func AddCreateLinks ¶
func AddCreateLinks(module string, fn func(ctx context.Context, user *User, auth AuthService) []CreatableMaterialLink)
AddCreateLinks registers fn adding the module's items to the "Create" menu of the user: called once, from Wire.
func AddDashboardBlock ¶
func AddDashboardBlock(b DashboardBlock)
AddDashboardBlock adds the module's block to the admin's Overview (shown while the module is enabled, to whom has b.Permission). Called once, from Wire.
func AddEmbedKind ¶
func AddEmbedKind(k EmbedKind)
AddEmbedKind adds the module's kind of embedded thing (its Module set: off with the module).
func AddFieldFormatter ¶
func AddFieldFormatter(f FieldFormatter)
AddFieldFormatter registers the module's field formatter. Called once, from Wire.
func AddFileStorage ¶
func AddFileStorage(d FileStorage)
AddFileStorage adds a file storage, from the package's init: importing the package ("_" in the site's main package, app module add) is all it takes. A name already taken panics at startup.
func AddFormSection ¶
func AddFormSection(s FormSection)
AddFormSection registers the module's section of a core admin form: called once, from Wire; used only while the module is on.
func AddJob ¶
AddJob registers a background job of module: the scheduler runs it every j.Every while the module is enabled. Called once, from Wire.
func AddMail ¶
func AddMail(d MailDef)
AddMail adds the module's email to the site's (the Mail page, Deps.Mail's Send): listed while the module is on. Called once, from Wire.
func AddMailTransport ¶
func AddMailTransport(t MailTransport)
AddMailTransport adds a way of sending email, from the module's init. A mistake in it (a name not allowed or taken, no New) panics at startup.
func AddNodePage ¶
func AddNodePage(module string, fn func(ctx context.Context, node Node) NodePageParts)
AddNodePage registers fn adding the module's parts to a material's page (links, actions): called once, from Wire.
func AddNodeSettings ¶
func AddNodeSettings(s NodeSettings)
AddNodeSettings registers the module's section of the material form: called once, from Wire.
func AddPageData ¶
AddPageData registers fn adding the module's data to every page the site renders (e.g. its form on every page): called once, from Wire.
func AddPathOwner ¶
AddPathOwner registers answers, telling whether the module answers a path of its own (no leading "/"; a feed's address): a View page or another module's page doesn't take it (PathOwner). Called once, from Wire, under the module's name.
func AddProfileTab ¶
func AddProfileTab(t ProfileTab)
AddProfileTab registers the module's profile tab: called once, from Wire. It is shown only while the module is enabled.
func AddSitemapPaths ¶
AddSitemapPaths registers fn adding the module's pages to the sitemap: called once, from Wire.
func AddTermPage ¶
func AddTermPage(module string, fn func(ctx context.Context, term TaxonomyTerm) any)
AddTermPage registers the module's part of term pages: fn's result is the data of its templates there (.moduleTerm.<module>, e.g. its "term_actions_<module>"). Called once, from Wire; it runs only while the module is enabled.
func AddTextFilter ¶
func AddTextFilter(f TextFilter)
AddTextFilter registers the module's text filter. Called once, from Wire.
func AddUserMenuCount ¶
AddUserMenuCount adds n to the number on the user menu's toggle (data["userMenuCount"], e.g. the module's unread items), from the module's AddPageData.
func AddUserSettingsSection ¶
func AddUserSettingsSection(s UserSettingsSection)
AddUserSettingsSection registers the module's section of the profile form, rendered by its template "user_settings_<module>": called once, from Wire.
func AddViewField ¶
func AddViewField(f ViewField)
AddViewField registers the module's field: called once, from Wire.
func AddViewFilter ¶
func AddViewFilter(f ViewFilter)
AddViewFilter registers the module's filter: called once, from Wire.
func AddViewSort ¶
func AddViewSort(s ViewSort)
AddViewSort registers the module's sort criterion: called once, from Wire. It is offered and applied while the module is on.
func ApplySiteLanguages ¶
func ApplySiteLanguages(def string, others []SiteLanguage)
ApplySiteLanguages makes def the running site's default language and others its other languages - once they are saved (SiteInformationRepository.Update, SetLanguages).
func AsGuest ¶
AsGuest - ctx whose content queries see only what a guest may view (the content closed to guests left out): for output that is public by nature and kept by any cache, whoever asks (a feed).
func AuthJSONMiddleware ¶
AuthJSONMiddleware - AuthMiddleware for a JSON endpoint (a guest gets a JSON error, not the login page).
func AuthMiddleware ¶
AuthMiddleware - the user signed in by the session (Routes.Store), for the module's routes that need to know them.
func ChangeNode ¶
func ChangeNode(ctx context.Context, nodeID int, user *User, change func(ctx context.Context) error) error
ChangeNode runs change of the node nodeID by user (its publishing, say) in one transaction, recorded in its history - a revision, the action log, OnNodePublished - as the bulk actions' changes are.
func CheckBotTrap ¶
CheckBotTrap - an error when r's form looks sent by a bot: the site's bot trap (its fields - the template's {{botTrap}} in the form) caught it; nil when it passes or the trap is off.
func CommentReason ¶
CommentReason - a hold reason with its detail ("reported:3").
func CommentsPerPage ¶
func CommentsPerPage() int
CommentsPerPage - the comments a material's page shows at a time.
func ContextUserID ¶
ContextUserID - the signed-in user of the request ctx belongs to (a handler's r.Context(), a node or term page's hook: AddNodePage, AddTermPage); false - a guest.
func CopyNode ¶
CopyNode creates a copy of the node nodeID (an admin-created type's) by user: its fields' values, flags and view roles, titled title ("" - "Copy of …"), unpublished, with an address of its own, in ctx's language (i18n.WithLang): its id. ErrNodeNotCopyable - a field set's item or a module's content type's.
func DBDialect ¶
func DBDialect() string
DBDialect - the database the site runs on (dialect.MySQL, dialect.Postgres): a module's own ent client opens its driver on Deps.DB with it.
func DocumentAllowed ¶
DocumentAllowed - whether a file a visitor sends (name, its first bytes) may be kept: not of an extension never accepted (pages, scripts, programs), not content a browser could run (HTML, SVG, scripts, executables) whatever the name - the core's own check of documents.
func Driver ¶
Driver - the module's own ent client's driver for ctx (its generated NewClient(Driver(…))): the context's transaction (InTx), else db.
func EmbedTemplate ¶
func EmbedTemplate(ctx context.Context, templates TemplateService, define string, data map[string]any) (template.HTML, error)
EmbedTemplate renders an embedded thing: the template define (one of the module's templates/blocks/*.html, always parsed along) with data, in the zone, language and theme of ctx's request.
func EscapePathSegments ¶
EscapePathSegments - rel with each of its path segments escaped.
func FileIDs ¶
FileIDs - the files of an image or file field's value: one, or several in order for a field with several images (FieldInstanceDef.Multiple).
func FirstFileID ¶
FirstFileID - the first file of an image or file field's value (0 - none): where one picture stands for the content.
func FormPreviewPath ¶
FormPreviewPath - where the form of a new item of contentType (nodeID 0) or of the item nodeID sends its preview: the content form's "formPreviewURL" (its Preview button).
func ImageFormatsLabel ¶
ImageFormatsLabel - the image formats of a MIME allow-list as people know them ("JPEG, PNG"; FileUploadService.ImageTypes).
func InTx ¶
InTx runs fn in a transaction, the core's unit of work on db (inside one, fn joins it): the core's repositories called with fn's ctx write in it, and so does the module's own client opened with Driver(ctx, db).
func IsDuplicateKey ¶
IsDuplicateKey - err is a unique key's violation.
func IsNotFound ¶
IsNotFound - err says the record is missing (ErrEntityNotFound, the module's generated ent's not-found error, wrapped or not): a handler answers 404 for it (RenderLoadFailure does).
func IsValidCommentMode ¶
IsValidCommentMode - whether s is a comment mode.
func LocalPath ¶
LocalPath - path in code's addresses: with its prefix, as is for the default language.
func LogFallback ¶
LogFallback logs err of a fallback the module goes on with (a default value, an empty list): debug for a missing record, else warn.
func MailTemplatePath ¶
MailTemplatePath - the edit page of the email key on the Mail page (a module's settings linking to its email's text).
func ModuleEnabled ¶
ModuleEnabled - whether the module name is on (the Modules page).
func ModuleNodeData ¶
ModuleNodeData - the modules' data for a material's page (AddNodePage parts and the like), for a module rendering its own material page.
func ModuleNodeTypePathPrefix ¶
ModuleNodeTypePathPrefix - the path prefix of a module's content type's materials ("<type>/").
func NodeRelPath ¶
func NodeRelPath(nodeType ContentType, slug string) string
NodeRelPath - a material's address (without the leading slash) from its type and slug.
func NodeTypeEnabled ¶
NodeTypeEnabled - whether content of nodeType is available: false for a type of a disabled module.
func OnAction ¶
func OnAction(module string, fn func(ctx context.Context, e ActionEvent))
OnAction adds the module's listener of the recorded actions - the action log's; it runs in the acting request (quick, its errors its own). Called once, from Wire; module "" - always (a test's).
func OnNodeFormSaved ¶
OnNodeFormSaved registers fn, called while module is enabled after a content item's own form (create or edit) saved it, in the save's transaction - its error fails the save; node has the ID and Type. Changes made elsewhere (bulk actions, publishing, the schedule, a copy) don't call it. Called once, from Wire.
func OnNodePublished ¶
OnNodePublished registers fn, called when a content item becomes public (published and not on moderation): created so, or by its form, its publishing, the bulk actions or the schedule - while module is enabled. It runs in the change's transaction; its error is logged. Called once, from Wire.
func OnNotFound ¶
OnNotFound adds the module's hook told of every page request answered 404 - its path (no query) and referrer; a redirected path or a blocked request never gets there. It runs in the request after the answer: quick, its errors its own. Called once, from Wire.
func OptionalAuthMiddleware ¶
OptionalAuthMiddleware - the user signed in by the session when there is one; a guest goes on.
func OrderRandom ¶
OrderRandom - an ent order option shuffling the rows, in the site's database's own way.
func PathOwner ¶
PathOwner - what answers path on the site besides the module ("" - nothing: the address is free for it): the engine's routes ("routes"), content ("content"), a View page ("views"), a term page ("terms") or another module's page (that module's name).
func PermEditAny ¶
PermEditAny - the permission to edit anyone's material of nodeType.
func PlainPreview ¶
PlainPreview - the start of s as plain text, its code blocks left out, at most limit characters.
func PrivateFiles ¶
PrivateFiles - the store of the private files (on disk or in a bucket), never served as they are: a module serves them itself, after its own access check.
func PublicBaseURL ¶
PublicBaseURL - the site's address for the request (absolute links).
func PublicFiles ¶
PublicFiles - the store of the public files (on disk or in an object storage): a module keeps files of its own there under a folder named after it; a file's key is its path under PublicFilesURL.
func PublicFilesURL ¶
func PublicFilesURL() string
PublicFilesURL - the address of the public files (uploads).
func RSSPostURL ¶
RSSPostURL - a material's absolute address in a feed.
func Rebind ¶
Rebind - a hand-written query's ? placeholders in the site's database's own (a module's SQL on Deps.DB).
func RecordAction ¶
RecordAction records what the module did for the action log: who did it (the request's user and address) comes from ctx. Without an action log it costs nothing.
func RecordNodeCreated ¶
RecordNodeCreated records for the action log that the module's own save created the content n ("Content created"). The core's content form records it itself; a module type saved by the module's code calls it.
func RecordNodeSaved ¶
RecordNodeSaved records what the module's own save changed of the content (before and after it): published or unpublished, a new author, a new address - as the core's content form does.
func Register ¶
func Register(r Registration)
Register adds a module from outside the engine: called from the module's package init, so importing the package ("_" in the site's main package) is all it takes - the engine lists it after its own. A name the engine has already panics at startup.
func RequestTheme ¶
RequestTheme - the theme of the request's render (a previewed one), "" - the active theme.
func SafeRedirectPath ¶
SafeRedirectPath - destination when it is a path of this site (a "back" link of a form), else "".
func SetContentListFilter ¶
SetContentListFilter sets what narrows the content lists' nodes - every content View's, the search's - for a request, while module is enabled: fn(ctx) returns the condition the nodes' query adds (on its selector: s.C("langcode") is the nodes' column), nil - none for ctx. Called once, from Wire.
func SetLanguageVisibility ¶
SetLanguageVisibility sets what says whether a thing (kind, ref: a menu link…) shows on a page in a language, while module is enabled (off - in every language).
func SetLanguagesSwitch ¶
func SetLanguagesSwitch(module string)
SetLanguagesSwitch makes the site's languages besides the default one in use - their prefixes, their addresses - while module is enabled: called once, from the languages module's Wire; none set (module "") - one language.
func SetNodeURLsInLanguage ¶
func SetNodeURLsInLanguage(module string, fn func(ctx context.Context, ids []int, lang string) map[int]string)
SetNodeURLsInLanguage sets what gives content items' addresses in a language - their public versions in it - while module is enabled.
func SetNodeWorkflow ¶
func SetNodeWorkflow(w NodeWorkflow)
SetNodeWorkflow sets the site's editorial workflow: called once, from Wire; used only while the module is on.
func SetPluginBlockData ¶
func SetPluginBlockData(id PluginBlockID, load func(ctx context.Context, p BlockPlacement) (any, error))
SetPluginBlockData sets the loader of the module's plugin block id's data: called once, from Wire. Every refresh of the blocks' cache calls load for each of the block's placements; its result is the block template's .Data (templates don't query the database).
func SetPluginBlockSettings ¶
func SetPluginBlockSettings(id PluginBlockID, list func(ctx context.Context) ([]PluginBlockSetting, error))
SetPluginBlockSettings sets the settings of the module's plugin block id, offered on its placement page and kept with the placement: called once, from Wire; list - on every page and save (its options may come from the database).
func SetPluginBlockTargets ¶
func SetPluginBlockTargets(id PluginBlockID, list func(ctx context.Context) ([]PluginBlockTarget, error))
SetPluginBlockTargets sets what the module's plugin block id can show (the placement page's choice): called once, from Wire.
func SetTextTranslator ¶
SetTextTranslator sets what gives a text of the site (a menu link's title…: kind, ref) in a language (false - none, the text as entered), while module is enabled. Called once, from the languages module's Wire.
func SiteDomain ¶
func SiteDomain() string
SiteDomain - the site's address (public_base_url), "" when not set.
func TruncateMeta ¶
TruncateMeta - s cut for a meta description of at most n characters.
func UserMailTokens ¶
func UserMailTokens(baseURL string, site *SiteInformation, u *User) mailtemplate.TokenData
UserMailTokens - the tokens of an account e-mail to u ([site:…], [user:…], mailtemplate) under the site's address baseURL.
func UserRoleNames ¶
UserRoleNames - the roles of u (a guest's for nil; every signed-in user has RoleUser too).
func WithContentVisitor ¶
func WithContentVisitor(ctx context.Context, v ContentVisitor) context.Context
WithContentVisitor - ctx whose content and comment queries leave out what v may not view: a background job working for one user (their e-mail) sees what they may (AuthService.ContentVisitor).
Types ¶
type AccountSettings ¶
type AccountSettings = entity.AccountSettings
AccountSettings - the account settings (the "Account settings" page's data, .account).
type AccountSettingsSection ¶
type AccountSettingsSection = interfaces.AccountSettingsSection
AccountSettingsSection - a module's section of the "Account settings" page (its settings of accounts).
type ActionActor ¶
ActionActor - who did an action: the user, the address.
func ActionActorFrom ¶
func ActionActorFrom(ctx context.Context) ActionActor
ActionActorFrom - who acts in ctx: the signed-in user and the address (zero - nobody known).
type ActionEvent ¶
ActionEvent - a recorded action, with who did it and when.
type ActionGroup ¶
ActionGroup - a module's kind of actions: its group shows on the log's filter and settings.
func ActionGroups ¶
func ActionGroups() []ActionGroup
ActionGroups - the groups of actions (the core's first), ActionTypeOf - an action type by name: for an action log's pages.
type ActionObject ¶
ActionObject - what an action was done to.
func NodeActionObject ¶
func NodeActionObject(n Node) ActionObject
NodeActionObject - the content n as the object of a module's action (RecordAction): the action shows in the content's log too.
type ActionType ¶
ActionType - an action of a group: its Label, its Tone (ActionTone*).
func ActionTypeOf ¶
func ActionTypeOf(name string) (ActionType, bool)
ActionTypeOf - see ActionGroups.
type AdminNodesFilter ¶
type AdminNodesFilter = entity.AdminNodesFilter
AdminNodesFilter - a page of the admin's content list (NodesRepository.ListForAdmin): type, status, address, order.
type AuthService ¶
type AuthService = service.AuthService
AuthService - who the user is and what they may (Deps.Base.Auth).
type BaseController ¶
type BaseController = interfaces.BaseController
BaseController - what a module's controller embeds.
func NewBaseController ¶
func NewBaseController(d BaseDeps) *BaseController
NewBaseController - a module's controller's base from d (Deps.Base).
type BlockPlacement ¶
type BlockPlacement = entity.BlockPlacementDef
BlockPlacement - where a block is placed (a region of a theme) and its settings (PluginSetting).
type BreadcrumbItem ¶
type BreadcrumbItem = entity.BreadcrumbItem
BreadcrumbItem - a link of a page's breadcrumbs.
type CaptchaService ¶
type CaptchaService = service.CaptchaService
CaptchaService - the site's reCAPTCHA (Captcha).
type CommentMode ¶
type CommentMode = entity.CommentMode
CommentMode - a material's comments: open, closed, hidden.
type CommentsService ¶
type CommentsService interface {
ByID(ctx context.Context, id int) (*Comment, error)
// Approve publishes a comment waiting for approval or marked as spam.
Approve(ctx context.Context, id int) error
// Hold takes a published comment back to waiting for approval for
// reason (CommentReason*).
Hold(ctx context.Context, id int, reason string) error
// MarkSpam marks the comment as spam: shown to nobody.
MarkSpam(ctx context.Context, id int) error
// Delete removes the comment together with all its replies.
Delete(ctx context.Context, id int) error
ByNodeIDPaginated(ctx context.Context, nid int, status int8, page int) (Comments, int, error)
CountByNodeID(ctx context.Context, nid int, status int8, rootOnly bool) (int, error)
// OnCommentPosted registers the module's fn, called after a published
// comment is created (a reply too: its ParentID) while the module is
// enabled: a module telling of it. Its error is logged; the comment
// stands. Called once, from Wire.
OnCommentPosted(module string, fn func(ctx context.Context, c Comment) error)
// OnNodeCommentsChanged registers the module's fn, called after a
// comment of a material is created, updated or deleted while the
// module is enabled: a module keeping its own counts of a material's
// comments updates them. Its error is logged; the comment's change
// stands. Called once, from Wire.
OnNodeCommentsChanged(module string, fn func(ctx context.Context, nodeID int) error)
}
CommentsService - the materials' comments (Deps.Comments).
type ContentType ¶
type ContentType = entity.ContentType
ContentType - a content type's machine name.
func NodeTypesByLabel ¶
func NodeTypesByLabel(labels map[string]string) []ContentType
NodeTypesByLabel - the node types of labels (ContentTypeService.NodeTypeLabels) sorted by label.
type ContentTypeDef ¶
type ContentTypeDef = entity.ContentTypeDef
ContentTypeDef - a content type (Deps.ContentTypes).
type ContentTypeDefs ¶
type ContentTypeDefs = entity.ContentTypeDefs
ContentTypeDefs - content types.
type ContentTypeFieldType ¶
type ContentTypeFieldType = entity.ContentTypeFieldType
ContentTypeFieldType - a field's type (FieldType*).
type ContentTypeService ¶
type ContentTypeService interface {
ContentTypeByMachineName(ctx context.Context, machineName string) (*ContentTypeDef, error)
// ContentTypes - the content types, not the field sets.
ContentTypes(ctx context.Context) (ContentTypeDefs, error)
FieldsByContentTypeID(ctx context.Context, contentTypeID int) (FieldInstanceDefs, error)
FieldValues(ctx context.Context, nodeID int, fields FieldInstanceDefs) (map[int]any, error)
SetFieldValues(ctx context.Context, nodeID int, fields FieldInstanceDefs, values map[int]any, textFormats map[int]int) error
// NodeTypeLabels - every node type's label by machine name: the
// content types' own and the modules' node types' (translated).
NodeTypeLabels(ctx context.Context) map[string]string
}
ContentTypeService - the content types and the materials' field values (Deps.ContentTypes).
type ContentTypeSettings ¶
type ContentTypeSettings = interfaces.ContentTypeSettings
ContentTypeSettings - a module's section in the content type's form.
type ContentVisitor ¶
type ContentVisitor = entity.ContentVisitor
ContentVisitor - what of the content a visitor may not view (AuthService.ContentVisitor).
type CreatableMaterialLink ¶
type CreatableMaterialLink = entity.CreatableMaterialLink
CreatableMaterialLink - an item of the "Create" menu (AddCreateLinks).
type DashboardBlock ¶
type DashboardBlock = service.DashboardBlock
DashboardBlock - a module's block on the admin's Overview (/admin): its template dashboard_<Name> (the module's templates/partials), its card's Title (i18n.N) and "all" link, its column (Side), its Weight, the Permission it needs and its Data for the request.
type Deps ¶
type Deps struct {
// Base - what the module's controllers' base is built from
// (NewBaseController); what the module itself needs of the core is
// below.
Base BaseDeps
DB *sql.DB
Logger *slog.Logger
// Auth - who the user is and what they may.
Auth AuthService
// Templates - the site's templates.
Templates TemplateService
// SiteInformation - the site's name, e-mail and languages.
SiteInformation SiteInformationRepository
// RefreshBlocks rebuilds the blocks' cache (in the background): after
// a change the cached blocks show that isn't a material's or a
// comment's (those rebuild it themselves).
RefreshBlocks func()
Nodes NodesService
NodeRepo NodesRepository
NodeDeleter NodeDeleter
ContentTypes ContentTypeService
Taxonomy TaxonomyService
ImageStyles ImageStyleService
Comments CommentsService
FileUpload FileUploader
Files FileRepository
Users UserRepository
Mail Mailer
// UploadSettings - the site's upload policy (file size limit).
UploadSettings UploadSettingsRepository
// Redirects - the site's redirects (a module adding them).
Redirects RedirectService
// Roles - the site's roles (a module's choice of who may do
// something).
Roles interface {
Roles(ctx context.Context) (Roles, error)
}
// Vocabularies - deleting a vocabulary nothing else uses (a module's
// uninstall step).
Vocabularies interface {
DeleteVocabularyIfUnused(ctx context.Context, vid int) (bool, error)
}
}
Deps - the core's database handles and services a module builds on.
type DynamicContent ¶
type DynamicContent = entity.DynamicContent
DynamicContent - a material with its fields' values (the content form's data, .dc).
type EmbedKind ¶
EmbedKind - a kind of thing a text embeds with a tag [[<kind>:<name>]] (or a template with {{embed "<kind>:<name>"}}): Render gives what name embeds for its ctx's visitor (the request's: access, language, zone), ErrEntityNotFound for a missing one; Label, Search and Describe offer the kind in the editor's "Insert" window.
type EmbedOption ¶
type EmbedOption = service.EmbedOption
EmbedOption - a thing of the module's kind as the editor shows it (the "Insert" window's list and preview, the card over its tag): EmbedKind's Search and Describe give them.
type FeedNodeFilter ¶
type FeedNodeFilter = entity.FeedNodeFilter
FeedNodeFilter - the materials a feed takes (NodesRepository.ListForFeed).
type FieldFormatter ¶
type FieldFormatter = service.FieldFormatter
FieldFormatter - a module's way of showing a field (a link field's videos, say), chosen per field on the content type's "Detail page" tab and per View field: Name (unique), Module, Label (i18n.N), FieldType, Render(ctx, value, layout) - the field's value (a link field's: Links) as HTML, cheap and without network, a part it can't show shown as the core does; Hosts - its sites, offered as a link field's allowed ones; EditorScript - its script (static/<name>.js) the content form loads for the fields it shows. Off with its module: the field shows as links.
type FieldInstanceDef ¶
type FieldInstanceDef = entity.FieldInstanceDef
FieldInstanceDef - a content type's field.
type FieldInstanceDefs ¶
type FieldInstanceDefs = entity.FieldInstanceDefs
FieldInstanceDefs - a content type's fields.
type FieldLayout ¶
type FieldLayout = entity.FieldLayout
FieldLayout - how a field with several values shows them: all one after another, the first large and the others small (FieldLayoutFeatured), or the first only (FieldLayoutFirst - the formatter gets just that one).
type FieldUploadPolicy ¶
type FieldUploadPolicy = entity.FieldUploadPolicy
FieldUploadPolicy - what an upload may be (extensions, size).
type File ¶
File - an uploaded file (an image).
func OriginalImage ¶
OriginalImage - an image's original file's address.
func StyledImage ¶
StyledImage - an image's address in the image style styleName.
type FileRepository ¶
type FileRepository interface {
// Create records an uploaded file (its URI, type, size, dimensions)
// by createdBy.
Create(ctx context.Context, uri, mimeType string, width, height, sizeBytes int, createdBy int) (*File, error)
// ByIDs - the files with these ids, by id (a missing one is absent).
ByIDs(ctx context.Context, ids []int) (map[int]File, error)
}
FileRepository - the uploaded files (Deps.Files).
type FileStorage ¶
type FileStorage = filestorage.Driver
FileStorage - a storage the site's files can be kept in besides its directories (files.storage, files.private_storage name it): Public opens the public files' store, Private the private files' (nil - none).
type FileStorageConfig ¶
type FileStorageConfig = filestorage.Config
FileStorageConfig - what a FileStorage opens its store from: its own section of the config's files (Decode) and the environment.
type FileUploader ¶
type FileUploader interface {
// ImageTypes - the image MIME types the upload policy allows (empty -
// every format the engine accepts, ImageFormatsLabel).
ImageTypes(ctx context.Context) ([]string, error)
// UploadImage saves an image to dir (relative to the public files,
// e.g. a module's "galleries/12") under a unique name, checked by
// policy (its zero limits - the site's); its public:// URI.
UploadImage(ctx context.Context, file multipart.File, header *multipart.FileHeader, dir string, policy FieldUploadPolicy) (string, *UploadResult, error)
}
FileUploader - the uploads (Deps.FileUpload).
type FormSection ¶
type FormSection = interfaces.FormSection
FormSection - a module's section of a core admin form: its template is "form_<Form>_<module>".
type ImageStyleService ¶
type ImageStyleService interface {
ImageStyles(ctx context.Context) (ImageStyleDefs, error)
ImageStyleByName(ctx context.Context, name string) (*ImageStyleDef, error)
}
ImageStyleService - the image styles (Deps.ImageStyles).
type Job ¶
Job - a background job the site's scheduler runs: Name (unique, e.g. "<module>_digest"), Every (a minute at least), Run (its error is logged; a run may take up to 50 seconds).
type Link ¶
Link - one value of a link field: its address and title (Text - the title, else the address; Host - its site).
type MailDef ¶
MailDef - one of the site's emails, a module's (AddMail): its key ("<module>.<name>"), the Mail page's label, description and recipient (i18n.N), whether it can be switched off, its placeholders and their sample values, its default text (i18n.N); Load and Save when the module keeps the text itself (else the Mail page does).
type MailSender ¶
type MailSender = mailsender.EmailSender
MailSender - what a MailTransport's New gives: it sends a message.
type MailTemplate ¶
type MailTemplate = entity.MailTemplate
MailTemplate - an email's subject and body with placeholders.
type MailTransport ¶
type MailTransport = service.MailTransport
MailTransport - a way of sending the site's email besides the engine's SMTP (an HTTP API of a mail service): its name, its module (it sends while the module is enabled), its title and settings on the Mail page, and New, building its sender from the saved settings.
type MailTransportField ¶
type MailTransportField = service.MailTransportField
MailTransportField - a setting of a MailTransport: shown on the Mail page (a secret never shown back), set from the environment by Env.
type Mailer ¶
type Mailer interface {
SendPlain(to, subject, body string) error
Send(ctx context.Context, key, to string, data mailtemplate.TokenData) error
}
Mailer - the site's e-mail (Deps.Mail): with e-mail off nothing is sent. Send sends one of the site's emails (AddMail) by its key: its template (the Mail page's text) with data's placeholders, unless it is switched off there; SendPlain - a message as given.
type Mux ¶
type Mux interface {
Handle(pattern string, handler http.Handler)
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}
Mux - where a module registers its routes (Go's net/http patterns).
type NodeDeleter ¶
type NodeDeleter interface {
// Delete deletes nodeID for good, whether in the trash or not.
Delete(ctx context.Context, nodeID int) error
// Remove takes nodeID out of sight as user's action: a content type's
// item into the trash, a module's type's deleted (trashed - which).
Remove(ctx context.Context, nodeID int, user *User) (trashed bool, err error)
// AfterDelete adds a module's own cleanup of a deleted material
// (files it keeps outside the database), run after every delete,
// however the material was deleted: called once, from Wire.
AfterDelete(fn func(ctx context.Context, n Node))
}
NodeDeleter - deleting a material with everything of it: its fields' values, comments, files nothing else uses, the modules' data (Deps.NodeDeleter).
type NodeFormPreviewer ¶
type NodeFormPreviewer = interfaces.NodeFormPreviewer
NodeFormPreviewer - a module's content type whose form previews its item unsaved (FormPreviewPath; without it - no Preview button).
type NodeLink ¶
type NodeLink = interfaces.NodeLink
NodeLink - a link a module adds to a material's page.
type NodeMetaFields ¶
type NodeMetaFields = form.NodeMetaFields
NodeMetaFields - a material form's title and description fields.
func NodeMetaFromPageSEO ¶
func NodeMetaFromPageSEO(ps PageSEO) NodeMetaFields
NodeMetaFromPageSEO - the form fields of a material's page SEO.
type NodePageParts ¶
type NodePageParts = interfaces.NodePageParts
NodePageParts - what a module adds to a material's page (AddNodePage).
type NodeSettings ¶
type NodeSettings = interfaces.NodeSettings
NodeSettings - a module's section in the material's form.
type NodeTypeController ¶
type NodeTypeController = interfaces.NodeTypeController
NodeTypeController - the pages of a module's content type (Parts.NodeTypes).
type NodeWorkflow ¶
type NodeWorkflow = interfaces.NodeWorkflow
NodeWorkflow - a module's editorial workflow publishing some content types' items.
type NodesRepository ¶
type NodesRepository = entity.NodesRepository
NodesRepository - the materials (Deps.NodeRepo).
type NodesService ¶
type NodesService = service.NodesService
NodesService - the materials' service (Deps.Nodes).
type PageSEO ¶
PageSEO - a page's title and meta tags.
func PageSEOForList ¶
PageSEOForList - a list page's title and meta tags (its canonical address path).
type Parts ¶
type Parts struct {
// Routes registers the module's routes; their mux answers 404 while
// the module is off.
Routes func(Routes)
// NodeTypes - the module's content types with pages of their own
// (the node dispatcher sends their nodes there).
NodeTypes map[entity.ContentType]interfaces.NodeTypeController
// Fallback answers a path no route matched (a feed, a forum section)
// while the module is on: true - answered.
Fallback func(w http.ResponseWriter, r *http.Request) bool
// Uninstall - the module's own uninstall step, run when the module is
// deleted on the Modules page, after its content and before its tables.
Uninstall func(ctx context.Context) error
// Requirements - the module's lines of the status report (checked
// only while it is enabled).
Requirements StatusCheck
// UserContent - the module's content of a user that "delete the
// account and all its content" (/admin/people) counts and deletes too.
UserContent *UserContent
}
Parts - what a wired module gives the core. Every field is optional.
type Picture ¶
Picture - an image's <img> (the template function img): its address, other widths and size (StyledPicture).
func OriginalPicture ¶
OriginalPicture - the image itself, for the template function img.
func StyledPicture ¶
StyledPicture - an image in the image style styleName, for the template function img: its address, the style's other widths (srcset) and its size.
type PluginBlockID ¶
type PluginBlockID = entity.PluginBlockID
PluginBlockID - a plugin block's id (the module's, its manifest's).
type PluginBlockSetting ¶
type PluginBlockSetting = entity.PluginBlockSetting
PluginBlockSetting - one setting of a plugin block on its placement page (SetPluginBlockSettings); its value is the placement's PluginSetting "<Key>" in the block's template.
type PluginBlockSettingType ¶
type PluginBlockSettingType = entity.PluginBlockSettingType
PluginBlockSettingType - a setting's kind: a number, a choice, a line of text.
type PluginBlockTarget ¶
type PluginBlockTarget = entity.PluginBlockTarget
PluginBlockTarget - one thing a plugin block can show.
type ProfileTab ¶
type ProfileTab = interfaces.ProfileTab
ProfileTab - a module's tab of the user profile (/me/<Path>, /<profile>/<Path>): who may open it, its badge, its data; its template is "profile_tab_<module>".
type RSSChannel ¶
type RSSChannel = interfaces.RSSChannel
RSSChannel - the feed's channel: its title, address, items.
type RSSEnclosure ¶
type RSSEnclosure = interfaces.RSSEnclosure
RSSEnclosure - an item's attached file (an image).
type RedirectService ¶
type RedirectService interface {
// Create adds a redirect from the path from to to.
Create(ctx context.Context, from, to string) error
// GetRedirect - where fromPath redirects to.
GetRedirect(fromPath string) (toPath string, ok bool)
}
RedirectService - the site's redirects (Deps.Redirects).
type Registration ¶
type Registration struct {
Module manifestkit.Module
// Steps - the module's RegisterSteps (its schema, install, update and
// demo steps); nil - none.
Steps func()
Wire func(Deps) Parts
// Catalog - its translations: <lang>.json files at the root of the
// file system (the module's translations/ directory); nil - none.
Catalog fs.FS
// Assets - its templates/ and static/; nil - none.
Assets fs.FS
}
Registration - a module from outside the engine (its own repository, imported by the site's main package): what the engine's own modules give it too - its description and steps, its Wire, its interface catalogs (translations/) and embedded files (templates/, static/).
func Registered ¶
func Registered() []Registration
Registered - the modules from outside the engine, in the order they registered (the engine lists them after its own).
type Requirement ¶
type Requirement = entity.Requirement
Requirement - one line: what was checked (Title), what was found (Value) and, when not OK, what to do (Description, HTML); translated.
type RequirementSeverity ¶
type RequirementSeverity = entity.RequirementSeverity
RequirementSeverity - how a check came out.
type Routes ¶
type Routes struct {
// Mux - the router, gated by the module's state.
Mux Mux
Store *sessions.CookieStore
// AdminOnly wraps a handler of the admin: signed in, with the admin
// permission.
AdminOnly func(http.Handler) http.Handler
}
Routes - what route registration gives a module.
type SiteInformation ¶
type SiteInformation = entity.SiteInformation
SiteInformation - the site's name, e-mail, language, address.
type SiteInformationRepository ¶
type SiteInformationRepository interface {
Get(ctx context.Context) (*SiteInformation, error)
Update(ctx context.Context, s *SiteInformation) error
// SetLanguages saves the site's languages besides its default one.
SetLanguages(ctx context.Context, languages []SiteLanguage) error
}
SiteInformationRepository - the site's name, e-mail and languages (Deps.SiteInformation).
type SiteLanguage ¶
type SiteLanguage = entity.SiteLanguage
SiteLanguage - a language of the site besides its default one: its code and its addresses' prefix (SiteInformation.Languages).
func MoveDefaultLanguage ¶
func MoveDefaultLanguage(others []SiteLanguage, oldDef, newDef string) []SiteLanguage
MoveDefaultLanguage - others once newDef becomes the default language instead of oldDef (the old one keeps its addresses under its code).
func SiteLanguages ¶
func SiteLanguages() (string, []SiteLanguage)
SiteLanguages - the site's default language and the others in use.
type StatusCheck ¶
type StatusCheck = service.StatusCheck
StatusCheck - a module's checks: its lines of the status report, in ctx's language.
func CheckWritableDir ¶
func CheckWritableDir(title string, dir func() string) StatusCheck
CheckWritableDir - a check that dir() is a directory the site can write to; title - the directory's name, English, translated with the report (i18n.N).
func CheckWritableStore ¶
func CheckWritableStore(title string, store func() filestore.Store) StatusCheck
CheckWritableStore - a check that the store a module keeps files in (PublicFiles, PrivateFiles) takes a new file; its line shows where the store keeps them.
type TaxonomyService ¶
type TaxonomyService interface {
Vocabularies(ctx context.Context) (TaxonomyVocabularies, error)
VocabularyByID(ctx context.Context, id int) (*TaxonomyVocabulary, error)
TermByID(ctx context.Context, id int) (*TaxonomyTerm, error)
TermBySlug(ctx context.Context, slug string) (*TaxonomyTerm, error)
// TermsByIDs - the terms with these ids, by id (a missing one is
// absent).
TermsByIDs(ctx context.Context, ids []int) (map[int]TaxonomyTerm, error)
TermsByVocabularyID(ctx context.Context, vocabularyID int) (TaxonomyTerms, error)
// NodeTermsByID - a material's terms (its terms index).
NodeTermsByID(ctx context.Context, nodeID int) (TaxonomyTerms, error)
// FieldTermIDsForNode - the terms a material's taxonomy fields hold.
FieldTermIDsForNode(ctx context.Context, nodeID int) ([]int, error)
// UpdateNodeTerms sets a material's terms index.
UpdateNodeTerms(ctx context.Context, nodeID int, termIDs []int) error
}
TaxonomyService - the vocabularies and their terms (Deps.Taxonomy).
type TaxonomyVocabularies ¶
type TaxonomyVocabularies = entity.TaxonomyVocabularies
TaxonomyVocabularies - vocabularies.
type TaxonomyVocabulary ¶
type TaxonomyVocabulary = entity.TaxonomyVocabulary
TaxonomyVocabulary - a vocabulary.
type TeaserBuilder ¶
type TeaserBuilder interface {
Build(ctx context.Context, nodes Nodes) ([]TeaserItem, error)
}
TeaserBuilder - the materials' cards (Deps.Teasers).
type TeaserItem ¶
type TeaserItem = entity.TeaserItem
TeaserItem - a material's card (Deps.Teasers).
type TemplateService ¶
type TemplateService = service.TemplateService
TemplateService - the templates (BaseController.TemplateService).
type TextFilter ¶
type TextFilter = service.TextFilter
TextFilter - a module's processing of HTML text when it's shown, turned on per text format (the format page's "Processing when shown"): Name, Module, Label, Description, Apply(ctx, html) - ctx carries the page's language, called on every show, so cheap and without network - and an optional TinyMCE button the formats' editors get (EditorButton, EditorPlugin - the module's script registering it, static/<name>.js).
type UnsavedPreview ¶
type UnsavedPreview = interfaces.UnsavedPreview
UnsavedPreview - the strip over a previewed item's page: the page's data "unsavedPreview".
type UploadResult ¶
type UploadResult = files.UploadResult
UploadResult - what an upload stored: its type, size and dimensions.
type UploadSettings ¶
type UploadSettings = entity.UploadSettings
UploadSettings - the site's upload policy.
type UploadSettingsRepository ¶
type UploadSettingsRepository interface {
Get(ctx context.Context) (*UploadSettings, error)
}
UploadSettingsRepository - the site's upload policy (Deps.UploadSettings).
type User ¶
User - a site user.
func DeletedUser ¶
func DeletedUser() *User
DeletedUser - the author shown for content whose account is gone.
type UserContent ¶
type UserContent = service.ModuleUserContent
UserContent - a module's content of a user (Parts.UserContent): Label names its count on the deletion's confirmation (a translation source with @count, "private messages: @count"), Count - how much the user has, Delete - deletes it, before the account.
type UserRepository ¶
type UserRepository interface {
ByID(ctx context.Context, id int) (*User, error)
// ByIDs - the users with these ids, by id (a missing one is absent).
ByIDs(ctx context.Context, ids []int) (map[int]User, error)
}
UserRepository - the users (Deps.Users).
type UserService ¶
type UserService = service.UserService
UserService - the users' service (BaseDeps.Users, BaseController.UserService).
type UserSettingsSection ¶
type UserSettingsSection = interfaces.UserSettingsSection
UserSettingsSection - a module's section of a user's profile form (the user's own settings in the module).
type ViewDisplayDef ¶
type ViewDisplayDef = entity.ViewDisplayDef
ViewDisplayDef - a View's display.
type ViewField ¶
type ViewField = entity.ViewModuleField
ViewField - a value shown in a View's rows: each node's markup (Render), its settings in a View (Params: how it is shown).
type ViewFilter ¶
type ViewFilter = entity.ViewModuleFilter
ViewFilter - a number a View filters by: equal, at least, at most, has one or not.
type ViewOption ¶
type ViewOption = entity.ViewModuleOption
ViewOption - a value of a choice filter (ViewFilter.Options).
type ViewParam ¶
type ViewParam = entity.ViewModuleParam
ViewParam - a setting of a criterion or a field in a View: the kinds of a plugin block's setting (PluginBlockSetting*).
type ViewSort ¶
type ViewSort = entity.ViewModuleSort
ViewSort - a sort criterion: each node's number (Values), its settings in a View (Params: a threshold).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package demokit - the part of the module SDK a module's demo step uses (app install -demo, docs/modules/write-a-module.md): the step's registration, its texts by language, a block and a menu link of the core's, and the install transaction for the module's own ent client.
|
Package demokit - the part of the module SDK a module's demo step uses (app install -demo, docs/modules/write-a-module.md): the step's registration, its texts by language, a block and a menu link of the core's, and the install transaction for the module's own ent client. |
|
Package manifestkit - the part of the module SDK (modulekit) a module's manifest and own ent schema use: the module's description and its schema's registration.
|
Package manifestkit - the part of the module SDK (modulekit) a module's manifest and own ent schema use: the module's description and its schema's registration. |
|
Package schemakit - the engine's conventions for ent schemas, shared by the core's schema and a module's own (its ent/schema): the same table options and column types, so a module's tables look as the core's do.
|
Package schemakit - the engine's conventions for ent schemas, shared by the core's schema and a module's own (its ent/schema): the same table options and column types, so a module's tables look as the core's do. |
|
Package testkit - the part of the module SDK a module's tests use, as a module from its own repository can:
|
Package testkit - the part of the module SDK a module's tests use, as a module from its own repository can: |