plugin

package
v0.0.0-...-fa214a9 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorUnknownPlugin is the error returned when trying to get unknown plugin
	ErrorUnknownPlugin = errors.New("Unknown plugin")
)

Functions

func GetAll

func GetAll() map[string]Plugin

GetAll returns loaded plugins map with the key as plugin name and value as plugin instance

func GetName

func GetName(p Plugin) (string, error)

GetName returns the name for a loaded plugin

Types

type Config

type Config struct {
	Enabled []string `env:"PLUGINS_ENABLED"`
	Settings
}

Config is the configuration for app plugins

func (Config) SetUp

func (c Config) SetUp(instance Plugin) (map[string]string, error)

SetUp applies configuration for enabled plugins

type Disqus

type Disqus struct{}

Disqus is https://disqus.com/ Plugin implementation

func (*Disqus) Defaults

func (p *Disqus) Defaults() map[string]string

Defaults returns maps of default plugin configurations

func (*Disqus) SetUp

func (p *Disqus) SetUp(settings map[string]string) (map[string]string, error)

SetUp applies settings map to a plugin

type ErrorConfiguring

type ErrorConfiguring struct {
	// contains filtered or unexported fields
}

ErrorConfiguring is the error returned when plugin configuring fails

func NewErrorConfiguring

func NewErrorConfiguring(field string) *ErrorConfiguring

NewErrorConfiguring creates new ErrorConfiguring instance

func (*ErrorConfiguring) Error

func (e *ErrorConfiguring) Error() string

func (*ErrorConfiguring) Field

func (e *ErrorConfiguring) Field() string

Field returns configuring error field name

type GoogleAnalytics

type GoogleAnalytics struct{}

GoogleAnalytics is http://www.google.com/analytics/ Plugin implementation

func (*GoogleAnalytics) Defaults

func (p *GoogleAnalytics) Defaults() map[string]string

Defaults returns maps of default plugin configurations

func (*GoogleAnalytics) SetUp

func (p *GoogleAnalytics) SetUp(settings map[string]string) (map[string]string, error)

SetUp applies settings map to a plugin

type GoogleTagManager

type GoogleTagManager struct{}

GoogleTagManager is https://tagmanager.google.com Plugin implementation

func (*GoogleTagManager) Defaults

func (p *GoogleTagManager) Defaults() map[string]string

Defaults returns maps of default plugin configurations

func (*GoogleTagManager) SetUp

func (p *GoogleTagManager) SetUp(settings map[string]string) (map[string]string, error)

SetUp applies settings map to a plugin

type HighlightJS

type HighlightJS struct{}

HighlightJS is https://highlightjs.org/ Plugin implementation

func (*HighlightJS) Defaults

func (p *HighlightJS) Defaults() map[string]string

Defaults returns maps of default plugin configurations

func (*HighlightJS) SetUp

func (p *HighlightJS) SetUp(settings map[string]string) (map[string]string, error)

SetUp applies settings map to a plugin

type Plugin

type Plugin interface {
	// Defaults returns maps of default plugin configurations
	Defaults() map[string]string
	// SetUp applies settings map to a plugin
	SetUp(settings map[string]string) (map[string]string, error)
}

Plugin is the interface for plugins

func GetByName

func GetByName(name string) (Plugin, error)

GetByName returns plugin instance by name

type Settings

type Settings struct {
	Disqus      map[string]string `env:"PLUGINS_DISQUS"`
	Ga          map[string]string `env:"PLUGINS_GA"`
	Gtm         map[string]string `env:"PLUGINS_GTM"`
	Yamka       map[string]string `env:"PLUGINS_YAMKA"`
	Highlightjs map[string]string `env:"PLUGINS_HIGHLIGHTJS"`
	Yasha       map[string]string `env:"PLUGINS_YASHA"`
}

Settings is the configuration for available plugins

func (Settings) Get

func (s Settings) Get(pluginName string) (map[string]string, bool)

Get gets plugin settings by name

type YandexMetrika

type YandexMetrika struct{}

YandexMetrika is https://metrika.yandex.ru/ Plugin implementation

func (*YandexMetrika) Defaults

func (p *YandexMetrika) Defaults() map[string]string

Defaults returns maps of default plugin configurations

func (*YandexMetrika) SetUp

func (p *YandexMetrika) SetUp(settings map[string]string) (map[string]string, error)

SetUp applies settings map to a plugin

type YandexShare

type YandexShare struct{}

YandexShare is https://tech.yandex.ru/share/ Plugin implementation

func (*YandexShare) Defaults

func (p *YandexShare) Defaults() map[string]string

Defaults returns maps of default plugin configurations

func (*YandexShare) SetUp

func (p *YandexShare) SetUp(settings map[string]string) (map[string]string, error)

SetUp applies settings map to a plugin

Jump to

Keyboard shortcuts

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