package classes import ( "time" "git.golem15.com/golem15/sm-sitemap-plugin/models" ) // ItemInfo is what the sitemap knows about one URL it is about to write, the // PHP $itemInfo array: URL (before the final Url::to in BeforeAddItem, the // written loc in AddItem), MTime, the record's modification time when the // item has one, Lastmod, the written lastmod ("" when omitted), and the // hreflang Alternates. type ItemInfo struct { URL string MTime *time.Time Lastmod string Alternates []Alternate } // BeforeAddItem is the typed successor of the PHP event // golem15.sitemap.beforeAddItem. The generator fires it with // festival.Bus.UntilHandled for every URL before it is counted and written; // a listener that sets Skip drops the URL (PHP: a listener returned false). // // app.Events.Listen("acme.seo", func(ctx context.Context, e *classes.BeforeAddItem) error { // if strings.HasSuffix(e.Info.URL, "/draft") { // e.Skip = true // } // return nil // }) type BeforeAddItem struct { Item models.DefinitionItem Info ItemInfo Skip bool } // IsHandled reports Skip, so UntilHandled stops at the first listener that // drops the URL (festival.Handleable). func (e *BeforeAddItem) IsHandled() bool { return e != nil && e.Skip } // AddItem is the typed successor of the PHP event golem15.sitemap.addItem. // The generator fires it with festival.Bus.Fire after a URL's elements are // built; listeners may append child XML to Extra, which is written as it is, // before the url closing tag, so it must be escaped already (EscapeText, // EscapeAttr). // // app.Events.Listen("acme.images", func(ctx context.Context, e *classes.AddItem) error { // e.Extra = append(e.Extra, ""+classes.EscapeText(img)+"") // return nil // }) type AddItem struct { Item models.DefinitionItem Info ItemInfo Extra []string }