Skip to content

Commit a1bb8fd

Browse files
kinlaneclaude
andcommitted
Header: drop Credits/APIs.io, add Fork on GitHub + Run Locally (dist zip)
- Remove the Credits and APIs.io header links. - Replace the plain GitHub link with a styled "Fork on GitHub" button (octocat icon) linking to the repo's /fork. - Add a "Run Locally" download button that serves dist/api-validator.zip — the full static build plus a RUN-LOCALLY.txt how-to. Generated by a new post-build step (tools/zip-dist.mjs) wired into `npm run build`; the archive lives in gitignored dist/ so it's produced fresh on each deploy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 30b8e1b commit a1bb8fd

4 files changed

Lines changed: 64 additions & 4 deletions

File tree

index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
<span class="tag">validator.apicommons.org</span>
1616
</div>
1717
<nav>
18-
<a href="https://github.com/api-commons/api-validator/blob/main/THIRD_PARTY_NOTICES.md" target="_blank" rel="noopener" title="Rule sources &amp; licenses">Credits</a>
19-
<a href="https://apis.io" target="_blank" rel="noopener">APIs.io</a>
2018
<a href="https://apicommons.org/tools/" target="_blank" rel="noopener">API Commons</a>
21-
<a href="https://github.com/api-commons/api-validator" target="_blank" rel="noopener">GitHub</a>
19+
<a class="gh-btn" href="https://github.com/api-commons/api-validator/fork" target="_blank" rel="noopener" title="Fork this project on GitHub">
20+
<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg>
21+
Fork on GitHub
22+
</a>
2223
<button id="engage-ae" class="engage-btn" type="button" title="Work with API Evangelist on a governance review or service">Get a review</button>
24+
<a id="run-local" class="dl-btn" href="/api-validator.zip" download="api-validator.zip" title="Download the built app as a zip and run it on your own machine">Run Locally</a>
2325
<button id="download-apisjson" class="reset-btn" type="button" title="Assemble all saved artifacts into an APIs.json (YAML) and download">Download as APIs.json</button>
2426
<button id="reset-storage" class="reset-btn" type="button" title="Clear all saved artifacts and rules stored in this browser">Reset</button>
2527
</nav>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"compile-rules": "node tools/compile-rules.mjs",
1010
"dev": "vite",
11-
"build": "vite build",
11+
"build": "vite build && node tools/zip-dist.mjs",
1212
"preview": "vite preview",
1313
"check:rulesets": "tsx tools/check-rulesets.ts",
1414
"check": "npm run check:rulesets"

src/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; }
179179
.reset-btn { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 4px 12px; font-size: 0.85rem; cursor: pointer; }
180180
.reset-btn:hover { color: #f14c4c; border-color: #f14c4c; }
181181

182+
/* GitHub "Fork" button in the header */
183+
.gh-btn { display: inline-flex; align-items: center; gap: 6px; background: #24292f; color: #fff; border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; padding: 4px 12px; font-size: 0.85rem; font-weight: 600; text-decoration: none; }
184+
.gh-btn:hover { background: #30363d; }
185+
.gh-btn svg { width: 15px; height: 15px; fill: currentColor; }
186+
187+
/* neutral download button (Run Locally) — accent hover, not destructive red */
188+
.dl-btn { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 4px 12px; font-size: 0.85rem; cursor: pointer; text-decoration: none; }
189+
.dl-btn:hover { color: var(--accent); border-color: var(--accent); }
190+
182191
/* ---- collapsible result groups (by rule category) ---- */
183192
#results .ok, #results .err { display: block; padding: 0.75rem; color: var(--muted); }
184193
#results .err { color: var(--error); }

tools/zip-dist.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Post-build step: package the built site (dist/) into dist/api-validator.zip so
2+
// the "Run Locally" button can hand a user the whole app as a static bundle they
3+
// serve themselves. Runs after `vite build`; uses the system `zip` (present on
4+
// macOS and the ubuntu CI runner).
5+
import { execSync } from 'node:child_process';
6+
import { existsSync, writeFileSync } from 'node:fs';
7+
8+
const OUT = 'api-validator.zip';
9+
10+
if (!existsSync('dist')) {
11+
console.error('zip-dist: dist/ not found — run `vite build` first.');
12+
process.exit(1);
13+
}
14+
15+
// A short how-to that travels inside the archive.
16+
writeFileSync(
17+
'dist/RUN-LOCALLY.txt',
18+
[
19+
'API Validator — run locally',
20+
'',
21+
'This is the fully built, static app. It runs entirely in your browser; there',
22+
'is no backend and no keys are required.',
23+
'',
24+
'1. Unzip this archive.',
25+
'2. From the unzipped folder, start any static web server at the folder ROOT:',
26+
'',
27+
' python3 -m http.server 8000',
28+
' or',
29+
' npx serve .',
30+
'',
31+
'3. Open http://localhost:8000/ in your browser.',
32+
'',
33+
'(Opening index.html directly via file:// will not work — ES modules need to be',
34+
'served over http, so use a local server as above.)',
35+
'',
36+
'Source: https://github.com/api-commons/api-validator',
37+
'',
38+
].join('\n'),
39+
);
40+
41+
// Build the archive from inside dist/ (so paths are relative), excluding any
42+
// pre-existing zip. -X drops extra macOS metadata for a clean cross-platform zip.
43+
// Never fail the build over the optional archive — the site still deploys.
44+
try {
45+
execSync(`cd dist && rm -f ${OUT} && zip -r -q -X ${OUT} . -x '*.zip'`, { stdio: 'inherit' });
46+
console.log(`zip-dist: wrote dist/${OUT}`);
47+
} catch (e) {
48+
console.warn(`zip-dist: could not create ${OUT} (is \`zip\` installed?) — skipping. ${e?.message || e}`);
49+
}

0 commit comments

Comments
 (0)