- 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)
28 lines
961 B
Go
28 lines
961 B
Go
package sitemap
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.golem15.com/golem15/sm-sitemap-plugin/classes"
|
|
"git.golem15.com/golem15/summercms/modules/backpack"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
)
|
|
|
|
// listen subscribes to the framework's record events (D-92): a saved
|
|
// record of a content type moves the lastmod of its addresses when the
|
|
// save changed something real, a deleted one leaves the files, and both
|
|
// queue a debounced rebuild (classes.RecordSaved, classes.RecordDeleted).
|
|
// Listener errors are logged by the bus and never fail the write that
|
|
// fired them.
|
|
func (p *Plugin) listen(app *backpack.App) {
|
|
if app == nil || app.Events == nil {
|
|
return
|
|
}
|
|
app.Events.Listen("golem15.sitemap", func(ctx context.Context, ev *pact.RecordSaved) error {
|
|
return classes.RecordSaved(ctx, p.app, ev)
|
|
})
|
|
app.Events.Listen("golem15.sitemap", func(ctx context.Context, ev *pact.RecordDeleted) error {
|
|
return classes.RecordDeleted(ctx, p.app, ev)
|
|
})
|
|
}
|