feat!: remove the PHP-parity sitemap, tiers, definitions screen and XSL

BREAKING CHANGE: /sitemap.xsl is gone (404), the definitions screen and
the Phase 17 settings tile are replaced by the settings singleton, and
priority, change frequency, priority tiers and the update manifest are
no longer written or read. The config keys golem15.sitemap.cache_seconds
and golem15.sitemap.priority_tiers are removed; site_url, lastmod_ignore
and rebuild_delay_seconds are new.

- sitemap:import and sitemap:import-winter write the additional addresses
  (and site_url, default_locale) instead of the definition
- the golem15_sitemap_definitions table stays in the database, unread
This commit is contained in:
Jakub Zych
2026-11-04 11:12:51 +01:00
parent 3ba70bb69f
commit 84cb27a810
42 changed files with 582 additions and 5371 deletions

View File

@@ -1,6 +1,7 @@
// Package console holds the sitemap plugin's commands: sitemap:import (the
// PHP ImportCommand) and sitemap:import-winter (a copy of a WinterCMS
// site's definition and settings).
// Package console holds the sitemap plugin's commands: sitemap:rebuild,
// sitemap:import (a JSON list of additional addresses) and
// sitemap:import-winter (a copy of a WinterCMS site's url items and
// settings).
package console
import (
@@ -56,20 +57,24 @@ func lookupDB(ctx context.Context, app *backpack.App) (*gorm.DB, func(), error)
return gdb, func() { _ = sqlDB.Close() }, nil
}
// singletonDefinition loads the definition with the fixed theme key,
// creating it when there is none (PHP Definition::firstOrCreate).
func singletonDefinition(tx *gorm.DB) (models.Definition, error) {
var defs []models.Definition
if err := tx.Where("theme = ?", models.DefinitionTheme).Order("id ASC").Limit(1).Find(&defs).Error; err != nil {
return models.Definition{}, err
// loadSettingsForUpdate reads settings row 1 inside tx, locked, creating
// it when the migration's row is gone.
func loadSettingsForUpdate(tx *gorm.DB) (models.Settings, error) {
if err := tx.Exec(`INSERT INTO golem15_sitemap_settings (id) VALUES (1) ON CONFLICT (id) DO NOTHING`).Error; err != nil {
return models.Settings{}, err
}
if len(defs) > 0 {
return defs[0], nil
var s models.Settings
if err := tx.Raw(`SELECT * FROM golem15_sitemap_settings WHERE id = 1 FOR UPDATE`).Scan(&s).Error; err != nil {
return models.Settings{}, err
}
theme := models.DefinitionTheme
def := models.Definition{Theme: &theme}
if err := tx.Create(&def).Error; err != nil {
return models.Definition{}, err
}
return def, nil
return s, nil
}
// saveExtra stores the additional addresses on settings row 1.
func saveExtra(tx *gorm.DB, rows []models.ExtraURL) error {
if rows == nil {
rows = []models.ExtraURL{}
}
value := lagoon.Jsonable[[]models.ExtraURL]{Data: rows, Valid: true}
return tx.Exec(`UPDATE golem15_sitemap_settings SET extra_urls = ? WHERE id = 1`, value).Error
}