Files
davidandClaude Opus 5.5 2b9d04297f Phase 10, part 5: access enforced on every page, form and fragment
One table maps every address to an area (a module, Settings, anything
signed in, or public); each route is checked against it, and the app won't
start with a route missing from it. Changing needs edit on the module. For
members who may only view, forms that would change something are shown
disabled and htmx buttons hidden. The menu, the Overview, Search and the
SEO emails follow each person's modules; Settings is for admins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:13:16 -07:00

85 lines
5.1 KiB
HTML

{{define "content"}}{{template "settings-start" .}}{{with .Data}}{{$d := .}}
<h2>Search engines</h2>
<p class="lede">Google Search Console is where Google says what it really shows for your sites: every number in SEO comes from it. Supermarket reads it (read-only) twice a day and keeps 16 months of it.</p>
<form method="post" action="/settings/search" autocomplete="off">
<section class="card" id="google">
<h3>Google Search Console</h3>
{{range .Fields}}{{template "key-field" (dict "F" . "Set" (index $d.Set .Name))}}{{end}}
<p class="help">Redirect URI to register on the OAuth client: <code id="google-redirect">{{.Redirect}}</code> <button type="button" class="link small" data-copy="google-redirect">Copy</button></p>
{{template "key-field" (dict "F" .Speed "Set" .SpeedSet)}}
{{if .Connected}}
<p class="ok">Connected{{with .Account}} as {{.}}{{end}}.</p>
<label class="check small"><input type="checkbox" name="remove:google.refresh_token"> disconnect</label>
{{end}}
</section>
{{if .Connected}}
<section class="card">
<h3>Your websites' properties</h3>
{{with .PropsError}}<p class="error">Couldn't list your properties: {{.}}</p>{{end}}
{{if .Sites}}
{{range .Sites}}
<label>{{.URL}}
<select name="property">
<option value="">none</option>
{{$cur := .Property}}{{range $d.Properties}}<option value="{{.URL}}" {{if eq .URL $cur}}selected{{end}}>{{.URL}}</option>{{end}}
{{if and $cur (not $d.Properties)}}<option value="{{$cur}}" selected>{{$cur}}</option>{{end}}
</select>
{{with .Last}}<span class="help {{if .Error}}error-text{{end}}">Synced {{ago .At}}{{if .Error}}: {{.Error}}{{else}}; data through {{.Through}}{{end}}.</span>{{end}}
</label>
{{end}}
{{else}}<p class="help">Add your websites to the <a href="/settings/profile">profile</a> first.</p>{{end}}
{{if not .Properties}}<p class="help">This account sees no verified properties. Add your site in Search Console, or sign in with the account that owns it.</p>{{end}}
</section>
{{end}}
<section class="card" id="bing">
<h3>Bing Webmaster Tools</h3>
<p class="small">Bing's clicks, impressions, searches and crawl issues, on SEO → Search engines. DuckDuckGo and many AI assistants draw on Bing's index.</p>
{{template "key-field" (dict "F" .BingKey "Set" .BingSet)}}
</section>
<section class="card" id="gitea">
<h3>Gitea: your sites' repositories</h3>
<p class="small">For changes you approve: Supermarket pushes a branch to the website's Hugo repository (set in the <a href="/settings/profile">profile</a>) and opens a pull request. It never merges.</p>
<label>Gitea's address <input name="gitea_url" value="{{.GiteaURL}}" placeholder="https://gitea.example.com"></label>
{{template "key-field" (dict "F" .GiteaKey "Set" .GiteaSet)}}
{{if .GiteaSet}}
<button hx-disabled-elt="this" type="button" class="secondary small" hx-post="/settings/search/test/gitea" hx-target="#test-gitea" hx-indicator="#testing-gitea">Test</button>
<span id="testing-gitea" class="htmx-indicator">Checking…</span>
<div id="test-gitea"></div>
{{end}}
</section>
{{if .Connected}}{{$s := .SEO}}
<section class="card">
<h3>The morning check and the Monday report</h3>
<p class="small">A page or search counts as a real move when its clicks change by more than this many, or its position by more than this many places on at least this many impressions. Raise them if the check lists too much; on a small site an average position jumps as soon as one search appears or disappears.</p>
<div class="cols">
<label>Clicks, more than <input name="min_clicks" inputmode="numeric" value="{{$s.MinClicks}}" size="4"></label>
<label>Positions, more than <input name="min_positions" inputmode="decimal" value="{{$s.MinPositions}}" size="4"></label>
<label>On at least <input name="min_impressions" inputmode="numeric" value="{{$s.MinImpressions}}" size="6"> impressions</label>
</div>
{{if $.Viewer.User}}
<p class="help">The Monday report and the morning check (sent when something really moved, at most once a day) go to each person with SEO who asks for them, under Settings → Your account.</p>
{{else}}
<label class="check"><input type="checkbox" name="email_report" {{if $s.EmailReport}}checked{{end}}> Email me the Monday report (through the mailbox under <a href="/settings/email">Settings → Email</a>)</label>
<label class="check"><input type="checkbox" name="email_check" {{if $s.EmailCheck}}checked{{end}}> Email me the morning check when something really moved (at most once a day, when Search Console's data moves on)</label>
{{end}}
</section>
{{end}}
<div class="actions">
<button type="submit">Save</button>
</div>
</form>
<div class="actions">
{{if and (index .Set "google.client_id") (index .Set "google.client_secret")}}
<form method="post" action="/auth/google/start"><button type="submit" class="{{if .Connected}}secondary{{end}}">{{if .Connected}}Connect again{{else}}Connect Search Console{{end}}</button></form>
{{end}}
{{if .Connected}}<form method="post" action="/settings/search/sync" data-busy="Syncing…"><button type="submit" class="secondary">Sync now</button></form>{{end}}
</div>
{{end}}{{template "settings-end"}}{{end}}