A webmail client. Forked from https://git.sr.ht/~migadu/alps
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
1.1 KiB

  1. package alps
  2. import (
  3. "html/template"
  4. "github.com/labstack/echo/v4"
  5. )
  6. // PluginDir is the path to the plugins directory.
  7. const PluginDir = "plugins"
  8. // Plugin extends alps with additional functionality.
  9. type Plugin interface {
  10. // Name should return the plugin name.
  11. Name() string
  12. // LoadTemplate populates t with the plugin's functions and templates.
  13. LoadTemplate(t *template.Template) error
  14. // SetRoutes populates group with the plugin's routes.
  15. SetRoutes(group *echo.Group)
  16. // Inject is called prior to rendering a template. It can extend the
  17. // template data by setting new items in the Extra map.
  18. Inject(ctx *Context, name string, data RenderData) error
  19. // Close is called when the plugin is unloaded.
  20. Close() error
  21. }
  22. // PluginLoaderFunc loads plugins for the provided server.
  23. type PluginLoaderFunc func(*Server) ([]Plugin, error)
  24. var pluginLoaders []PluginLoaderFunc
  25. // RegisterPluginLoader registers a plugin loader. The loader will be called on
  26. // server start-up and reload.
  27. func RegisterPluginLoader(f PluginLoaderFunc) {
  28. pluginLoaders = append(pluginLoaders, f)
  29. }