forked from go-catupiry/catu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.go
56 lines (44 loc) · 1.28 KB
/
Plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package bolo
import (
"github.com/gookit/event"
"github.com/sirupsen/logrus"
)
// Core plugin
type Plugin struct {
Name string
}
func (p *Plugin) Init(a App) error {
logrus.WithFields(logrus.Fields{
"PluginName": p.Name,
}).Debug("bolo.Plugin.Init Running init")
a.GetEvents().On("bindMiddlewares", event.ListenerFunc(func(e event.Event) error {
return p.BindMiddlewares(a)
}), event.High)
a.GetEvents().On("setTemplateFunctions", event.ListenerFunc(func(e event.Event) error {
return p.setTemplateFunctions(a)
}), event.Normal)
return nil
}
func (p *Plugin) GetName() string {
return p.Name
}
func (p *Plugin) BindMiddlewares(a App) error {
BindMiddlewares(a, p)
return nil
}
func (p *Plugin) setTemplateFunctions(app App) error {
app.SetTemplateFunction("paginate", paginate)
app.SetTemplateFunction("contentDates", contentDates)
app.SetTemplateFunction("truncate", truncate)
app.SetTemplateFunction("formatDecimalWithDots", formatDecimalWithDots)
app.SetTemplateFunction("html", noEscapeHTML)
app.SetTemplateFunction("currentDate", currentDate)
app.SetTemplateFunction("renderResponseMessages", renderResponseMessages)
return nil
}
func (p *Plugin) GetMigrations() []*Migration {
return []*Migration{}
}
func (p *Plugin) SetTemplateFuncMap(app App) error {
return nil
}