Documentation
¶
Overview ¶
Package plugin runs the wasm plugins an instance has installed, each enabled site by site.
Index ¶
- Constants
- Variables
- type Host
- func (h *Host) Close(ctx context.Context)
- func (h *Host) Emit(site *db.Site, event string, payload map[string]any)
- func (h *Host) Enabled(ctx context.Context, siteID int64) ([]string, error)
- func (h *Host) Installed() []*Plugin
- func (h *Host) ModuleHasContent(name string) bool
- func (h *Host) PagePublic(ctx context.Context, site *db.Site, name string) bool
- func (h *Host) ProfileSections(ctx context.Context, site *db.Site, owner, viewer *db.User) []module.ProfileSection
- func (h *Host) RenderModule(env module.Env, name string, params map[string]string, body string) (string, bool, error)
- func (h *Host) SetEnabled(ctx context.Context, siteID int64, name string, on bool) error
- type Manifest
- type ModuleSpec
- type Plugin
- type Settings
Constants ¶
const ( PermKV = "kv" PermPagesRead = "pages.read" PermHTTP = "http" )
const API = 1
A plugin built for another API version is skipped rather than loaded into calls it would misread.
Variables ¶
var Events = []string{"page.created", "page.edited", "page.deleted", "vote.changed", "post.created"}
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
A nil Host has no plugins, so an instance without a plugins directory runs exactly as before.
func Load ¶
func Load(ctx context.Context, dir string, d *db.DB, log *slog.Logger, builtin func(string) bool) (*Host, error)
A broken plugin is logged and left out rather than keeping the wiki from starting.
func (*Host) Emit ¶
Events go out in the background. A plugin only learns of the event and cannot hold up or refuse the change that caused it.
func (*Host) ModuleHasContent ¶
func (*Host) PagePublic ¶
Events about a page an anonymous visitor may not read stay away from plugins, whose output anyone may read.
func (*Host) ProfileSections ¶
func (h *Host) ProfileSections(ctx context.Context, site *db.Site, owner, viewer *db.User) []module.ProfileSection
A plugin that fails is left out, so one broken plugin costs only its own block.
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
API int `json:"api"`
Title string `json:"title"`
Description string `json:"description"`
Modules []ModuleSpec `json:"modules"`
Events []string `json:"events"`
Permissions []string `json:"permissions"`
AllowedHosts []string `json:"allowed_hosts"`
ProfileTitle string `json:"profile_title"`
ProfileBadge bool `json:"profile_badge"`
MemoryPages uint32 `json:"memory_pages"`
TimeoutMS int `json:"timeout_ms"`
}
type ModuleSpec ¶
type Settings ¶
type Settings struct {
Config map[string]string `json:"config"`
AllowedHosts []string `json:"allowed_hosts"`
}
Settings is what the instance's operator gives a plugin, kept beside it in config.json. The plugin's author cannot know the addresses on this machine, so the operator's hosts replace the ones the manifest names.