seo-supervisor 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +16 -3
- package/CHANGELOG.md +430 -0
- package/NOTICE +7 -0
- package/README.md +230 -25
- package/agents/seo-auditor.md +16 -0
- package/agents/seo-reviewer.md +16 -0
- package/bin/agents.mjs +194 -29
- package/bin/extras.mjs +422 -0
- package/bin/prompt.mjs +34 -14
- package/bin/seo-supervisor.mjs +386 -53
- package/commands/seo-audit.md +29 -3
- package/commands/seo-brief.md +28 -0
- package/commands/seo-connect.md +27 -0
- package/commands/seo-fix.md +24 -3
- package/commands/seo-grow.md +26 -0
- package/commands/seo-launch.md +17 -3
- package/commands/seo-review.md +13 -1
- package/commands/seo-rewrite.md +25 -0
- package/commands/seo-setup.md +17 -1
- package/commands/seo-watch.md +28 -0
- package/hooks/hooks.json +117 -0
- package/package.json +20 -7
- package/skills/seo-supervisor/NOTICE +7 -0
- package/skills/seo-supervisor/SKILL.md +302 -21
- package/skills/seo-supervisor/audience.md +61 -0
- package/skills/seo-supervisor/examples/drafts/security.md +41 -0
- package/skills/seo-supervisor/examples/hooks/README.md +28 -0
- package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
- package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
- package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
- package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
- package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
- package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
- package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
- package/skills/seo-supervisor/examples/sample-audit.json +94 -2
- package/skills/seo-supervisor/examples/sample-report.html +111 -61
- package/skills/seo-supervisor/examples/sample-report.md +147 -44
- package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
- package/skills/seo-supervisor/examples/snippets.md +648 -1
- package/skills/seo-supervisor/grow.md +342 -0
- package/skills/seo-supervisor/og-images.md +85 -0
- package/skills/seo-supervisor/page-types.md +124 -0
- package/skills/seo-supervisor/planning.md +19 -7
- package/skills/seo-supervisor/profile-template.md +41 -0
- package/skills/seo-supervisor/report-format.md +177 -10
- package/skills/seo-supervisor/rewrite.md +59 -0
- package/skills/seo-supervisor/rules/ai-search.md +65 -12
- package/skills/seo-supervisor/rules/content.md +33 -9
- package/skills/seo-supervisor/rules/crawl-index.md +33 -6
- package/skills/seo-supervisor/rules/internal-linking.md +49 -6
- package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
- package/skills/seo-supervisor/rules/media.md +13 -1
- package/skills/seo-supervisor/rules/metadata.md +41 -9
- package/skills/seo-supervisor/rules/performance.md +50 -5
- package/skills/seo-supervisor/rules/rendering.md +39 -2
- package/skills/seo-supervisor/rules/search-intent.md +32 -0
- package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
- package/skills/seo-supervisor/rules/structured-data.md +37 -14
- package/skills/seo-supervisor/rules/trust-security.md +25 -2
- package/skills/seo-supervisor/rules/urls.md +10 -2
- package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
- package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
- package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
- package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
- package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
- package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
- package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
- package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
- package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
- package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
- package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
- package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
- package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
- package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
- package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
- package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
- package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
- package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
- package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
- package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
- package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
- package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
- package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
- package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
- package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
- package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
- package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
- package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
- package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
- package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
- package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
- package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
- package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
- package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
- package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
- package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
- package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
- package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
- package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
- package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
- package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
- package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
- package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
- package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
- package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
- package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
- package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
- package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
- package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
- package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
- package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
- package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
- package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
- package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
- package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
- package/skills/seo-supervisor/scripts/google.mjs +1341 -0
- package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
- package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
- package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
- package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
- package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
- package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
- package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
- package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
- package/skills/seo-supervisor/scripts/guard.mjs +74 -0
- package/skills/seo-supervisor/scripts/images.mjs +408 -0
- package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
- package/skills/seo-supervisor/scripts/issues.mjs +217 -0
- package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
- package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
- package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
- package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
- package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
- package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
- package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
- package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
- package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
- package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
- package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
- package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
- package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
- package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
- package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
- package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
- package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
- package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
- package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
- package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
- package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
- package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
- package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
- package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
- package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
- package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
- package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
- package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
- package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
- package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
- package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
- package/skills/seo-supervisor/scripts/osm.mjs +359 -0
- package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
- package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
- package/skills/seo-supervisor/scripts/report/client.js +37 -0
- package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
- package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
- package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
- package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
- package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
- package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
- package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
- package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
- package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
- package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
- package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
- package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
- package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
- package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
- package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
- package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
- package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
- package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
- package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
- package/skills/seo-supervisor/scripts/report/styles.css +223 -0
- package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
- package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
- package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
- package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
- package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
- package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
- package/skills/seo-supervisor/site-types/content.md +34 -1
- package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
- package/skills/seo-supervisor/site-types/local-business.md +96 -6
- package/skills/seo-supervisor/site-types/services.md +46 -0
- package/skills/seo-supervisor/site-types/tools.md +3 -3
- package/skills/seo-supervisor/strategy.md +232 -0
- package/skills/seo-supervisor/troubleshooting.md +56 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
var DEFAULT_TAB='__DEFAULT_TAB__';
|
|
3
|
+
var d=document;d.documentElement.classList.add('js');
|
|
4
|
+
var root=d.documentElement,tb=d.querySelector('.theme-btn');
|
|
5
|
+
if(tb){var syncTheme=function(){var light=root.dataset.theme==='light';tb.querySelector('.tl').textContent=light?'Dark':'Light';tb.setAttribute('aria-label','Switch to '+(light?'dark':'light')+' theme');};
|
|
6
|
+
tb.hidden=false;syncTheme();
|
|
7
|
+
tb.addEventListener('click',function(){var light=root.dataset.theme!=='light';if(light)root.dataset.theme='light';else delete root.dataset.theme;try{localStorage.setItem('seo-report-theme',light?'light':'dark')}catch(e){}syncTheme();});}
|
|
8
|
+
var tabs=[].slice.call(d.querySelectorAll('.tab')),panels=[].slice.call(d.querySelectorAll('.tp'));
|
|
9
|
+
function show(name,focusTab){var ok=false;tabs.forEach(function(t){var on=t.dataset.tab===name;t.setAttribute('aria-selected',on);t.tabIndex=on?0:-1;if(on){ok=true;if(focusTab)t.focus();}});
|
|
10
|
+
if(!ok)return false;panels.forEach(function(p){p.hidden=p.id!=='p-'+name;});return true;}
|
|
11
|
+
tabs.forEach(function(t,i){t.addEventListener('click',function(){history.replaceState(null,'','#'+t.dataset.tab);show(t.dataset.tab);});
|
|
12
|
+
t.addEventListener('keydown',function(e){var k=e.key,j=i;if(k==='ArrowRight')j=(i+1)%tabs.length;else if(k==='ArrowLeft')j=(i-1+tabs.length)%tabs.length;else if(k==='Home')j=0;else if(k==='End')j=tabs.length-1;else return;
|
|
13
|
+
e.preventDefault();history.replaceState(null,'','#'+tabs[j].dataset.tab);show(tabs[j].dataset.tab,true);});});
|
|
14
|
+
var list=d.getElementById('flist');
|
|
15
|
+
function setOpen(f,open){f.classList.toggle('open',open);f.querySelector('.f-head').setAttribute('aria-expanded',open);
|
|
16
|
+
if(list)list.classList.toggle('focus',!!list.querySelector('.f.open'));}
|
|
17
|
+
[].forEach.call(d.querySelectorAll('.f-head'),function(b){b.addEventListener('click',function(){var f=b.closest('.f');setOpen(f,!f.classList.contains('open'));});});
|
|
18
|
+
var state={sev:'all',status:'all',area:'all',q:''};
|
|
19
|
+
function apply(){if(!list)return;var n=0,all=list.children.length;[].forEach.call(list.children,function(f){
|
|
20
|
+
var ok=(state.sev==='all'||f.dataset.sev===state.sev)&&(state.status==='all'||f.dataset.status===state.status)&&(state.area==='all'||f.dataset.area===state.area)&&(!state.q||f.dataset.text.indexOf(state.q)>-1);
|
|
21
|
+
f.hidden=!ok;if(ok)n++;});
|
|
22
|
+
d.getElementById('showing').textContent=(n===all?all:n+' of '+all)+' findings';d.getElementById('fnone').hidden=n>0;}
|
|
23
|
+
[].forEach.call(d.querySelectorAll('.segb[data-sev]'),function(b){b.addEventListener('click',function(){[].forEach.call(d.querySelectorAll('.segb[data-sev]'),function(x){x.setAttribute('aria-pressed',x===b);});state.sev=b.dataset.sev;apply();});});
|
|
24
|
+
var pb=[].slice.call(d.querySelectorAll('.segb[data-pstatus]'));pb.forEach(function(b){b.addEventListener('click',function(){pb.forEach(function(x){x.setAttribute('aria-pressed',x===b);});var st=b.dataset.pstatus;[].forEach.call(d.querySelectorAll('.prow'),function(r){r.hidden=st!=='all'&&r.dataset.status!==st;});});});
|
|
25
|
+
var q=d.getElementById('q');if(q)q.addEventListener('input',function(){state.q=q.value.trim().toLowerCase();apply();});
|
|
26
|
+
var fs=d.getElementById('fstatus');if(fs)fs.addEventListener('change',function(){state.status=fs.value;apply();});
|
|
27
|
+
var fa=d.getElementById('farea');if(fa)fa.addEventListener('change',function(){state.area=fa.value;apply();});
|
|
28
|
+
var fr=d.getElementById('freset');if(fr)fr.addEventListener('click',function(){state={sev:'all',status:'all',area:'all',q:''};if(q)q.value='';if(fs)fs.value='all';if(fa)fa.value='all';
|
|
29
|
+
[].forEach.call(d.querySelectorAll('.segb[data-sev]'),function(x){x.setAttribute('aria-pressed',x.dataset.sev==='all');});apply();});
|
|
30
|
+
[].forEach.call(d.querySelectorAll('.area[data-sev]'),function(a){a.addEventListener('click',function(e){e.preventDefault();var b=d.querySelector('.segb[data-sev="'+a.dataset.sev+'"]');if(b)b.click();history.replaceState(null,'','#findings');show('findings');window.scrollTo(0,0);});});
|
|
31
|
+
[].forEach.call(d.querySelectorAll('.area[data-area]'),function(a){a.addEventListener('click',function(e){e.preventDefault();if(fa){fa.value=a.dataset.area;state.area=a.dataset.area;apply();}
|
|
32
|
+
history.replaceState(null,'','#findings');show('findings');window.scrollTo(0,0);});});
|
|
33
|
+
function route(e){var h=decodeURIComponent(location.hash.slice(1));if(!h){show(DEFAULT_TAB);return;}
|
|
34
|
+
if(show(h)||(h.slice(0,2)==='p-'&&show(h.slice(2))))return;var f=d.getElementById(h);if(f&&f.classList.contains('f')){show('findings');f.hidden=false;setOpen(f,true);f.scrollIntoView({block:'start'});if(e)f.querySelector('.f-head').focus({preventScroll:true});}else show(DEFAULT_TAB);}
|
|
35
|
+
window.addEventListener('beforeprint',function(){[].forEach.call(d.querySelectorAll('details'),function(r){r.open=true;});});
|
|
36
|
+
window.addEventListener('hashchange',route);route();
|
|
37
|
+
})();
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The Since last audit tab and the parts the Markdown reuses, plus the Search Central posts and the audit timeline.
|
|
3
|
+
import { esc, fmtDate, link, noteCode, noteMd, num, obj, isCount } from "./format.mjs";
|
|
4
|
+
|
|
5
|
+
export function diffParts({ raw, findings }, { googleUpdatesText }) {
|
|
6
|
+
// links-import.mjs computes links-dropped, as only it has both audits' links.json summaries.
|
|
7
|
+
const LINKS_DROP = {
|
|
8
|
+
sites: "Sites linking to you (Search Console)",
|
|
9
|
+
bingPages: "Your pages with links from other sites (Bing)",
|
|
10
|
+
};
|
|
11
|
+
const linksDrop = (c =>
|
|
12
|
+
c &&
|
|
13
|
+
c.kind === "links-dropped" &&
|
|
14
|
+
Object.hasOwn(LINKS_DROP, c.what) &&
|
|
15
|
+
[c.before, c.after].every(n => Number.isInteger(n) && n >= 0) &&
|
|
16
|
+
c.after < c.before
|
|
17
|
+
? c
|
|
18
|
+
: null)(obj(raw.linksChange));
|
|
19
|
+
const linksDropText = () =>
|
|
20
|
+
`${num(linksDrop.before)} → ${num(linksDrop.after)} (−${Math.round((100 * (linksDrop.before - linksDrop.after)) / linksDrop.before)}%) since the last audit. Information only: it doesn't change the score. To find which links went, run the backlink check (backlinks.mjs) on Search Console's Latest links export or Bing's sample: it lists the links that are gone.`;
|
|
21
|
+
const linksDroppedHtml = () =>
|
|
22
|
+
linksDrop
|
|
23
|
+
? `\n <section class="panel"><h2>Links dropped</h2><ul class="lim"><li><b>${LINKS_DROP[linksDrop.what]}</b><span>${esc(linksDropText())}</span></li></ul></section>`
|
|
24
|
+
: "";
|
|
25
|
+
const linksDroppedMd = () =>
|
|
26
|
+
linksDrop ? ["### Links dropped", "", `- ${LINKS_DROP[linksDrop.what]}: ${linksDropText()}`, ""] : [];
|
|
27
|
+
// Search Central posts from google-updates.mjs --blog, listed by date and never offered as a cause.
|
|
28
|
+
function googlePostsText(html = false) {
|
|
29
|
+
const g = obj(raw.googleUpdates);
|
|
30
|
+
if (!Array.isArray(g?.posts)) return "";
|
|
31
|
+
const list = g.posts.filter(
|
|
32
|
+
p => obj(p) && typeof p.title === "string" && p.title.trim() && /^\d{4}-\d{2}-\d{2}$/.test(p.date),
|
|
33
|
+
);
|
|
34
|
+
const day = d => fmtDate(d, false);
|
|
35
|
+
const name = p => (!html ? noteMd(p.title) : link(p.url, esc(p.title)));
|
|
36
|
+
return list.length
|
|
37
|
+
? `Google Search Central announcements in this period: ${list.map(p => `${name(p)} (${day(p.date)})`).join(" · ")}`
|
|
38
|
+
: "Google Search Central posted no announcements in this period.";
|
|
39
|
+
}
|
|
40
|
+
// One row per crawl from seo-diff.mjs --history, shown from three crawls on, as two are just Since last audit.
|
|
41
|
+
const timelineRows = () =>
|
|
42
|
+
(Array.isArray(obj(raw.diff)?.timeline) ? raw.diff.timeline : [])
|
|
43
|
+
.filter(x => obj(x) && !isNaN(Date.parse(x.date)) && isCount(x.pages))
|
|
44
|
+
.slice(-100)
|
|
45
|
+
.reverse();
|
|
46
|
+
const timelineCells = x => [
|
|
47
|
+
fmtDate(x.date),
|
|
48
|
+
...["pages", "findings", "regressions", "improvements", "added", "removed"].map(k =>
|
|
49
|
+
isCount(x[k]) ? num(x[k]) : "–",
|
|
50
|
+
),
|
|
51
|
+
];
|
|
52
|
+
const TIMELINE_HEAD = [
|
|
53
|
+
"Crawl",
|
|
54
|
+
"Pages",
|
|
55
|
+
"Crawler findings",
|
|
56
|
+
"Regressions",
|
|
57
|
+
"Improvements",
|
|
58
|
+
"Pages added",
|
|
59
|
+
"Pages gone",
|
|
60
|
+
];
|
|
61
|
+
const TIMELINE_INTRO =
|
|
62
|
+
"Every crawl filed in seo-audit/history, newest first, each compared with the one before it. Crawler findings are the crawler's own count, before the audit's review. – means it couldn't be told: that crawl or the one before covered part of the site. Information only.";
|
|
63
|
+
const posts = () =>
|
|
64
|
+
googlePostsText() && {
|
|
65
|
+
title: "Google Search Central",
|
|
66
|
+
blocks: [{ quiet: { html: googlePostsText(true), md: googlePostsText() } }],
|
|
67
|
+
};
|
|
68
|
+
const timeline = () => {
|
|
69
|
+
const rows = timelineRows();
|
|
70
|
+
return (
|
|
71
|
+
rows.length >= 3 && {
|
|
72
|
+
cls: "timeline",
|
|
73
|
+
title: "Audit timeline",
|
|
74
|
+
blocks: [
|
|
75
|
+
{ p: TIMELINE_INTRO },
|
|
76
|
+
{ head: TIMELINE_HEAD, align: ["---", ...Array(6).fill("---:")], rows: rows.map(timelineCells) },
|
|
77
|
+
],
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const diff = raw.diff && typeof raw.diff === "object" ? raw.diff : null;
|
|
83
|
+
const DIFF_KIND = {
|
|
84
|
+
"canonical-changed": ["Canonical changed", "URL-04"],
|
|
85
|
+
"noindex-added": ["Now noindex", "CRAWL-02"],
|
|
86
|
+
"noindex-removed": ["No longer noindex", "CRAWL-02"],
|
|
87
|
+
"title-changed": ["Title changed", "META-01"],
|
|
88
|
+
"h1-removed": ["H1 removed", "CONTENT-01"],
|
|
89
|
+
"h1-added": ["H1 added", "CONTENT-01"],
|
|
90
|
+
"schema-removed": ["Schema removed", "SCHEMA-03"],
|
|
91
|
+
"schema-added": ["Schema added", "SCHEMA-03"],
|
|
92
|
+
"status-error": ["Now an error", "CRAWL-05"],
|
|
93
|
+
"status-fixed": ["Error fixed", "CRAWL-05"],
|
|
94
|
+
"description-changed": ["Description changed", "META-02"],
|
|
95
|
+
"og-removed": ["Open Graph tags removed", "META-04"],
|
|
96
|
+
"og-added": ["Open Graph tags added", "META-04"],
|
|
97
|
+
"content-shrunk": ["Word count fell", "CONTENT-05"],
|
|
98
|
+
"content-grew": ["Word count grew", "CONTENT-05"],
|
|
99
|
+
"speed-slower": ["Now slower", "PERF-01"],
|
|
100
|
+
"speed-faster": ["Now faster", "PERF-01"],
|
|
101
|
+
"schema-fields-removed": ["Schema fields removed", "SCHEMA-03"],
|
|
102
|
+
"schema-fields-added": ["Schema fields added", "SCHEMA-03"],
|
|
103
|
+
"robots-changed": ["robots.txt changed", "MAP-05"],
|
|
104
|
+
"left-sitemap": ["Left the sitemap", "MAP-03"],
|
|
105
|
+
"joined-sitemap": ["Joined the sitemap", "MAP-03"],
|
|
106
|
+
"lost-internal-links": ["Fewer internal links", "LINK-02"],
|
|
107
|
+
"redirect-changed": ["Redirect changed", "URL-07"],
|
|
108
|
+
"redirect-added": ["Now redirects", "URL-07"],
|
|
109
|
+
"redirect-removed": ["Redirect removed", "URL-07"],
|
|
110
|
+
"h1-changed": ["H1 changed", "CONTENT-01"],
|
|
111
|
+
"h2-changed": ["H2s changed", "CONTENT-02"],
|
|
112
|
+
"hreflang-changed": ["hreflang changed", "META-08"],
|
|
113
|
+
"schema-retired-removed": ["Retired schema removed", "SCHEMA-05"],
|
|
114
|
+
"section-shrunk": ["Section shrank", null],
|
|
115
|
+
};
|
|
116
|
+
const diffSections = d =>
|
|
117
|
+
[
|
|
118
|
+
["Regressions", d.regressions],
|
|
119
|
+
["Improvements", d.improvements],
|
|
120
|
+
["Other changes", d.changed],
|
|
121
|
+
].filter(([, list]) => (list || []).length);
|
|
122
|
+
const diffText = c =>
|
|
123
|
+
`${DIFF_KIND[c.kind]?.[0] || c.kind}${c.source ? ` (${c.source})` : ""}: ${c.detail ?? `${c.before ?? "none"} → ${c.after ?? "none"}`}`;
|
|
124
|
+
// The finding on the same page and rule, if any.
|
|
125
|
+
const diffFinding = c =>
|
|
126
|
+
findings.find(
|
|
127
|
+
f =>
|
|
128
|
+
f.rule === DIFF_KIND[c.kind]?.[1] &&
|
|
129
|
+
(f.evidence || []).some(e => {
|
|
130
|
+
try {
|
|
131
|
+
return new URL(e.url).pathname === c.path;
|
|
132
|
+
} catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
// "Nothing changed" claims a field only when both crawls recorded it.
|
|
138
|
+
const sameFields = d => {
|
|
139
|
+
const c = new Set(d.compared || []);
|
|
140
|
+
const f = [
|
|
141
|
+
"status",
|
|
142
|
+
"indexing",
|
|
143
|
+
"canonical",
|
|
144
|
+
"title",
|
|
145
|
+
c.has("description") && "description",
|
|
146
|
+
c.has("og") && "share tags",
|
|
147
|
+
"H1",
|
|
148
|
+
c.has("h2") && "H2s",
|
|
149
|
+
c.has("hreflang") && "hreflang",
|
|
150
|
+
"schema",
|
|
151
|
+
c.has("schemaProps") && "schema fields",
|
|
152
|
+
c.has("words") && "length",
|
|
153
|
+
c.has("sitemap") && "sitemap listing",
|
|
154
|
+
c.has("links") && "internal links",
|
|
155
|
+
].filter(Boolean);
|
|
156
|
+
const also = [
|
|
157
|
+
c.has("redirects") && "no redirect changed",
|
|
158
|
+
c.has("robots") && "robots.txt has the same rules",
|
|
159
|
+
c.has("sections") && "no section lost half its pages",
|
|
160
|
+
c.has("speed") && "no page got much faster or slower",
|
|
161
|
+
].filter(Boolean);
|
|
162
|
+
return `${f.slice(0, -1).join(", ")} and ${f.at(-1)} as last time${also.length ? `, ${[...also.slice(0, -1), `and ${also.at(-1)}`].join(", ")}` : ""}`;
|
|
163
|
+
};
|
|
164
|
+
// Why no page is listed as gone or added: true means --max stopped the crawl, "section" means --include/--exclude.
|
|
165
|
+
const unknownText = (why, which) =>
|
|
166
|
+
why === "section"
|
|
167
|
+
? `${which === "gone" ? "This crawl" : "The last crawl"} covered one part of the site (--include or --exclude), so pages outside it aren't listed as ${which}.`
|
|
168
|
+
: why === true
|
|
169
|
+
? `${which === "gone" ? "This crawl" : "The last crawl"} stopped at its page limit (--max), so pages it didn't reach aren't listed as ${which}.`
|
|
170
|
+
: "";
|
|
171
|
+
const unknownLines = d =>
|
|
172
|
+
[unknownText(d.removedUnknown, "gone"), unknownText(d.addedUnknown, "added")].filter(Boolean);
|
|
173
|
+
// seo-diff.mjs's addedBurst, a local threshold (50 pages and 20%). It shows the count and where the pages are, never
|
|
174
|
+
// what they're about, and paths and titles come from the crawl, so they're escaped.
|
|
175
|
+
const HACKED_HELP = "https://support.google.com/webmasters/answer/9044101#hacked-url-injection";
|
|
176
|
+
const BURST_NOTE =
|
|
177
|
+
"Our own line: this shows when at least 50 pages are new and they add at least 20% to the pages the last audit found. Information only: it doesn't change the score.";
|
|
178
|
+
const burst = (b =>
|
|
179
|
+
b && isCount(b.pages) && isCount(b.before) && b.before > 0
|
|
180
|
+
? {
|
|
181
|
+
pages: b.pages,
|
|
182
|
+
before: b.before,
|
|
183
|
+
sections: (Array.isArray(b.sections) ? b.sections : []).filter(
|
|
184
|
+
s => typeof s?.path === "string" && isCount(s.pages),
|
|
185
|
+
),
|
|
186
|
+
examples: (Array.isArray(b.examples) ? b.examples : []).filter(e => typeof e?.path === "string").slice(0, 10),
|
|
187
|
+
}
|
|
188
|
+
: null)(obj(diff?.addedBurst));
|
|
189
|
+
const burstText = () =>
|
|
190
|
+
`${num(burst.pages)} new pages appeared since the last audit${diff.since ? ` (on ${fmtDate(diff.since)})` : ""}, ${Math.round((100 * burst.pages) / burst.before)}% more than the ${num(burst.before)} pages it found. If you didn't add them, check for hacked or spam pages`;
|
|
191
|
+
// "/blog/ 12 · /cheap-pills/ 180"; folders past seo-diff's top 20 are summed into one count.
|
|
192
|
+
const burstFolders = code => {
|
|
193
|
+
const other = burst.pages - burst.sections.reduce((n, s) => n + s.pages, 0);
|
|
194
|
+
return `New pages by folder: ${burst.sections.map(s => `${code(s.path)}${s.path === "/" ? " (top level)" : ""} ${num(s.pages)}`).join(" · ")}${other > 0 ? ` · other folders ${num(other)}` : ""}`;
|
|
195
|
+
};
|
|
196
|
+
const burstHtml = () =>
|
|
197
|
+
burst
|
|
198
|
+
? `<section class="panel"><h2>Many new pages<span class="mono quiet"> ${num(burst.pages)}</span></h2><p>${esc(burstText())}: see <a href="${HACKED_HELP}" rel="noopener">Google's help on hacked content</a>.</p>${burst.sections.length ? `<p class="quiet">${burstFolders(esc)}</p>` : ""}${burst.examples.length ? `<p class="quiet">Some of them, from different folders:</p><ul class="lim">${burst.examples.map(e => `<li><b><code>${esc(e.path)}</code></b><span>${esc(e.title || "no title")}</span></li>`).join("")}</ul>` : ""}<p class="quiet">${BURST_NOTE}</p></section>
|
|
199
|
+
`
|
|
200
|
+
: "";
|
|
201
|
+
const burstMd = () =>
|
|
202
|
+
burst
|
|
203
|
+
? [
|
|
204
|
+
"### Many new pages",
|
|
205
|
+
"",
|
|
206
|
+
`${noteMd(burstText())}: see Google's help on hacked content, ${HACKED_HELP}`,
|
|
207
|
+
"",
|
|
208
|
+
...(burst.sections.length ? [burstFolders(noteCode), ""] : []),
|
|
209
|
+
...(burst.examples.length
|
|
210
|
+
? [
|
|
211
|
+
"Some of them, from different folders:",
|
|
212
|
+
"",
|
|
213
|
+
...burst.examples.map(e => `- ${noteCode(e.path)} ${e.title ? noteMd(e.title) : "no title"}`),
|
|
214
|
+
"",
|
|
215
|
+
]
|
|
216
|
+
: []),
|
|
217
|
+
BURST_NOTE,
|
|
218
|
+
"",
|
|
219
|
+
]
|
|
220
|
+
: [];
|
|
221
|
+
const diffHtml = () => `<div class="limits">
|
|
222
|
+
${burstHtml()}<p class="quiet">Compared with the crawl of ${esc(fmtDate(diff.since))}. Pages are matched by path.${unknownLines(
|
|
223
|
+
diff,
|
|
224
|
+
)
|
|
225
|
+
.map(t => ` ${t}`)
|
|
226
|
+
.join(
|
|
227
|
+
"",
|
|
228
|
+
)}</p>${googleUpdatesText() ? `\n <p class="quiet">${googleUpdatesText(true)}</p>` : ""}${googlePostsText() ? `\n <p class="quiet">${googlePostsText(true)}</p>` : ""}${linksDroppedHtml()}
|
|
229
|
+
${diffSections(diff)
|
|
230
|
+
.map(
|
|
231
|
+
([h, list]) =>
|
|
232
|
+
`<section class="panel"><h2>${h}<span class="mono quiet"> ${list.length}</span></h2><ul class="lim">${list
|
|
233
|
+
.map(c => {
|
|
234
|
+
const f = diffFinding(c);
|
|
235
|
+
return `<li><b><code>${esc(c.path)}</code></b><span>${esc(diffText(c))}${f ? ` · <a href="#${esc(f.id)}">${esc(f.id)}</a>` : ""}</span></li>`;
|
|
236
|
+
})
|
|
237
|
+
.join("")}</ul></section>`,
|
|
238
|
+
)
|
|
239
|
+
.join("")}
|
|
240
|
+
${[
|
|
241
|
+
["Pages added", diff.added],
|
|
242
|
+
["Pages gone", diff.removed],
|
|
243
|
+
]
|
|
244
|
+
.filter(([, l]) => (l || []).length)
|
|
245
|
+
.map(
|
|
246
|
+
([h, l]) =>
|
|
247
|
+
`<section class="panel"><h2>${h}<span class="mono quiet"> ${l.length}</span></h2><ul class="lim">${l.map(p => `<li><span><code>${esc(p)}</code></span></li>`).join("")}</ul></section>`,
|
|
248
|
+
)
|
|
249
|
+
.join("")}
|
|
250
|
+
${!diffSections(diff).length && !(diff.added || []).length && !(diff.removed || []).length ? `<section class="panel empty-state"><h2>Nothing changed</h2><p>Every page has the same ${sameFields(diff)}.</p></section>` : ""}
|
|
251
|
+
</div>`;
|
|
252
|
+
return {
|
|
253
|
+
diff,
|
|
254
|
+
diffHtml,
|
|
255
|
+
posts,
|
|
256
|
+
timeline,
|
|
257
|
+
googlePostsText,
|
|
258
|
+
burstMd,
|
|
259
|
+
diffSections,
|
|
260
|
+
diffText,
|
|
261
|
+
unknownLines,
|
|
262
|
+
linksDroppedMd,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The Findings, Decisions, Changes, Passed and Limits tabs.
|
|
3
|
+
import { SEV, isOpen } from "../lib/score.mjs";
|
|
4
|
+
import { recheckOf, RECHECK_NOTE } from "../lib/recheck.mjs";
|
|
5
|
+
import { SEV_LABEL, STATUS_LABEL, ICON, dot, esc, inl, link, num } from "./format.mjs";
|
|
6
|
+
import { needsYou } from "./model.mjs";
|
|
7
|
+
import { actions, isOwnersCall } from "./overview.mjs";
|
|
8
|
+
|
|
9
|
+
// A finding's optional effort; an unknown value shows nothing.
|
|
10
|
+
const EFFORT = { quick: "under 30 minutes", hours: "an hour or two", "half-day": "half a day or more" };
|
|
11
|
+
export const effortOf = f =>
|
|
12
|
+
typeof f.effort === "string" && Object.hasOwn(EFFORT, f.effort) ? `Effort: ${EFFORT[f.effort]}` : "";
|
|
13
|
+
// The re-check command's URL may come from the crawl, so it's escaped.
|
|
14
|
+
const recheckHtml = f => {
|
|
15
|
+
const r = recheckOf(f);
|
|
16
|
+
return r
|
|
17
|
+
? `<div class="ev recheck"><h4>Check the fix yourself</h4><p><code>${esc(r.command)}</code></p><p class="quiet">${esc(r.hint)}</p></div>`
|
|
18
|
+
: "";
|
|
19
|
+
};
|
|
20
|
+
// Plain text with the command in backticks: inl renders it on the page, mdSafe in the Markdown. Fix mode asks first
|
|
21
|
+
// on anything isOwnersCall() marks.
|
|
22
|
+
export const nextStep = (f, decisions = []) =>
|
|
23
|
+
!isOpen(f) || f.status === "wont-fix" || !f.id
|
|
24
|
+
? ""
|
|
25
|
+
: `\`/seo-fix ${f.id}\` ${isOwnersCall(f, decisions) ? "asks you first: the agent won't change this without your go-ahead." : "fixes it and checks the fix."}`;
|
|
26
|
+
|
|
27
|
+
export function findingTabs(m, { trafficHtml, clarityHtml }) {
|
|
28
|
+
const { findings, decisions, fixed, passed, notChecked, notes, mdFile, notShown = [] } = m;
|
|
29
|
+
const anyRecheck = () => findings.some(f => recheckOf(f));
|
|
30
|
+
const recheckNote = () => anyRecheck() && { title: "Checking a fix yourself", blocks: [{ quiet: RECHECK_NOTE }] };
|
|
31
|
+
function evidenceHtml(f) {
|
|
32
|
+
const ev = f.evidence || [];
|
|
33
|
+
if (!ev.length) return "";
|
|
34
|
+
const shown = ev.slice(0, 10);
|
|
35
|
+
const listedRest = ev.length - shown.length;
|
|
36
|
+
const total = Math.max(f.count || 0, ev.length);
|
|
37
|
+
const notes = [];
|
|
38
|
+
if (listedRest > 0)
|
|
39
|
+
notes.push(
|
|
40
|
+
`${num(listedRest)} more ${listedRest === 1 ? "example" : "examples"}${mdFile ? ` in <code>${esc(mdFile)}</code>` : ""}`,
|
|
41
|
+
);
|
|
42
|
+
if (total > ev.length) notes.push(`${num(total)} cases found in total; these are examples`);
|
|
43
|
+
return `<div class="ev"><h4>Evidence</h4><div class="tablewrap"><table><thead><tr><th scope="col">Where</th><th scope="col">Detail</th></tr></thead><tbody>${shown.map(e => `<tr><td>${e.url ? link(e.url, esc(e.url)) : ""}${e.file ? `${e.url ? "<br>" : ""}<code>${esc(e.file)}${e.line ? ":" + esc(e.line) : ""}</code>` : ""}</td><td>${inl(e.detail || "")}</td></tr>`).join("")}</tbody></table></div>${notes.length ? `<p class="quiet">${notes.join(". ")}.</p>` : ""}</div>`;
|
|
44
|
+
}
|
|
45
|
+
function findingHtml(f) {
|
|
46
|
+
const isFixed = !isOpen(f);
|
|
47
|
+
return `<article class="f ${isFixed ? "is-fixed" : ""}" id="${esc(f.id)}" data-sev="${f.severity}" data-status="${esc(f.status)}" data-area="${esc(f.category)}" data-text="${esc([f.id, f.rule, f.title, f.what, f.category].join(" ").toLowerCase())}">
|
|
48
|
+
<h3><button class="f-head" aria-expanded="false" aria-controls="${esc(f.id)}-b">
|
|
49
|
+
${dot(f.severity)}
|
|
50
|
+
<span class="f-title">${inl(f.title)}</span>
|
|
51
|
+
<span class="f-meta"><span class="sev-t">${SEV_LABEL[f.severity]}</span>${needsYou(f) ? `<span class="own">Needs you</span>` : ""}<span>${esc(f.category)}</span>${f.rule ? `<span class="mono">${esc(f.rule)}</span>` : ""}${f.count > 1 ? `<span class="mono">${num(f.count)}×</span>` : ""}${effortOf(f) ? `<span>${esc(effortOf(f))}</span>` : ""}</span>
|
|
52
|
+
${isFixed ? `<span class="stamp">${ICON.check}Fixed</span>` : `<span class="st st-${esc(f.status)}">${esc(STATUS_LABEL[f.status] || f.status)}</span>`}
|
|
53
|
+
${ICON.chevron}
|
|
54
|
+
</button></h3>
|
|
55
|
+
<div class="f-body" id="${esc(f.id)}-b" role="region" aria-label="${esc(f.title)}">
|
|
56
|
+
<div class="f-cols">
|
|
57
|
+
<div>
|
|
58
|
+
${f.what ? `<h4>What's wrong</h4><p>${inl(f.what)}</p>` : ""}
|
|
59
|
+
${f.why ? `<h4>Why it matters</h4><p>${inl(f.why)}</p>` : ""}
|
|
60
|
+
</div>
|
|
61
|
+
<div>
|
|
62
|
+
${f.fix ? `<div class="howfix"><h4>How to fix</h4><p>${inl(f.fix)}</p></div>` : ""}
|
|
63
|
+
${f.decision ? `<div class="dec-inline"><h4>Decision needed</h4><p>${inl(f.decision.question || "")}</p>${(f.decision.options || []).length ? `<ul>${f.decision.options.map(o => `<li>${inl(o)}</li>`).join("")}</ul>` : ""}${f.decision.recommendation ? `<p><strong>Recommended:</strong> ${inl(f.decision.recommendation)}</p>` : ""}</div>` : ""}
|
|
64
|
+
${isFixed && f.fixed ? `<div class="donebox"><h4>What was done</h4><p>${inl(f.fixed.summary || "")}</p>${(f.fixed.files || []).length ? `<p class="files">${f.fixed.files.map(x => `<code>${esc(x)}</code>`).join(" ")}</p>` : ""}${f.fixed.verified ? `<p class="quiet">${ICON.check} ${inl(f.fixed.verified)}</p>` : ""}</div>` : ""}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
${trafficHtml(f)}${clarityHtml(f)}${evidenceHtml(f)}${nextStep(f, decisions) ? `<div class="ev next"><h4>Next step</h4><p>${inl(nextStep(f, decisions))}</p></div>` : ""}${recheckHtml(f)}
|
|
68
|
+
</div>
|
|
69
|
+
</article>`;
|
|
70
|
+
}
|
|
71
|
+
// extra: panels render-report.mjs appends after the list.
|
|
72
|
+
function findingsHtml(extra = "") {
|
|
73
|
+
if (!findings.length)
|
|
74
|
+
return `<section class="panel empty-state"><h2>No findings</h2><p>Every checked rule passed. See Passed for what was checked and Limits for what wasn't.</p></section>${extra}`;
|
|
75
|
+
const sevPresent = SEV.filter(s => findings.some(f => f.severity === s));
|
|
76
|
+
const areasPresent = [...new Set(findings.map(f => f.category))].sort();
|
|
77
|
+
const statuses = [...new Set(findings.map(f => f.status))];
|
|
78
|
+
return `<div class="toolbar" role="group" aria-label="Filter findings">
|
|
79
|
+
<label class="search">${ICON.search}<span class="sr">Search findings</span><input type="search" id="q" placeholder="Search title, rule or ID" autocomplete="off"></label>
|
|
80
|
+
<div class="seg" role="group" aria-label="Severity"><button type="button" class="segb" data-sev="all" aria-pressed="true">All</button>${sevPresent.map(s => `<button type="button" class="segb" data-sev="${s}" aria-pressed="false">${dot(s)}${SEV_LABEL[s]}<span class="mono">${findings.filter(f => f.severity === s).length}</span></button>`).join("")}</div>
|
|
81
|
+
<label class="sel"><span class="sr">Status</span><select id="fstatus"><option value="all">Any status</option>${statuses.map(s => `<option value="${esc(s)}">${esc(STATUS_LABEL[s] || s)}</option>`).join("")}</select></label>
|
|
82
|
+
<label class="sel"><span class="sr">Area</span><select id="farea"><option value="all">All areas</option>${areasPresent.map(a => `<option value="${esc(a)}">${esc(a)}</option>`).join("")}</select></label>
|
|
83
|
+
<p class="showing" id="showing" aria-live="polite">${findings.length} findings</p>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="flist" id="flist">${findings.map(findingHtml).join("")}</div>
|
|
86
|
+
<p class="empty" id="fnone" hidden>No findings match these filters. <button type="button" class="link" id="freset">Clear filters</button></p>${extra}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Decisions, then the fixBy: "owner" tasks, so everything the Overview marks "Needs you" is on one tab.
|
|
90
|
+
const { tasks } = actions(m);
|
|
91
|
+
const tasksHtml = () =>
|
|
92
|
+
tasks.length
|
|
93
|
+
? `<section class="panel"><h2>Your tasks</h2><p class="quiet">Findings only you can resolve: a setting on your host or an account, your content or your facts. The agent won't change them without your go-ahead.</p><ul class="lim">${tasks.map(f => `<li><b><a href="#${esc(f.id)}">${esc(f.id)}</a></b><span>${inl(f.title)} · ${SEV_LABEL[f.severity]}</span></li>`).join("")}</ul></section>`
|
|
94
|
+
: "";
|
|
95
|
+
const decisionsHtml = () =>
|
|
96
|
+
decisions.length || tasks.length
|
|
97
|
+
? `${
|
|
98
|
+
decisions.length
|
|
99
|
+
? `<div class="cards">${decisions
|
|
100
|
+
.map(
|
|
101
|
+
d => `<article class="panel dcard">
|
|
102
|
+
${d.id ? (findings.some(f => f.id === d.id) ? `<a class="mono idlink" href="#${esc(d.id)}">${esc(d.id)}</a>` : `<span class="mono idlink">${esc(d.id)}</span>`) : ""}
|
|
103
|
+
<h3>${inl(d.question)}</h3>${d.context ? `<p>${inl(d.context)}</p>` : ""}
|
|
104
|
+
${(d.options || []).length ? `<ul class="opts">${d.options.map(o => `<li>${inl(o)}</li>`).join("")}</ul>` : ""}
|
|
105
|
+
${d.recommendation ? `<p class="rec"><strong>Recommended</strong> ${inl(d.recommendation)}</p>` : ""}
|
|
106
|
+
</article>`,
|
|
107
|
+
)
|
|
108
|
+
.join("")}</div>`
|
|
109
|
+
: ""
|
|
110
|
+
}${tasksHtml()}`
|
|
111
|
+
: `<section class="panel empty-state"><h2>No decisions needed</h2><p>Nothing in this audit needs an owner's call.</p></section>`;
|
|
112
|
+
const changesHtml = () =>
|
|
113
|
+
fixed.length
|
|
114
|
+
? `<ol class="changes">${fixed
|
|
115
|
+
.map(
|
|
116
|
+
f => `<li class="panel">
|
|
117
|
+
<span class="stamp">${ICON.check}Fixed</span>
|
|
118
|
+
<div><h3><a href="#${esc(f.id)}">${inl(f.title)}</a></h3>
|
|
119
|
+
${f.fixed?.summary ? `<p>${inl(f.fixed.summary)}</p>` : ""}
|
|
120
|
+
${(f.fixed?.files || []).length ? `<p class="files">${f.fixed.files.map(x => `<code>${esc(x)}</code>`).join(" ")}</p>` : ""}
|
|
121
|
+
${f.fixed?.verified ? `<p class="quiet">${ICON.check} ${inl(f.fixed.verified)}</p>` : ""}</div>
|
|
122
|
+
<span class="mono quiet">${esc(f.id)}</span>
|
|
123
|
+
</li>`,
|
|
124
|
+
)
|
|
125
|
+
.join("")}</ol>`
|
|
126
|
+
: `<section class="panel empty-state"><h2>No changes yet</h2><p>Run <code>/seo-fix</code> to fix findings. Each fix is re-checked and listed here with the files it touched.</p></section>`;
|
|
127
|
+
function passedHtml() {
|
|
128
|
+
const fixedRules = fixed.map(f => ({
|
|
129
|
+
rule: f.rule || f.id,
|
|
130
|
+
title: f.title,
|
|
131
|
+
category: f.category,
|
|
132
|
+
detail: "fixed this run",
|
|
133
|
+
}));
|
|
134
|
+
const all = [...passed, ...fixedRules.filter(x => !passed.some(p => p.rule === x.rule))];
|
|
135
|
+
if (!all.length)
|
|
136
|
+
return `<section class="panel empty-state"><h2>No passed rules recorded</h2><p>This file lists findings only.</p></section>`;
|
|
137
|
+
const groups = all.reduce((m, p) => ((m[p.category || "Other"] ||= []).push(p), m), {});
|
|
138
|
+
return `<div class="pgrid">${Object.entries(groups)
|
|
139
|
+
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
140
|
+
.map(
|
|
141
|
+
([c, ps]) =>
|
|
142
|
+
`<section class="panel pgroup"><h3>${esc(c)}<span class="mono quiet">${ps.length}</span></h3><ul>${ps.map(p => `<li>${ICON.check}<span><span class="mono quiet">${esc(p.rule)}</span> ${inl(p.title)}${p.detail ? `<span class="quiet"> · ${inl(p.detail)}</span>` : ""}</span></li>`).join("")}</ul></section>`,
|
|
143
|
+
)
|
|
144
|
+
.join("")}</div>`;
|
|
145
|
+
}
|
|
146
|
+
// notShown (report/sources.mjs) lists results that couldn't be shown: unreadable, for another site or out of date.
|
|
147
|
+
// extra: panels render-report.mjs adds, such as the check settings.
|
|
148
|
+
const limitsHtml = (extra = "") =>
|
|
149
|
+
notChecked.length || notes.length || notShown.length || extra
|
|
150
|
+
? `<div class="limits">
|
|
151
|
+
${notChecked.length ? `<section class="panel"><h2>Not checked</h2><p class="quiet">These couldn't be verified in this run, so they count neither for nor against the score.</p><ul class="lim">${notChecked.map(n => `<li><b>${inl(n.area || n.rule || "")}</b><span>${inl(n.reason || "")}</span></li>`).join("")}</ul></section>` : ""}
|
|
152
|
+
${notShown.length ? `<section class="panel"><h2>Not shown</h2><p class="quiet">Results that were produced but can't be shown in this report, and why. Information only: they never change the score.</p><ul class="lim">${notShown.map(n => `<li><b>${esc(n.what)}</b><span>${esc(n.why)}</span></li>`).join("")}</ul></section>` : ""}
|
|
153
|
+
${notes.length ? `<section class="panel"><h2>Notes from the audit</h2><ul class="lim">${notes.map(n => `<li><span>${inl(n)}</span></li>`).join("")}</ul></section>` : ""}${extra}
|
|
154
|
+
</div>`
|
|
155
|
+
: `<section class="panel empty-state"><h2>No limits recorded</h2><p>Every planned check ran.</p></section>`;
|
|
156
|
+
return {
|
|
157
|
+
findingsHtml,
|
|
158
|
+
decisionsHtml,
|
|
159
|
+
changesHtml,
|
|
160
|
+
passedHtml,
|
|
161
|
+
limitsHtml,
|
|
162
|
+
recheckNote,
|
|
163
|
+
decisionCount: decisions.length + tasks.length,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Pure escaping and formatting helpers for the report.
|
|
3
|
+
|
|
4
|
+
export const SEV_LABEL = {
|
|
5
|
+
blocker: "Blocker",
|
|
6
|
+
high: "High",
|
|
7
|
+
"needs-decision": "Decision",
|
|
8
|
+
medium: "Medium",
|
|
9
|
+
low: "Low",
|
|
10
|
+
};
|
|
11
|
+
export const STATUS_LABEL = {
|
|
12
|
+
open: "Open",
|
|
13
|
+
fixed: "Fixed",
|
|
14
|
+
"wont-fix": "Won't fix",
|
|
15
|
+
"needs-decision": "Needs decision",
|
|
16
|
+
"in-progress": "In progress",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// inl escapes too, then turns `code` and **bold** into tags.
|
|
20
|
+
export const esc = s =>
|
|
21
|
+
String(s ?? "").replace(
|
|
22
|
+
/[&<>"']/g,
|
|
23
|
+
c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c],
|
|
24
|
+
);
|
|
25
|
+
export const inl = s =>
|
|
26
|
+
esc(s)
|
|
27
|
+
.replace(/`([^`]+)`/g, "<code>$1</code>")
|
|
28
|
+
.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
|
|
29
|
+
// Every link built from the audit file goes through this: only a full http(s) URL becomes a link, so javascript:,
|
|
30
|
+
// data: and the like stay plain text and a click can't run a script.
|
|
31
|
+
export const safeHref = u => (typeof u === "string" && /^https?:\/\//i.test(u) && URL.canParse(u) ? u : null);
|
|
32
|
+
// html: the link's text, already escaped. In Markdown, the few characters that would end the link are %-encoded.
|
|
33
|
+
export const link = (u, html) => (safeHref(u) ? `<a href="${esc(u)}" rel="noopener">${html}</a>` : html);
|
|
34
|
+
export const mdLink = (u, md) =>
|
|
35
|
+
safeHref(u)
|
|
36
|
+
? `[${md}](${u.replace(/[\s()<>]/g, c => ({ "(": "%28", ")": "%29" })[c] || encodeURIComponent(c))})`
|
|
37
|
+
: md;
|
|
38
|
+
// A YYYY-MM-DD prefix is that calendar day on every machine, whatever its time zone; other times are shown in UTC.
|
|
39
|
+
export const fmtDate = (d, year = true) => {
|
|
40
|
+
const day = /^\d{4}-\d{2}-\d{2}/.exec(String(d ?? ""))?.[0],
|
|
41
|
+
x = new Date(day ? day + "T00:00:00Z" : d || Date.now());
|
|
42
|
+
return isNaN(x.getTime())
|
|
43
|
+
? String(d)
|
|
44
|
+
: x.toLocaleDateString("en-GB", {
|
|
45
|
+
day: "numeric",
|
|
46
|
+
month: "short",
|
|
47
|
+
...(year && { year: "numeric" }),
|
|
48
|
+
timeZone: "UTC",
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export const num = n => Number(n).toLocaleString("en-US");
|
|
52
|
+
export const obj = x => (x && typeof x === "object" ? x : null);
|
|
53
|
+
export const plural = (n, w, p = w + "s") => `${num(n)} ${n === 1 ? w : p}`;
|
|
54
|
+
export const firstSentence = s => {
|
|
55
|
+
const m = String(s || "").match(/^.*?[.!?](\s|$)/);
|
|
56
|
+
return m ? m[0].trim() : String(s || "");
|
|
57
|
+
};
|
|
58
|
+
export const ICON = {
|
|
59
|
+
chevron:
|
|
60
|
+
'<svg class="chev" viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 3.5 10 8l-4.5 4.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
61
|
+
check:
|
|
62
|
+
'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
63
|
+
arrow:
|
|
64
|
+
'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9.5M8.5 4l4 4-4 4" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
65
|
+
search:
|
|
66
|
+
'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="7" cy="7" r="4.5" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="m10.5 10.5 3 3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',
|
|
67
|
+
};
|
|
68
|
+
export const dot = s => `<i class="dot d-${s}" aria-hidden="true"></i>`;
|
|
69
|
+
|
|
70
|
+
// The Markdown escapers the report, the plan and issues.mjs share. mdSafe is inl's twin for text that may quote pages
|
|
71
|
+
// or other sites: its `code` and **bold** stay, URLs outside code become code spans, and the rest is escaped, so none
|
|
72
|
+
// of it can render as a link, an image or a tag.
|
|
73
|
+
export const noteMd = s =>
|
|
74
|
+
String(s ?? "")
|
|
75
|
+
.replace(/\s+/g, " ")
|
|
76
|
+
.replace(/[\\`*_[\]<>]/g, "\\$&");
|
|
77
|
+
export const noteCode = s => "`" + String(s ?? "").replace(/[`\r\n]/g, " ") + "`";
|
|
78
|
+
export const notePath = u => {
|
|
79
|
+
try {
|
|
80
|
+
const x = new URL(u);
|
|
81
|
+
return x.pathname + x.search;
|
|
82
|
+
} catch {
|
|
83
|
+
return String(u ?? "");
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export const cellMd = s =>
|
|
87
|
+
String(s ?? "")
|
|
88
|
+
.replace(/\|/g, "\\|")
|
|
89
|
+
.replace(/\r?\n/g, " ");
|
|
90
|
+
const urlsCoded = (s, text) =>
|
|
91
|
+
s
|
|
92
|
+
.split(/(https?:\/\/[^\s<>"]*[^\s<>".,;:!?)'])/)
|
|
93
|
+
.map((q, j) => (j % 2 ? noteCode(q) : text(q)))
|
|
94
|
+
.join("");
|
|
95
|
+
export const mdSafe = (s, text = noteMd) =>
|
|
96
|
+
String(s ?? "")
|
|
97
|
+
.replace(/\s+/g, " ")
|
|
98
|
+
.split(/(`[^`]+`)/)
|
|
99
|
+
.map((p, i) =>
|
|
100
|
+
i % 2
|
|
101
|
+
? p
|
|
102
|
+
: p
|
|
103
|
+
.split(/\*\*([^*]+)\*\*/)
|
|
104
|
+
.map((q, j) => (j % 2 ? `**${urlsCoded(q, text)}**` : urlsCoded(q, text)))
|
|
105
|
+
.join(""),
|
|
106
|
+
)
|
|
107
|
+
.join("");
|
|
108
|
+
|
|
109
|
+
// Validators for values read from the audit file.
|
|
110
|
+
export const isCount = x => Number.isInteger(x) && x >= 0;
|
|
111
|
+
export const isText = x => typeof x === "string" && x !== "";
|