- 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
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
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, "<image:image><image:loc>"+classes.EscapeText(img)+"</image:loc></image:image>")
|
|
// return nil
|
|
// })
|
|
type AddItem struct {
|
|
Item models.DefinitionItem
|
|
Info ItemInfo
|
|
Extra []string
|
|
}
|