config

package
v0.0.0-...-545971b Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PluginSystem

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

PluginSystem represents loaded plugins.

func NewPluginSystem

func NewPluginSystem(log ambient.AppLogger, storage *Storage, loader *ambient.PluginLoader) (*PluginSystem, error)

NewPluginSystem returns a plugin system.

func (*PluginSystem) Authorized

func (p *PluginSystem) Authorized(pluginName string, grant ambient.Grant) bool

Authorized returns whether a plugin is inherited granted for a plugin.

func (*PluginSystem) Content

func (p *PluginSystem) Content() string

Content returns the site home page content.

func (*PluginSystem) DeletePostByID

func (p *PluginSystem) DeletePostByID(ID string) error

DeletePostByID deletes a post.

func (*PluginSystem) Enabled

func (p *PluginSystem) Enabled(name string) bool

Enabled returns if the plugin is enabled or not. If it cannot be found, it will still return false.

func (*PluginSystem) FullURL

func (p *PluginSystem) FullURL() string

FullURL returns the URL with the scheme at the beginning.

func (*PluginSystem) GrantRequests

func (p *PluginSystem) GrantRequests(pluginName string, grant ambient.Grant) ([]ambient.GrantRequest, error)

GrantRequests returns a list of grant requests.

func (*PluginSystem) Granted

func (p *PluginSystem) Granted(pluginName string, grant ambient.Grant) bool

Granted returns whether a plugin is explicitly granted for a plugin.

func (*PluginSystem) InitializePlugin

func (p *PluginSystem) InitializePlugin(pluginName string, pluginVersion string) error

InitializePlugin will initialize the plugin in the storage and will return an error if one occurs.

func (*PluginSystem) IsMiddleware

func (p *PluginSystem) IsMiddleware(name string) bool

IsMiddleware returns if the plugin is middleware.

func (*PluginSystem) Load

func (p *PluginSystem) Load() error

Load will load the storage and return an error if one occurs.

func (*PluginSystem) LoadPlugin

func (p *PluginSystem) LoadPlugin(plugin ambient.Plugin, middleware bool, grpcPlugin bool) (err error)

LoadPlugin loads a single plugin into the plugin system and saves the config.

func (*PluginSystem) LoaderMiddleware

func (p *PluginSystem) LoaderMiddleware() []ambient.MiddlewarePlugin

LoaderMiddleware returns the loader middleware, these include initial gRPC plugins as well.

func (*PluginSystem) LoaderPlugins

func (p *PluginSystem) LoaderPlugins() []ambient.Plugin

LoaderPlugins returns the loader plugins, these include initial gRPC plugins as well.

func (*PluginSystem) MiddlewareNames

func (p *PluginSystem) MiddlewareNames() []string

MiddlewareNames returns a list of middleware plugin names.

func (*PluginSystem) Names

func (p *PluginSystem) Names() []string

Names returns a list of plugin names.

func (*PluginSystem) Plugin

func (p *PluginSystem) Plugin(name string) (ambient.Plugin, error)

Plugin returns a plugin by name.

func (*PluginSystem) PluginData

func (p *PluginSystem) PluginData(name string) (ambient.PluginData, error)

PluginData returns a plugin data by name.

func (*PluginSystem) Plugins

func (p *PluginSystem) Plugins() map[string]ambient.Plugin

Plugins returns the map of plugins. This returns a map that is passed by reference and all the values are pointers so any changes to it will be reflected in the plugin system.

func (*PluginSystem) PluginsData

func (p *PluginSystem) PluginsData() map[string]ambient.PluginData

PluginsData returns the plugin data map.

func (*PluginSystem) PostByID

func (p *PluginSystem) PostByID(ID string) (ambient.Post, error)

PostByID returns the post by ID.

func (*PluginSystem) PostBySlug

func (p *PluginSystem) PostBySlug(slug string) ambient.PostWithID

PostBySlug returns the post by slug.

func (*PluginSystem) PostsAndPages

func (p *PluginSystem) PostsAndPages(onlyPublished bool) ambient.PostWithIDList

PostsAndPages returns the list of posts and pages.

func (*PluginSystem) PublishedPages

func (p *PluginSystem) PublishedPages() []ambient.Post

PublishedPages returns the list of published pages.

func (*PluginSystem) PublishedPosts

func (p *PluginSystem) PublishedPosts() []ambient.Post

PublishedPosts returns the list of published posts.

func (*PluginSystem) RemoveGrant

