Redesign portfolio, add real project screenshots and refresh content

- New design language: self-hosted fonts, numbered sections, hero card, nav pill with scroll-spy
- Two-pane project pop-up with WebP screenshots; gold ring on the final-year project
- Content moved to src/data JSON and updated from the new CV
- Staggered card entrances and stat count-up; simpler dot cursor
- Capture script converts manual screenshots to WebP

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbertandClaude Sonnet 5.5 committed 2026-10-09 02:57:15 +01:00
1 parent 2e67bc1418
commit 89d4de8df0
85 files changed
+4111 -1150

No files matched your search

+103
View File
@@ -0,0 +1,103 @@
# Project screenshots
`npm run capture` builds the screenshots shown in the project pop-ups.
Each project in `capture.config.json` comes from one of two routes:
| Route | For | How |
|---|---|---|
| **Automated** (`serve` + `steps`) | Web apps, this portfolio | Clones or reads the source, runs its server, and Playwright clicks through it and takes the screenshots. |
| **Manual drop** (`manual: true`) | Android, Java Swing, hardware, phone apps, stock photos | You drop images in `scripts/capture/manual/<id>/`, and the runner downscales them to WebP (720px wide for phone shots, 1440px otherwise). |
Output goes to `public/images/projects/<id>-<name>`, and the list is written
into that project's `images` in `src/data/projects.json`, along with an
`orientation` (`portrait` or `landscape`) that sizes the pop-up's media pane. The site shows a carousel
when there are two or more images.
## One-time setup (Windows)
```powershell
cd F:\Portfolio
npm install # adds the playwright dev dependency
npx playwright install chromium # downloads the browser Playwright drives
# or skip the download and use the Edge that ships with Windows:
# $env:CAPTURE_CHANNEL = "msedge"
```
## Running it
```powershell
npm run capture # every enabled project
npm run capture -- --only=portfolio # one project
npm run capture -- --only=mass,routines
```
It keeps going if one project fails, prints a summary, and exits non-zero if anything failed.
Nothing is committed. Look at the new images, then commit them yourself.
## Adding or changing a web project
Edit its entry in `capture.config.json`:
```json
{
"id": "qr-hunt",
"enabled": true,
"source": { "git": "https://github.com/you/repo.git", "branch": "main" },
"setup": ["npm ci"],
"serve": { "command": "npm run dev -- --port 5180 --strictPort", "url": "http://localhost:5180" },
"steps": [
{ "goto": "/" },
{ "wait": 800 },
{ "screenshot": "home" },
{ "click": "text=Start game" },
{ "fill": "input[name=team]", "value": "Demo team" },
{ "press": "Enter" },
{ "waitFor": ".leaderboard" },
{ "screenshot": "leaderboard" }
]
}
```
- `source.git` is cloned into `.capture-work/<id>/` and refreshed on each run. Private
Gitea or GitLab repos use whatever git credentials your machine already has (the same
ones VS Code uses).
- `source.local` uses a folder you already have, e.g. `"local": "F:\\Projects\\qr-hunt"`.
- `serve` starts the server and waits for `url`. Leave it out to capture a deployed site
by setting `url` instead.
- `steps` actions: `goto`, `click`, `fill` (+`value`), `press`, `hover`, `scrollTo`,
`scrollBy`, `waitFor`, `wait` (ms), `screenshot` (+`selector`, `fullPage`).
A `screenshot` name becomes part of the filename, so `"screenshot": "detail"` on
`mass` gives `mass-detail.png`.
- Use demo data in steps. Don't type real passwords or tokens into the config.
## Manual screenshots
- **Android:** run the app in the Android Studio emulator and use the camera button
in the emulator toolbar. Save into `scripts/capture/manual/routines/`.
- **Java Swing (CV Builder):** `Win + Shift + S` on the window. Save into `scripts/capture/manual/<id>/`.
- **Radar:** screenshot the live dashboard in a browser.
- **Phone apps:** a phone screenshot or the emulator, saved in filename order.
Then run `npm run capture -- --only=<id>` to promote them.
## Scheduling
To refresh every Sunday at 10:00 with Task Scheduler:
```powershell
schtasks /Create /SC WEEKLY /D SUN /ST 10:00 /TN "PortfolioCapture" /TR "cmd /c cd /d F:\Portfolio && npm run capture >> capture.log 2>&1"
```
Scheduled runs can only capture what they can reach. Projects that need a running
emulator, device or hardware stay on the manual route.
## Before you publish
Screenshots are public once committed. Check each one for:
- email addresses, phone numbers, real names of other people
- hostnames, IP addresses, NAS or router names, Tailscale or Gitea URLs
- API keys, tokens and Discord server or channel names
- patient, customer or other third-party data
Crop or blur if needed. Use demo content where possible.
+126
View File
@@ -0,0 +1,126 @@
{
"outputDir": "public/images/projects",
"projectsFile": "src/data/projects.json",
"workDir": ".capture-work",
"viewport": {
"width": 1440,
"height": 900
},
"deviceScaleFactor": 1,
"colorScheme": "light",
"settleMs": 400,
"projects": [
{
"id": "portfolio",
"_note": "This site. Builds and runs the real server, so the GitHub tracker has data.",
"enabled": true,
"source": {
"local": "."
},
"serve": {
"command": "npm run build && npm start",
"url": "http://localhost:3001",
"readyTimeoutSec": 180
},
"steps": [
{
"goto": "/"
},
{
"wait": 1200
},
{
"screenshot": "home"
},
{
"scrollTo": ".project-grid"
},
{
"wait": 900
},
{
"screenshot": "projects"
},
{
"click": ".project-card"
},
{
"wait": 900
},
{
"screenshot": "detail"
},
{
"press": "Escape"
},
{
"scrollTo": ".homelab-grid"
},
{
"wait": 900
},
{
"screenshot": "homelab"
}
]
},
{
"id": "mass",
"_note": "Phone app. Drop emulator or device screenshots in scripts/capture/manual/mass/.",
"manual": true,
"enabled": true
},
{
"id": "geo-hunt",
"_note": "React Native app. Emulator screenshots.",
"manual": true,
"enabled": true
},
{
"id": "routines",
"_note": "Android. Use the emulator screenshot button in Android Studio.",
"manual": true,
"enabled": true
},
{
"id": "crudl",
"_note": "React Native app. Emulator screenshots.",
"manual": true,
"enabled": true
},
{
"id": "qr-hunt",
"_note": "Web app, screenshots taken by hand at 1440x900.",
"manual": true,
"enabled": true
},
{
"id": "cv-builder",
"_note": "Java Swing desktop app. Window screenshots.",
"manual": true,
"enabled": true
},
{
"id": "radar",
"_note": "Hardware. Stock photo of an ESP32 board until I photograph the build.",
"manual": true,
"enabled": true
},
{
"id": "ai-bot",
"_note": "Discord bot. Stock photo of Python code; chat screenshots would leak other users.",
"manual": true,
"enabled": true
},
{
"id": "homelab",
"_note": "Stock photo of network cabling.",
"manual": true,
"enabled": true
}
],
"manualMaxWidth": {
"portrait": 720,
"landscape": 1440
}
}
+293
View File
@@ -0,0 +1,293 @@
// Automated project screenshots for the portfolio.
//
// npm run capture capture every enabled project
// npm run capture -- --only=portfolio,mass
//
// For each project in capture.config.json the runner can:
// 1. get the source (a local folder, or a git clone/pull into .capture-work/),
// 2. run its setup commands (e.g. npm ci),
// 3. start its dev/preview server and wait until it answers,
// 4. drive it with Playwright (click, type, scroll, screenshot), or
// 5. for native apps (Android, Swing, hardware) promote screenshots you dropped
// into scripts/capture/manual/<id>/,
// then write the PNGs to public/images/projects/<id>-<name>.png and list them in
// that project's "images" array in src/data/projects.json.
//
// Nothing is published or committed. Review the new images before you commit.
import { spawn } from "node:child_process";
import { promises as fs } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const onlyArg = process.argv.find((a) => a.startsWith("--only="));
const ONLY = onlyArg ? new Set(onlyArg.slice("--only=".length).split(",").map((s) => s.trim())) : null;
const config = JSON.parse(
await fs.readFile(path.join(ROOT, "scripts/capture/capture.config.json"), "utf8")
);
const OUT_DIR = path.join(ROOT, config.outputDir ?? "public/images/projects");
const WORK_DIR = path.join(ROOT, config.workDir ?? ".capture-work");
const DATA_FILE = path.join(ROOT, config.projectsFile ?? "src/data/projects.json");
const MANUAL_DIR = path.join(ROOT, "scripts/capture/manual");
const IMAGE_RE = /\.(png|jpe?g|webp)$/i;
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const log = (msg) => console.log(`[capture] ${msg}`);
// Run a command and resolve when it exits 0. Output streams to this terminal.
function run(cmd, argv = [], { cwd = ROOT, shell = false } = {}) {
return new Promise((resolve, reject) => {
const child = spawn(cmd, argv, { cwd, shell, stdio: "inherit" });
child.on("error", reject);
child.on("exit", (code) =>
code === 0 ? resolve() : reject(new Error(`"${[cmd, ...argv].join(" ")}" exited with ${code}`))
);
});
}
// Start a long-running server. Detached on POSIX so the whole group can be stopped.
function startServer(command, cwd) {
return spawn(command, { cwd, shell: true, stdio: "inherit", detached: process.platform !== "win32" });
}
// Stop a server and everything it spawned (npm -> node -> vite is a tree).
async function stopServer(child) {
if (!child || child.exitCode !== null) return;
if (process.platform === "win32") {
await run("taskkill", ["/pid", String(child.pid), "/T", "/F"]).catch(() => {});
} else {
try { process.kill(-child.pid, "SIGTERM"); } catch {}
}
await sleep(500);
}
async function waitForUrl(url, timeoutSec) {
const deadline = Date.now() + timeoutSec * 1000;
while (Date.now() < deadline) {
try {
const res = await fetch(url, { redirect: "manual" });
if (res.status < 500) return;
} catch {
// not listening yet
}
await sleep(1000);
}
throw new Error(`timed out after ${timeoutSec}s waiting for ${url}`);
}
// Returns the directory to work in. Git sources are cloned once, then refreshed.
async function prepareSource(project) {
const src = project.source ?? {};
if (src.local) return path.resolve(ROOT, src.local);
if (!src.git) throw new Error("source needs either \"local\" or \"git\"");
const dir = path.join(WORK_DIR, project.id);
const branch = src.branch ?? "main";
await fs.mkdir(WORK_DIR, { recursive: true });
const exists = await fs.stat(path.join(dir, ".git")).then(() => true, () => false);
if (!exists) {
log(`cloning ${project.id} from ${src.git}`);
await run("git", ["clone", "--depth", "1", "--branch", branch, src.git, dir]);
} else {
log(`updating ${project.id} (${branch})`);
await run("git", ["-C", dir, "fetch", "--depth", "1", "origin", branch]);
await run("git", ["-C", dir, "reset", "--hard", "FETCH_HEAD"]);
}
return dir;
}
function slug(s) {
return String(s).toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-|-$/g, "");
}
// Playwright actions. Each step is one key (the action) plus optional sibling keys.
async function runSteps(page, project, baseUrl, produced) {
const steps = project.steps ?? [{ goto: "/" }, { wait: 800 }, { screenshot: "home" }];
const settle = config.settleMs ?? 400;
for (const step of steps) {
if ("goto" in step) {
const target = new URL(step.goto, baseUrl).toString();
await page.goto(target, { waitUntil: "load", timeout: 60000 });
await sleep(settle);
} else if ("click" in step) {
await page.locator(step.click).first().click({ timeout: 15000 });
} else if ("fill" in step) {
await page.locator(step.fill).first().fill(String(step.value ?? ""));
} else if ("press" in step) {
await page.keyboard.press(step.press);
} else if ("hover" in step) {
await page.locator(step.hover).first().hover({ timeout: 15000 });
} else if ("scrollTo" in step) {
await page.locator(step.scrollTo).first().scrollIntoViewIfNeeded({ timeout: 15000 });
} else if ("scrollBy" in step) {
await page.evaluate((y) => window.scrollBy(0, y), step.scrollBy);
} else if ("waitFor" in step) {
await page.locator(step.waitFor).first().waitFor({ state: "visible", timeout: 30000 });
} else if ("wait" in step) {
await sleep(step.wait);
} else if ("screenshot" in step) {
const name = slug(step.screenshot);
const file = `${project.id}-${name}.png`;
await sleep(settle);
if (step.selector) {
await page.locator(step.selector).first().screenshot({
path: path.join(OUT_DIR, file),
animations: "disabled",
});
} else {
await page.screenshot({ path: path.join(OUT_DIR, file), fullPage: !!step.fullPage, animations: "disabled" });
}
produced.push(file);
log(` saved ${file}`);
} else {
throw new Error(`unknown step: ${JSON.stringify(step)}`);
}
}
}
async function captureWithBrowser(project, baseUrl) {
let chromium;
try {
({ chromium } = await import("playwright"));
} catch {
throw new Error("Playwright is not installed. Run: npm install && npx playwright install chromium");
}
// CAPTURE_CHANNEL=msedge (or chrome) drives a browser that is already installed,
// instead of the Chromium build from `npx playwright install`.
const browser = await chromium.launch({ headless: true, channel: process.env.CAPTURE_CHANNEL || undefined });
const produced = [];
try {
const context = await browser.newContext({
viewport: project.viewport ?? config.viewport ?? { width: 1440, height: 900 },
deviceScaleFactor: project.deviceScaleFactor ?? config.deviceScaleFactor ?? 1,
colorScheme: project.colorScheme ?? config.colorScheme ?? "light",
reducedMotion: "reduce",
});
const page = await context.newPage();
await runSteps(page, project, baseUrl, produced);
await context.close();
} finally {
await browser.close();
}
return produced;
}
// Convert hand-taken screenshots (Android emulator, Swing app, hardware, stock photo)
// from scripts/capture/manual/<id>/ into the output folder, numbered in filename order.
// Each one is downscaled and saved as WebP so a 1080x2400 phone shot ships at ~60 KB.
async function promoteManual(project) {
const dir = path.join(MANUAL_DIR, project.id);
const entries = await fs.readdir(dir).catch(() => []);
const files = entries.filter((f) => IMAGE_RE.test(f)).sort((a, b) =>
a.localeCompare(b, undefined, { numeric: true })
);
if (files.length === 0) return null;
let sharp;
try {
sharp = (await import("sharp")).default;
} catch {
throw new Error("sharp is not installed. Run: npm install");
}
const max = config.manualMaxWidth ?? { portrait: 720, landscape: 1440 };
const produced = [];
for (let i = 0; i < files.length; i++) {
const input = sharp(path.join(dir, files[i]));
const { width, height } = await input.metadata();
const file = `${project.id}-${i + 1}.webp`;
await input
.resize({ width: height > width ? max.portrait : max.landscape, withoutEnlargement: true })
.webp({ quality: 82 })
.toFile(path.join(OUT_DIR, file));
produced.push(file);
log(` converted ${files[i]} -> ${file}`);
}
return produced;
}
// "portrait" for phone screenshots, "landscape" otherwise. The site uses this to
// size the media pane in the project pop-up.
async function orientationOf(file) {
const sharp = (await import("sharp")).default;
const { width, height } = await sharp(path.join(OUT_DIR, file)).metadata();
return height > width ? "portrait" : "landscape";
}
async function captureProject(project) {
if (project.manual) return promoteManual(project);
const cwd = await prepareSource(project);
for (const cmd of project.setup ?? []) {
log(` ${project.id}: ${cmd}`);
await run(cmd, [], { cwd, shell: true });
}
let baseUrl = project.url;
let server = null;
try {
if (project.serve) {
log(` ${project.id}: starting "${project.serve.command}"`);
server = startServer(project.serve.command, path.join(cwd, project.serve.cwd ?? ""));
baseUrl = project.serve.url;
await waitForUrl(baseUrl, project.serve.readyTimeoutSec ?? 120);
}
if (!baseUrl) throw new Error("set \"serve\" or \"url\" for this project");
return await captureWithBrowser(project, baseUrl);
} finally {
await stopServer(server);
}
}
// Remove screenshots from an earlier run that this run did not replace.
async function pruneOld(id, keep) {
const entries = await fs.readdir(OUT_DIR).catch(() => []);
for (const f of entries) {
if (f.startsWith(`${id}-`) && IMAGE_RE.test(f) && !keep.includes(f)) {
await fs.unlink(path.join(OUT_DIR, f));
log(` removed old ${f}`);
}
}
}
async function main() {
await fs.mkdir(OUT_DIR, { recursive: true });
const data = JSON.parse(await fs.readFile(DATA_FILE, "utf8"));
const results = { ok: [], skipped: [], failed: [] };
for (const project of config.projects) {
const id = project.id;
if (ONLY ? !ONLY.has(id) : project.enabled === false) {
continue;
}
log(`== ${id}`);
try {
const files = await captureProject(project);
if (!files || files.length === 0) {
log(` nothing to capture for ${id} (manual folder empty or missing), skipped`);
results.skipped.push(id);
continue;
}
await pruneOld(id, files);
const entry = data.find((p) => p.id === id);
if (entry) {
entry.images = files;
entry.orientation = await orientationOf(files[0]);
}
else log(` warning: no project with id "${id}" in ${path.relative(ROOT, DATA_FILE)}`);
results.ok.push(`${id} (${files.length})`);
} catch (err) {
console.error(`[capture] FAILED ${id}: ${err.message}`);
results.failed.push(id);
}
}
if (results.ok.length) {
await fs.writeFile(DATA_FILE, JSON.stringify(data, null, 2) + "\n");
log(`updated ${path.relative(ROOT, DATA_FILE)}`);
}
log(`done. captured: ${results.ok.join(", ") || "none"}; skipped: ${results.skipped.join(", ") || "none"}; failed: ${results.failed.join(", ") || "none"}`);
process.exitCode = results.failed.length ? 1 : 0;
}
await main();
+12
View File
@@ -0,0 +1,12 @@
# Hand-taken screenshots
For projects that can't be driven by a browser (Android, Java Swing, hardware),
drop images into a folder named after the project id, then run `npm run capture`:
scripts/capture/manual/routines/ -> Routines App
scripts/capture/manual/mass/ -> MASS (phone screenshots)
scripts/capture/manual/radar/ -> 240 GHz Doppler Radar
scripts/capture/manual/ai-bot/ -> AI Discord Bot
Files are copied in filename order (1.png, 2.png, ...). Use PNG, JPG or WebP.
Folder contents are gitignored, so only the processed copies in public/images/projects/ get committed.