- golem15_seo_crawls, crawl pages, links, issues and ignores (P33-37) - classes/crawl: fetchguard client on the site host and its www twin, sitemap index and robots.txt seeds, two workers with a delay, limits - h1_missing and h1_multiple with the P33-38 fix route - POST /_seo/api/v1/crawls queues the golem15.seo.crawl job; GET /issues answers the stored issues with id, severity, source, fix, found_at, ignored and crawl_id
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package seo
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.golem15.com/golem15/sm-seo-plugin/classes"
|
|
"git.golem15.com/golem15/sm-seo-plugin/classes/crawl"
|
|
"git.golem15.com/golem15/summercms/modules/conga"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
)
|
|
|
|
// Jobs registers the entry generation job (D-94) and the crawl job
|
|
// (golem15.seo.crawl, D-14) on conga. A crawl is not retried: a failed run
|
|
// records its error and keeps what it fetched.
|
|
func (p *Plugin) Jobs() []pact.Job {
|
|
return []pact.Job{
|
|
conga.Job(p.generateEntries, conga.MaxAttempts(3)),
|
|
conga.Job(p.crawl, conga.MaxAttempts(1), conga.Timeout(6*time.Hour)),
|
|
}
|
|
}
|
|
|
|
// crawl runs one crawl job (golem15.seo.crawl).
|
|
func (p *Plugin) crawl(ctx context.Context, args crawl.CrawlArgs) error {
|
|
svc := p.Service()
|
|
if svc == nil {
|
|
return classes.ErrNotBooted
|
|
}
|
|
return crawl.Run(ctx, svc, args.CrawlID)
|
|
}
|
|
|
|
// generateEntries runs one generation job.
|
|
func (p *Plugin) generateEntries(ctx context.Context, args classes.GenerateEntriesArgs) error {
|
|
svc := p.Service()
|
|
if svc == nil {
|
|
return classes.ErrNotBooted
|
|
}
|
|
res, err := svc.GenerateEntries(ctx, args.Type)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pluginLog.Info("golem15.seo: entries generated", "type", args.Type, "created", res.Created, "updated", res.Updated)
|
|
return nil
|
|
}
|
|
|
|
var _ pact.HasJobs = (*Plugin)(nil)
|