- RecordSaved with a change outside golem15.sitemap.lastmod_ignore moves the lastmod of the record's rows (only the changed locale's for a translated change); a no-op save, an ignored change or a rebuild does not - RecordDeleted takes the record's rows out of the files at once - record events queue one rebuild per golem15.sitemap.rebuild_delay_seconds (rebuild_pending_until, P33-12); the job clears it when it starts - sitemap:rebuild [--queue], scheduled nightly at 03:00 (pact.HasSchedule)
83 lines
2.5 KiB
Go
83 lines
2.5 KiB
Go
// Package sitemap is the golem15.sitemap plugin: it serves a sitemap index
|
|
// at /sitemap.xml whose entries are per-group files of a configurable size
|
|
// (sitemap-<slug>-<n>.xml, D-30), built from the published records of every
|
|
// signpost content type and the additional addresses of its settings, with
|
|
// stable file numbers and real lastmod. Other plugins narrow it through the
|
|
// Filter of the contract package and read it through its Listing.
|
|
package sitemap
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
|
|
"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"
|
|
"git.golem15.com/golem15/summercms/modules/surf"
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
)
|
|
|
|
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)
|
|
_ pact.HasJobs = (*Plugin)(nil)
|
|
_ surf.BucketProvider = (*Plugin)(nil)
|
|
)
|
|
|
|
//go:embed config
|
|
var configFS embed.FS
|
|
|
|
// Plugin is the golem15.sitemap plugin.
|
|
type Plugin struct {
|
|
app *backpack.App
|
|
}
|
|
|
|
func (p *Plugin) ID() string { return "golem15.sitemap" }
|
|
|
|
// Requires is empty: the sitemap reads content types through signpost, not
|
|
// from a named plugin, and a Filter through the service registry.
|
|
func (p *Plugin) Requires() []string { return nil }
|
|
|
|
func (p *Plugin) Register(app *backpack.App) error {
|
|
p.app = app
|
|
return nil
|
|
}
|
|
|
|
// Boot keeps the booted application for the routes, jobs and commands and
|
|
// subscribes to the record events.
|
|
func (p *Plugin) Boot(app *backpack.App) error {
|
|
p.app = app
|
|
p.listen(app)
|
|
return nil
|
|
}
|
|
|
|
// ConfigFS ships config/config.yaml: lastmod_ignore and
|
|
// rebuild_delay_seconds.
|
|
func (p *Plugin) ConfigFS() fs.FS { return configFS }
|
|
|
|
// Commands registers sitemap:rebuild, sitemap:import and
|
|
// sitemap:import-winter.
|
|
func (p *Plugin) Commands() []bonfire.Command {
|
|
return []bonfire.Command{
|
|
console.Rebuild(p.app),
|
|
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() }
|
|
|
|
func init() {
|
|
party.Register(&Plugin{})
|
|
}
|