feat(17-03): sitemap plugin tracer, /sitemap.xml byte-identical to PHP

- golem15.sitemap plugin: golem15_sitemap_definitions migration, Definition
  model (Fillable theme and data) with tolerant PHP-shaped item decoding and
  PHP toArray item encoding
- Url::to and buildUrl port, libxml-format serializer, generator for url and
  registry items
- GET /sitemap.xml serves the definition with theme default (404 without one,
  empty body without items)
- tests/php/gen-goldens.php and the tracer golden; TestSitemapGolden and the
  Postgres TestSitemapTracer
This commit is contained in:
2026-10-12 16:53:09 +02:00
commit fe39e26ce0
20 changed files with 2742 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
// createDefinitions creates golem15_sitemap_definitions with the PHP columns
// (v1.0.2 create_definitions_table, renamed in v2.0.0 and v2.0.1): a
// nullable indexed theme and the data text of the items.
var createDefinitions = []*gormigrate.Migration{
{
ID: "202610110001_create_golem15_sitemap_definitions",
Migrate: func(tx *gorm.DB) error {
for _, stmt := range []string{
`CREATE TABLE golem15_sitemap_definitions (
id SERIAL PRIMARY KEY,
theme VARCHAR(255) NULL,
data TEXT NULL,
created_at TIMESTAMPTZ NULL,
updated_at TIMESTAMPTZ NULL
)`,
`CREATE INDEX golem15_sitemap_definitions_theme_index ON golem15_sitemap_definitions (theme)`,
} {
if err := tx.Exec(stmt).Error; err != nil {
return err
}
}
return nil
},
Rollback: func(tx *gorm.DB) error {
return tx.Exec(`DROP TABLE IF EXISTS golem15_sitemap_definitions`).Error
},
},
}
func init() {
Register(createDefinitions...)
}

17
updates/registry.go Normal file
View File

@@ -0,0 +1,17 @@
// Package updates holds the sitemap plugin's ordered gormigrate steps.
package updates
import "github.com/go-gormigrate/gormigrate/v2"
var all []*gormigrate.Migration
// Register appends gormigrate steps so later files add migrations without
// editing plugin.go.
func Register(ms ...*gormigrate.Migration) {
all = append(all, ms...)
}
// All returns every migration registered by this package.
func All() []*gormigrate.Migration {
return all
}