- docs/examples/blog: scaffolder output for acme.blog (make:plugin, make:model) in the root module, with a Post model, a fill allow-list and NewPost, the create migration and GET /api/blog/posts paginated through lagoon - short tests activate the plugin, check the route with surf, the fill allow-list and the migration order - docs/setup/porting-a-plugin.md: registration, model, migrations and routes sections with src= copies of the plugin - TestDocsRequiredPages requires setup/porting-a-plugin
69 lines
2.0 KiB
Go
69 lines
2.0 KiB
Go
package blog
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
|
|
"git.golem15.com/golem15/summercms/modules/backpack"
|
|
"git.golem15.com/golem15/summercms/modules/bonfire"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
"git.golem15.com/golem15/summercms/modules/party"
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
)
|
|
|
|
var (
|
|
_ pact.HasConfig = (*Plugin)(nil)
|
|
_ pact.HasLang = (*Plugin)(nil)
|
|
_ pact.HasMailTemplates = (*Plugin)(nil)
|
|
_ pact.HasModels = (*Plugin)(nil)
|
|
_ pact.HasMigrations = (*Plugin)(nil)
|
|
_ pact.HasCommands = (*Plugin)(nil)
|
|
_ pact.HasJobs = (*Plugin)(nil)
|
|
_ pact.HasAdminControllers = (*Plugin)(nil)
|
|
)
|
|
|
|
//go:embed config
|
|
var configFS embed.FS
|
|
|
|
//go:embed lang
|
|
var langFS embed.FS
|
|
|
|
//go:embed views/mail
|
|
var mailFS embed.FS
|
|
|
|
// Plugin is the acme.blog plugin, the Go form of Plugin.php.
|
|
type Plugin struct {
|
|
app *backpack.App
|
|
}
|
|
|
|
func (p *Plugin) ID() string { return "acme.blog" }
|
|
func (p *Plugin) Requires() []string { return nil }
|
|
|
|
func (p *Plugin) Register(*backpack.App) error { return nil }
|
|
|
|
// Boot keeps the application, so route handlers and commands can reach its
|
|
// services, such as the database, when they run.
|
|
func (p *Plugin) Boot(app *backpack.App) error {
|
|
p.app = app
|
|
return nil
|
|
}
|
|
|
|
func (p *Plugin) ConfigFS() fs.FS { return configFS }
|
|
func (p *Plugin) LangFS() fs.FS { return langFS }
|
|
|
|
func (p *Plugin) MailTemplatesFS() fs.FS { return mailFS }
|
|
func (p *Plugin) MailTemplates() []string { return nil }
|
|
func (p *Plugin) MailLayouts() map[string]string { return nil }
|
|
|
|
func (p *Plugin) Models() []any { return generatedModels() }
|
|
func (p *Plugin) Migrations() []*gormigrate.Migration { return generatedMigrations() }
|
|
func (p *Plugin) Commands() []bonfire.Command { return generatedCommands() }
|
|
func (p *Plugin) Jobs() []pact.Job { return generatedJobs() }
|
|
func (p *Plugin) AdminControllers() []pact.AdminController {
|
|
return generatedAdminControllers()
|
|
}
|
|
|
|
func init() {
|
|
party.Register(&Plugin{})
|
|
}
|