Phase 3 part 4: changes approved one at a time, as Gitea pull requests

Proposals (at most 3 waiting) for pages on page one without clicks and
for the audit's title and description issues: the AI writes the title
(without the site's suffix, within the pixel budget) and description
from the live page and its searches. A yes syncs a working copy of the
site's Gitea repository (token as a header only), finds the page's Hugo
content file, sets title and description in its front matter, builds
with Hugo to check the page comes out as proposed, pushes a branch and
opens a pull request; it never merges. Merged changes are checked on
the live site, then compared before and after from Search Console.
Hugo is in the image. Schema 15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 08:04:01 -07:00
co-authored by Claude Opus 5.5
parent 43a7b42126
commit 438192faba
26 changed files with 2267 additions and 11 deletions
+25 -1
View File
@@ -114,6 +114,9 @@ func (s *Server) renderSearchSettings(w http.ResponseWriter, r *http.Request, er
data := map[string]any{
"Fields": googleFields,
"Speed": pageSpeedKey,
"GiteaKey": giteaToken,
"GiteaSet": s.Secrets.Has(secrets.GiteaToken),
"GiteaURL": s.giteaURL(),
"SpeedSet": s.Secrets.Has(secrets.PageSpeedAPIKey),
"Set": s.secretState(secrets.GoogleClientID, secrets.GoogleClientSecret, secrets.GoogleRefreshToken),
"Redirect": s.callbackURL("google"),
@@ -139,7 +142,7 @@ func (s *Server) searchSettingsSave(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if err := s.saveSecrets(r, append(googleFields, pageSpeedKey)); err != nil {
if err := s.saveSecrets(r, append(googleFields, pageSpeedKey, giteaToken)); err != nil {
s.serverError(w, err)
return
}
@@ -152,6 +155,17 @@ func (s *Server) searchSettingsSave(w http.ResponseWriter, r *http.Request) {
gauth.token = ""
gauth.mu.Unlock()
}
if _, has := r.PostForm["gitea_url"]; has {
u := strings.TrimRight(strings.TrimSpace(r.PostFormValue("gitea_url")), "/")
if u != "" && !strings.HasPrefix(u, "https://") && !strings.HasPrefix(u, "http://") {
s.renderSearchSettings(w, r, "Gitea's address must start with https://")
return
}
if err := s.DB.PutJSON(giteaURLKey, u); err != nil {
s.serverError(w, err)
return
}
}
if _, has := r.PostForm["min_clicks"]; has {
f := r.PostFormValue
clicks, _ := strconv.Atoi(f("min_clicks"))
@@ -226,6 +240,9 @@ func (s *Server) RunSEO(ctx context.Context) {
if err := seo.RecoverAudits(s.DB); err != nil {
s.Log.Error("seo: recovering audits", "err", err)
}
if err := seo.RecoverChanges(s.DB); err != nil {
s.Log.Error("seo: recovering changes", "err", err)
}
tick := time.NewTicker(30 * time.Minute)
defer tick.Stop()
for {
@@ -246,6 +263,7 @@ func (s *Server) RunSEO(ctx context.Context) {
}
s.weeklyReports(ctx, time.Now())
}
s.refreshChanges(ctx)
select {
case <-ctx.Done():
return
@@ -577,3 +595,9 @@ func (s *Server) weeklyAudits(now time.Time) {
}
}
}
func (s *Server) giteaTest(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)
defer cancel()
s.fragment(w, "sources", "test-result", s.testGitea(ctx))
}