feat: sitemap index and per-type files from a slot table (tracer)
- contract package: Filter, Listing and their types (D-95)
- golem15_sitemap_urls slot table and the new settings columns
- Rebuild over signpost Records, stable slot assignment, rebuild job
- GET /sitemap.xml index and GET /_sitemap/files/{file} from the table
This commit is contained in:
@@ -3,10 +3,12 @@ package models
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/cabana"
|
||||
"git.golem15.com/golem15/summercms/modules/lagoon"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -53,8 +55,44 @@ type Settings struct {
|
||||
PriorityBlog *string `gorm:"column:priority_blog"`
|
||||
PriorityCategories *string `gorm:"column:priority_categories"`
|
||||
PriorityLegal *string `gorm:"column:priority_legal"`
|
||||
|
||||
SiteURL *string `gorm:"column:site_url"`
|
||||
FileSize int `gorm:"column:file_size"`
|
||||
DefaultLocale *string `gorm:"column:default_locale"`
|
||||
ExtraURLs lagoon.Jsonable[[]ExtraURL] `gorm:"column:extra_urls"`
|
||||
RebuildPendingUntil *time.Time `gorm:"column:rebuild_pending_until"`
|
||||
NumberedSize *int `gorm:"column:numbered_size"`
|
||||
BuiltAt *time.Time `gorm:"column:built_at"`
|
||||
RebuildRequestedAt *time.Time `gorm:"column:rebuild_requested_at"`
|
||||
}
|
||||
|
||||
// DefaultFileSize is the number of addresses per sitemap file when the
|
||||
// setting is not stored (D-30); MaxFileSize is the protocol's limit.
|
||||
const (
|
||||
DefaultFileSize = 1000
|
||||
MaxFileSize = 50000
|
||||
)
|
||||
|
||||
// ExtraURL is one additional address of the settings: URL is a path (or an
|
||||
// absolute http(s) URL on the site), LastMod its optional last change as
|
||||
// the admin's date picker sends it.
|
||||
type ExtraURL struct {
|
||||
URL string `json:"url"`
|
||||
LastMod string `json:"lastmod"`
|
||||
}
|
||||
|
||||
// EffectiveFileSize is the stored file size, or DefaultFileSize when it is
|
||||
// outside 1..MaxFileSize.
|
||||
func (s Settings) EffectiveFileSize() int {
|
||||
if s.FileSize < 1 || s.FileSize > MaxFileSize {
|
||||
return DefaultFileSize
|
||||
}
|
||||
return s.FileSize
|
||||
}
|
||||
|
||||
// Extra returns the additional addresses.
|
||||
func (s Settings) Extra() []ExtraURL { return s.ExtraURLs.Get() }
|
||||
|
||||
func (Settings) TableName() string { return "golem15_sitemap_settings" }
|
||||
|
||||
// Fillable lists only the settings columns.
|
||||
@@ -114,7 +152,7 @@ func AllowedFrontendURL(u string) bool {
|
||||
// DefaultSettings is the settings PHP read when nothing was saved: tiers on
|
||||
// with the default priorities.
|
||||
func DefaultSettings() Settings {
|
||||
return Settings{ID: 1, EnablePriorityTiers: true}
|
||||
return Settings{ID: 1, EnablePriorityTiers: true, FileSize: DefaultFileSize}
|
||||
}
|
||||
|
||||
// Priority returns the value of a priority setting: the stored text, or the
|
||||
|
||||
Reference in New Issue
Block a user