feat(journal): add EmbedRegistry, YAML boot config, and pair-aware sanitizer
This commit is contained in:
27
plugin.go
27
plugin.go
@@ -51,17 +51,44 @@ func (p *Plugin) Requires() []string { return []string{"golem15.translate"} }
|
||||
|
||||
func (p *Plugin) Register(app *backpack.App) error {
|
||||
p.app = app
|
||||
if app != nil {
|
||||
if existing, ok := app.Lookup[*classes.EmbedRegistry](); !ok || existing == nil {
|
||||
if err := app.Publish(classes.NewEmbedRegistry()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Plugin) Boot(app *backpack.App) error {
|
||||
p.app = app
|
||||
if err := p.wireEmbedProviders(app); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := p.wireSiteCache(app); err != nil {
|
||||
return err
|
||||
}
|
||||
return p.wireSearch(app)
|
||||
}
|
||||
|
||||
func (p *Plugin) wireEmbedProviders(app *backpack.App) error {
|
||||
if app == nil || app.Config == nil {
|
||||
return nil
|
||||
}
|
||||
reg, ok := app.Lookup[*classes.EmbedRegistry]()
|
||||
if !ok || reg == nil {
|
||||
reg = classes.NewEmbedRegistry()
|
||||
if err := app.Publish(reg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := reg.LoadFromConfig(app.Config); err != nil {
|
||||
return fmt.Errorf("golem15.journal: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// wireSiteCache keeps the Journal's deprecated purge keys working for one
|
||||
// release. When the framework keys site_cache.purge_url or purge_token are
|
||||
// set, the framework owns the purger (cooler.Install, cooler.SiteCacheFromApp)
|
||||
|
||||
Reference in New Issue
Block a user