func (p *PluginSystem) RemoveGrant(pluginName string, grant ambient.Grant) error

RemoveGrant removes a plugin grant.

func (*PluginSystem) RemovePlugin

func (p *PluginSystem) RemovePlugin(pluginName string) error

RemovePlugin will delete the plugin from the storage and will return an error if one occurs.

func (*PluginSystem) Router

func (p *PluginSystem) Router() ambient.RouterPlugin

Router returns the router.

func (*PluginSystem) Routes

func (p *PluginSystem) Routes(pluginName string) []ambient.Route

Routes returns a list of plugin routes.

func (*PluginSystem) Save

func (p *PluginSystem) Save() error

Save will save the storage and return an error if one occurs.

func (*PluginSystem) SavePost

func (p *PluginSystem) SavePost(ID string, post ambient.Post) error

SavePost saves a post.

func (*PluginSystem) Scheme

func (p *PluginSystem) Scheme() string

Scheme returns the site scheme.

func (*PluginSystem) SessionManager

func (p *PluginSystem) SessionManager() ambient.SessionManagerPlugin

SessionManager returns the session manager.

func (*PluginSystem) SetContent

func (p *PluginSystem) SetContent(content string) error

SetContent sets the home page content.

func (*PluginSystem) SetEnabled

func (p *PluginSystem) SetEnabled(pluginName string, enabled bool) error

SetEnabled sets a plugin as enabled or not.

func (*PluginSystem) SetGrant

func (p *PluginSystem) SetGrant(pluginName string, grant ambient.Grant) error

SetGrant sets a plugin grant.

func (*PluginSystem) SetRoute

func (p *PluginSystem) SetRoute(pluginName string, route []ambient.Route)

SetRoute saves a route.

func (*PluginSystem) SetScheme

func (p *PluginSystem) SetScheme(scheme string) error

SetScheme sets the site scheme.

func (*PluginSystem) SetSetting

func (p *PluginSystem) SetSetting(pluginName string, settingName string, value interface{}) error

SetSetting sets a plugin setting.

func (*PluginSystem) SetTitle

func (p *PluginSystem) SetTitle(title string) error

SetTitle sets the title.

func (*PluginSystem) SetURL

func (p *PluginSystem) SetURL(URL string) error

SetURL sets the site URL.

func (*PluginSystem) Setting

func (p *PluginSystem) Setting(pluginName string, settingName string) (interface{}, error)

Setting returns a setting value.

func (*PluginSystem) SettingDefault

func (p *PluginSystem) SettingDefault(pluginName string, settingName string) (interface{}, error)

SettingDefault returns a setting default for a setting.

func (*PluginSystem) StorageManager

func (p *PluginSystem) StorageManager() ambient.Storage

StorageManager returns the storage manager.

func (*PluginSystem) Tags

func (p *PluginSystem) Tags(onlyPublished bool) ambient.TagList

Tags returns the list of tags.

func (*PluginSystem) TemplateEngine

func (p *PluginSystem) TemplateEngine() ambient.TemplateEnginePlugin

TemplateEngine returns the template engine.

func (*PluginSystem) Title

func (p *PluginSystem) Title() string

Title returns the title.

func (*PluginSystem) Trusted

func (p *PluginSystem) Trusted(pluginName string) bool

Trusted returns if a plugin is trusted.

func (*PluginSystem) TrustedPluginNames

func (p *PluginSystem) TrustedPluginNames() []string

TrustedPluginNames returns a list of sorted trusted names.

func (*PluginSystem) URL

func (p *PluginSystem) URL() string

URL returns the URL without the scheme at the beginning.

func (*PluginSystem) Updated

func (p *PluginSystem) Updated() time.Time

Updated returns the home last updated timestamp.

type Storage

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

Storage represents a writable and readable object.

func NewStorage

NewStorage returns a writable and readable site object. Returns an error if the object cannot be initially read.

func (*Storage) Load

func (s *Storage) Load() error

Load reads the site object from the data storage and returns an error if it cannot be read.

func (*Storage) LoadDecrypted

func (s *Storage) LoadDecrypted() error

LoadDecrypted reads the site object from the data storage always decrypted and returns an error if it cannot be read.

func (*Storage) Save

func (s *Storage) Save() error

Save writes the site object to the data storage and returns an error if it cannot be written.

func (*Storage) SaveDecrypted

func (s *Storage) SaveDecrypted() error

SaveDecrypted writes the site object to the data storage always decrypted and returns an error if it cannot be written.

Jump to

Keyboard shortcuts

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