feat: auto-link phrases in the resolve answer (tracer)

- golem15_seo_autolinks (migration 202610280007) and the settings column
  autolink_max (Links tab, 0 to 20, default 3)
- classes/autolinks.go: checked save and delete with history, ForPage
- ok resolve answers carry autolinks for the page's locale without
  disabled phrases and links to the page itself, and autolink_max
This commit is contained in:
Jakub Zych
2026-11-04 16:22:23 +01:00
parent b553fc2937
commit 6203aec2bc
13 changed files with 671 additions and 9 deletions

View File

@@ -179,6 +179,10 @@ type Settings struct {
LinksNewTab bool `gorm:"column:links_new_tab"`
NofollowDomains string `gorm:"column:nofollow_domains"`
SponsoredDomains string `gorm:"column:sponsored_domains"`
// AutolinkMax is the most phrases of SEO › Auto-links linked in one
// text (Links tab, 0 to 20, 3 by default); 0 turns auto-linking off
// (D-82).
AutolinkMax int `gorm:"column:autolink_max"`
// BreadcrumbHome is the home crumb's name (translatable; empty: the
// per-locale default copy).
BreadcrumbHome string `gorm:"column:breadcrumb_home"`
@@ -247,7 +251,7 @@ func (Settings) Fillable() []string {
"local_region", "local_country", "local_latitude", "local_longitude",
"local_hours", "page_form", "page_segment", "page_title_suffix",
"page_description_suffix", "crawl_schedule", "crawl_max_pages",
"crawl_delay", "crawl_keep", "generic_anchors",
"crawl_delay", "crawl_keep", "generic_anchors", "autolink_max",
}
}
@@ -264,6 +268,7 @@ func DefaultSettings() Settings {
URLHost: HostKeep,
URLSlash: SlashKeep,
LinksNewTab: true,
AutolinkMax: DefaultAutolinkMax,
PageForm: PageFormQuery,
PublisherType: PublisherOrganization,
LocalType: DefaultLocalType,
@@ -299,9 +304,9 @@ const (
// pl lists of UI-SPEC C27, one per line.
const DefaultGenericAnchors = "click here\nhere\nmore\nread more\nlearn more\nthis link\nlink\nkliknij tutaj\ntutaj\ntu\nwięcej\nczytaj więcej\nczytaj dalej\nten link"
// AuditProblems refuses Site audit values outside their ranges
// (lagoon::validation.between.numeric, UI-SPEC C20) and an unknown
// schedule. The settings screen and the API check it on save; Problems
// AuditProblems refuses Site audit values and the Links tab's
// autolink_max outside their ranges (lagoon::validation.between.numeric,
// UI-SPEC C20) and an unknown schedule. The settings screen and the API check it on save; Problems
// leaves it out, so a partial Settings value checks its templates only.
func (s Settings) AuditProblems() map[string][]Problem {
out := map[string][]Problem{}
@@ -315,6 +320,7 @@ func (s Settings) AuditProblems() map[string][]Problem {
between("crawl_max_pages", s.CrawlMaxPages, MinCrawlMaxPages, MaxCrawlMaxPages)
between("crawl_delay", s.CrawlDelay, MinCrawlDelay, MaxCrawlDelay)
between("crawl_keep", s.CrawlKeep, MinCrawlKeep, MaxCrawlKeep)
between("autolink_max", s.AutolinkMax, MinAutolinkMax, MaxAutolinkMax)
switch s.CrawlSchedule {
case CrawlOff, CrawlDaily, CrawlWeekly:
default: