Documentation
¶
Index ¶
- Constants
- Variables
- func Compatible(required, current string) bool
- func ContextWithRuntime(ctx context.Context, runtime *Runtime) context.Context
- func DatabaseTableName(owner, name string) string
- func JoinMultiValue(values []string) string
- func RebindSQL(dialect, query string) string
- func Register(p Plugin)
- func RegisterTheme(theme Theme)
- func SplitMultiValue(value string) []string
- type Activator
- type AdminAction
- type AdminActionProvider
- type AdminMenuItem
- type AdminMenuProvider
- type AdminNotice
- type AdminNoticeProvider
- type AdminPage
- type AdminPageActionProvider
- type AdminPageActionResult
- type AdminPageProvider
- type AdminPageRenderContext
- type ArchivePayload
- type AttachmentDataPayload
- type AttachmentDeleteHandlePayload
- type AttachmentEditPayload
- type AttachmentMetaInfo
- type AttachmentPayload
- type AttachmentReplacePayload
- type AttachmentURLPayload
- type AutosavePayload
- type BackupPayload
- type ColumnDefinition
- type ColumnType
- type CommentActionPayload
- type CommentAvatarPayload
- type CommentBadge
- type CommentEnrichment
- type CommentFilterPayload
- type CommentGuardPayload
- type CommentLinkPayload
- type CommentListPayload
- type CommentParserPayload
- type CommentPermalinkPayload
- type CommentRenderPayload
- type CommentSavePayload
- type CommentWriteInput
- type ConfigHandler
- type ConfigProvider
- type ConfigValidator
- type ContentAuthorPayload
- type ContentDeletePayload
- type ContentFieldInput
- type ContentFieldReadOnlyPayload
- type ContentFieldsPayload
- type ContentFieldsProvider
- type ContentFilterPayload
- type ContentListPayload
- type ContentParserPayload
- type ContentPermalinkPayload
- type ContentRenderPayload
- type ContentSavePayload
- type ContentStatusPayload
- type ContentTitlePayload
- type ContentWriteInput
- type DatabaseMigrator
- type DatabaseProvider
- type Deactivator
- type ExcerptAfterPayload
- type ExcerptPayload
- type FeedItemPayload
- type FieldOption
- type FieldSchema
- type FieldType
- type FrontendHTMLPayload
- type HookControl
- type HookDispatch
- type HookFunc
- type ImageProcessPayload
- type IndexDefinition
- type InfoProvider
- type Manager
- func (m *Manager) ActiveAdminMenuItems(ctx context.Context) []AdminMenuItem
- func (m *Manager) ActivePublicPaths(ctx context.Context, runtime *Runtime) ([]string, error)
- func (m *Manager) ActiveRoutes() []Route
- func (m *Manager) Apply(ctx context.Context, name string, payload any) (any, error)
- func (m *Manager) ApplyActive(ctx context.Context, name string, payload any) (any, error)
- func (m *Manager) CallActiveService(ctx context.Context, runtime *Runtime, name string, args ...any) (any, error)
- func (m *Manager) Dispatch(ctx context.Context, name string, payload any) (HookDispatch, error)
- func (m *Manager) DispatchActive(ctx context.Context, name string, payload any) (HookDispatch, error)
- func (m *Manager) HasActiveHook(name string) bool
- func (m *Manager) HasActiveService(name string) bool
- func (m *Manager) IsActive(name string) bool
- func (m *Manager) Plugin(name string) (Plugin, bool)
- func (m *Manager) PluginInfo(p Plugin) PluginInfo
- func (m *Manager) Plugins() []Plugin
- func (m *Manager) Register(p Plugin)
- func (m *Manager) RegisterAdminMenu(item AdminMenuItem)
- func (m *Manager) RegisterHook(name string, fn HookFunc)
- func (m *Manager) RegisterHookWithPriority(name string, priority int, fn HookFunc)
- func (m *Manager) RegisterPublicPathProvider(provider PublicPathProvider)
- func (m *Manager) RegisterRoute(method, pattern string, handler RouteHandler)
- func (m *Manager) RegisterRuntimeHook(name string, fn RuntimeHookFunc)
- func (m *Manager) RegisterRuntimeHookWithPriority(name string, priority int, fn RuntimeHookFunc)
- func (m *Manager) RegisterService(name string, fn ServiceFunc)
- func (m *Manager) RegisterTheme(theme Theme)
- func (m *Manager) Routes() []Route
- func (m *Manager) SetActivePlugins(names []string)
- func (m *Manager) Theme(name string) (Theme, bool)
- func (m *Manager) Themes() []Theme
- type MetaPermalinkPayload
- type PersonalConfigProvider
- type Plugin
- type PluginInfo
- type PublicArchivePeriod
- type PublicComment
- type PublicCommentQuery
- type PublicContent
- type PublicContentQuery
- type PublicMeta
- type PublicMetaQuery
- type PublicPathProvider
- type PublicRevision
- type PublicUser
- type PublicUserQuery
- type RequestPayload
- type RevisionPayload
- type Route
- type RouteHandler
- type Runtime
- func (r *Runtime) DatabaseTableName(table string) string
- func (r *Runtime) GetAdminURL(ctx context.Context) string
- func (r *Runtime) GetComment(ctx context.Context, coid int64) (PublicComment, error)
- func (r *Runtime) GetContent(ctx context.Context, cid int64) (PublicContent, error)
- func (r *Runtime) GetMeta(ctx context.Context, mid int64) (PublicMeta, error)
- func (r *Runtime) GetSiteURL(ctx context.Context) string
- func (r *Runtime) GetUser(ctx context.Context, uid int64) (PublicUser, error)
- func (r *Runtime) OpenPluginDatabase(ctx context.Context) (*sql.DB, error)
- func (r *Runtime) RebindSQL(ctx context.Context, query string) string
- func (r *Runtime) WithComponent(kind, owner string) *Runtime
- func (r *Runtime) WithOwner(owner string) *Runtime
- type RuntimeHookFunc
- type ServiceFunc
- type StaticProvider
- type TableDefinition
- type Theme
- type ThemeCapabilities
- type TrackbackPayload
- type Translator
- type UploadHandlePayload
- type UploadPayload
- type UserHashValidatePayload
- type UserLoginPayload
- type UserLogoutPayload
- type UserRegisterPayload
- type WAFPayload
- type WAFStatistics
- type XMLRPCPingbackPayload
- type XMLRPCTextPayload
- type XMLRPCUploadPayload
Constants ¶
const ( HookPriorityEarly = -100 HookPriorityNormal = 0 HookPriorityLate = 100 )
const ( HookContentBeforeSave = "content.before_save" HookContentAfterSave = "content.after_save" HookContentBeforeDelete = "content.before_delete" HookContentAfterDelete = "content.after_delete" HookContentBeforeStatus = "content.before_status_change" HookContentAfterStatus = "content.after_status_change" HookContentFilter = "content.filter" HookContentBeforeRender = "content.before_render" HookContentAfterRender = "content.after_render" HookContentTitle = "content.title" HookContentParse = "content.parse" HookExcerpt = "content.excerpt" HookExcerptAfterRender = "excerpt.after_render" HookContentList = "content.list" HookContentFields = "content.fields" HookContentFieldReadOnly = "content.field_read_only" HookContentPermalink = "content.permalink" HookContentAuthor = "content.author" HookCommentBeforeSave = "comment.before_save" HookCommentAfterSave = "comment.after_save" HookCommentBeforeMark = "comment.before_mark" HookCommentAfterMark = "comment.after_mark" HookCommentBeforeDelete = "comment.before_delete" HookCommentAfterDelete = "comment.after_delete" HookCommentFilter = "comment.filter" HookCommentBeforeRender = "comment.before_render" HookCommentAfterRender = "comment.after_render" HookCommentParse = "comment.parse" HookCommentAvatar = "comment.avatar" HookCommentPermalink = "comment.permalink" HookCommentListRender = "comment.list_render" HookCommentReplyLink = "comment.reply_link" HookCommentGuard = "comment.guard_validate" HookUploadBeforeSave = "upload.before_save" HookUploadHandle = "upload.handle" HookUploadAfterSave = "upload.after_save" HookAttachmentBeforeEdit = "attachment.before_edit" HookAttachmentAfterEdit = "attachment.after_edit" HookAttachmentBeforeReplace = "attachment.before_replace" HookAttachmentReplaceHandle = "attachment.replace_handle" HookAttachmentAfterReplace = "attachment.after_replace" HookAttachmentBeforeDelete = "attachment.before_delete" HookAttachmentDeleteHandle = "attachment.delete_handle" HookAttachmentAfterDelete = "attachment.after_delete" HookAttachmentURL = "attachment.url" HookAttachmentData = "attachment.data" HookRequestBefore = "request.before" HookRequestFallback = "request.fallback" HookRequestAfter = "request.after" HookUserLoginBefore = "user.login_before" HookUserLoginAuthenticated = "user.login_authenticated" HookUserLoginAfter = "user.login_after" HookUserLoginFail = "user.login_fail" HookUserLogout = "user.logout" HookUserRegisterBefore = "user.register_before" HookUserRegisterAfter = "user.register_after" HookAdminMenu = "admin.menu" HookFrontendHead = "frontend.head" HookArchiveBeforeQuery = "archive.before_query" HookArchiveAfterQuery = "archive.after_query" HookArchiveBeforeRender = "archive.before_render" HookArchiveAfterRender = "archive.after_render" HookArchiveSearch = "archive.search" HookMetaPermalink = "meta.permalink" HookFeedItem = "feed.item" HookFeedCommentItem = "feed.comment_item" HookXMLRPCTextFilter = "xmlrpc.text_filter" HookXMLRPCUpload = "xmlrpc.upload" HookXMLRPCPingback = "xmlrpc.pingback" HookXMLRPCFinishPingback = "xmlrpc.finish_pingback" HookTrackback = "trackback.handle" HookFinishTrackback = "trackback.finish" HookBackupExport = "backup.export" HookBackupImport = "backup.import" HookUserHashValidate = "user.hash_validate" HookRevisionBeforeSave = "revision.before_save" HookRevisionAfterSave = "revision.after_save" HookWAFCheck = "waf.check" HookImageProcess = "image.process" HookAutosaveBeforeSave = "autosave.before_save" HookAutosaveAfterSave = "autosave.after_save" )
const ( NoticeInfo = "info" NoticeSuccess = "success" NoticeWarning = "warning" NoticeError = "error" NoticeAuto = "auto" NoticeSnackbar = "snackbar" NoticeCard = "card" )
const GopherInkVersion = "0.5.0"
Variables ¶
var ( )
var Default = NewManager()
Functions ¶
func Compatible ¶
func ContextWithRuntime ¶
func DatabaseTableName ¶
func JoinMultiValue ¶
JoinMultiValue encodes selected values for a multi-value field.
func RegisterTheme ¶
func RegisterTheme(theme Theme)
func SplitMultiValue ¶
SplitMultiValue decodes a stored multi-value field back into its values. Multi-value fields persist as newline-joined tokens.
Types ¶
type AdminAction ¶
AdminAction describes a POST action rendered next to a plugin's save button.
type AdminActionProvider ¶
type AdminActionProvider interface {
AdminActions() []AdminAction
HandleAdminAction(context.Context, *Runtime, string) (AdminNotice, error)
}
AdminActionProvider handles authenticated, CSRF-protected plugin settings actions.
type AdminMenuItem ¶
type AdminMenuProvider ¶
type AdminMenuProvider interface {
AdminMenuItems(context.Context) []AdminMenuItem
}
type AdminNotice ¶
type AdminNotice struct {
Type string `json:"type"`
Mode string `json:"mode,omitempty"`
Message string `json:"message"`
SkipCoreI18n bool `json:"skipCoreI18n,omitempty"`
}
AdminNotice is a plain-text message displayed by the native admin UI.
type AdminNoticeProvider ¶
type AdminNoticeProvider interface {
AdminNotices(context.Context, *Runtime, map[string]string) []AdminNotice
}
AdminNoticeProvider supplies messages for a plugin's native configuration page.
type AdminPageActionProvider ¶
type AdminPageActionProvider interface {
HandleAdminPageAction(context.Context, *Runtime, string, map[string][]string) (AdminPageActionResult, error)
}
AdminPageActionProvider handles POST actions from a native plugin page.
type AdminPageActionResult ¶
type AdminPageActionResult struct {
ConfigPatch map[string]string
Notice AdminNotice
}
type AdminPageProvider ¶
type AdminPageProvider interface {
AdminPages() []AdminPage
RenderAdminPage(context.Context, *Runtime, string, AdminPageRenderContext) (template.HTML, error)
}
AdminPageProvider renders trusted plugin UI inside the authenticated admin shell.
type AdminPageRenderContext ¶
type AdminPageRenderContext struct {
CSRF string
Config map[string]string
// Query carries the GET query parameters of the page request (same shape as
// url.Values), so native pages can support pagination, filtering and other
// stateful views through their own ?key=value links without a custom route.
Query map[string][]string
}
type ArchivePayload ¶
type ArchivePayload struct {
Type string
Slug string
Query *PublicContentQuery
Results []PublicContent
Total int64
Data map[string]any
Handled bool
}
type AttachmentDataPayload ¶
type AttachmentEditPayload ¶
type AttachmentMetaInfo ¶
type AttachmentPayload ¶
type AttachmentURLPayload ¶
type AutosavePayload ¶
type BackupPayload ¶
type ColumnDefinition ¶
type ColumnType ¶
type ColumnType string
const ( ColInt64 ColumnType = "int64" ColVarchar ColumnType = "varchar" ColText ColumnType = "text" ColFloat ColumnType = "float" ColDatetime ColumnType = "datetime" ColBool ColumnType = "bool" )
type CommentActionPayload ¶
type CommentAvatarPayload ¶
type CommentBadge ¶
type CommentEnrichment ¶
type CommentEnrichment struct {
Badges []CommentBadge
CSSClasses []string
Extra map[string]any
}
type CommentFilterPayload ¶
type CommentFilterPayload struct {
Comment any
}
type CommentGuardPayload ¶
type CommentLinkPayload ¶
type CommentLinkPayload struct {
Comment PublicComment
Content PublicContent
URL string
HTML template.HTML
}
type CommentListPayload ¶
type CommentListPayload struct {
Content PublicContent
Comments []PublicComment
Views any
Pager any
HTML template.HTML
Handled bool
}
type CommentParserPayload ¶
type CommentPermalinkPayload ¶
type CommentPermalinkPayload struct {
Comment PublicComment
Content PublicContent
URL string
}
type CommentRenderPayload ¶
type CommentSavePayload ¶
type CommentWriteInput ¶
type ConfigHandler ¶
type ConfigProvider ¶
type ConfigProvider interface {
ConfigSchema() []FieldSchema
}
type ConfigValidator ¶
type ContentAuthorPayload ¶
type ContentAuthorPayload struct {
Content PublicContent
Author PublicUser
}
type ContentDeletePayload ¶
type ContentFieldInput ¶
type ContentFieldsPayload ¶
type ContentFieldsPayload struct {
ContentID int64
Type string
Fields []FieldSchema
}
type ContentFieldsProvider ¶
type ContentFieldsProvider interface {
ContentFieldSchema() []FieldSchema
}
type ContentFilterPayload ¶
type ContentFilterPayload struct {
Content any
}
type ContentListPayload ¶
type ContentParserPayload ¶
type ContentPermalinkPayload ¶
type ContentPermalinkPayload struct {
Content PublicContent
URL string
}
type ContentRenderPayload ¶
type ContentSavePayload ¶
type ContentStatusPayload ¶
type ContentTitlePayload ¶
type ContentWriteInput ¶
type ContentWriteInput struct {
ID int64
PublishedID int64
AuthorID int64
Operation string
Title string
Slug string
SlugID int64
Text string
Type string
Status string
Password string
Created int64
SortOrder int64
Template string
Parent int64
AllowComment bool
AllowPing bool
AllowFeed bool
CategoryIDs []int64
Tags []string
Fields []ContentFieldInput
DraftOf int64
}
type DatabaseMigrator ¶
type DatabaseProvider ¶
type DatabaseProvider interface {
DatabaseTables() []TableDefinition
DatabaseVersion() int
}
type ExcerptAfterPayload ¶
type ExcerptAfterPayload struct {
Content PublicContent
Text string
Limit int
Excerpt string
}
type ExcerptPayload ¶
type FeedItemPayload ¶
type FeedItemPayload struct {
Kind string
Content PublicContent
Comment PublicComment
Item any
Handled bool
}
type FieldOption ¶
type FieldSchema ¶
type FieldSchema struct {
Name string
Label string
Group string
Type FieldType
Default string
Description string
Required bool
ShowWhenField string
ShowWhenValue string
Min string
Max string
Step string
Options []FieldOption
ForTypes []string
ReadOnly bool
Wide bool
// Translate is attached while core collects theme and plugin content
// fields, keeping extension-owned labels out of the core translation table.
Translate func(string) string
}
type FieldType ¶
type FieldType string
const ( FieldText FieldType = "text" FieldPassword FieldType = "password" FieldTextarea FieldType = "textarea" FieldRadio FieldType = "radio" FieldCheckbox FieldType = "checkbox" FieldSelect FieldType = "select" FieldNumber FieldType = "number" FieldColor FieldType = "color" FieldImage FieldType = "image" // FieldSwitch renders an MDUI switch; the stored value is "1"/"0" like a checkbox. FieldSwitch FieldType = "switch" // FieldSlider renders an MDUI slider bound to Min/Max/Step; the stored value is numeric. FieldSlider FieldType = "slider" // FieldDate, FieldTime and FieldDatetime render native date/time pickers; the // stored value is the raw control value (YYYY-MM-DD, HH:MM, or YYYY-MM-DDTHH:MM). FieldDate FieldType = "date" FieldTime FieldType = "time" FieldDatetime FieldType = "datetime" // FieldMultiSelect and FieldMultiCheckbox store multiple selected values joined // by newlines, mirroring Typecho's Checkbox->multiMode()/multi-select forms. FieldMultiSelect FieldType = "multiselect" FieldMultiCheckbox FieldType = "multicheckbox" )
func (FieldType) IsBoolean ¶
IsBooleanField reports whether a field type stores a "1"/"0" boolean value.
func (FieldType) IsMultiValue ¶
IsMultiValueField reports whether a field type stores several selected values.
type FrontendHTMLPayload ¶
type HookControl ¶
HookControl lets a hook stop the remaining callbacks while preserving a payload.
func StopHook ¶
func StopHook(payload any) HookControl
type HookDispatch ¶
HookDispatch reports whether a hook point was handled and whether propagation stopped.
type ImageProcessPayload ¶
type IndexDefinition ¶
type InfoProvider ¶
type InfoProvider interface {
Info() PluginInfo
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
func (*Manager) ActiveAdminMenuItems ¶
func (m *Manager) ActiveAdminMenuItems(ctx context.Context) []AdminMenuItem
func (*Manager) ActivePublicPaths ¶
ActivePublicPaths collects configured paths from active plugins. Providers execute outside the manager lock so they can safely use Runtime services.
func (*Manager) ActiveRoutes ¶
func (*Manager) ApplyActive ¶
func (*Manager) CallActiveService ¶
func (*Manager) DispatchActive ¶
func (*Manager) HasActiveHook ¶
func (*Manager) HasActiveService ¶
func (*Manager) PluginInfo ¶
func (m *Manager) PluginInfo(p Plugin) PluginInfo
func (*Manager) RegisterAdminMenu ¶
func (m *Manager) RegisterAdminMenu(item AdminMenuItem)
func (*Manager) RegisterHook ¶
func (*Manager) RegisterHookWithPriority ¶
func (*Manager) RegisterPublicPathProvider ¶
func (m *Manager) RegisterPublicPathProvider(provider PublicPathProvider)
RegisterPublicPathProvider registers runtime-configured exact public paths. The handler for those paths can be implemented by a registered route or by HookRequestFallback after the WAF route snapshot has accepted the path.
func (*Manager) RegisterRoute ¶
func (m *Manager) RegisterRoute(method, pattern string, handler RouteHandler)
func (*Manager) RegisterRuntimeHook ¶
func (m *Manager) RegisterRuntimeHook(name string, fn RuntimeHookFunc)
func (*Manager) RegisterRuntimeHookWithPriority ¶
func (m *Manager) RegisterRuntimeHookWithPriority(name string, priority int, fn RuntimeHookFunc)
func (*Manager) RegisterService ¶
func (m *Manager) RegisterService(name string, fn ServiceFunc)
RegisterService publishes a single-owner named service from Plugin.Init. Duplicate names fail during startup so callers never observe an ambiguous provider.
func (*Manager) RegisterTheme ¶
func (*Manager) SetActivePlugins ¶
type MetaPermalinkPayload ¶
type MetaPermalinkPayload struct {
Meta PublicMeta
URL string
}
type PersonalConfigProvider ¶
type PersonalConfigProvider interface {
PersonalConfigSchema() []FieldSchema
}
type PluginInfo ¶
type PublicArchivePeriod ¶
type PublicComment ¶
type PublicComment struct {
COID int64
CID int64
Created int64
Author string
AuthorID int64
// OwnerID is the author UID of the content this comment belongs to.
OwnerID int64
Mail string
URL string
IP string
Agent string
Text string
Type string
Status string
Parent int64
// Title, Slug and ContentType carry the source metadata that trackback and
// pingback comments store; for a normal comment Title/Slug are empty and
// ContentType mirrors the parent content type.
Title string
Slug string
ContentType string
}
type PublicCommentQuery ¶
type PublicContent ¶
type PublicContent struct {
CID int64
Title string
Slug string
SlugID int64
Created int64
Modified int64
Text string
Type string
Status string
AuthorID int64
Password string
CommentsNum int64
AllowComment string
AllowPing string
AllowFeed string
Template string
Parent int64
SortOrder int64
DraftOf int64
}
type PublicContentQuery ¶
type PublicMeta ¶
type PublicMetaQuery ¶
type PublicPathProvider ¶
PublicPathProvider returns exact public paths owned by a plugin whose paths are determined from runtime configuration. The core calls providers only while rebuilding its public route snapshot, never for each unknown request.
type PublicRevision ¶
type PublicUser ¶
type PublicUserQuery ¶
type RequestPayload ¶
type RevisionPayload ¶
type Route ¶
type Route struct {
Plugin string
Method string
Pattern string
Handler RouteHandler
InvalidatesPublicData bool
}
type RouteHandler ¶
type RouteHandler func(*Runtime, http.ResponseWriter, *http.Request)
type Runtime ¶
type Runtime struct {
OwnerKind string
Owner string
ListContents func(context.Context, PublicContentQuery) ([]PublicContent, int64, error)
ListComments func(context.Context, PublicCommentQuery) ([]PublicComment, int64, error)
ListUsers func(context.Context, PublicUserQuery) ([]PublicUser, int64, error)
ListMetas func(context.Context, PublicMetaQuery) ([]PublicMeta, int64, error)
ListRevisions func(context.Context, int64) ([]PublicRevision, error)
GetRevision func(context.Context, int64) (PublicRevision, error)
RestoreRevision func(context.Context, int64, int64) error
DeleteRevision func(context.Context, int64, int64) error
ArchiveMonths func(context.Context, int) ([]PublicArchivePeriod, error)
AdjacentPosts func(context.Context, int64) (PublicContent, PublicContent, error)
RelatedPosts func(context.Context, int64, int) ([]PublicContent, error)
GetEditingDraft func(context.Context, int64) (PublicContent, error)
PublishDraft func(context.Context, int64) error
ListThemeFiles func(context.Context, ...string) ([]string, error)
ThemeEditableDir func(context.Context, ...string) (string, bool)
ContentURL func(context.Context, int64) (string, error)
CommentURL func(context.Context, int64) (string, error)
AvatarURL func(context.Context, string, int) string
Language func(context.Context) string
SiteURL func(context.Context) string
AdminURL func(context.Context) string
ClientIP func(*http.Request) string
CurrentUser func(*http.Request) (PublicUser, bool)
CSRFToken func(*http.Request, string) string
ValidateCSRF func(*http.Request, string) bool
Option func(context.Context, string) (string, error)
SetOption func(context.Context, string, string) error
SaveContent func(context.Context, ContentWriteInput) (PublicContent, error)
DeleteContent func(context.Context, int64) error
SaveComment func(context.Context, CommentWriteInput) (PublicComment, error)
DeleteComment func(context.Context, int64) error
Config func(context.Context, string) (map[string]string, error)
PersonalConfig func(context.Context, string, int64) (map[string]string, error)
DispatchHook func(context.Context, string, any) (HookDispatch, error)
ServiceAvailable func(string) bool
CallService func(context.Context, string, ...any) (any, error)
NotifyAdmin func(http.ResponseWriter, *http.Request, ...AdminNotice)
OpenPluginDB func(context.Context) (*sql.DB, error)
PluginDBDialect func(context.Context) string
IsIPBanned func(context.Context, string) bool
IsURLAllowed func(context.Context, string) bool
BanIP func(context.Context, string, time.Duration, string) error
UnbanIP func(context.Context, string) error
WAFStats func(context.Context) (WAFStatistics, error)
GetContentAuthor func(context.Context, int64) (PublicUser, error)
ListContentMetas func(context.Context, int64) ([]PublicMeta, error)
GetContentFields func(context.Context, int64) (map[string]any, error)
SetContentField func(context.Context, int64, ContentFieldInput) error
IncrementContentFieldInt func(context.Context, int64, string, int64) (int64, error)
DeleteContentField func(context.Context, int64, string) error
ThumbnailURL func(context.Context, int64, int, int) (string, error)
AttachmentMeta func(context.Context, int64) (AttachmentMetaInfo, error)
ActiveTheme func(context.Context) string
ContentRenderMode func(context.Context) string
// PluginActive reports whether a named plugin is currently activated,
// equivalent to Typecho's Plugin::export()['activated'] lookup.
PluginActive func(string) bool
// PluginURL returns the public base URL for a plugin's bundled static
// assets (served under /plugin/<name>/). When owner is empty the calling
// plugin's own asset base is returned.
PluginURL func(ctx context.Context, owner string) string
// RenderContent returns the rendered HTML of any content by CID, applying
// the same markdown/autop pipeline and render hooks the frontend uses.
RenderContent func(context.Context, int64) (template.HTML, error)
// Excerpt returns a plain-text/HTML excerpt of the given text, honoring the
// content.excerpt hooks. limit is the maximum rune length.
Excerpt func(ctx context.Context, text string, limit int) string
// FeedURL, CommentsFeedURL, XMLRPCURL, LoginURL, RegisterURL, LogoutURL,
// ProfileURL and ThemeURL expose core-defined route shapes so extensions
// need not hardcode them. ThemeURL(name, file) resolves a theme asset URL.
FeedURL func(context.Context) string
CommentsFeedURL func(context.Context) string
XMLRPCURL func(context.Context) string
LoginURL func(context.Context) string
RegisterURL func(context.Context) string
LogoutURL func(context.Context) string
ProfileURL func(context.Context) string
ThemeURL func(ctx context.Context, name, file string) string
// PluginDataDir returns and creates a private on-disk directory for the
// calling extension under the data directory, for swappable side files such
// as an IP database that should not be bundled into the binary. It mirrors
// the theme ThemeEditableDir capability for plugins.
PluginDataDir func(context.Context) (string, error)
}
func (*Runtime) DatabaseTableName ¶
func (*Runtime) GetComment ¶
func (*Runtime) GetContent ¶
func (*Runtime) OpenPluginDatabase ¶
func (*Runtime) WithComponent ¶
type ServiceFunc ¶
ServiceFunc exposes one named capability to other active plugins and themes. Structured return values remain subject to html/template escaping in themes.
type StaticProvider ¶
StaticProvider lets a plugin ship bundled front-end assets (JS/CSS/images). Core serves the returned filesystem at /plugin/<name>/ and exposes the base URL through Runtime.PluginURL and the pluginURL template function, mirroring the theme Static mechanism and Typecho's pluginUrl option.
type TableDefinition ¶
type TableDefinition struct {
Name string
Columns []ColumnDefinition
Indexes []IndexDefinition
}
type Theme ¶
type Theme struct {
Name string
DisplayName string
Version string
Author string
Description string
Homepage string
Screenshot string
TemplateList []string
Templates fs.FS
Static fs.FS
Funcs template.FuncMap
Translate func(lang, key string) string
ConfigSchema []FieldSchema
ContentFields []FieldSchema
ConfigValidator func(map[string]string) map[string]string
ConfigHandler func(context.Context, *Runtime, map[string]string, bool) error
AdminNotices func(context.Context, *Runtime, map[string]string) []AdminNotice
AdminPages []AdminPage
RenderAdminPage func(context.Context, *Runtime, string, AdminPageRenderContext) (template.HTML, error)
HandleAdminPageAction func(context.Context, *Runtime, string, map[string][]string) (AdminPageActionResult, error)
EnrichComments func(context.Context, *Runtime, map[string]string, []PublicComment) map[int64]CommentEnrichment
Capabilities ThemeCapabilities
InitRuntime func(context.Context, *Runtime) error
AdjustData func(context.Context, map[string]any) error
Routes []Route
EditableDir string
Embedded bool
}
type ThemeCapabilities ¶
type ThemeCapabilities struct {
CommentGuard bool
}
ThemeCapabilities declares optional core protocols implemented by a theme. The core remains responsible for enforcing security-sensitive capabilities.
type TrackbackPayload ¶
type TrackbackPayload struct {
Content PublicContent
Input any
Comment PublicComment
Handled bool
}
type Translator ¶
Translator lets an extension localize its own labels and messages. Core only provides the current language through Runtime.Language and calls this method when rendering native extension UI.
type UploadHandlePayload ¶
type UploadPayload ¶
type UserHashValidatePayload ¶
type UserLoginPayload ¶
type UserLogoutPayload ¶
type UserLogoutPayload struct {
User PublicUser
IP string
UserAgent string
}
type UserRegisterPayload ¶
type WAFPayload ¶
type WAFStatistics ¶
type XMLRPCPingbackPayload ¶
type XMLRPCPingbackPayload struct {
SourceURI string
TargetURI string
Content PublicContent
Comment PublicComment
Message string
Handled bool
}
type XMLRPCTextPayload ¶
type XMLRPCTextPayload struct {
Method string
Content PublicContent
Text string
}