feat(17-03): full sitemap generation, settings, hooks and import commands
- generator in Definition::addItemToSet order: 50000 URL cap, lastmod from the record or the updates manifest (regular file, 5 MiB cap, fail safe), BeforeAddItem (skip) and AddItem (extra XML) festival events, tier or item priority, per-alternate expansion of list type children - priority tiers from golem15.sitemap.priority_tiers, compiled at boot, defaults equal to the PHP getPriorityForUrl rules - frontend_url rewrite of loc, xhtml:link href and the stylesheet href; GET /sitemap.xsl serves the PHP stylesheet byte for byte - golem15_sitemap_settings singleton and Settings model - sitemap:import (PHP ImportCommand) and sitemap:import-winter with the read-only Winter export SQL - urlto and full goldens generated from PHP; TestSitemapImportSmoke
This commit is contained in:
42
plugin.go
42
plugin.go
@@ -5,9 +5,16 @@
|
||||
package sitemap
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/classes"
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/console"
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/models"
|
||||
"git.golem15.com/golem15/sm-sitemap-plugin/updates"
|
||||
"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"
|
||||
@@ -15,14 +22,25 @@ import (
|
||||
|
||||
var (
|
||||
_ party.Plugin = (*Plugin)(nil)
|
||||
_ pact.HasConfig = (*Plugin)(nil)
|
||||
_ pact.HasMigrations = (*Plugin)(nil)
|
||||
_ pact.HasModels = (*Plugin)(nil)
|
||||
_ pact.HasRoutes = (*Plugin)(nil)
|
||||
_ pact.HasCommands = (*Plugin)(nil)
|
||||
)
|
||||
|
||||
//go:embed config
|
||||
var configFS embed.FS
|
||||
|
||||
// sitemapXSL is the PHP plugin's assets/sitemap.xsl, byte for byte.
|
||||
//
|
||||
//go:embed assets/sitemap.xsl
|
||||
var sitemapXSL []byte
|
||||
|
||||
// Plugin is the golem15.sitemap plugin.
|
||||
type Plugin struct {
|
||||
app *backpack.App
|
||||
app *backpack.App
|
||||
tiers classes.Tiers
|
||||
}
|
||||
|
||||
func (p *Plugin) ID() string { return "golem15.sitemap" }
|
||||
@@ -36,11 +54,33 @@ func (p *Plugin) Register(app *backpack.App) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Boot compiles the priority tier rules (classes.TiersConfigKey); a rule
|
||||
// with an unknown setting or a pattern that does not compile fails the boot.
|
||||
func (p *Plugin) Boot(app *backpack.App) error {
|
||||
p.app = app
|
||||
var tiers classes.Tiers
|
||||
var err error
|
||||
if app != nil {
|
||||
tiers, err = classes.LoadTiers(app.Config)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("golem15.sitemap: %w", err)
|
||||
}
|
||||
p.tiers = tiers
|
||||
return nil
|
||||
}
|
||||
|
||||
// ConfigFS ships config/config.yaml: the default priority tier rules.
|
||||
func (p *Plugin) ConfigFS() fs.FS { return configFS }
|
||||
|
||||
// Commands registers sitemap:import and sitemap:import-winter.
|
||||
func (p *Plugin) Commands() []bonfire.Command {
|
||||
return []bonfire.Command{
|
||||
console.Import(p.app),
|
||||
console.ImportWinter(p.app),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Plugin) Migrations() []*gormigrate.Migration { return updates.All() }
|
||||
|
||||
func (p *Plugin) Models() []any { return models.All() }
|
||||
|
||||
Reference in New Issue
Block a user