Documentation
¶
Overview ¶
Package bearblog is an Ambient plugin that provides basic blog functionality.
Index ¶
- Constants
- type Plugin
- func (p *Plugin) Assets() ([]ambient.Asset, ambient.FileSystemReader)
- func (p *Plugin) DisallowAnon(h http.Handler) http.Handler
- func (p *Plugin) FuncMap() func(r *http.Request) template.FuncMap
- func (p *Plugin) GrantRequests() []ambient.GrantRequest
- func (p *Plugin) Middleware() []func(next http.Handler) http.Handler
- func (p *Plugin) PluginName() string
- func (p *Plugin) PluginVersion() string
- func (p *Plugin) Routes()
- func (p *Plugin) Settings() []ambient.Setting
Examples ¶
Constants ¶
View Source
const ( // LoginURL allows user to set the login URL. LoginURL = "Login URL" // Author allows user to set the author. Author = "Author" // Subtitle allows user to set the Subtitle. Subtitle = "Subtitle" // Description allows user to set the description. Description = "Description" Footer = "Footer" // AllowHTMLinMarkdown allows user to set if they allow HTML in markdown. AllowHTMLinMarkdown = "Allow HTML in Markdown" // Username allows user to set the login username. Username = "Username" // Password allows user to set the login password. Password = "Password" // MFAKey allows user to set the MFA key. MFAKey = "MFA Key" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plugin ¶
type Plugin struct {
*ambient.PluginBase
// contains filtered or unexported fields
}
Plugin represents an Ambient plugin.
func New ¶
New returns an Ambient plugin that provides basic blog functionality.
Example ¶
package main
import (
"encoding/base64"
"log"
"os"
"github.com/ambientkit/ambient"
"github.com/ambientkit/ambient/pkg/ambientapp"
"github.com/ambientkit/plugin/generic/bearblog"
"github.com/ambientkit/plugin/logger/zaplogger"
"github.com/ambientkit/plugin/pkg/passhash"
"github.com/ambientkit/plugin/storage/memorystorage"
)
func main() {
// Generate a password hash.
s, err := passhash.HashString(os.Args[1])
if err != nil {
log.Fatalln(err.Error())
}
plugins := &ambient.PluginLoader{
// Core plugins are implicitly trusted.
Router: nil,
TemplateEngine: nil,
SessionManager: nil,
// Trusted plugins are those that are typically needed to boot so they
// will be enabled and given full access.
TrustedPlugins: map[string]bool{},
Plugins: []ambient.Plugin{
bearblog.New(base64.StdEncoding.EncodeToString([]byte(s))),
},
Middleware: []ambient.MiddlewarePlugin{
// Middleware - executes top to bottom.
},
}
_, _, err = ambientapp.NewApp("myapp", "1.0",
zaplogger.New(),
ambient.StoragePluginGroup{
Storage: memorystorage.New(),
},
plugins)
if err != nil {
log.Fatalln(err.Error())
}
}
func (*Plugin) Assets ¶
func (p *Plugin) Assets() ([]ambient.Asset, ambient.FileSystemReader)
Assets returns a list of assets and an embedded filesystem.
func (*Plugin) DisallowAnon ¶
DisallowAnon does not allow anonymous users to access the page.
func (*Plugin) GrantRequests ¶
func (p *Plugin) GrantRequests() []ambient.GrantRequest
GrantRequests returns a list of grants requested by the plugin.
func (*Plugin) Middleware ¶
Middleware returns router middleware.
func (*Plugin) PluginName ¶
PluginName returns the plugin name.
func (*Plugin) PluginVersion ¶
PluginVersion returns the plugin version.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.