plugin

package
v0.9.0-rc.53 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plugin runs the wasm plugins an instance has installed, each enabled site by site.

Index

Constants

View Source
const (
	PermKV        = "kv"
	PermPagesRead = "pages.read"
	PermHTTP      = "http"
)
View Source
const API = 1

A plugin built for another API version is skipped rather than loaded into calls it would misread.

Variables

View Source
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) Close

func (h *Host) Close(ctx context.Context)

func (*Host) Emit

func (h *Host) Emit(site *db.Site, event string, payload map[string]any)

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

func (h *Host) Enabled(ctx context.Context, siteID int64) ([]string, error)

func (*Host) Installed

func (h *Host) Installed() []*Plugin

func (*Host) ModuleHasContent

func (h *Host) ModuleHasContent(name string) bool

func (*Host) PagePublic

func (h *Host) PagePublic(ctx context.Context, site *db.Site, name string) bool

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.

func (*Host) RenderModule

func (h *Host) RenderModule(env module.Env, name string, params map[string]string, body string) (string, bool, error)

What a plugin returns is wikitext and goes through the renderer like any other source, so a plugin cannot put raw markup on the page.

func (*Host) SetEnabled

func (h *Host) SetEnabled(ctx context.Context, siteID int64, name string, on bool) error

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"`
}

func (*Manifest) Has

func (m *Manifest) Has(perm string) bool

type ModuleSpec

type ModuleSpec struct {
	Name    string `json:"name"`
	Content bool   `json:"content"`
}

type Plugin

type Plugin struct {
	Manifest
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

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