From 9cb2060ef98853de15a3f0f95b17a930a70b1e15 Mon Sep 17 00:00:00 2001 From: Kkkermit <132657029+Kkkermit@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:01:00 +0000 Subject: [PATCH 1/3] feat(site): a website on GitHub Pages with downloads, set-up and help A static website in site/ for https://kkkermit.github.io/Statsify/: the downloads for each system (the visitor's own picked out), the set-up guide, the changelog from GitHub's release notes, troubleshooting with search, and the FAQ. It's plain TypeScript and CSS with its own Vite config and a strict CSP, in the app's colours and font, light or dark with the system. The release list is saved while the site is built (scripts/site-releases.mjs), so visitors' browsers never call GitHub's API. The new Website workflow (pages.yml) builds and tests it and publishes it from main; release.yml starts it after each release, so a new version shows up on its own. Tests: Vitest for reading releases, picking files, detecting the system and parsing release notes; Playwright for axe (both colour schemes, laptop and phone), no sideways scroll from 320 px to 4K, downloads per system, the changelog shown as text only, tabs, copy buttons, search and the menu. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TCk6t7edJdscNtTSeFmyQN --- .github/labeler.yml | 2 +- .github/workflows/ci.yml | 9 +- .github/workflows/pages.yml | 94 ++ .github/workflows/release-on-main.yml | 4 +- .github/workflows/release.yml | 10 + .gitignore | 3 + AGENTS.md | 23 +- CONTRIBUTING.md | 1 + README.md | 3 + docs/DEVELOPMENT.md | 26 +- docs/RELEASING.md | 18 +- eslint.config.js | 4 +- package.json | 7 +- scripts/site-releases.mjs | 47 + site/e2e/releases.json | 147 +++ site/e2e/site.spec.ts | 276 +++++ site/index.html | 1020 +++++++++++++++++ site/main.ts | 454 ++++++++ site/playwright.config.ts | 32 + site/releases.test.ts | 242 ++++ site/releases.ts | 252 +++++ site/styles.css | 1494 +++++++++++++++++++++++++ site/vite.config.ts | 52 + tsconfig.json | 3 +- tsconfig.node.json | 11 +- tsconfig.site.json | 24 + vitest.config.ts | 2 +- 27 files changed, 4243 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/pages.yml create mode 100644 scripts/site-releases.mjs create mode 100644 site/e2e/releases.json create mode 100644 site/e2e/site.spec.ts create mode 100644 site/index.html create mode 100644 site/main.ts create mode 100644 site/playwright.config.ts create mode 100644 site/releases.test.ts create mode 100644 site/releases.ts create mode 100644 site/styles.css create mode 100644 site/vite.config.ts create mode 100644 tsconfig.site.json diff --git a/.github/labeler.yml b/.github/labeler.yml index 9054dbc..4499a9e 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -8,7 +8,7 @@ desktop: # its docs or tests is still listed as a feature. documentation: - changed-files: - - any-glob-to-all-files: ["**/*.md", "docs/**", "LICENSE"] + - any-glob-to-all-files: ["**/*.md", "docs/**", "LICENSE", "site/**"] tests: - changed-files: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e62b9be..590bec5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,10 +70,11 @@ jobs: files=$(git diff --name-only --no-renames "$BASE" "$GITHUB_SHA"); then echo "Changed files:" echo "$files" - # Markdown, docs/, the licence and the repository's settings in .github/ can't change - # what the end-to-end tests see; this workflow can. The checks job always runs: one of - # its tests checks every file name, docs included. - code=$(grep -vE '\.md$|^docs/|^LICENSE$|^\.github/' <<< "$files" || true) + # Markdown, docs/, the licence, the website (site/, tested by pages.yml) and the + # repository's settings in .github/ can't change what the end-to-end tests see; this + # workflow can. The checks job always runs: it type-checks, lints and unit-tests the + # website too, and one of its tests checks every file name, docs included. + code=$(grep -vE '\.md$|^docs/|^LICENSE$|^\.github/|^site/|^scripts/site-releases\.mjs$' <<< "$files" || true) if [[ -z "$code" ]] && ! grep -qx '.github/workflows/ci.yml' <<< "$files"; then e2e=false; fi grep -qE '^src-tauri/|^\.github/workflows/ci\.yml$' <<< "$files" || rust=false fi diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..6a4323f --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,94 @@ +name: Website + +# Builds the website in site/ (downloads, changelog, set-up guide, troubleshooting and FAQ), tests +# it, and publishes it on GitHub Pages. The page reads the releases from a list saved while it is +# built (scripts/site-releases.mjs), so it is built again whenever the site changes on main and +# after every release: release.yml starts this workflow once it has published one. Pull requests +# that change the site build and test it without publishing. +# +# One-time set-up: Settings → Pages → Source: GitHub Actions (docs/RELEASING.md). +on: + push: + branches: [main] + paths: + - "site/**" + - "public/favicon.svg" + - "public/logo.svg" + - "public/apple-touch-icon.png" + - "docs/screenshots/**" + - "scripts/site-releases.mjs" + - "package-lock.json" + - ".github/workflows/pages.yml" + pull_request: + paths: + - "site/**" + - "public/favicon.svg" + - "public/logo.svg" + - "public/apple-touch-icon.png" + - "docs/screenshots/**" + - "scripts/site-releases.mjs" + - "package-lock.json" + - ".github/workflows/pages.yml" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + # A newer build replaces one still running, but a publish already under way finishes. + group: pages-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build: + name: Build and test the website + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: .nvmrc + cache: npm + - run: npm ci + - name: Save the release list + env: + GITHUB_TOKEN: ${{ github.token }} + run: node scripts/site-releases.mjs + - run: npm run site:build + - name: Install Playwright's browser + run: npx playwright install --with-deps --only-shell chromium + - name: Test the website (axe accessibility, layout from phone to 4K, downloads, changelog) + env: + SITE_PREBUILT: "1" + run: npm run site:test + - name: Upload screenshots of failed tests + if: failure() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: site-test-failures + path: test-results/ + retention-days: 7 + - name: Package the website for Pages + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 + with: + path: site/dist + + publish: + name: Publish to GitHub Pages + needs: build + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deploy.outputs.page_url }} + steps: + - id: deploy + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 diff --git a/.github/workflows/release-on-main.yml b/.github/workflows/release-on-main.yml index e4fb8b5..7ea7d3d 100644 --- a/.github/workflows/release-on-main.yml +++ b/.github/workflows/release-on-main.yml @@ -56,8 +56,10 @@ jobs: needs: check if: needs.check.outputs.release == 'true' permissions: - # Creating the tag and the release (only release.yml's publish job uses it). + # Creating the tag and the release, then starting the Website workflow (only release.yml's + # publish job uses them). contents: write + actions: write uses: ./.github/workflows/release.yml with: tag: ${{ needs.check.outputs.tag }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94a58b6..61a358a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -147,6 +147,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + # Starting the Website workflow (pages.yml) once the release is out. + actions: write steps: - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: @@ -205,3 +207,11 @@ jobs: fi gh release create "$TAG" release/* --repo "$GITHUB_REPOSITORY" "${flags[@]}" gh release edit "$TAG" --draft=false --repo "$GITHUB_REPOSITORY" || refused + - name: Update the website + # The website lists the releases and links their files, so it's built again with this one. + # Its failing leaves the release as it is. + env: + GH_TOKEN: ${{ github.token }} + run: | + gh workflow run pages.yml --ref main --repo "$GITHUB_REPOSITORY" || + echo "::warning::The website wasn't rebuilt. Run the Website workflow by hand to list this release." diff --git a/.gitignore b/.gitignore index b6cf9cf..92be8b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Dependencies and build output (Rust build output: src-tauri/.gitignore) node_modules /dist/ +# The website's build, and the release list scripts/site-releases.mjs saves for it +/site/dist/ +/site/public/releases.json *.tsbuildinfo # Tests and coverage diff --git a/AGENTS.md b/AGENTS.md index 81e7dba..19f322c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -62,6 +62,10 @@ npm run e2e # Playwright: builds, previews on :4173, runs desktop/ E2E_PORT=4801 npm run e2e # the same on another port (several runs on one machine) npm run check # typecheck + lint + test + build npm run version:set -- 1.2.0 # set the version in all six places (--check 1.2.0, --print) +npm run site:dev # the website (site/) on http://127.0.0.1:5174 +npm run site:releases # save the releases it shows to site/public/releases.json +npm run site:build # the website -> site/dist/ (site:preview serves it on :4174) +npm run site:test # the website's Playwright tests (builds it first) # Rust (inside src-tauri/). The crate embeds dist/, so build the web app first or create a # placeholder: mkdir -p dist && echo 'ci' > dist/index.html @@ -70,7 +74,8 @@ cargo clippy --all-targets -- -D warnings cargo test ``` -Ports are fixed (`strictPort`): 5173 dev, 4173 preview/e2e, 43821 desktop sign-in listener. +Ports are fixed (`strictPort`): 5173 dev, 4173 preview/e2e, 43821 desktop sign-in listener, +5174 and 4174 the website's dev server and preview. ## Repository map @@ -78,6 +83,7 @@ Ports are fixed (`strictPort`): 5173 dev, 4173 preview/e2e, 43821 desktop sign-i app/ the React app (web and desktop UI) src-tauri/ the desktop shell (Rust, Tauri 2) e2e/ Playwright specs and their fakes +site/ the website on GitHub Pages: downloads, changelog, set-up guide, troubleshooting, FAQ scripts/ test set-up, repository-wide checks, the version script docs/ user guide, development, database and release docs, README screenshots public/ static files served as-is (icons, web manifest, logo) @@ -133,6 +139,15 @@ Tests sit next to the code they test (`*.test.ts` / `*.test.tsx`). differ only by case (they would clash on Windows and macOS). `scripts/set-version.mjs`: sets or checks the version in `package.json`, `package-lock.json`, `tauri.conf.json`, `Cargo.toml` and `Cargo.lock` (`npm run version:set`). +- `site/`: the project's website, published by `pages.yml` at https://kkkermit.github.io/Statsify/. + Plain TypeScript and CSS built by its own Vite config (`site/vite.config.ts`, with a + `` CSP), no framework. `index.html` holds the content; `main.ts` adds the downloads and + changelog from `releases.json` (saved at build time by `scripts/site-releases.mjs`, so + visitors' browsers never call GitHub's API), the install tabs, copy buttons, help search and + the menu; `releases.ts` is the pure part (reading releases, picking each system's files, + parsing GitHub's generated notes), tested in `releases.test.ts`; `e2e/` has its Playwright + tests and a fixture release list. It uses the app's colours and font and follows the system's + light or dark mode. Keep its text in step with the README and the user guide. - `docs/GUIDE.md` user guide, `docs/DEVELOPMENT.md` developer set-up and debugging, `docs/DATABASE.md` the SQLite schema and binary format, `docs/RELEASING.md` the release process, `docs/screenshots/` README images. @@ -848,6 +863,12 @@ label)` (axe WCAG 2.2 A/AA, no serious or critical violations), `enterDemo`, `se actor); otherwise the release is left as a draft for an admin to publish. Pull requests that change it or the version script run a dry run, which calls `ci.yml` with `run: build` (the pull request's own CI run has the checks). + - `pages.yml` (**Website**): builds `site/` with the current release list, runs its tests + (`npm run site:test`: axe in both colour schemes, no sideways scroll from 320 px to 4K, the + downloads per system, the changelog, tabs, search and the menu) and publishes it to GitHub + Pages, on pushes to `main` that change the site and when `release.yml` starts it after a + release; pull requests that change the site run the build and tests only. CI's end-to-end + tests skip changes that only touch `site/`. - `codeql.yml`: code scanning for TypeScript, Rust and the workflows, on pull requests, pushes to `main` and weekly. - `labeler.yml`: labels pull requests by files (`.github/labeler.yml`) and title type; the diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 156b83b..fdb492d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -92,6 +92,7 @@ release notes group changes by those labels; the maintainer may adjust them. - **Desktop app** (when a pull request changes `src-tauri/`, dependencies or the build): the installers build on Windows, Linux and macOS, and can be downloaded from the run's page, handy for testing. +- **Website** (when a pull request changes `site/`): builds the website and runs its tests. - **CodeQL:** security scanning of the TypeScript, the Rust and the workflows. All of them must pass before merging. If an end-to-end test fails, that job's `e2e-failures-` diff --git a/README.md b/README.md index e560282..4674f08 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,9 @@ Overview: now playing, 30-day listening time, plays, top artist, streak, top tracks and recent plays

+**Website:** [kkkermit.github.io/Statsify](https://kkkermit.github.io/Statsify/) has the downloads, +the set-up guide, the changelog and answers to common problems. + Statsify works with your own Spotify account through Spotify's official Web API. You create a free **Client ID** for it once (about two minutes, [see below](#one-time-spotify-setup-about-2-minutes)), or click **Explore the demo** to look around with fictional data first. diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 894caeb..c3699b3 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -135,6 +135,24 @@ Set `VITE_SPOTIFY_CLIENT_ID` at build time to fill in the Client ID for everyone five accounts, see the [README](../README.md#why-do-i-need-my-own-client-id)); leave it unset and each person enters their own. +### The website + +`site/` is the project's website at https://kkkermit.github.io/Statsify/: downloads, the +changelog, the set-up guide, troubleshooting and the FAQ. It's a separate static page built with +its own Vite config, and the **Website** workflow publishes it to GitHub Pages. + +```bash +npm run site:releases # saves the release list it shows to site/public/releases.json +npm run site:dev # http://127.0.0.1:5174 +npm run site:build # builds into site/dist/ +npm run site:preview # serves site/dist/ on http://127.0.0.1:4174 +npm run site:test # its Playwright tests (they build it first) +``` + +Without `site/public/releases.json` the page still works, and links to GitHub Releases where the +downloads and changelog would be. `site:releases` asks GitHub's API anonymously; set +`GITHUB_TOKEN` if you hit the rate limit. + ### Ports and settings The ports are fixed (`strictPort`), because Spotify needs the exact redirect address. If one is @@ -144,6 +162,8 @@ taken, stop whatever uses it rather than picking another port. | ----- | ------------------------------------------ | | 5173 | `npm run dev` (and `npm run desktop:dev`) | | 4173 | `npm run preview` and the end-to-end tests | +| 5174 | `npm run site:dev` (the website) | +| 4174 | `npm run site:preview` and its tests | | 43821 | The desktop app's sign-in listener | | Variable | What it does | @@ -255,6 +275,7 @@ them, and npm and Cargo dependencies, every week (`.github/dependabot.yml`). | **Desktop app** (`desktop.yml`) | Changes to the app reaching `main`; pull requests that change `src-tauri/`, dependencies or the build | Builds the installers on Windows, Linux and macOS and keeps them as downloadable artifacts for 14 days | | **Release on main** (`release-on-main.yml`) | Pushes to `main` | Releases the version in `package.json` when it has no tag yet, by running **Release** on that commit | | **Release** (`release.yml`) | Called by Release on main, version tags (`v1.2.0`); dry runs when the workflow itself changes | Checks the version, runs CI and the desktop builds, and publishes a GitHub Release ([RELEASING.md](RELEASING.md)) | +| **Website** (`pages.yml`) | Website changes on `main` and in pull requests; after each release | Builds and tests `site/` and, from `main`, publishes it to GitHub Pages | | **CodeQL** (`codeql.yml`) | Pull requests, pushes to `main`, weekly | Security scanning of the TypeScript, the Rust and the workflows | | **Label pull requests** (`labeler.yml`) | Pull requests | Labels each pull request by its files and its title's type, for the release notes | @@ -270,8 +291,9 @@ How **CI** is laid out, and why: as each other (see [End-to-end tests](#end-to-end-tests-playwright)). Each job runs two browsers, half of a 4-core runner. A failing job uploads its screenshots as `e2e-failures-`; the other jobs still run to the end. -- **What changed** decides what a change needs. Changes to Markdown, `docs/` or `.github/` (other - than `ci.yml`) skip the end-to-end tests; changes outside `src-tauri/` skip the Rust checks. +- **What changed** decides what a change needs. Changes to Markdown, `docs/`, the website + (`site/`, which the **Website** workflow tests) or `.github/` (other than `ci.yml`) skip the + end-to-end tests; changes outside `src-tauri/` skip the Rust checks. Runs by hand and releases run everything. - The branch rules require **Lint, test & build** and **Desktop shell (Rust)**. **Lint, test & build** waits for the build, the checks and every end-to-end job, and passes only if each passed diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 0f0ce97..dbf0113 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -56,7 +56,10 @@ npm run version:set -- --print # show the current version - runs all of CI (tests, end-to-end and accessibility checks, Rust checks); - builds the installers on Windows, Linux and macOS, and the web app; - publishes a GitHub Release tagged `v1.3.0` on the merged commit, with the files, their - SHA-256 checksums and the generated notes. + SHA-256 checksums and the generated notes; + - starts the [Website workflow](https://github.com/Kkkermit/Statsify/actions/workflows/pages.yml), + so [the website](https://kkkermit.github.io/Statsify/) offers the new version a few minutes + later. When the tag already exists, the run stops after its first step: merges that don't change the version release nothing. @@ -104,6 +107,17 @@ A published tag still can't be moved or deleted. Only people with write access, running this repository's own code on `main`, a tag or a feature branch, can create tags; pull requests from forks get a read-only token. +### One-time set-up: the website + +The website is published with GitHub Actions. Once, in **Settings → Pages**, set **Source** to +**GitHub Actions**, or with an admin's `gh`: + +```bash +gh api -X POST repos/Kkkermit/Statsify/pages -f build_type=workflow +``` + +Then run the **Website** workflow from the Actions tab, or merge a change to `site/`. + ### What a release contains | File | For | @@ -132,7 +146,7 @@ their own, and the app asks for it on first run. replaces its files and publishes it. - **"The repository's rules don't let GitHub Actions" create the tag:** the release is a draft with every file. Publish it from the Releases page, and do the one-time set-up above so the next - one publishes itself. + one publishes itself. Then run the **Website** workflow by hand, so the website lists it. - **A published release has a bug:** release a patch version. Never move or reuse a published tag: people's checksums and links depend on it. The pipeline refuses to change the files of a published release. diff --git a/eslint.config.js b/eslint.config.js index bb33a1c..22ebe85 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -6,7 +6,7 @@ import tseslint from "typescript-eslint"; export default tseslint.config( // .claude/worktrees: copies of the repo that coding agents work in. - { ignores: ["dist", "coverage", "src-tauri/target", "src-tauri/gen", "playwright-report", "test-results", ".claude"] }, + { ignores: ["dist", "site/dist", "coverage", "src-tauri/target", "src-tauri/gen", "playwright-report", "test-results", ".claude"] }, { extends: [js.configs.recommended, ...tseslint.configs.recommended], files: ["**/*.{ts,tsx}"], @@ -26,7 +26,7 @@ export default tseslint.config( }, }, { - files: ["e2e/**/*.ts", "*.config.ts"], + files: ["e2e/**/*.ts", "*.config.ts", "site/e2e/**/*.ts", "site/*.config.ts"], languageOptions: { globals: { ...globals.node } }, }, ); diff --git a/package.json b/package.json index 1a2d9e5..90fbd94 100644 --- a/package.json +++ b/package.json @@ -33,13 +33,18 @@ "preview": "vite preview", "typecheck": "tsc -b", "lint": "eslint .", - "format": "prettier --write \"app/**/*.{ts,tsx,css}\" \"e2e/**/*.ts\" \"docs/**/*.md\" \"*.md\"", + "format": "prettier --write \"app/**/*.{ts,tsx,css}\" \"site/**/*.{ts,css,html}\" \"e2e/**/*.ts\" \"docs/**/*.md\" \"*.md\"", "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage", "e2e": "playwright test", "check": "npm run typecheck && npm run lint && npm run test && npm run build", "version:set": "node scripts/set-version.mjs", + "site:dev": "vite --config site/vite.config.ts", + "site:build": "vite build --config site/vite.config.ts", + "site:preview": "vite preview --config site/vite.config.ts", + "site:releases": "node scripts/site-releases.mjs", + "site:test": "playwright test --config site/playwright.config.ts", "tauri": "tauri", "desktop:dev": "tauri dev", "desktop:build": "tauri build" diff --git a/scripts/site-releases.mjs b/scripts/site-releases.mjs new file mode 100644 index 0000000..a8190b9 --- /dev/null +++ b/scripts/site-releases.mjs @@ -0,0 +1,47 @@ +#!/usr/bin/env node +/** + * Saves the repository's releases for the website (site/), which shows its downloads and + * changelog from this file rather than asking GitHub's API from every visitor's browser. + * + * node scripts/site-releases.mjs [output] (default: site/public/releases.json) + * + * GITHUB_REPOSITORY picks the repository (default Kkkermit/Statsify), and GITHUB_TOKEN, when set, + * is sent so the request isn't held to the anonymous rate limit. Drafts are left out. + */ +import { mkdirSync, writeFileSync } from "node:fs"; +import { dirname, resolve } from "node:path"; + +const repository = process.env.GITHUB_REPOSITORY || "Kkkermit/Statsify"; +const output = resolve(process.argv[2] || "site/public/releases.json"); + +const headers = { + Accept: "application/vnd.github+json", + "User-Agent": "statsify-site", + "X-GitHub-Api-Version": "2022-11-28", +}; +if (process.env.GITHUB_TOKEN) headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`; + +const response = await fetch(`https://api.github.com/repos/${repository}/releases?per_page=20`, { + headers, + signal: AbortSignal.timeout(30_000), +}); +if (!response.ok) { + console.error(`GitHub answered ${response.status} ${response.statusText} for ${repository}'s releases.`); + process.exit(1); +} + +const releases = (await response.json()) + .filter((r) => !r.draft) + .map((r) => ({ + tag: r.tag_name, + name: r.name, + date: r.published_at, + url: r.html_url, + prerelease: r.prerelease, + body: r.body ?? "", + assets: r.assets.map((a) => ({ name: a.name, size: a.size, url: a.browser_download_url })), + })); + +mkdirSync(dirname(output), { recursive: true }); +writeFileSync(output, `${JSON.stringify(releases, null, "\t")}\n`); +console.log(`Saved ${releases.length} releases of ${repository} to ${output}.`); diff --git a/site/e2e/releases.json b/site/e2e/releases.json new file mode 100644 index 0000000..cd6dea2 --- /dev/null +++ b/site/e2e/releases.json @@ -0,0 +1,147 @@ +[ + { + "tag": "v1.3.0-beta.1", + "name": "Statsify 1.3.0-beta.1", + "date": "2026-12-10T09:00:00Z", + "url": "https://github.com/Kkkermit/Statsify/releases/tag/v1.3.0-beta.1", + "prerelease": true, + "body": "## What's Changed\n### New features\n* feat: a year in review by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/30\n", + "assets": [ + { + "name": "SHA256SUMS.txt", + "size": 659, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/SHA256SUMS.txt" + }, + { + "name": "Statsify_1.3.0-beta.1_amd64.AppImage", + "size": 82115064, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_amd64.AppImage" + }, + { + "name": "Statsify_1.3.0-beta.1_amd64.deb", + "size": 3504044, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_amd64.deb" + }, + { + "name": "Statsify_1.3.0-beta.1_universal.dmg", + "size": 6710528, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_universal.dmg" + }, + { + "name": "Statsify_1.3.0-beta.1_web.zip", + "size": 584051, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_web.zip" + }, + { + "name": "Statsify_1.3.0-beta.1_x64-portable.exe", + "size": 5309440, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_x64-portable.exe" + }, + { + "name": "Statsify_1.3.0-beta.1_x64-setup.exe", + "size": 2431234, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_x64-setup.exe" + } + ] + }, + { + "tag": "v1.2.0", + "name": "Statsify 1.2.0", + "date": "2026-12-03T12:37:44Z", + "url": "https://github.com/Kkkermit/Statsify/releases/tag/v1.2.0", + "prerelease": false, + "body": "## Download\n\n| System | File |\n| --- | --- |\n| Windows | `Statsify_1.2.0_x64-setup.exe` |\n\n\n\n## What's Changed\n### New features\n* feat(lyrics): lyrics that follow the song word by word by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/21\n* feat: an `All time` range on Streams by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/22\n### Bug fixes\n* fix(desktop): the tray icon on Linux by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/23\n\n**Full Changelog**: https://github.com/Kkkermit/Statsify/compare/v1.1.0...v1.2.0", + "assets": [ + { + "name": "SHA256SUMS.txt", + "size": 659, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/SHA256SUMS.txt" + }, + { + "name": "Statsify_1.2.0_amd64.AppImage", + "size": 82115064, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_amd64.AppImage" + }, + { + "name": "Statsify_1.2.0_amd64.deb", + "size": 3504044, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_amd64.deb" + }, + { + "name": "Statsify_1.2.0_universal.dmg", + "size": 6710528, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_universal.dmg" + }, + { + "name": "Statsify_1.2.0_web.zip", + "size": 584051, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_web.zip" + }, + { + "name": "Statsify_1.2.0_x64-portable.exe", + "size": 5309440, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_x64-portable.exe" + }, + { + "name": "Statsify_1.2.0_x64-setup.exe", + "size": 2431234, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_x64-setup.exe" + }, + { + "name": "Statsify_1.2.0_x64_en-US.msi", + "size": 3129344, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_x64_en-US.msi" + } + ] + }, + { + "tag": "v1.1.0", + "name": "Statsify 1.1.0", + "date": "2026-11-20T10:00:00Z", + "url": "https://github.com/Kkkermit/Statsify/releases/tag/v1.1.0", + "prerelease": false, + "body": "", + "assets": [ + { + "name": "SHA256SUMS.txt", + "size": 659, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/SHA256SUMS.txt" + }, + { + "name": "Statsify_1.1.0_amd64.AppImage", + "size": 82115064, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_amd64.AppImage" + }, + { + "name": "Statsify_1.1.0_amd64.deb", + "size": 3504044, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_amd64.deb" + }, + { + "name": "Statsify_1.1.0_universal.dmg", + "size": 6710528, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_universal.dmg" + }, + { + "name": "Statsify_1.1.0_web.zip", + "size": 584051, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_web.zip" + }, + { + "name": "Statsify_1.1.0_x64-portable.exe", + "size": 5309440, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_x64-portable.exe" + }, + { + "name": "Statsify_1.1.0_x64-setup.exe", + "size": 2431234, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_x64-setup.exe" + }, + { + "name": "Statsify_1.1.0_x64_en-US.msi", + "size": 3129344, + "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_x64_en-US.msi" + } + ] + } +] diff --git a/site/e2e/site.spec.ts b/site/e2e/site.spec.ts new file mode 100644 index 0000000..12c2cd3 --- /dev/null +++ b/site/e2e/site.spec.ts @@ -0,0 +1,276 @@ +import { readFileSync } from "node:fs"; +import AxeBuilder from "@axe-core/playwright"; +import { expect, test, type Page } from "@playwright/test"; + +const RELEASES = readFileSync(new URL("./releases.json", import.meta.url), "utf8"); +const WCAG_TAGS = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]; +const MAC = + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15"; +const LINUX = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"; + +/** Answers releases.json from the fixture, and fails the test on any page or console error. */ +async function open(page: Page, releases: string | null = RELEASES): Promise { + const errors: string[] = []; + page.on("pageerror", (e) => errors.push(e.message)); + page.on("console", (m) => { + if (m.type() === "error") errors.push(m.text()); + }); + await page.route("**/releases.json", (route) => + releases === null + ? route.fulfill({ status: 404, body: "Not found" }) + : route.fulfill({ contentType: "application/json", body: releases }), + ); + await page.goto("/"); + return errors; +} + +async function noSeriousA11y(page: Page, label: string): Promise { + const results = await new AxeBuilder({ page }).withTags(WCAG_TAGS).analyze(); + const serious = results.violations.filter((v) => v.impact === "serious" || v.impact === "critical"); + expect(serious.map((v) => `${label}: ${v.id} ${v.nodes[0]?.target.join(" ")} – ${v.help}`)).toEqual([]); +} + +async function noSidewaysScroll(page: Page): Promise { + expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBe( + 0, + ); +} + +test.describe("the page", () => { + for (const scheme of ["dark", "light"] as const) { + test(`is accessible in ${scheme} mode, with every answer open [all sizes]`, async ({ page }) => { + await page.emulateMedia({ colorScheme: scheme, reducedMotion: "reduce" }); + const errors = await open(page); + await expect(page.getByRole("heading", { level: 1 })).toHaveText("Your Spotify, by the numbers."); + await expect(page.locator(".release").first()).toBeVisible(); + await page.evaluate(() => document.querySelectorAll("details").forEach((d) => (d.open = true))); + await noSeriousA11y(page, scheme); + await noSidewaysScroll(page); + expect(errors).toEqual([]); + }); + } + + test("never scrolls sideways, from a small phone to a 4K screen", async ({ page }) => { + await open(page); + for (const width of [320, 375, 768, 1024, 1440, 2560, 3840]) { + await page.setViewportSize({ width, height: 900 }); + await page.evaluate(() => document.querySelectorAll("details").forEach((d) => (d.open = true))); + await noSidewaysScroll(page); + } + }); + + test("keeps still with reduced motion", async ({ page }) => { + await page.emulateMedia({ reducedMotion: "reduce" }); + await open(page); + await expect(page.locator(".hero-text > *").first()).toHaveCSS("animation-name", "none"); + await expect(page.locator(".hero-shot")).toHaveCSS("opacity", "1"); + }); +}); + +test.describe("downloads", () => { + test("offer the Windows installer to a Windows computer", async ({ page }) => { + await open(page); + const hero = page.getByRole("link", { name: "Download for Windows" }); + await expect(hero).toHaveAttribute("href", /\/v1\.2\.0\/Statsify_1\.2\.0_x64-setup\.exe$/); + await expect(page.getByText("Version 1.2.0 for Windows 10 and 11, 2.4 MB", { exact: true })).toBeVisible(); + const windows = page.getByRole("region", { name: "Windows" }); + await expect(windows.getByText("Your system")).toBeVisible(); + const files = windows.getByRole("link", { name: /^Download/ }); + await expect(files).toHaveCount(3); + await expect(files.nth(0)).toHaveAccessibleName("Download Installer for Windows (.exe, 2.4 MB)"); + await expect(files.nth(0)).toHaveClass(/button-primary/); + await expect(files.nth(1)).toHaveAccessibleName(/^Download MSI package/); + await expect(files.nth(2)).toHaveAccessibleName(/^Download Portable/); + await expect(page.getByRole("region", { name: "macOS" }).getByText("Your system")).toBeHidden(); + await expect(page.getByRole("region", { name: "macOS" }).getByRole("link", { name: /^Download/ })).not.toHaveClass( + /button-primary/, + ); + }); + + test.describe("on a Mac", () => { + test.use({ userAgent: MAC }); + test("offer the disk image", async ({ page }) => { + await open(page); + await expect(page.getByRole("link", { name: "Download for macOS" })).toHaveAttribute("href", /_universal\.dmg$/); + await expect(page.getByRole("region", { name: "macOS" }).getByText("Your system")).toBeVisible(); + await expect(page.getByRole("tab", { name: "macOS" })).toHaveAttribute("aria-selected", "true"); + }); + }); + + test.describe("on Linux", () => { + test.use({ userAgent: LINUX }); + test("let you choose between the package and the AppImage", async ({ page }) => { + await open(page); + const hero = page.getByRole("link", { name: "Download for Linux" }); + await expect(hero).toHaveAttribute("href", "#download"); + await expect(page.getByText("Version 1.2.0, as a Debian package or an AppImage", { exact: true })).toBeVisible(); + const files = page.getByRole("region", { name: "Linux" }).getByRole("link", { name: /^Download/ }); + await expect(files.nth(0)).toHaveAccessibleName(/^Download Debian package/); + await expect(files.nth(1)).toHaveAccessibleName(/^Download AppImage/); + }); + }); + + test("say on a phone that Statsify is for computers [all sizes]", async ({ page, isMobile }) => { + test.skip(!isMobile, "Only a phone is told this."); + await open(page); + await expect(page.getByText("Statsify runs on computers")).toBeVisible(); + await expect(page.getByRole("link", { name: "Download Statsify" }).first()).toHaveAttribute("href", "#download"); + }); + + test("skip pre-releases, and link the checksums", async ({ page }) => { + await open(page); + await expect(page.getByText("Version 1.2.0, released 3 December 2026.")).toBeVisible(); + await page.getByText("Check a download against its checksum").click(); + await expect(page.getByRole("link", { name: "SHA256SUMS.txt" })).toHaveAttribute( + "href", + /\/v1\.2\.0\/SHA256SUMS\.txt$/, + ); + }); + + test("fall back to GitHub when the release list can't be loaded", async ({ page }) => { + const errors = await open(page, null); + await expect(page.getByText("The release notes couldn't be loaded here.")).toBeVisible(); + const windows = page.getByRole("region", { name: "Windows" }); + await expect(windows.getByRole("link", { name: "Open Releases" })).toHaveAttribute( + "href", + "https://github.com/Kkkermit/Statsify/releases/latest", + ); + await expect(page.getByRole("link", { name: "Download for Windows" })).toHaveCount(0); + // The 404 itself is the only error. + expect(errors.filter((e) => !e.includes("404"))).toEqual([]); + }); +}); + +test.describe("what's new", () => { + test("lists the releases newest first, with the latest open", async ({ page }) => { + await open(page); + const releases = page.locator(".release"); + await expect(releases).toHaveCount(3); + await expect(releases.nth(0).getByRole("heading", { level: 3 })).toHaveText("1.3.0-beta.1"); + await expect(releases.nth(0)).toContainText("Pre-release"); + await expect(releases.nth(0)).toHaveAttribute("open", ""); + await expect(releases.nth(1)).toContainText("Latest"); + await releases.nth(1).locator("summary").click(); + const latest = releases.nth(1); + await expect(latest.getByRole("heading", { level: 4 })).toHaveText(["New features", "Bug fixes"]); + await expect(latest.getByRole("listitem").first()).toHaveText("Lyrics that follow the song word by word #21"); + await expect(latest.getByRole("link", { name: "Pull request 21" })).toHaveAttribute( + "href", + "https://github.com/Kkkermit/Statsify/pull/21", + ); + await expect(latest.locator("code")).toHaveText("All time"); + await expect(latest.getByRole("link", { name: "Every commit" })).toHaveAttribute( + "href", + /compare\/v1\.1\.0\.\.\.v1\.2\.0$/, + ); + await expect(releases.nth(2)).toContainText("No notes for this release"); + }); + + test("shows release notes as text, never as markup", async ({ page }) => { + const hostile = JSON.parse(RELEASES) as { body: string }[]; + hostile[0].body = + '* [link](javascript:alert(1)) by @x in https://evil.example/pull/1'; + await open(page, JSON.stringify(hostile)); + const first = page.locator(".release").first(); + await expect(first.getByRole("listitem")).toContainText(''); + await expect(first.locator("img")).toHaveCount(0); + await expect(first.locator('a[href^="javascript:"]')).toHaveCount(0); + expect(await page.evaluate(() => "pwned" in window)).toBe(false); + }); +}); + +test.describe("getting started", () => { + test("tabs follow the arrow keys, Home and End", async ({ page }) => { + await open(page); + const windows = page.getByRole("tab", { name: "Windows" }); + await expect(windows).toHaveAttribute("aria-selected", "true"); + await expect(page.getByRole("tabpanel")).toContainText("Windows protected your PC"); + await windows.focus(); + await page.keyboard.press("ArrowRight"); + await expect(page.getByRole("tab", { name: "macOS" })).toBeFocused(); + await expect(page.getByRole("tabpanel")).toContainText("Privacy & Security"); + await page.keyboard.press("End"); + await expect(page.getByRole("tab", { name: "Linux" })).toHaveAttribute("aria-selected", "true"); + await page.keyboard.press("ArrowRight"); + await expect(windows).toBeFocused(); + await page.keyboard.press("ArrowLeft"); + await expect(page.getByRole("tabpanel")).toContainText("sudo apt install"); + }); + + test("copies the redirect URI", async ({ page, context }) => { + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await open(page); + const step = page.locator("#connect-spotify"); + await step.getByRole("button", { name: "Copy address" }).click(); + await expect(step.getByRole("button", { name: "Copied" })).toHaveText("Copied"); + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe("http://127.0.0.1:43821/callback"); + await expect(page.locator("[data-announcer]")).toHaveText("Copied"); + }); +}); + +test.describe("help", () => { + test("search finds answers in help and the FAQ, and says when nothing matches", async ({ page }) => { + await open(page); + const search = page.getByRole("searchbox", { name: "Search troubleshooting and the FAQ" }); + await search.fill("redirect uri"); + await expect(page.locator("[data-search-status]")).toHaveText(/^\d+ answers?$/); + const visible = page.locator(".qa:visible"); + await expect(visible.first()).toContainText(/redirect/i); + await expect(page.locator("#t-playing")).toBeHidden(); + await search.fill("premium"); + await expect(page.locator("#faq .qa:visible").first()).toContainText("Premium"); + await search.fill("zzzz nothing"); + await expect(page.getByText("Nothing matches that.")).toBeVisible(); + await search.fill(""); + await expect(page.locator("#t-playing")).toBeVisible(); + await expect(page.getByText("Nothing matches that.")).toBeHidden(); + }); + + test("opens a handful of matches by itself, and closes them again", async ({ page }) => { + await open(page); + const search = page.getByRole("searchbox", { name: "Search troubleshooting and the FAQ" }); + await search.fill("damaged"); + const answer = page.locator(".qa", { hasText: "is damaged and can't be opened" }); + await expect(answer).toHaveAttribute("open", ""); + await search.fill(""); + await expect(answer).not.toHaveAttribute("open", ""); + }); +}); + +test.describe("navigation", () => { + test("the menu opens on a phone, closes on a link, and Esc gives focus back [all sizes]", async ({ + page, + isMobile, + }) => { + test.skip(!isMobile, "The menu button is for narrow screens."); + await open(page); + const button = page.getByRole("button", { name: "Menu" }); + const nav = page.getByRole("navigation", { name: "Sections" }); + await expect(nav.getByRole("link", { name: "FAQ" })).toBeHidden(); + await button.click(); + await expect(button).toHaveAttribute("aria-expanded", "true"); + await nav.getByRole("link", { name: "Set up" }).click(); + await expect(button).toHaveAttribute("aria-expanded", "false"); + await expect(page).toHaveURL(/#set-up$/); + await button.click(); + await page.keyboard.press("Escape"); + await expect(button).toHaveAttribute("aria-expanded", "false"); + await expect(button).toBeFocused(); + }); + + test("marks the section you're reading", async ({ page }) => { + await open(page); + const nav = page.getByRole("navigation", { name: "Sections" }); + await nav.getByRole("link", { name: "Troubleshooting" }).click(); + await expect(nav.getByRole("link", { name: "Troubleshooting" })).toHaveAttribute("aria-current", "location"); + }); + + test("skip link moves to the content", async ({ page }) => { + await open(page); + await page.keyboard.press("Tab"); + const skip = page.getByRole("link", { name: "Skip to content" }); + await expect(skip).toBeFocused(); + await page.keyboard.press("Enter"); + await expect(page.locator("main")).toBeFocused(); + }); +}); diff --git a/site/index.html b/site/index.html new file mode 100644 index 0000000..d7a69fc --- /dev/null +++ b/site/index.html @@ -0,0 +1,1020 @@ + + + + + + Statsify: your Spotify stats, on your computer + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+

Your Spotify, by the numbers.

+

+ Statsify shows your Spotify stats, keeps a record of every song you play and works as a remote for the + Spotify app. There's no Statsify server, so your listening history stays on your computer. +

+ +

+ Free and open source, for Windows, macOS and Linux + All downloads +

+
+
+ Statsify's Overview page: the song that's playing, listening time, plays, top artist and streak for the last 30 days, top tracks and recent plays +
+
+
+ +
+
+
+

Features

+

+ Statsify reads your stats from Spotify's Web API, and your full history from the data export Spotify sends + you when you ask for it. +

+
+ +
+
+

Your stats

+
+
Top charts
+
+ Top songs, artists, albums and genres for the last 4 weeks, 6 months and year, with rank changes. +
+
All time
+
Streams, minutes, songs and artists since your first listen, and your longest streak.
+
Streams
+
+ Any period, from the last 24 hours to dates you pick. Every play is listed, and you can export them as + CSV. +
+
Insights
+
+ When in the week you listen, a calendar of every day, records, skips, devices and songs you've stopped + playing. +
+
+
+
+

Listening

+
+
Player
+
+ Play, skip, shuffle, volume, the queue and your Spotify devices. In the desktop app, Play starts + Spotify hidden in the tray. +
+
Lyrics
+
Synced lyrics that follow the song word by word. Click a line to jump to it.
+
Full screen
+
The cover, the lyrics or both, on a background in the colours of the song.
+
Instant playlists
+
+ Your top songs of a month, forgotten favourites or most skipped, played straight away or saved as a + private playlist. +
+
+
+
+

Everything else

+
+
Library
+
+ Playlists, liked songs, albums and artists, with search and sorting, your own folders and up to four + pins. +
+
Appearance
+
+ Five themes, nine accent colours or your own, interface size from 75 to 150 %, and a see-through + window. +
+
History file
+
The desktop app keeps every play in a SQLite file that you can query and back up.
+
Demo
+
A made-up library with three years of history, to try Statsify without a Spotify account.
+
+
+
+ +
+
+
+ Insights page: lifetime listening time, plays, streaks, skip rate and a chart of listening over time +
+
+ Insights from your whole history. Spotify's API only shares your last 50 plays, so + Statsify builds lifetime stats from your Spotify data export, then adds new plays itself while it runs. + How to import it +
+
+
+
+ A playlist page with its cover, search, sorting and the list of songs +
+
+ Playlists of any size. Search, sort and play from any playlist and see its stats. A + 10,000-song playlist scrolls like a short one. +
+
+
+
+
+ +
+
+
+

Download

+

+ Every version is on GitHub Releases. +

+
+ + + +
+
+
+

Windows

+

Windows 10 and 11, 64-bit

+ +
+ +
+
+
+

macOS

+

Apple silicon and Intel

+ +
+ +
+
+
+

Linux

+

64-bit x86

+ +
+ +
+
+
+

Web

+

+ For your own server, over HTTPS at the root of a domain. + How to host it +

+
+ +
+
+ +
+

+ The installers aren't signed yet, so Windows and macOS warn you the first time you open Statsify. + Set up shows what to click. +

+
+ + Check a download against its checksum + + +
+

+ Every release lists each file's SHA-256 checksum in + SHA256SUMS.txt. Work + out your file's checksum and compare the two. +

+
+
Windows, in PowerShell
+
+
Get-FileHash .\Statsify_*.exe
+
+
macOS
+
+
shasum -a 256 Statsify_*.dmg
+
+
Linux, with SHA256SUMS.txt in the same folder
+
+
sha256sum -c --ignore-missing SHA256SUMS.txt
+
+
+
+
+
+
+
+ +
+
+
+

Set up

+

+ Install the app, connect it to Spotify, and if you want lifetime stats, import your history. The Spotify + step is copy and paste, and the app walks you through it too. +

+
+ +
    +
  1. +
    + +

    Install Statsify

    + About 1 minute +
    +
    +
    +
    + + + +
    + +
    +

    Windows

    +
      +
    1. + Download the installer (Statsify_…_x64-setup.exe) and open it. It installs for you + only, so it doesn't need an administrator. +
    2. +
    3. + If Windows says "Windows protected your PC", choose More info, then + Run anyway. It says this because the installer isn't signed yet. +
    4. +
    5. Open Statsify from the Start menu.
    6. +
    +

    + To run Statsify without installing it, use the portable .exe. It needs Microsoft Edge + WebView2, which Windows 11 already has. +

    +
    + +
    +

    macOS

    +
      +
    1. Download the disk image (.dmg), open it and drag Statsify to Applications.
    2. +
    3. + Open Statsify. macOS says it can't check the app, because it isn't signed yet. Choose + Done. +
    4. +
    5. + Open System Settings, then Privacy & Security, scroll down + and choose Open Anyway. On macOS 14 and earlier you can instead Control-click + the app and choose Open. +
    6. +
    +
    +

    + If macOS says Statsify "is damaged and can't be opened", the app is fine but unsigned. Run this + in Terminal, then open it again. +

    +
    xattr -dr com.apple.quarantine /Applications/Statsify.app
    +
    +
    + +
    +

    Linux

    +
      +
    1. + On Debian, Ubuntu, Mint and similar, download the Debian package and install it from the folder + you saved it in. +
      sudo apt install ./Statsify_*_amd64.deb
      +
    2. +
    3. + On any other distribution, download the AppImage, make it executable and run it. +
      + chmod +x Statsify_*.AppImage && ./Statsify_*.AppImage +
      +
    4. +
    +

    + The tray icon needs AppIndicator support. On GNOME, install the AppIndicator and + KStatusNotifierItem Support extension. +

    +
    +
    +
    +
  2. + +
  3. +
    + +

    Connect to Spotify

    + About 2 minutes +
    +
    +

    + Statsify signs in with a Client ID that you create, for free, in Spotify's developer dashboard. + There's no Statsify server to share one, so each person or household makes their own. +

    +
      +
    1. + Open the Spotify Developer Dashboard, sign in + and choose Create app. Any name and description will do. +
    2. +
    3. + Under Redirect URIs, add this address exactly. +
      http://127.0.0.1:43821/callback
      + + Spotify won't accept localhost here. If you host the web version yourself, use + https://your-domain/callback instead. + +
    4. +
    5. Tick Web API and Web Playback SDK, and save.
    6. +
    7. + Under User Management, add the Spotify account of each person who'll use Statsify, + up to five. +
    8. +
    9. + Copy the Client ID from Basic Information, paste it into Statsify + and choose Save and sign in. Approve access in your browser, then go back to + Statsify. +
    10. +
    +

    + The Client ID isn't a secret and there's no password to keep. Spotify asks for Premium on the account + that creates it, and for playback control. Stats work on any account. +

    +
    +
  4. + +
  5. +
    + +

    Import your history Optional

    + Up to 30 days +
    +
    +

    + Spotify's API only shares your last 50 plays. For lifetime stats, ask Spotify for a copy of your data. +

    +
      +
    1. + On Spotify's privacy page, request + Extended streaming history. It covers every play since you joined and can take up + to 30 days. Account data covers the last year and usually arrives within 5 days. + You can import both. +
    2. +
    3. When Spotify emails you, download the .zip.
    4. +
    5. + Drop it on Statsify's Import history page. It's read on your computer and isn't + uploaded anywhere. +
    6. +
    +

    After that, Statsify saves new plays itself while it's open or in the tray.

    +
    +
  6. +
+
+
+ +
+
+
+

Changelog

+

Recent releases, newest first. Each change links to its pull request on GitHub.

+

Every release on GitHub

+
+
+
+

+ The release notes are on GitHub Releases. +

+
+
+
+
+ +
+
+
+
+

Troubleshooting

+

Find the message you saw, or search for it.

+
+ + +
+ +
+
+

Installing

+
+ Windows says "Windows protected your PC" +
+

+ That's SmartScreen, which warns about apps that aren't signed yet. Choose + More info, then Run anyway. +

+
+
+
+ macOS says Statsify "is damaged and can't be opened" +
+

The app is fine but unsigned. Run this in Terminal, then open Statsify again.

+
xattr -dr com.apple.quarantine /Applications/Statsify.app
+
+
+
+ macOS won't open Statsify at all +
+

+ Try to open it once, then go to System Settings, then + Privacy & Security, scroll down and choose Open Anyway. On + macOS 14 and earlier, Control-click the app and choose Open. +

+
+
+
+ There's no tray icon on Linux +
+

+ The tray needs AppIndicator support. On GNOME, install the AppIndicator and KStatusNotifierItem + Support extension and restart Statsify. +

+
+
+
+ The portable Windows app doesn't start +
+

+ It needs Microsoft Edge WebView2. Windows 11 has it. On Windows 10, use the installer, which adds + WebView2 when it's missing. +

+
+
+
+ +
+

Signing in

+
+ Spotify says "INVALID_CLIENT: Invalid client" +
+

+ Spotify doesn't know the Client ID you entered. On Statsify's welcome page, choose + Change next to the Client ID, paste the one from your Spotify app's + Basic Information page and sign in again. +

+
+
+
+ Spotify says "INVALID_CLIENT: Invalid redirect URI" +
+

+ For the desktop app, your Spotify app's Redirect URIs must include this address + exactly. +

+
http://127.0.0.1:43821/callback
+

+ Common slips are a missing /callback, https instead of http, + and localhost instead of 127.0.0.1. +

+
+
+
+ "Spotify didn't allow this" +
+

+ Your Spotify account probably isn't listed under User Management in your Spotify + app. Add it in the + Spotify Developer Dashboard. The same message + shows for other people's playlists, which Spotify doesn't share with apps like Statsify. +

+
+
+
+ "Session expired" or "This sign-in link is invalid or has expired" +
+

+ Spotify ended the sign-in, for example because Statsify's access was removed on Spotify's + Manage apps page, or the sign-in took too long. + Sign in again. +

+
+
+
+ The browser never goes back to Statsify after signing in +
+

+ When Spotify's page shows an error, it can't send you back to the app. In Statsify, choose + Wrong Client ID? to stop waiting, then fix the Client ID or the redirect URI as + above. +

+
+
+
+ +
+

Playing music

+
+ "No active Spotify device", or Play does nothing +
+

+ Statsify is a remote, and the music plays in a Spotify app. Install the Spotify desktop app and sign + in to it once. After that, Statsify starts it hidden in the tray when you press Play. You can also + pick a phone or speaker with the devices button in the player bar. +

+
+
+
+ "Spotify isn't installed on this PC" +
+

+ Install Spotify from spotify.com or the Microsoft + Store, sign in once, then press Play again. For the Microsoft Store version, check that Spotify is + turned on under Settings, Apps, + Advanced app settings, App execution aliases. +

+
+
+
+ "Spotify started but hasn't come online" +
+

+ Spotify is probably waiting for you to sign in or install an update. Choose + Open Spotify, sign in, then close its window. Next time it starts hidden. +

+
+
+
+ "Playback control needs Spotify Premium" +
+

+ Spotify only lets other apps control Premium accounts. Without Premium you still get every stat, + 30-second previews and Open in Spotify. +

+
+
+
+ A device is greyed out +
+

+ Some TVs, cars and speakers don't let other apps control them. Start the music on it from Spotify + itself, or pick another device. +

+
+
+
+ +
+

Your history

+
+ "No streaming history files found" when importing +
+

+ Choose the .zip from Spotify's email, or the StreamingHistory or + Streaming_History_Audio .json files inside it. +

+
+
+
+ "Damaged or incomplete zip" +
+

The download didn't finish. Download the file from Spotify's email again and import that.

+
+
+
+ Some plays are missing from Streams or All time +
+

+ Spotify only shares your last 50 plays, and not how long you listened to each. Statsify saves them + while it's open or in the tray, so if it's closed while you play more than 50 songs, the oldest are + missed. Your next data export fills the gaps with the exact plays. +

+
+
+
+ "Your listening history couldn't be opened" +
+

+ Statsify stops saving rather than risk overwriting your history. Choose + Try again. If the message says the file is from a newer version of Statsify, + install the newest version. +

+
+
+
+ +
+

Lyrics and other messages

+
+ There are no lyrics for a song +
+

+ Spotify doesn't share lyrics with apps, so Statsify gets them from + LRCLIB, a free database that people add lyrics to. Popular songs + are well covered and less-known ones can be missing. You can add them on LRCLIB, and Statsify looks + again after three days. +

+
+
+
+ Lyrics run early or late +
+

+ Nudge them with − and + next to the lyrics, a tenth of a second at + a time. Statsify remembers the change for that song. +

+
+
+
+ Stats or playlists look out of date +
+

+ Statsify keeps Spotify's answers for a few minutes. Clear cache in + Settings, under Data & about, fetches everything again and + keeps your history. +

+
+
+
+ "Spotify asked us to slow down" or "You're offline" +
+

+ Spotify limits how many requests an app can make in a short time. Wait a moment and choose + Try again. When you're offline, pages load again once you're back. +

+
+
+
+ + + + +
+
+
+ +
+
+
+

FAQ

+

+ Error messages are under Troubleshooting. The + user guide covers the rest of + the app. +

+
+
+
+ Is Statsify free? +
+

+ Yes. It's open source under the Apache-2.0 licence, with no ads and no subscription. If you'd like to + support it, you can buy me a coffee. +

+
+
+
+ Is it made by Spotify? +
+

+ No. Statsify is an independent project. It uses Spotify's official Web API, but isn't affiliated with, + endorsed or sponsored by Spotify. +

+
+
+
+ Do I need Spotify Premium? +
+

+ Stats, your library, lyrics and 30-second previews work with any account. Controlling playback needs + Premium. Spotify also asks for Premium on the account that creates the Client ID. If yours doesn't + have it, someone with Premium can create one and add you under + User Management. +

+
+
+
+ Why do I need my own Client ID? +
+

+ Statsify has no server, so there's no shared Statsify account at Spotify. Spotify also lets each + Client ID be used by at most five people, so one shared ID couldn't work for everyone. It's free and + takes about two minutes. +

+
+
+
+ Can friends or family use it? +
+

+ Yes, up to five Spotify accounts per Client ID. Add each one under User Management + in your Spotify app and give them the Client ID. Everyone signs in with their own Spotify account on + their own device. +

+
+
+
+ Where is my data kept? +
+

+ On your computer. The desktop app keeps your history in one SQLite file in its data folder, and the + web version keeps it in your browser. Statsify only talks to Spotify, and to LRCLIB for lyrics, which + gets the song's title, artist, album and length and nothing about you. +

+
+
+
+ Why are some numbers or features missing? +
+

+ Since February 2026, Spotify leaves popularity scores, follower counts, artists' top tracks and other + people's playlists out of what it shares with apps like Statsify. Statsify says where something isn't + available instead of showing zeros. +

+
+
+
+ Can Statsify play music by itself? +
+

+ No, it's a remote. Spotify's music is protected, and on a computer only Spotify's own apps can play + it. Statsify tells the Spotify app what to play, and the desktop app starts Spotify hidden when it + needs to. With Premium, the web version can also play in the browser tab. +

+
+
+
+ Is there a phone app? +
+

+ No. Statsify runs on Windows, macOS and Linux. The web version works in a phone's browser too, if you + host it yourself. +

+
+
+
+ How do I update Statsify? +
+

+ Download the new version and install it over the old one. Your history, settings and sign-in are kept. + Statsify doesn't update itself yet. +

+
+
+
+ How do I uninstall it and delete my data? +
+

+ In Statsify, Sign out and erase data under Settings, + Account deletes your history from this computer. Then remove the app like any other. + The Windows installer's uninstaller can also delete the app's data. Neither touches your Spotify + account. To take away Statsify's access, remove it on Spotify's + Manage apps page. +

+
+
+
+
+
+
+ + + +

+ + diff --git a/site/main.ts b/site/main.ts new file mode 100644 index 0000000..a21b407 --- /dev/null +++ b/site/main.ts @@ -0,0 +1,454 @@ +import "./styles.css"; +import { + checksumsOf, + detectSystem, + downloadsFor, + formatDate, + formatSize, + inline, + latestRelease, + parseNotes, + readReleases, + versionOf, + type Download, + type Platform, + type Release, + type System, +} from "./releases"; + +const SVG = "http://www.w3.org/2000/svg"; +const RELEASES_PAGE = "https://github.com/Kkkermit/Statsify/releases"; + +function icon(name: string, extra = ""): SVGSVGElement { + const svg = document.createElementNS(SVG, "svg"); + svg.setAttribute("class", `icon ${extra}`.trim()); + svg.setAttribute("aria-hidden", "true"); + const use = document.createElementNS(SVG, "use"); + use.setAttribute("href", `#i-${name}`); + svg.append(use); + return svg; +} + +function el( + tag: K, + className?: string, + ...children: (Node | string)[] +): HTMLElementTagNameMap[K] { + const node = document.createElement(tag); + if (className) node.className = className; + node.append(...children); + return node; +} + +function link(text: string, href: string, className?: string): HTMLAnchorElement { + const a = el("a", className, text); + a.href = href; + return a; +} + +const announcer = document.querySelector("[data-announcer]"); +function announce(message: string): void { + if (!announcer) return; + announcer.textContent = ""; + // Set after a tick, so the same message twice is read twice. + setTimeout(() => (announcer.textContent = message), 50); +} + +function currentSystem(): System { + const nav = navigator as Navigator & { userAgentData?: { platform?: string } }; + return detectSystem( + navigator.userAgent, + nav.userAgentData?.platform ?? navigator.platform ?? "", + navigator.maxTouchPoints, + ); +} + +/* Downloads ------------------------------------------------------------------------------- */ + +const SYSTEM_NAMES: Record = { windows: "Windows", macos: "macOS", linux: "Linux", web: "the web" }; + +function extension(name: string): string { + const match = /\.([A-Za-z]+)$/.exec(name); + return match ? `.${match[1]}` : ""; +} + +/** The file's type after its name, unless the name already says it ("AppImage"). */ +function fileType(download: Download): HTMLSpanElement[] { + const ext = extension(download.asset.name); + return download.label.toLowerCase().includes(ext.slice(1).toLowerCase()) ? [] : [el("span", "file-ext", ext)]; +} + +function fileRow(download: Download, platform: Platform, primary: boolean): HTMLLIElement { + const size = formatSize(download.asset.size); + const button = link( + "Download", + download.asset.url, + `button button-small ${primary ? "button-primary" : "button-secondary"}`, + ); + button.setAttribute( + "aria-label", + `Download ${download.label} for ${SYSTEM_NAMES[platform]} (${extension(download.asset.name)}, ${size})`, + ); + return el( + "li", + "file", + el( + "span", + "file-name", + el("span", "", el("strong", "", download.label), ...fileType(download)), + el("span", "file-detail", download.detail), + ), + el("span", "file-size", size), + button, + ); +} + +function showDownloads(release: Release | undefined, system: System): void { + for (const group of document.querySelectorAll("[data-platform]")) { + if (group.dataset.platform === system) group.querySelector(".your-system")?.removeAttribute("hidden"); + } + if (system === "mobile") document.querySelector("[data-mobile-note]")?.removeAttribute("hidden"); + if (!release) return; + + const version = versionOf(release); + const files = downloadsFor(release); + for (const box of document.querySelectorAll("[data-files]")) { + const platform = box.dataset.files as Platform; + const list = files[platform]; + // The button for the file most people on this computer want is the filled one. + if (list?.length) box.replaceChildren(...list.map((d, i) => fileRow(d, platform, i === 0 && platform === system))); + } + + document + .querySelector("[data-release-summary]") + ?.replaceChildren( + `Version ${version}, released ${formatDate(release.date)}. Older versions are on `, + link("GitHub Releases", RELEASES_PAGE), + ".", + ); + const checksums = checksumsOf(release); + const checksumLink = document.querySelector("[data-checksums]"); + if (checksums && checksumLink) checksumLink.href = checksums.url; + + const hero = document.querySelector("[data-hero-download]"); + const meta = document.querySelector("[data-hero-meta]"); + if (!hero || !meta) return; + const first = system === "windows" || system === "macos" ? files[system][0] : undefined; + if (first) { + hero.href = first.asset.url; + hero.textContent = `Download for ${SYSTEM_NAMES[system as Platform]}`; + const size = formatSize(first.asset.size); + meta.textContent = + system === "windows" + ? `Version ${version} for Windows 10 and 11, ${size}` + : `Version ${version} for Apple silicon and Intel Macs, ${size}`; + } else if (system === "linux") { + // Linux has two formats to choose from, so the button goes to the choice. + hero.textContent = "Download for Linux"; + meta.textContent = `Version ${version}, as a Debian package or an AppImage`; + } else { + meta.textContent = `Version ${version}, free for Windows, macOS and Linux`; + } +} + +/* Changelog ------------------------------------------------------------------------------- */ + +function changeText(text: string): (Node | string)[] { + return inline(text).map((part) => { + if (part.kind === "code") return el("code", "", part.text); + if (part.kind === "strong") return el("strong", "", part.text); + if (part.kind === "link") return link(part.text, part.url); + return part.text; + }); +} + +function releaseCard(release: Release, open: boolean, latest: boolean): HTMLDetailsElement { + const notes = parseNotes(release.body); + const count = notes.groups.reduce((sum, g) => sum + g.changes.length, 0); + + const title = el("span", "release-title", el("h3", "", versionOf(release))); + if (latest) title.append(el("span", "tag", "Latest")); + if (release.prerelease) title.append(el("span", "tag", "Pre-release")); + const date = el("time", "release-date", formatDate(release.date)); + date.dateTime = release.date; + const summary = el( + "summary", + "", + title, + date, + el("span", "release-count", count ? `${count} ${count === 1 ? "change" : "changes"}` : ""), + icon("chevron", "chevron"), + ); + + const body = el("div", "release-body"); + for (const group of notes.groups) { + const list = el("ul", "changes"); + for (const change of group.changes) { + const item = el("li", "", ...changeText(change.text)); + if (change.pr) { + const pr = link(`#${change.pr.number}`, change.pr.url, "pr"); + pr.setAttribute("aria-label", `Pull request ${change.pr.number}`); + item.append(" ", pr); + } + list.append(item); + } + body.append(el("h4", "change-group", group.title), list); + } + if (!notes.groups.length) body.append(el("p", "placeholder", "No notes for this release")); + + const links = el("p", "release-links", link("Downloads and full notes", release.url)); + if (notes.compareUrl) links.append(link("Every commit", notes.compareUrl)); + body.append(links); + + const card = el("details", "release", summary, body); + card.open = open; + return card; +} + +function showChangelog(releases: Release[] | undefined): void { + const box = document.querySelector("[data-changelog]"); + if (!box) return; + box.removeAttribute("aria-busy"); + if (!releases?.length) { + box.replaceChildren( + el( + "p", + "placeholder", + "The release notes couldn't be loaded here. They're all on ", + link("GitHub Releases", RELEASES_PAGE), + ".", + ), + ); + return; + } + const latest = latestRelease(releases); + box.replaceChildren(...releases.slice(0, 6).map((r, i) => releaseCard(r, i === 0, r === latest))); +} + +function showChangelogLoading(): void { + const box = document.querySelector("[data-changelog]"); + if (!box) return; + box.setAttribute("aria-busy", "true"); + box.replaceChildren( + ...[0, 1, 2].map(() => { + const row = el("div", "release-loading", el("span"), el("span")); + row.setAttribute("aria-hidden", "true"); + return row; + }), + el("p", "visually-hidden", "Loading the release notes"), + ); +} + +async function loadReleases(): Promise { + try { + const response = await fetch(new URL("releases.json", document.baseURI), { + cache: "no-cache", + signal: AbortSignal.timeout(10_000), + }); + if (!response.ok) return undefined; + return readReleases(await response.json()); + } catch { + return undefined; + } +} + +/* Header, menu and the section you're in ------------------------------------------------- */ + +function setupHeader(): void { + const header = document.querySelector("[data-header]"); + const button = document.querySelector("[data-menu-button]"); + const nav = document.querySelector("[data-nav]"); + if (!header || !button || !nav) return; + + const onScroll = () => header.classList.toggle("is-scrolled", window.scrollY > 8); + onScroll(); + window.addEventListener("scroll", onScroll, { passive: true }); + + const setOpen = (open: boolean, returnFocus = false) => { + header.classList.toggle("is-open", open); + button.setAttribute("aria-expanded", String(open)); + if (!open && returnFocus) button.focus(); + }; + button.addEventListener("click", () => setOpen(button.getAttribute("aria-expanded") !== "true")); + nav.addEventListener("click", (event) => { + if ((event.target as Element).closest("a")) setOpen(false); + }); + document.addEventListener("keydown", (event) => { + if (event.key === "Escape" && header.classList.contains("is-open")) setOpen(false, true); + }); + document.addEventListener("click", (event) => { + if (header.classList.contains("is-open") && !header.contains(event.target as Node)) setOpen(false); + }); + matchMedia("(min-width: 64rem)").addEventListener("change", () => setOpen(false)); + // Tabbing past the last link closes the menu, so it never covers the page you move into. + header.addEventListener("focusout", (event) => { + if (header.classList.contains("is-open") && !header.contains(event.relatedTarget as Node | null)) setOpen(false); + }); + + const links = new Map(); + for (const a of nav.querySelectorAll('a[href^="#"]')) links.set(a.hash.slice(1), a); + const visible = new Set(); + const spy = new IntersectionObserver( + (entries) => { + for (const entry of entries) { + if (entry.isIntersecting) visible.add(entry.target.id); + else visible.delete(entry.target.id); + } + // The first section, in page order, that crosses the reading line. + const current = [...links.keys()].find((id) => visible.has(id)); + for (const [id, a] of links) { + if (id === current) a.setAttribute("aria-current", "location"); + else a.removeAttribute("aria-current"); + } + }, + { rootMargin: "-35% 0px -60% 0px" }, + ); + for (const id of links.keys()) { + const section = document.getElementById(id); + if (section) spy.observe(section); + } +} + +/* Install tabs ---------------------------------------------------------------------------- */ + +function setupTabs(system: System): void { + for (const root of document.querySelectorAll("[data-tabs]")) { + const tabs = [...root.querySelectorAll('[role="tab"]')]; + const select = (tab: HTMLButtonElement, focus: boolean) => { + for (const other of tabs) { + const selected = other === tab; + other.setAttribute("aria-selected", String(selected)); + other.tabIndex = selected ? 0 : -1; + const panel = document.getElementById(other.getAttribute("aria-controls") ?? ""); + if (panel) panel.hidden = !selected; + } + if (focus) tab.focus(); + }; + root.addEventListener("click", (event) => { + const tab = (event.target as Element).closest('[role="tab"]'); + if (tab) select(tab, false); + }); + root.addEventListener("keydown", (event) => { + const index = tabs.indexOf(event.target as HTMLButtonElement); + if (index < 0) return; + const next = + event.key === "ArrowRight" + ? tabs[(index + 1) % tabs.length] + : event.key === "ArrowLeft" + ? tabs[(index - 1 + tabs.length) % tabs.length] + : event.key === "Home" + ? tabs[0] + : event.key === "End" + ? tabs[tabs.length - 1] + : undefined; + if (!next) return; + event.preventDefault(); + select(next, true); + }); + select(tabs.find((t) => t.dataset.system === system) ?? tabs[0], false); + } +} + +/* Copy buttons ---------------------------------------------------------------------------- */ + +function setupCopy(): void { + if (!navigator.clipboard) return; + for (const block of document.querySelectorAll(".code")) { + const code = block.querySelector("code"); + if (!code) continue; + const text = code.textContent ?? ""; + const label = el("span", "", "Copy"); + const button = el("button", "copy", icon("copy"), label); + button.type = "button"; + const name = /^https?:/.test(text) ? "Copy address" : "Copy command"; + button.setAttribute("aria-label", name); + let timer = 0; + button.addEventListener("click", async () => { + try { + await navigator.clipboard.writeText(text); + } catch { + announce("Couldn't copy. Select the text and copy it yourself."); + return; + } + button.classList.add("is-done"); + button.replaceChildren(icon("check"), label); + label.textContent = "Copied"; + button.setAttribute("aria-label", "Copied"); + announce("Copied"); + clearTimeout(timer); + timer = window.setTimeout(() => { + button.classList.remove("is-done"); + button.replaceChildren(icon("copy"), label); + label.textContent = "Copy"; + button.setAttribute("aria-label", name); + }, 2000); + }); + block.append(button); + } +} + +/* Search through troubleshooting and the FAQ ---------------------------------------------- */ + +function setupSearch(): void { + const box = document.querySelector("[data-search]"); + const input = document.querySelector("[data-search-input]"); + const status = document.querySelector("[data-search-status]"); + const empty = document.querySelector("[data-search-empty]"); + if (!box || !input || !status || !empty) return; + box.hidden = false; + + const items = [...document.querySelectorAll("#troubleshooting .qa, #faq .qa")].map((item) => ({ + item, + text: (item.textContent ?? "").toLowerCase().replace(/\s+/g, " "), + })); + const groups = [...document.querySelectorAll("[data-qa-group]")]; + const opened = new Set(); + let timer = 0; + + const run = () => { + const words = input.value.toLowerCase().trim().split(/\s+/).filter(Boolean); + let matches = 0; + for (const { item, text } of items) { + const match = words.every((w) => text.includes(w)); + item.hidden = !match; + if (match) matches++; + } + for (const group of groups) group.hidden = !group.querySelector(".qa:not([hidden])"); + for (const item of opened) item.open = false; + opened.clear(); + if (!words.length) { + status.textContent = ""; + empty.hidden = true; + return; + } + // When only a few answers match, they open, so the answer is right there. + if (matches <= 3) { + for (const { item } of items) { + if (!item.hidden && !item.open) { + item.open = true; + opened.add(item); + } + } + } + status.textContent = matches === 1 ? "1 answer" : `${matches} answers`; + empty.hidden = matches > 0; + }; + input.addEventListener("input", () => { + clearTimeout(timer); + timer = window.setTimeout(run, 120); + }); +} + +/* Start ----------------------------------------------------------------------------------- */ + +const system = currentSystem(); +setupHeader(); +setupTabs(system); +setupCopy(); +setupSearch(); +showDownloads(undefined, system); +showChangelogLoading(); +void loadReleases().then((releases) => { + showDownloads(releases ? latestRelease(releases) : undefined, system); + showChangelog(releases); +}); diff --git a/site/playwright.config.ts b/site/playwright.config.ts new file mode 100644 index 0000000..e650dfa --- /dev/null +++ b/site/playwright.config.ts @@ -0,0 +1,32 @@ +import { defineConfig, devices } from "@playwright/test"; + +const port = Number(process.env.SITE_PORT) || 4174; +const origin = `http://127.0.0.1:${port}`; +const ci = Boolean(process.env.CI); + +/** + * The website's tests (`npm run site:test`), against its production build. Separate from the + * app's end-to-end tests: the Pages workflow runs these when the site changes. Every test answers + * releases.json from a fixture, so nothing depends on the real releases. + */ +export default defineConfig({ + testDir: "./e2e", + timeout: 30_000, + expect: { timeout: 10_000 }, + fullyParallel: true, + forbidOnly: ci, + retries: ci ? 1 : 0, + reporter: ci ? [["github"], ["list"]] : "list", + use: { baseURL: origin, screenshot: "only-on-failure" }, + projects: [ + { name: "desktop", use: { ...devices["Desktop Chrome"], viewport: { width: 1366, height: 768 } } }, + { name: "phone", grep: /\[all sizes\]/, use: { ...devices["Pixel 7"] } }, + ], + webServer: { + command: `${process.env.SITE_PREBUILT ? "" : "npm run site:build && "}npx vite preview --config site/vite.config.ts --port ${port}`, + cwd: "..", + url: origin, + reuseExistingServer: !ci, + timeout: 120_000, + }, +}); diff --git a/site/releases.test.ts b/site/releases.test.ts new file mode 100644 index 0000000..90df02e --- /dev/null +++ b/site/releases.test.ts @@ -0,0 +1,242 @@ +import { describe, expect, it } from "vitest"; +import { + checksumsOf, + detectSystem, + downloadsFor, + formatDate, + formatSize, + inline, + latestRelease, + parseNotes, + readReleases, + tidyTitle, + type Release, +} from "./releases"; + +const asset = (name: string, size = 1000) => ({ + name, + size, + url: `https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/${name}`, +}); + +const release = (tag: string, date: string, extra: Partial = {}): Release => ({ + tag, + name: `Statsify ${tag.slice(1)}`, + date, + url: `https://github.com/Kkkermit/Statsify/releases/tag/${tag}`, + prerelease: false, + body: "", + assets: [], + ...extra, +}); + +// The shape GitHub generates, with the download table release.yml puts first. +const BODY = `## Download + +| System | File | +| --- | --- | +| Windows | \`Statsify_1.2.0_x64-setup.exe\` | + +The installers aren't code-signed yet. + + + +## What's Changed +### New features +* feat: Statsify 1.2.0: faster CI, open-source docs and a hardened Rust shell by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/21 +* feat(lyrics): word-by-word \`LRC\` timing by @someone in https://github.com/Kkkermit/Statsify/pull/30 +### Dependencies +* chore(deps-dev): Bump cross-spawn from 7.0.6 to 7.1.2 by @dependabot[bot] in https://github.com/Kkkermit/Spotify-Stats/pull/18 + +## New Contributors +* @dependabot[bot] made their first contribution in https://github.com/Kkkermit/Spotify-Stats/pull/10 + +**Full Changelog**: https://github.com/Kkkermit/Statsify/compare/v1.1.1...v1.2.0`; + +describe("readReleases", () => { + it("keeps well-formed releases, newest first", () => { + const raw = [ + release("v1.0.0", "2026-11-29T18:23:53Z"), + release("v1.2.0", "2026-12-03T12:37:44Z", { assets: [asset("Statsify_1.2.0_universal.dmg")] }), + ]; + const out = readReleases(raw); + expect(out.map((r) => r.tag)).toEqual(["v1.2.0", "v1.0.0"]); + expect(out[0].assets).toHaveLength(1); + }); + + it("drops anything that isn't a release, or links away from GitHub", () => { + const out = readReleases([ + null, + "v1.0.0", + { tag: "latest", date: "2026-01-01", url: "https://github.com/x" }, + { ...release("v1.0.0", "2026-01-01"), url: "javascript:alert(1)" }, + { ...release("v1.1.0", "not a date") }, + { + ...release("v1.2.0", "2026-12-03T00:00:00Z"), + assets: [asset("ok.dmg"), { name: "evil.exe", size: 1, url: "https://evil.example/evil.exe" }, { name: 5 }], + }, + ]); + expect(out.map((r) => r.tag)).toEqual(["v1.2.0"]); + expect(out[0].assets.map((a) => a.name)).toEqual(["ok.dmg"]); + }); + + it("returns nothing for something other than a list", () => { + expect(readReleases({ message: "rate limited" })).toEqual([]); + expect(readReleases(undefined)).toEqual([]); + }); + + it("names a release without a name after its version", () => { + expect(readReleases([{ ...release("v2.0.0", "2026-12-01T00:00:00Z"), name: " " }])[0].name).toBe("Statsify 2.0.0"); + }); +}); + +describe("latestRelease", () => { + it("skips pre-releases", () => { + const releases = readReleases([ + release("v1.3.0-beta.1", "2026-12-05T00:00:00Z", { prerelease: true }), + release("v1.2.0", "2026-12-03T00:00:00Z"), + ]); + expect(latestRelease(releases)?.tag).toBe("v1.2.0"); + }); +}); + +describe("downloadsFor", () => { + const r = release("v1.2.0", "2026-12-03T00:00:00Z", { + assets: [ + "SHA256SUMS.txt", + "Statsify_1.2.0_amd64.AppImage", + "Statsify_1.2.0_amd64.deb", + "Statsify_1.2.0_universal.dmg", + "Statsify_1.2.0_web.zip", + "Statsify_1.2.0_x64-portable.exe", + "Statsify_1.2.0_x64-setup.exe", + "Statsify_1.2.0_x64_en-US.msi", + ].map((n) => asset(n)), + }); + + it("puts each system's recommended file first", () => { + const files = downloadsFor(r); + expect(files.windows.map((d) => d.asset.name)).toEqual([ + "Statsify_1.2.0_x64-setup.exe", + "Statsify_1.2.0_x64_en-US.msi", + "Statsify_1.2.0_x64-portable.exe", + ]); + expect(files.windows[0].recommended).toBe(true); + expect(files.macos.map((d) => d.asset.name)).toEqual(["Statsify_1.2.0_universal.dmg"]); + expect(files.linux.map((d) => d.label)).toEqual(["Debian package", "AppImage"]); + expect(files.web.map((d) => d.asset.name)).toEqual(["Statsify_1.2.0_web.zip"]); + }); + + it("leaves out what a release doesn't have, such as a pre-release's MSI", () => { + const pre = { ...r, assets: r.assets.filter((a) => !a.name.endsWith(".msi")) }; + expect(downloadsFor(pre).windows.map((d) => d.label)).toEqual(["Installer", "Portable"]); + }); + + it("finds the checksums", () => { + expect(checksumsOf(r)?.name).toBe("SHA256SUMS.txt"); + }); +}); + +describe("detectSystem", () => { + it.each([ + ["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/140 Safari/537.36", "", 0, "windows"], + ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Safari/605.1.15", "MacIntel", 0, "macos"], + ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Safari/605.1.15", "MacIntel", 5, "mobile"], + ["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/140 Safari/537.36", "Linux x86_64", 0, "linux"], + ["Mozilla/5.0 (Linux; Android 15; Pixel 7) AppleWebKit/537.36 Chrome/140 Mobile Safari/537.36", "", 5, "mobile"], + [ + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148", + "iPhone", + 5, + "mobile", + ], + ["Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 Chrome/140 Safari/537.36", "", 0, "unknown"], + ["", "", 0, "unknown"], + ] as const)("%s on %s with %i touch points is %s", (ua, platform, touch, expected) => { + expect(detectSystem(ua, platform, touch)).toBe(expected); + }); + + it("prefers the platform the browser reports", () => { + expect(detectSystem("Mozilla/5.0", "Windows")).toBe("windows"); + expect(detectSystem("Mozilla/5.0", "macOS")).toBe("macos"); + }); +}); + +describe("formatting", () => { + it("gives sizes in KB and MB", () => { + expect(formatSize(659)).toBe("659 bytes"); + expect(formatSize(584_051)).toBe("584 KB"); + expect(formatSize(6_710_528)).toBe("6.7 MB"); + expect(formatSize(82_115_064)).toBe("82.1 MB"); + }); + + it("writes dates out, the same in every time zone", () => { + expect(formatDate("2026-12-03T12:37:44Z")).toBe("3 December 2026"); + expect(formatDate("2026-11-29T23:59:00Z")).toBe("29 November 2026"); + }); +}); + +describe("parseNotes", () => { + it("reads GitHub's generated notes, without the download table or new contributors", () => { + const notes = parseNotes(BODY); + expect(notes.groups.map((g) => g.title)).toEqual(["New features", "Dependencies"]); + expect(notes.groups[0].changes).toEqual([ + { + text: "Faster CI, open-source docs and a hardened Rust shell", + pr: { number: 21, url: "https://github.com/Kkkermit/Statsify/pull/21" }, + }, + { text: "Word-by-word `LRC` timing", pr: { number: 30, url: "https://github.com/Kkkermit/Statsify/pull/30" } }, + ]); + expect(notes.groups[1].changes[0].text).toBe("Bump cross-spawn from 7.0.6 to 7.1.2"); + expect(notes.compareUrl).toBe("https://github.com/Kkkermit/Statsify/compare/v1.1.1...v1.2.0"); + }); + + it("reads hand-written notes", () => { + const notes = parseNotes("Small fixes:\n\n- Fixed the tray icon\n- Faster start-up\n\n### Known issues\n* None"); + expect(notes.groups).toEqual([ + { title: "Changes", changes: [{ text: "Fixed the tray icon" }, { text: "Faster start-up" }] }, + { title: "Known issues", changes: [{ text: "None" }] }, + ]); + }); + + it("has no groups for an empty body", () => { + expect(parseNotes("")).toEqual({ groups: [], compareUrl: undefined }); + }); + + it("never links a pull request outside GitHub", () => { + const notes = parseNotes("* fix: something by @x in https://evil.example/pull/1"); + expect(notes.groups[0].changes[0].pr).toBeUndefined(); + }); +}); + +describe("tidyTitle", () => { + it("drops the commit type and a repeated version", () => { + expect(tidyTitle("fix(desktop): a macOS icon that fills the app-icon shape")).toBe( + "A macOS icon that fills the app-icon shape", + ); + expect(tidyTitle("feat!: drop Windows 7")).toBe("Drop Windows 7"); + expect(tidyTitle("build: Statsify 1.1.1 on Node 26 LTS")).toBe("Statsify 1.1.1 on Node 26 LTS"); + expect(tidyTitle("feat: Statsify 2.0.0-rc.1: a new look")).toBe("A new look"); + expect(tidyTitle("Plain title")).toBe("Plain title"); + expect(tidyTitle("Lyrics: a synced view")).toBe("Lyrics: a synced view"); + }); +}); + +describe("inline", () => { + it("splits code, bold and https links out of the text", () => { + expect(inline("Use `npm ci`, **not** [npm i](https://docs.npmjs.com) or https://x.dev/a")).toEqual([ + { kind: "text", text: "Use " }, + { kind: "code", text: "npm ci" }, + { kind: "text", text: ", " }, + { kind: "strong", text: "not" }, + { kind: "text", text: " " }, + { kind: "link", text: "npm i", url: "https://docs.npmjs.com" }, + { kind: "text", text: " or " }, + { kind: "link", text: "https://x.dev/a", url: "https://x.dev/a" }, + ]); + }); + + it("leaves other link schemes as text", () => { + expect(inline("[click](javascript:alert(1))")).toEqual([{ kind: "text", text: "[click](javascript:alert(1))" }]); + }); +}); diff --git a/site/releases.ts b/site/releases.ts new file mode 100644 index 0000000..197551b --- /dev/null +++ b/site/releases.ts @@ -0,0 +1,252 @@ +/** + * Release data for the website: validating the snapshot the Pages workflow saves + * (scripts/site-releases.mjs), picking each system's files and reading GitHub's generated release + * notes into a list of changes. Pure functions, so they are tested without a browser. + */ + +export interface Asset { + name: string; + size: number; + url: string; +} + +export interface Release { + tag: string; + name: string; + date: string; + url: string; + prerelease: boolean; + body: string; + assets: Asset[]; +} + +export type System = "windows" | "macos" | "linux" | "mobile" | "unknown"; +export type Platform = "windows" | "macos" | "linux" | "web"; + +export interface Download { + label: string; + detail: string; + asset: Asset; + recommended?: boolean; +} + +const GITHUB = /^https:\/\/github\.com\//; + +function isAsset(value: unknown): value is Asset { + const a = value as Asset; + return ( + typeof a === "object" && + a !== null && + typeof a.name === "string" && + typeof a.size === "number" && + Number.isFinite(a.size) && + a.size >= 0 && + typeof a.url === "string" && + GITHUB.test(a.url) + ); +} + +/** Keeps only well-formed releases with GitHub links, newest first. Anything else is dropped. */ +export function readReleases(raw: unknown): Release[] { + if (!Array.isArray(raw)) return []; + const releases: Release[] = []; + for (const item of raw as Partial[]) { + if (typeof item !== "object" || item === null) continue; + const { tag, name, date, url, prerelease, body, assets } = item; + if (typeof tag !== "string" || !/^v\d+\.\d+\.\d+/.test(tag)) continue; + if (typeof url !== "string" || !GITHUB.test(url)) continue; + if (typeof date !== "string" || Number.isNaN(Date.parse(date))) continue; + releases.push({ + tag, + name: typeof name === "string" && name.trim() ? name.trim() : `Statsify ${tag.slice(1)}`, + date, + url, + prerelease: prerelease === true, + body: typeof body === "string" ? body : "", + assets: Array.isArray(assets) ? assets.filter(isAsset) : [], + }); + } + return releases.sort((a, b) => Date.parse(b.date) - Date.parse(a.date)); +} + +/** The release people should download: the newest that isn't a pre-release. */ +export function latestRelease(releases: Release[]): Release | undefined { + return releases.find((r) => !r.prerelease); +} + +/** The version a release tag names, without the "v". */ +export function versionOf(release: Release): string { + return release.tag.replace(/^v/, ""); +} + +const FILES: { platform: Platform; test: RegExp; label: string; detail: string; recommended?: boolean }[] = [ + { + platform: "windows", + test: /_x64-setup\.exe$/, + label: "Installer", + detail: "Installs for you only, no admin needed", + recommended: true, + }, + { platform: "windows", test: /\.msi$/, label: "MSI package", detail: "For managed installs" }, + { platform: "windows", test: /-portable\.exe$/, label: "Portable", detail: "Runs without installing" }, + { + platform: "macos", + test: /_universal\.dmg$/, + label: "Disk image", + detail: "Apple silicon and Intel", + recommended: true, + }, + { + platform: "linux", + test: /\.deb$/, + label: "Debian package", + detail: "Debian, Ubuntu, Mint and others", + recommended: true, + }, + { platform: "linux", test: /\.AppImage$/, label: "AppImage", detail: "Most other distributions" }, + { platform: "web", test: /_web\.zip$/, label: "Web app", detail: "To host on your own server", recommended: true }, +]; + +/** Each system's files in a release, the recommended one first. */ +export function downloadsFor(release: Release): Record { + const out: Record = { windows: [], macos: [], linux: [], web: [] }; + for (const file of FILES) { + const asset = release.assets.find((a) => file.test.test(a.name)); + if (asset) + out[file.platform].push({ label: file.label, detail: file.detail, asset, recommended: file.recommended }); + } + return out; +} + +export function checksumsOf(release: Release): Asset | undefined { + return release.assets.find((a) => a.name === "SHA256SUMS.txt"); +} + +/** + * Which system the visitor is on, from the browser. iPads report themselves as a Mac, so a Mac + * with a touch screen counts as a phone or tablet: there is no Statsify for those. + */ +export function detectSystem(userAgent: string, platform = "", touchPoints = 0): System { + const ua = `${platform} ${userAgent}`.toLowerCase(); + if (/android|iphone|ipad|ipod|mobile/.test(ua)) return "mobile"; + if (/mac/.test(ua)) return touchPoints > 1 ? "mobile" : "macos"; + if (/win/.test(ua)) return "windows"; + if (/cros/.test(ua)) return "unknown"; + if (/linux|x11|bsd/.test(ua)) return "linux"; + return "unknown"; +} + +export function formatSize(bytes: number): string { + if (bytes >= 1_000_000) return `${(bytes / 1_000_000).toFixed(1)} MB`; + if (bytes >= 1_000) return `${Math.round(bytes / 1_000)} KB`; + return `${bytes} bytes`; +} + +const DATE = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "long", year: "numeric", timeZone: "UTC" }); + +export function formatDate(iso: string): string { + return DATE.format(new Date(iso)); +} + +export interface Change { + text: string; + pr?: { number: number; url: string }; +} + +export interface ChangeGroup { + title: string; + changes: Change[]; +} + +export interface Notes { + groups: ChangeGroup[]; + compareUrl?: string; +} + +/** Sections of a release body that aren't changes: the download table, first-time contributors. */ +const SKIPPED = /^(download|new contributors)$/i; +const CHANGE = + /^(.*?)(?:\s+by\s+@[\w-]+(?:\[bot\])?)?(?:\s+in\s+(https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/(\d+)))?\s*$/; + +/** + * A change's title as people read it: without the commit type ("feat(lyrics):") or the version + * a release pull request repeats ("Statsify 1.2.0:"), which the page already shows. + */ +export function tidyTitle(title: string): string { + const text = title + .replace(/^(feat|fix|perf|refactor|test|docs|chore|ci|build|style|revert|deps)(\([^)]*\))?!?:\s*/i, "") + .replace(/^Statsify \d+\.\d+\.\d+(-[\w.]+)?:\s*/i, "") + .trim(); + return text.charAt(0).toUpperCase() + text.slice(1); +} + +/** + * Reads GitHub's generated release notes ("## What's Changed", a "###" heading per label, one + * "* title by @someone in " line per change, then "**Full Changelog**: "). + * Hand-written notes work too: every list item is a change under the heading above it. + */ +export function parseNotes(body: string): Notes { + const groups: ChangeGroup[] = []; + let compareUrl: string | undefined; + let current: ChangeGroup | undefined; + let skipping = false; + const lines = body.replace(//g, "").split(/\r?\n/); + for (const raw of lines) { + const line = raw.trim(); + const heading = /^(#{1,4})\s+(.+)$/.exec(line); + if (heading) { + const title = heading[2].replace(/[*_`]/g, "").trim(); + if (heading[1].length <= 2) { + skipping = SKIPPED.test(title); + current = undefined; + if (/^what.s changed$/i.test(title)) continue; + } + if (skipping) continue; + current = { title, changes: [] }; + groups.push(current); + continue; + } + const full = /full changelog\**:?\s*(https:\/\/github\.com\/\S+)/i.exec(line); + if (full) { + compareUrl = full[1]; + continue; + } + if (skipping) continue; + const item = /^[*-]\s+(.+)$/.exec(line); + if (!item) continue; + const match = CHANGE.exec(item[1]); + const text = tidyTitle(match?.[1] ?? item[1]); + if (!text) continue; + if (!current) { + current = { title: "Changes", changes: [] }; + groups.push(current); + } + const change: Change = { text }; + if (match?.[2] && match[3]) change.pr = { number: Number(match[3]), url: match[2] }; + current.changes.push(change); + } + return { groups: groups.filter((g) => g.changes.length > 0), compareUrl }; +} + +export type Inline = + | { kind: "text"; text: string } + | { kind: "code"; text: string } + | { kind: "strong"; text: string } + | { kind: "link"; text: string; url: string }; + +/** Splits a change's text into plain text, `code`, **bold** and https links, for rendering as text nodes. */ +export function inline(text: string): Inline[] { + const out: Inline[] = []; + const pattern = /`([^`]+)`|\*\*([^*]+)\*\*|\[([^\]]+)\]\((https:\/\/[^\s)]+)\)|(https:\/\/[^\s)]+)/g; + let last = 0; + for (const m of text.matchAll(pattern)) { + if (m.index > last) out.push({ kind: "text", text: text.slice(last, m.index) }); + if (m[1] !== undefined) out.push({ kind: "code", text: m[1] }); + else if (m[2] !== undefined) out.push({ kind: "strong", text: m[2] }); + else if (m[3] !== undefined) out.push({ kind: "link", text: m[3], url: m[4] }); + else out.push({ kind: "link", text: m[5], url: m[5] }); + last = m.index + m[0].length; + } + if (last < text.length) out.push({ kind: "text", text: text.slice(last) }); + return out; +} diff --git a/site/styles.css b/site/styles.css new file mode 100644 index 0000000..92bbb1b --- /dev/null +++ b/site/styles.css @@ -0,0 +1,1494 @@ +@import "@fontsource-variable/figtree"; + +/* + * The Statsify website. It uses the app's own colours (its Midnight and Light themes), so the + * screenshots sit on the page without a seam. The chrome stays neutral; the green from the logo + * marks only the main action, the selected tab and "your system". Every size is a multiple of + * 4px (0.25rem). Contrast, measured on each theme's surfaces: primary and secondary text >= 7:1, + * muted text and accent text >= 4.5:1. + */ +:root { + --bg: #070707; + --surface: #121212; + --raised: #1c1c1c; + --line: rgb(255 255 255 / 0.08); + --line-strong: rgb(255 255 255 / 0.14); + --text: #f2f2f2; + --text-2: #b3b3b3; + --text-3: #8f8f8f; + --accent: #7ed957; + --accent-hover: #93e56f; + --accent-ink: #0a1606; + --accent-text: #7ed957; + --highlight: inset 0 1px 0 rgb(255 255 255 / 0.06); + --shot-shadow: none; + + --font: "Figtree Variable", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif; + --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace; + --gutter: clamp(1rem, 4vw, 2rem); + --header-h: 4rem; + --ease: cubic-bezier(0.22, 1, 0.36, 1); + color-scheme: dark; +} + +@media (prefers-color-scheme: light) { + :root { + --bg: #f3f5f1; + --surface: #ffffff; + --raised: #e7ebe4; + --line: rgb(11 11 11 / 0.09); + --line-strong: rgb(11 11 11 / 0.16); + --text: #121512; + --text-2: #4b5249; + --text-3: #5f665d; + --accent: #7ed957; + --accent-hover: #6fcc47; + --accent-ink: #0a1606; + --accent-text: #2a7313; + --highlight: 0 1px 2px rgb(0 0 0 / 0.05); + --shot-shadow: 0 8px 24px rgb(0 0 0 / 0.06); + color-scheme: light; + } +} + +/* Base ------------------------------------------------------------------------------------ */ + +*, +*::before, +*::after { + box-sizing: border-box; +} + +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; + scroll-padding-top: calc(var(--header-h) + 1rem); + overflow-x: clip; +} + +@media (min-width: 2200px) { + html { + font-size: 112.5%; + } +} + +@media (min-width: 3000px) { + html { + font-size: 125%; + } +} + +@media (prefers-reduced-motion: no-preference) { + html { + scroll-behavior: smooth; + } +} + +body { + margin: 0; + background: var(--bg); + color: var(--text); + font-family: var(--font); + font-size: 1rem; + line-height: 1.625; + overflow-x: clip; + -webkit-font-smoothing: antialiased; +} + +img, +svg { + display: block; + max-width: 100%; +} + +img { + height: auto; +} + +h1, +h2, +h3, +h4 { + margin: 0; + font-weight: 500; + text-wrap: balance; +} + +p, +dl, +dd, +figure { + margin: 0; +} + +p, +dd, +li { + text-wrap: pretty; +} + +strong { + font-weight: 500; + color: var(--text); +} + +a { + color: inherit; + text-decoration-color: var(--line-strong); + text-decoration-thickness: 1px; + text-underline-offset: 0.2em; + transition: text-decoration-color 150ms var(--ease); +} + +a:hover { + text-decoration-color: currentColor; +} + +code, +kbd { + font-family: var(--mono); + font-size: 0.875em; +} + +:not(.code) > code { + padding: 0.0625rem 0.25rem; + border-radius: 0.25rem; + background: var(--raised); + color: var(--text); + overflow-wrap: anywhere; +} + +kbd { + display: inline-block; + min-width: 1.5rem; + padding: 0 0.375rem; + border: 1px solid var(--line-strong); + border-radius: 0.25rem; + background: var(--surface); + color: var(--text); + line-height: 1.5; + text-align: center; +} + +::selection { + background: var(--accent); + color: var(--accent-ink); +} + +:focus-visible { + outline: 2px solid var(--accent-text); + outline-offset: 2px; + border-radius: 0.25rem; +} + +[hidden] { + display: none !important; +} + +.visually-hidden { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; +} + +.sprite { + position: absolute; + width: 0; + height: 0; + overflow: hidden; +} + +.icon { + width: 1.125rem; + height: 1.125rem; + flex: none; + fill: none; + stroke: currentColor; + stroke-width: 1.5; + stroke-linecap: round; + stroke-linejoin: round; +} + +/* Shapes drawn filled rather than outlined (the GitHub mark), styled where the sprite defines them. */ +.filled { + fill: currentColor; + stroke: none; +} + +.skip-link { + position: fixed; + top: 0.75rem; + left: 0.75rem; + z-index: 100; + padding: 0.5rem 1rem; + border-radius: 0.5rem; + background: var(--accent); + color: var(--accent-ink); + font-weight: 500; + text-decoration: none; + translate: 0 -200%; +} + +.skip-link:focus-visible { + translate: 0 0; +} + +main:focus { + outline: none; +} + +.wrap { + width: 100%; + max-width: 76rem; + margin-inline: auto; + padding-inline: var(--gutter); +} + +/* Buttons --------------------------------------------------------------------------------- */ + +.button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.5rem; + min-height: 2.75rem; + padding: 0.5rem 1.25rem; + border: 1px solid transparent; + border-radius: 0.625rem; + font: inherit; + font-weight: 500; + line-height: 1.25; + text-align: center; + text-decoration: none; + white-space: nowrap; + cursor: pointer; + transition: + background-color 150ms var(--ease), + border-color 150ms var(--ease), + color 150ms var(--ease), + transform 120ms var(--ease); +} + +.button:active { + transform: scale(0.98); +} + +.button-small { + min-height: 2.25rem; + padding: 0.375rem 1rem; + border-radius: 0.5rem; + font-size: 0.9375rem; +} + +.button-primary { + background: var(--accent); + color: var(--accent-ink); +} + +.button-primary:hover { + background: var(--accent-hover); +} + +.button-secondary { + border-color: var(--line-strong); + background: var(--surface); + color: var(--text); + box-shadow: var(--highlight); +} + +.button-secondary:hover { + background: var(--raised); +} + +/* Header ---------------------------------------------------------------------------------- */ + +.site-header { + position: sticky; + top: 0; + z-index: 50; + border-bottom: 1px solid transparent; + background: var(--bg); + transition: border-color 200ms var(--ease); +} + +.site-header.is-scrolled, +.site-header.is-open { + border-bottom-color: var(--line); +} + +.header-inner { + display: flex; + align-items: center; + gap: 1rem; + min-height: var(--header-h); +} + +.brand { + display: inline-flex; + align-items: center; + gap: 0.5rem; + margin-right: auto; + color: var(--text); + font-size: 1.125rem; + font-weight: 600; + text-decoration: none; +} + +.brand img { + width: 1.75rem; + height: 1.75rem; +} + +.menu-button { + display: none; + align-items: center; + gap: 0.5rem; + min-height: 2.25rem; + padding: 0.375rem 0.75rem; + border: 1px solid var(--line-strong); + border-radius: 0.5rem; + background: var(--surface); + color: var(--text); + font: inherit; + font-size: 0.9375rem; + font-weight: 500; + cursor: pointer; +} + +.menu-button .icon-close, +.is-open .menu-button .icon-open { + display: none; +} + +.is-open .menu-button .icon-close { + display: block; +} + +.site-nav { + display: flex; + align-items: center; + gap: 1rem; +} + +.site-nav ul { + display: flex; + gap: 0.25rem; + margin: 0; + padding: 0; + list-style: none; +} + +.site-nav ul a { + display: block; + padding: 0.375rem 0.75rem; + border-radius: 0.5rem; + color: var(--text-2); + font-size: 0.9375rem; + text-decoration: none; + transition: + color 150ms var(--ease), + background-color 150ms var(--ease); +} + +.site-nav ul a:hover { + color: var(--text); +} + +.site-nav ul a[aria-current] { + background: var(--raised); + color: var(--text); +} + +@media (max-width: 63.99rem) { + html.js .menu-button { + display: inline-flex; + } + + html.js .site-nav { + position: absolute; + top: 100%; + right: 0; + left: 0; + flex-direction: column; + align-items: stretch; + gap: 0.75rem; + max-height: calc(100dvh - var(--header-h)); + padding: 0.5rem var(--gutter) 1.5rem; + overflow-y: auto; + border-bottom: 1px solid var(--line); + background: var(--bg); + opacity: 0; + visibility: hidden; + translate: 0 -0.375rem; + transition: + opacity 200ms var(--ease), + translate 200ms var(--ease), + visibility 0s 200ms; + } + + html.js .is-open .site-nav { + opacity: 1; + visibility: visible; + translate: 0 0; + transition: + opacity 200ms var(--ease), + translate 200ms var(--ease); + } + + html.js .site-nav ul { + flex-direction: column; + gap: 0; + } + + html.js .site-nav ul a { + padding: 0.625rem 0.75rem; + font-size: 1rem; + } + + html.js .nav-github { + min-height: 2.75rem; + } + + html:not(.js) .header-inner { + flex-wrap: wrap; + padding-block: 0.5rem; + } + + html:not(.js) .site-nav, + html:not(.js) .site-nav ul { + flex-wrap: wrap; + } +} + +/* Hero ------------------------------------------------------------------------------------ */ + +.hero { + padding-top: clamp(3rem, 1rem + 6vw, 7rem); +} + +.hero-text { + max-width: 46rem; +} + +h1 { + font-size: clamp(2.5rem, 1rem + 4vw, 4.5rem); + letter-spacing: -0.03em; + line-height: 1.04; +} + +/* "by the numbers." keeps to one line once there's room for it. */ +@media (min-width: 30rem) { + h1 .line { + display: inline-block; + } +} + +.lead { + max-width: 38rem; + margin-top: 1.5rem; + color: var(--text-2); + font-size: 1.1875rem; + line-height: 1.875rem; +} + +.actions { + display: flex; + flex-wrap: wrap; + gap: 0.75rem; +} + +.hero .actions { + margin-top: 2rem; +} + +.hero-meta { + margin-top: 1rem; + color: var(--text-3); + font-size: 0.875rem; + font-variant-numeric: tabular-nums; +} + +.hero-meta a { + margin-left: 0.25rem; + color: var(--text-2); +} + +.screen { + overflow: hidden; + border: 1px solid var(--line-strong); + border-radius: 1rem; + background: #070707; + box-shadow: var(--shot-shadow); +} + +.hero-shot { + margin-top: clamp(3rem, 2rem + 3vw, 4rem); +} + +/* Sections -------------------------------------------------------------------------------- */ + +.section { + padding-block: clamp(4rem, 2rem + 5vw, 6rem); +} + +.hero + .section { + margin-top: clamp(4rem, 2rem + 5vw, 6rem); +} + +.section + .section { + border-top: 1px solid var(--line); +} + +.section-head { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 0.75rem; + max-width: 42rem; + margin-bottom: clamp(2rem, 1.5rem + 1.5vw, 3rem); +} + +h2 { + font-size: clamp(2rem, 1.5rem + 1.6vw, 2.5rem); + letter-spacing: -0.02em; + line-height: 1.15; +} + +.section-head p { + color: var(--text-2); + font-size: 1.0625rem; +} + +h3 { + font-size: 1.25rem; + line-height: 1.75rem; +} + +/* Features -------------------------------------------------------------------------------- */ + +.feature-groups { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 2.5rem 3rem; +} + +@media (min-width: 52rem) { + .feature-groups { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } +} + +.feature-group h3 { + padding-bottom: 0.75rem; + border-bottom: 1px solid var(--line); + color: var(--text-2); + font-size: 1rem; + line-height: 1.5rem; +} + +.feature-group dt { + margin-top: 1.25rem; + font-weight: 500; +} + +.feature-group dd { + margin-top: 0.25rem; + color: var(--text-2); + font-size: 0.9375rem; + line-height: 1.5rem; +} + +.shots { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 3rem 2rem; + margin-top: clamp(3rem, 2rem + 3vw, 5rem); +} + +@media (min-width: 56rem) { + .shots { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} + +.shots figcaption { + max-width: 36rem; + margin-top: 1rem; + color: var(--text-2); + font-size: 0.9375rem; + line-height: 1.5rem; +} + +/* Downloads ------------------------------------------------------------------------------- */ + +.mobile-note { + max-width: 42rem; + margin-bottom: 2rem; + padding: 1rem 1.25rem; + border: 1px solid var(--line-strong); + border-radius: 0.75rem; + background: var(--surface); + color: var(--text-2); +} + +.downloads { + border-top: 1px solid var(--line); +} + +.system { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 1rem 2rem; + padding-block: 1.5rem; + border-bottom: 1px solid var(--line); +} + +@media (min-width: 48rem) { + .system { + grid-template-columns: 15rem minmax(0, 1fr); + } +} + +.system-name { + display: grid; + align-content: start; + gap: 0.25rem; +} + +.system-name p { + color: var(--text-3); + font-size: 0.875rem; + line-height: 1.25rem; +} + +.system-name p a { + color: var(--text-2); +} + +.system-name .your-system { + margin-top: 0.25rem; + color: var(--accent-text); + font-weight: 500; +} + +.files { + display: grid; + grid-template-columns: minmax(0, 1fr); + margin: 0; + padding: 0; + list-style: none; +} + +.file { + display: grid; + grid-template-columns: minmax(0, 1fr) auto auto; + align-items: center; + gap: 0.25rem 1.5rem; + min-height: 3.5rem; + padding-block: 0.5rem; +} + +.file + .file { + border-top: 1px solid var(--line); +} + +.file-name { + display: grid; + line-height: 1.5rem; +} + +.file-ext { + margin-left: 0.25rem; + color: var(--text-3); + font-size: 0.875rem; +} + +.file-detail { + color: var(--text-2); + font-size: 0.875rem; + line-height: 1.25rem; +} + +.file-size { + color: var(--text-3); + font-size: 0.875rem; + font-variant-numeric: tabular-nums; + text-align: right; +} + +@media (max-width: 35.99rem) { + .file { + grid-template-columns: minmax(0, 1fr) auto; + } + + .file-size { + grid-row: 2; + grid-column: 1; + text-align: left; + } + + .file .button { + grid-row: 1 / span 2; + grid-column: 2; + } +} + +.download-notes { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 1rem; + max-width: 44rem; + margin-top: 2rem; + color: var(--text-2); + font-size: 0.9375rem; +} + +.disclosure summary { + display: inline-flex; + align-items: center; + gap: 0.5rem; + color: var(--text); + cursor: pointer; + list-style: none; +} + +.disclosure summary::-webkit-details-marker { + display: none; +} + +.disclosure-body { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 1rem; + padding-top: 1rem; +} + +.commands { + display: grid; + grid-template-columns: minmax(0, 1fr); +} + +.commands dt { + margin-top: 0.75rem; + color: var(--text); + font-size: 0.875rem; +} + +.commands dt:first-child { + margin-top: 0; +} + +.chevron { + color: var(--text-3); + transition: rotate 200ms var(--ease); +} + +details[open] > summary .chevron { + rotate: 180deg; +} + +/* Code with a copy button ----------------------------------------------------------------- */ + +.code { + display: flex; + align-items: center; + gap: 0.5rem; + max-width: 40rem; + margin-block: 0.5rem; + padding: 0.25rem 0.25rem 0.25rem 0.75rem; + border: 1px solid var(--line); + border-radius: 0.5rem; + background: var(--surface); +} + +.code code { + flex: 1; + min-width: 0; + padding-block: 0.375rem; + color: var(--text); + font-size: 0.8125rem; + line-height: 1.25rem; + white-space: pre-wrap; + overflow-wrap: anywhere; +} + +.copy { + display: inline-flex; + flex: none; + align-items: center; + gap: 0.375rem; + min-height: 2rem; + padding: 0.25rem 0.625rem; + border: 1px solid var(--line); + border-radius: 0.25rem; + background: var(--raised); + color: var(--text-2); + font: inherit; + font-size: 0.8125rem; + cursor: pointer; + transition: + color 150ms var(--ease), + background-color 150ms var(--ease); +} + +.copy .icon { + width: 1rem; + height: 1rem; +} + +.copy:hover { + color: var(--text); +} + +.copy.is-done { + color: var(--accent-text); +} + +@media (max-width: 23.99rem) { + .copy span { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + } +} + +/* Set up: the steps read like a tracklist, with a number and a length for each ------------ */ + +.tracklist { + margin: 0; + padding: 0; + border-top: 1px solid var(--line); + list-style: none; +} + +.track { + padding-block: 2rem; + border-bottom: 1px solid var(--line); +} + +.track-head { + display: grid; + grid-template-columns: 2rem minmax(0, 1fr) auto; + align-items: baseline; + gap: 0.25rem 1rem; +} + +@media (min-width: 40rem) { + .track-head { + grid-template-columns: 3rem minmax(0, 1fr) auto; + } +} + +.track-number { + color: var(--text-3); + font-size: 1.25rem; + font-variant-numeric: tabular-nums; +} + +.track-head h3 { + font-size: 1.5rem; + line-height: 2rem; +} + +.track-length { + color: var(--text-3); + font-size: 0.875rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.optional { + display: inline-block; + margin-left: 0.5rem; + padding: 0 0.5rem; + border: 1px solid var(--line-strong); + border-radius: 0.25rem; + color: var(--text-3); + font-size: 0.8125rem; + line-height: 1.5rem; + vertical-align: 0.25rem; +} + +.track-body { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 1rem; + max-width: 48rem; + margin-top: 1rem; + color: var(--text-2); +} + +@media (min-width: 40rem) { + .track-body { + margin-left: 4rem; + } +} + +@media (max-width: 30rem) { + .track-head { + grid-template-columns: 2rem minmax(0, 1fr); + } + + .track-length { + grid-column: 2; + } +} + +.steps { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 0.75rem; + margin: 0; + padding-left: 1.25rem; +} + +.steps li { + padding-left: 0.25rem; +} + +.steps li::marker { + color: var(--text-3); + font-variant-numeric: tabular-nums; +} + +.aside { + padding-left: 1rem; + border-left: 2px solid var(--line-strong); + font-size: 0.9375rem; +} + +.aside > * + * { + margin-top: 0.5rem; +} + +.hint { + display: block; + color: var(--text-3); + font-size: 0.875rem; + line-height: 1.25rem; +} + +/* Tabs ------------------------------------------------------------------------------------ */ + +.tab-list { + display: inline-grid; + grid-auto-columns: minmax(0, 1fr); + grid-auto-flow: column; + gap: 0.25rem; + padding: 0.25rem; + border: 1px solid var(--line); + border-radius: 0.625rem; + background: var(--surface); +} + +.tab-list [role="tab"] { + min-height: 2.25rem; + padding: 0.25rem 1rem; + border: 1px solid transparent; + border-radius: 0.375rem; + background: transparent; + color: var(--text-2); + font: inherit; + font-size: 0.9375rem; + cursor: pointer; + transition: + background-color 150ms var(--ease), + color 150ms var(--ease); +} + +.tab-list [role="tab"]:hover { + color: var(--text); +} + +.tab-list [role="tab"][aria-selected="true"] { + border-color: var(--line); + background: var(--raised); + color: var(--text); + box-shadow: var(--highlight); +} + +.tab-panel { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 1rem; + margin-top: 1.5rem; +} + +html.js .panel-title { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); +} + +html:not(.js) .tab-list { + display: none; +} + +html:not(.js) .panel-title { + color: var(--text); + font-size: 1rem; +} + +/* Sections with their heading beside them ------------------------------------------------- */ + +.split { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 0 4rem; +} + +.split-main { + min-width: 0; +} + +.split-head { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-content: start; + gap: 1.5rem; +} + +@media (min-width: 64rem) { + .split { + grid-template-columns: minmax(0, 18rem) minmax(0, 1fr); + align-items: start; + } + + .split .section-head { + margin-bottom: 0; + } +} + +@media (min-width: 64rem) and (min-height: 40rem) { + .split-head { + position: sticky; + top: calc(var(--header-h) + 2rem); + } +} + +@media (max-width: 63.99rem) { + .split-head { + margin-bottom: 2rem; + } + + .split-head .section-head { + margin-bottom: 0; + } +} + +/* Changelog ------------------------------------------------------------------------------- */ + +.changelog { + border-top: 1px solid var(--line); +} + +.placeholder { + padding-block: 1.5rem; + color: var(--text-2); +} + +.release { + border-bottom: 1px solid var(--line); +} + +.release summary { + display: grid; + grid-template-columns: minmax(0, 1fr) auto 1.125rem; + align-items: center; + gap: 0 1rem; + padding-block: 1.25rem; + cursor: pointer; + list-style: none; +} + +.release summary::-webkit-details-marker { + display: none; +} + +.release-title { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.25rem 0.75rem; +} + +.release-title h3 { + font-variant-numeric: tabular-nums; +} + +.tag { + padding: 0 0.5rem; + border: 1px solid var(--line-strong); + border-radius: 0.25rem; + color: var(--text-2); + font-size: 0.8125rem; + line-height: 1.5rem; +} + +.release-date { + grid-row: 2; + grid-column: 1; + color: var(--text-3); + font-size: 0.875rem; +} + +.release-count { + grid-row: 1 / span 2; + grid-column: 2; + color: var(--text-3); + font-size: 0.875rem; + font-variant-numeric: tabular-nums; +} + +.release summary .chevron { + grid-row: 1 / span 2; + grid-column: 3; +} + +.release-body { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 0.5rem; + padding-bottom: 1.5rem; +} + +.change-group { + margin-top: 0.5rem; + color: var(--text-2); + font-size: 0.875rem; + line-height: 1.25rem; +} + +.changes { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 0.5rem; + margin: 0; + padding-left: 1.25rem; + color: var(--text); + font-size: 0.9375rem; + line-height: 1.5rem; +} + +.changes li { + overflow-wrap: anywhere; +} + +.changes li::marker { + color: var(--text-3); +} + +.pr { + color: var(--text-3); + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.release-links { + display: flex; + flex-wrap: wrap; + gap: 0.5rem 1.5rem; + margin-top: 0.5rem; + color: var(--text-2); + font-size: 0.875rem; +} + +.release-loading { + display: grid; + gap: 0.5rem; + padding-block: 1.25rem; + border-bottom: 1px solid var(--line); +} + +.release-loading span { + display: block; + height: 1rem; + border-radius: 0.25rem; + background: var(--surface); +} + +.release-loading span:first-child { + width: 6rem; + height: 1.25rem; +} + +.release-loading span:last-child { + width: 10rem; +} + +/* Troubleshooting and the FAQ ------------------------------------------------------------- */ + +.search { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 0.5rem; +} + +.search label { + color: var(--text-2); + font-size: 0.875rem; +} + +.search-field { + position: relative; + max-width: 28rem; +} + +.search-field .icon { + position: absolute; + top: 50%; + left: 0.75rem; + color: var(--text-3); + translate: 0 -50%; + pointer-events: none; +} + +.search-field input { + width: 100%; + min-height: 2.75rem; + padding: 0.5rem 0.75rem 0.5rem 2.5rem; + border: 1px solid var(--line-strong); + border-radius: 0.625rem; + background: var(--surface); + color: var(--text); + font: inherit; + transition: border-color 150ms var(--ease); +} + +.search-field input::placeholder { + color: var(--text-3); + opacity: 1; +} + +.search-field input:focus-visible { + border-color: var(--accent-text); + outline-offset: 0; + border-radius: 0.625rem; +} + +.search-status { + color: var(--text-3); + font-size: 0.875rem; + font-variant-numeric: tabular-nums; +} + +.search-status:empty { + margin-top: -0.5rem; +} + +.toc ul { + display: grid; + margin: 0; + padding: 0; + border-left: 1px solid var(--line); + list-style: none; +} + +.toc a { + display: block; + padding: 0.25rem 0 0.25rem 1rem; + color: var(--text-2); + font-size: 0.9375rem; + text-decoration: none; + transition: color 150ms var(--ease); +} + +.toc a:hover { + color: var(--text); +} + +.qa-group + .qa-group { + margin-top: 3rem; +} + +.qa-group > h3 { + padding-bottom: 0.75rem; + border-bottom: 1px solid var(--line); +} + +.split-main.qa-group { + border-top: 1px solid var(--line); +} + +.qa { + border-bottom: 1px solid var(--line); +} + +.qa summary { + position: relative; + display: block; + padding: 1rem 2.5rem 1rem 0; + font-weight: 500; + line-height: 1.5rem; + cursor: pointer; + list-style: none; +} + +.qa summary::-webkit-details-marker { + display: none; +} + +.qa summary::before, +.qa summary::after { + content: ""; + position: absolute; + top: 50%; + right: 0.25rem; + width: 0.75rem; + height: 1.5px; + background: var(--text-3); + transition: rotate 200ms var(--ease); +} + +.qa summary::after { + rotate: 90deg; +} + +.qa[open] summary::after { + rotate: 0deg; +} + +.qa-body { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 0.75rem; + max-width: 44rem; + padding-bottom: 1.25rem; + color: var(--text-2); +} + +.stuck { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 0.75rem; + margin-top: 3rem; + padding: 1.5rem; + border: 1px solid var(--line); + border-radius: 0.75rem; + background: var(--surface); + color: var(--text-2); +} + +.stuck .actions { + margin-top: 0.5rem; +} + +/* Footer ---------------------------------------------------------------------------------- */ + +.site-footer { + padding-block: 2.5rem 3rem; + border-top: 1px solid var(--line); +} + +.footer-inner { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 1.5rem; +} + +.footer-inner .brand { + justify-self: start; + font-size: 1rem; +} + +.footer-inner .brand img { + width: 1.5rem; + height: 1.5rem; +} + +.footer-links { + display: flex; + flex-wrap: wrap; + gap: 0.5rem 1.5rem; + margin: 0; + padding: 0; + list-style: none; + font-size: 0.875rem; +} + +.footer-links a { + display: inline-block; + padding-block: 0.25rem; + color: var(--text-2); +} + +.legal { + max-width: 48rem; + color: var(--text-3); + font-size: 0.8125rem; + line-height: 1.25rem; +} + +/* Motion: one entrance for the first screen, and feedback for what people open or press ---- */ + +@media (prefers-reduced-motion: no-preference) { + .hero-text > * { + animation: enter 450ms var(--ease) both; + } + + .hero-text > :nth-child(2) { + animation-delay: 50ms; + } + + .hero-text > :nth-child(3) { + animation-delay: 100ms; + } + + .hero-text > :nth-child(4) { + animation-delay: 150ms; + } + + .hero-shot { + animation: enter 600ms var(--ease) 200ms both; + } + + .qa[open] .qa-body, + .release[open] .release-body, + .disclosure[open] .disclosure-body { + animation: open 200ms var(--ease); + } + + .tab-panel:not([hidden]) { + animation: open 160ms var(--ease); + } +} + +@keyframes enter { + from { + opacity: 0; + translate: 0 0.5rem; + } +} + +@keyframes open { + from { + opacity: 0; + translate: 0 -0.25rem; + } +} + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + transition-duration: 0.01ms !important; + } +} + +@media print { + .site-header, + .copy, + .search, + .toc { + display: none !important; + } +} diff --git a/site/vite.config.ts b/site/vite.config.ts new file mode 100644 index 0000000..94b80d1 --- /dev/null +++ b/site/vite.config.ts @@ -0,0 +1,52 @@ +import { createHash } from "node:crypto"; +import { fileURLToPath } from "node:url"; +import { defineConfig, type Plugin } from "vite"; + +/** + * GitHub Pages can't send headers, so the policy is a tag: the page's own files only, and + * the one inline script (it marks the page as scripted before the first paint) allowed by its hash. + */ +function siteCsp(): Plugin { + return { + name: "statsify-site-csp", + apply: "build", + transformIndexHtml(html) { + const hashes = [...html.matchAll(/]*)>([\s\S]*?)<\/script\b[^>]*>/gi)] + .filter((m) => !/\bsrc\s*=/i.test(m[1])) + .map((m) => `'sha256-${createHash("sha256").update(m[2]).digest("base64")}'`); + const policy = [ + "default-src 'self'", + `script-src 'self' ${hashes.join(" ")}`, + "style-src 'self'", + "img-src 'self' data:", + "font-src 'self' data:", + "connect-src 'self'", + "object-src 'none'", + "base-uri 'none'", + "form-action 'none'", + ].join("; "); + return html.replace("", `\n\t\t`); + }, + }; +} + +const root = fileURLToPath(new URL(".", import.meta.url)); + +// The website (site/), separate from the app: `npm run site:dev`, `site:build`, `site:preview`. +export default defineConfig({ + root, + // Relative links, so it works at https://.github.io// and anywhere else. + base: "./", + // The release list the Pages workflow saves (scripts/site-releases.mjs) is served from here. + publicDir: "public", + plugins: [siteCsp()], + server: { host: "127.0.0.1", port: 5174, strictPort: true }, + preview: { host: "127.0.0.1", port: 4174, strictPort: true }, + build: { + outDir: "dist", + emptyOutDir: true, + target: "es2022", + // The page's images are the README screenshots and the logo, outside site/. + assetsInlineLimit: 0, + }, +}); diff --git a/tsconfig.json b/tsconfig.json index 1ffef60..c76696d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "files": [], "references": [ { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.site.json" } ] } diff --git a/tsconfig.node.json b/tsconfig.node.json index d893bf2..4b23110 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -16,5 +16,14 @@ "noUnusedLocals": true, "noUnusedParameters": true }, - "include": ["vite.config.ts", "vitest.config.ts", "playwright.config.ts", "e2e", "scripts/filenames.test.ts"] + "include": [ + "vite.config.ts", + "vitest.config.ts", + "playwright.config.ts", + "e2e", + "scripts/filenames.test.ts", + "site/vite.config.ts", + "site/playwright.config.ts", + "site/e2e" + ] } diff --git a/tsconfig.site.json b/tsconfig.site.json new file mode 100644 index 0000000..8f5a8b1 --- /dev/null +++ b/tsconfig.site.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.site.tsbuildinfo", + "target": "ES2022", + "lib": ["ES2023", "DOM", "DOM.Iterable"], + "module": "ESNext", + "moduleResolution": "bundler", + "types": ["vite/client"], + "skipLibCheck": true, + "isolatedModules": true, + "moduleDetection": "force", + "verbatimModuleSyntax": true, + "noEmit": true, + + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true, + "noImplicitOverride": true + }, + "include": ["site"], + "exclude": ["site/vite.config.ts", "site/playwright.config.ts", "site/e2e", "site/dist"] +} diff --git a/vitest.config.ts b/vitest.config.ts index 14d32e5..0716c89 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -7,7 +7,7 @@ export default mergeConfig( test: { environment: "jsdom", setupFiles: ["./scripts/setupTests.ts"], - include: ["app/**/*.test.{ts,tsx}", "scripts/**/*.test.ts"], + include: ["app/**/*.test.{ts,tsx}", "scripts/**/*.test.ts", "site/**/*.test.ts"], css: false, restoreMocks: true, coverage: { From 3e7fa7c6ba2986a3698aab78a87098c6b815e2b2 Mon Sep 17 00:00:00 2001 From: Kkkermit <132657029+Kkkermit@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:08:45 +0000 Subject: [PATCH 2/3] fix(site): skip comment lines in release notes, check releases before saving CodeQL flagged two things on the website: - Release notes lost their HTML comments through one regular-expression replace, which is never a complete HTML sanitiser. The notes are only ever shown as text, so they don't need one: the parser now leaves out lines in a comment, on one line or several, and takes nothing else from them. - The release list was written to the file as GitHub sent it. Now only what the page uses is written, once checked: version tags, dates, whole-number sizes, text cut to a sane length and links into this repository, with the answer capped at 5 MB. Anything else is dropped. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TCk6t7edJdscNtTSeFmyQN --- scripts/site-releases.mjs | 60 ++++++++++++++++++++++++++++++++------- site/releases.test.ts | 19 +++++++++++++ site/releases.ts | 14 +++++++-- 3 files changed, 80 insertions(+), 13 deletions(-) diff --git a/scripts/site-releases.mjs b/scripts/site-releases.mjs index a8190b9..f84912a 100644 --- a/scripts/site-releases.mjs +++ b/scripts/site-releases.mjs @@ -7,12 +7,23 @@ * * GITHUB_REPOSITORY picks the repository (default Kkkermit/Statsify), and GITHUB_TOKEN, when set, * is sent so the request isn't held to the anonymous rate limit. Drafts are left out. + * + * The file is published with the website, so only what the page uses is written, and only once + * it has been checked: version tags, dates, whole-number sizes, text cut to a sane length, and + * links that lead to this repository on GitHub. Anything else is dropped. The page checks the + * file again when it reads it, and shows every part of it as text. */ import { mkdirSync, writeFileSync } from "node:fs"; import { dirname, resolve } from "node:path"; const repository = process.env.GITHUB_REPOSITORY || "Kkkermit/Statsify"; const output = resolve(process.argv[2] || "site/public/releases.json"); +const MAX_RESPONSE = 5_000_000; + +if (!/^[\w.-]+\/[\w.-]+$/.test(repository)) { + console.error(`GITHUB_REPOSITORY isn't owner/name: ${repository}`); + process.exit(1); +} const headers = { Accept: "application/vnd.github+json", @@ -29,18 +40,45 @@ if (!response.ok) { console.error(`GitHub answered ${response.status} ${response.statusText} for ${repository}'s releases.`); process.exit(1); } +const raw = await response.text(); +if (raw.length > MAX_RESPONSE) { + console.error(`GitHub's answer for ${repository}'s releases is larger than expected (${raw.length} bytes).`); + process.exit(1); +} + +/** A link to this repository on GitHub (its release pages and downloads), or nothing. */ +const repoLink = (value) => { + if (typeof value !== "string" || value.length > 500) return undefined; + const base = `https://github.com/${repository}/`.toLowerCase(); + return value.toLowerCase().startsWith(base) && !/[\s"'<>\\]/.test(value) ? value : undefined; +}; +const text = (value, max) => (typeof value === "string" ? value.slice(0, max) : ""); +const VERSION_TAG = /^v\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/; -const releases = (await response.json()) - .filter((r) => !r.draft) - .map((r) => ({ - tag: r.tag_name, - name: r.name, - date: r.published_at, - url: r.html_url, - prerelease: r.prerelease, - body: r.body ?? "", - assets: r.assets.map((a) => ({ name: a.name, size: a.size, url: a.browser_download_url })), - })); +const releases = []; +const data = JSON.parse(raw); +for (const r of Array.isArray(data) ? data : []) { + if (typeof r !== "object" || r === null || r.draft !== false) continue; + const tag = text(r.tag_name, 64); + const url = repoLink(r.html_url); + const time = Date.parse(r.published_at); + if (!VERSION_TAG.test(tag) || !url || Number.isNaN(time)) continue; + const assets = []; + for (const a of Array.isArray(r.assets) ? r.assets.slice(0, 50) : []) { + const link = repoLink(a?.browser_download_url); + if (!link || typeof a.name !== "string" || !Number.isSafeInteger(a.size) || a.size < 0) continue; + assets.push({ name: text(a.name, 200), size: a.size, url: link }); + } + releases.push({ + tag, + name: text(r.name, 200), + date: new Date(time).toISOString(), + url, + prerelease: r.prerelease === true, + body: text(r.body, 50_000), + assets, + }); +} mkdirSync(dirname(output), { recursive: true }); writeFileSync(output, `${JSON.stringify(releases, null, "\t")}\n`); diff --git a/site/releases.test.ts b/site/releases.test.ts index 90df02e..17e4819 100644 --- a/site/releases.test.ts +++ b/site/releases.test.ts @@ -199,6 +199,25 @@ describe("parseNotes", () => { ]); }); + it("leaves out lines in HTML comments, on one line or several", () => { + const notes = parseNotes( + [ + "", + "### Changes", + "* fix: a real change", + "", + "* fix: another real change", + "/g, "").split(/\r?\n/); - for (const raw of lines) { + let inComment = false; + for (const raw of body.split(/\r?\n/)) { const line = raw.trim(); + // Lines in HTML comments (GitHub adds one naming the notes' configuration) are left out + // whole. Nothing here is ever HTML: the page renders every part as text. + if (inComment) { + inComment = !line.includes("-->"); + continue; + } + if (line.startsWith(""); + continue; + } const heading = /^(#{1,4})\s+(.+)$/.exec(line); if (heading) { const title = heading[2].replace(/[*_`]/g, "").trim(); From 1dae7b7b192f0c83546b493fdc8084db704d36d3 Mon Sep 17 00:00:00 2001 From: Kkkermit <132657029+Kkkermit@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:19:33 +0000 Subject: [PATCH 3/3] refactor(site): releases from git, not GitHub's API; ask for a star and a coffee The website no longer calls GitHub's API at all. While it builds, every v* tag is a release and the pull requests squash-merged since the tag before it are its changes, grouped by their commit type like GitHub's notes, then bundled into the page (virtual:releases). Download links follow the file names release.yml gives. Nothing is fetched or written from the network, so there's no rate limit, no loading state and no release list file, and scripts/site-releases.mjs is gone. The Website workflow checks out the full history and tags; release.yml still starts it after each release. - Visitors are asked to star the repository (the header's button, a support box under the downloads, the footer and the FAQ) and to buy a coffee: in that box, and from a button in the corner that shows only while the first screen, the box and the footer are out of view. - Shorter, fewer comments; simpler tabs, copy buttons and search code; the file sizes and the loading skeleton go with the API. - Tests build with a fixture release list (SITE_RELEASES) into site/dist-test, and check the page without JavaScript, the star and coffee links and the corner button. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TCk6t7edJdscNtTSeFmyQN --- .github/workflows/ci.yml | 2 +- .github/workflows/pages.yml | 25 +-- .gitignore | 4 +- AGENTS.md | 21 +-- docs/DEVELOPMENT.md | 7 +- eslint.config.js | 2 +- package.json | 1 - scripts/site-releases.mjs | 85 --------- site/e2e/releases.json | 176 +++++-------------- site/e2e/site.spec.ts | 76 +++++--- site/env.d.ts | 8 + site/index.html | 42 ++++- site/main.ts | 333 +++++++++++++----------------------- site/playwright.config.ts | 8 +- site/releases.test.ts | 263 ++++++++-------------------- site/releases.ts | 322 ++++++++++++---------------------- site/styles.css | 138 +++++++-------- site/vite.config.ts | 82 +++++++-- tsconfig.site.json | 2 +- 19 files changed, 615 insertions(+), 982 deletions(-) delete mode 100644 scripts/site-releases.mjs create mode 100644 site/env.d.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 590bec5..d57c446 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,7 @@ jobs: # repository's settings in .github/ can't change what the end-to-end tests see; this # workflow can. The checks job always runs: it type-checks, lints and unit-tests the # website too, and one of its tests checks every file name, docs included. - code=$(grep -vE '\.md$|^docs/|^LICENSE$|^\.github/|^site/|^scripts/site-releases\.mjs$' <<< "$files" || true) + code=$(grep -vE '\.md$|^docs/|^LICENSE$|^\.github/|^site/' <<< "$files" || true) if [[ -z "$code" ]] && ! grep -qx '.github/workflows/ci.yml' <<< "$files"; then e2e=false; fi grep -qE '^src-tauri/|^\.github/workflows/ci\.yml$' <<< "$files" || rust=false fi diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 6a4323f..0ee9056 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,12 +1,9 @@ name: Website -# Builds the website in site/ (downloads, changelog, set-up guide, troubleshooting and FAQ), tests -# it, and publishes it on GitHub Pages. The page reads the releases from a list saved while it is -# built (scripts/site-releases.mjs), so it is built again whenever the site changes on main and -# after every release: release.yml starts this workflow once it has published one. Pull requests -# that change the site build and test it without publishing. -# -# One-time set-up: Settings → Pages → Source: GitHub Actions (docs/RELEASING.md). +# Builds, tests and publishes the website in site/ to GitHub Pages. Its releases and changelog come +# from the repository's version tags and the commits between them, so it is rebuilt when the site +# changes on main and after every release (release.yml starts it). Pull requests that change the +# site only build and test it. One-time set-up: Settings → Pages → Source: GitHub Actions. on: push: branches: [main] @@ -16,7 +13,6 @@ on: - "public/logo.svg" - "public/apple-touch-icon.png" - "docs/screenshots/**" - - "scripts/site-releases.mjs" - "package-lock.json" - ".github/workflows/pages.yml" pull_request: @@ -26,7 +22,6 @@ on: - "public/logo.svg" - "public/apple-touch-icon.png" - "docs/screenshots/**" - - "scripts/site-releases.mjs" - "package-lock.json" - ".github/workflows/pages.yml" workflow_dispatch: @@ -48,21 +43,16 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + # Every tag and the commits between them: they are the releases and their changes. + fetch-depth: 0 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version-file: .nvmrc cache: npm - run: npm ci - - name: Save the release list - env: - GITHUB_TOKEN: ${{ github.token }} - run: node scripts/site-releases.mjs - - run: npm run site:build - name: Install Playwright's browser run: npx playwright install --with-deps --only-shell chromium - - name: Test the website (axe accessibility, layout from phone to 4K, downloads, changelog) - env: - SITE_PREBUILT: "1" + - name: Test the website (axe, layout from phone to 4K, downloads, changelog) run: npm run site:test - name: Upload screenshots of failed tests if: failure() @@ -71,6 +61,7 @@ jobs: name: site-test-failures path: test-results/ retention-days: 7 + - run: npm run site:build - name: Package the website for Pages if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 diff --git a/.gitignore b/.gitignore index 92be8b6..366b4be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # Dependencies and build output (Rust build output: src-tauri/.gitignore) node_modules /dist/ -# The website's build, and the release list scripts/site-releases.mjs saves for it +# The website's build, and the build its tests use /site/dist/ -/site/public/releases.json +/site/dist-test/ *.tsbuildinfo # Tests and coverage diff --git a/AGENTS.md b/AGENTS.md index 19f322c..74625dc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -63,7 +63,6 @@ E2E_PORT=4801 npm run e2e # the same on another port (several runs on one machin npm run check # typecheck + lint + test + build npm run version:set -- 1.2.0 # set the version in all six places (--check 1.2.0, --print) npm run site:dev # the website (site/) on http://127.0.0.1:5174 -npm run site:releases # save the releases it shows to site/public/releases.json npm run site:build # the website -> site/dist/ (site:preview serves it on :4174) npm run site:test # the website's Playwright tests (builds it first) @@ -140,14 +139,16 @@ Tests sit next to the code they test (`*.test.ts` / `*.test.tsx`). checks the version in `package.json`, `package-lock.json`, `tauri.conf.json`, `Cargo.toml` and `Cargo.lock` (`npm run version:set`). - `site/`: the project's website, published by `pages.yml` at https://kkkermit.github.io/Statsify/. - Plain TypeScript and CSS built by its own Vite config (`site/vite.config.ts`, with a - `` CSP), no framework. `index.html` holds the content; `main.ts` adds the downloads and - changelog from `releases.json` (saved at build time by `scripts/site-releases.mjs`, so - visitors' browsers never call GitHub's API), the install tabs, copy buttons, help search and - the menu; `releases.ts` is the pure part (reading releases, picking each system's files, - parsing GitHub's generated notes), tested in `releases.test.ts`; `e2e/` has its Playwright - tests and a fixture release list. It uses the app's colours and font and follows the system's - light or dark mode. Keep its text in step with the README and the user guide. + Plain TypeScript and CSS built by its own Vite config (`site/vite.config.ts`, with a `` + CSP), no framework and no network calls. Its releases come from git while it builds: each + `v*` tag is a release, and the commit subjects since the tag before it (squash-merged pull + request titles) are its changes, bundled into the page as `virtual:releases`. Download links + follow the file names `release.yml` gives; keep `downloadsFor` in `releases.ts` in step with + it. `index.html` holds the content; `main.ts` adds the downloads, the changelog, install tabs, + copy buttons, the help search and the menu; `releases.ts` is the pure part, tested in + `releases.test.ts`; `e2e/` has its Playwright tests and the fixture release list they build + with (`SITE_RELEASES`). It uses the app's colours and font and follows the system's light or + dark mode. Keep its text in step with the README and the user guide. - `docs/GUIDE.md` user guide, `docs/DEVELOPMENT.md` developer set-up and debugging, `docs/DATABASE.md` the SQLite schema and binary format, `docs/RELEASING.md` the release process, `docs/screenshots/` README images. @@ -863,7 +864,7 @@ label)` (axe WCAG 2.2 A/AA, no serious or critical violations), `enterDemo`, `se actor); otherwise the release is left as a draft for an admin to publish. Pull requests that change it or the version script run a dry run, which calls `ci.yml` with `run: build` (the pull request's own CI run has the checks). - - `pages.yml` (**Website**): builds `site/` with the current release list, runs its tests + - `pages.yml` (**Website**): builds `site/` from the full git history and tags, runs its tests (`npm run site:test`: axe in both colour schemes, no sideways scroll from 320 px to 4K, the downloads per system, the changelog, tabs, search and the menu) and publishes it to GitHub Pages, on pushes to `main` that change the site and when `release.yml` starts it after a diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index c3699b3..e03be12 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -142,16 +142,15 @@ changelog, the set-up guide, troubleshooting and the FAQ. It's a separate static its own Vite config, and the **Website** workflow publishes it to GitHub Pages. ```bash -npm run site:releases # saves the release list it shows to site/public/releases.json npm run site:dev # http://127.0.0.1:5174 npm run site:build # builds into site/dist/ npm run site:preview # serves site/dist/ on http://127.0.0.1:4174 npm run site:test # its Playwright tests (they build it first) ``` -Without `site/public/releases.json` the page still works, and links to GitHub Releases where the -downloads and changelog would be. `site:releases` asks GitHub's API anonymously; set -`GITHUB_TOKEN` if you hit the rate limit. +The downloads and changelog come from the repository's version tags and the pull requests merged +between them, read with git while the site builds. A clone without tags shows links to GitHub +Releases instead: `git fetch --tags` fills them in. ### Ports and settings diff --git a/eslint.config.js b/eslint.config.js index 22ebe85..b84f739 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -6,7 +6,7 @@ import tseslint from "typescript-eslint"; export default tseslint.config( // .claude/worktrees: copies of the repo that coding agents work in. - { ignores: ["dist", "site/dist", "coverage", "src-tauri/target", "src-tauri/gen", "playwright-report", "test-results", ".claude"] }, + { ignores: ["dist", "site/dist", "site/dist-test", "coverage", "src-tauri/target", "src-tauri/gen", "playwright-report", "test-results", ".claude"] }, { extends: [js.configs.recommended, ...tseslint.configs.recommended], files: ["**/*.{ts,tsx}"], diff --git a/package.json b/package.json index 90fbd94..5ae8f80 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "site:dev": "vite --config site/vite.config.ts", "site:build": "vite build --config site/vite.config.ts", "site:preview": "vite preview --config site/vite.config.ts", - "site:releases": "node scripts/site-releases.mjs", "site:test": "playwright test --config site/playwright.config.ts", "tauri": "tauri", "desktop:dev": "tauri dev", diff --git a/scripts/site-releases.mjs b/scripts/site-releases.mjs deleted file mode 100644 index f84912a..0000000 --- a/scripts/site-releases.mjs +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env node -/** - * Saves the repository's releases for the website (site/), which shows its downloads and - * changelog from this file rather than asking GitHub's API from every visitor's browser. - * - * node scripts/site-releases.mjs [output] (default: site/public/releases.json) - * - * GITHUB_REPOSITORY picks the repository (default Kkkermit/Statsify), and GITHUB_TOKEN, when set, - * is sent so the request isn't held to the anonymous rate limit. Drafts are left out. - * - * The file is published with the website, so only what the page uses is written, and only once - * it has been checked: version tags, dates, whole-number sizes, text cut to a sane length, and - * links that lead to this repository on GitHub. Anything else is dropped. The page checks the - * file again when it reads it, and shows every part of it as text. - */ -import { mkdirSync, writeFileSync } from "node:fs"; -import { dirname, resolve } from "node:path"; - -const repository = process.env.GITHUB_REPOSITORY || "Kkkermit/Statsify"; -const output = resolve(process.argv[2] || "site/public/releases.json"); -const MAX_RESPONSE = 5_000_000; - -if (!/^[\w.-]+\/[\w.-]+$/.test(repository)) { - console.error(`GITHUB_REPOSITORY isn't owner/name: ${repository}`); - process.exit(1); -} - -const headers = { - Accept: "application/vnd.github+json", - "User-Agent": "statsify-site", - "X-GitHub-Api-Version": "2022-11-28", -}; -if (process.env.GITHUB_TOKEN) headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`; - -const response = await fetch(`https://api.github.com/repos/${repository}/releases?per_page=20`, { - headers, - signal: AbortSignal.timeout(30_000), -}); -if (!response.ok) { - console.error(`GitHub answered ${response.status} ${response.statusText} for ${repository}'s releases.`); - process.exit(1); -} -const raw = await response.text(); -if (raw.length > MAX_RESPONSE) { - console.error(`GitHub's answer for ${repository}'s releases is larger than expected (${raw.length} bytes).`); - process.exit(1); -} - -/** A link to this repository on GitHub (its release pages and downloads), or nothing. */ -const repoLink = (value) => { - if (typeof value !== "string" || value.length > 500) return undefined; - const base = `https://github.com/${repository}/`.toLowerCase(); - return value.toLowerCase().startsWith(base) && !/[\s"'<>\\]/.test(value) ? value : undefined; -}; -const text = (value, max) => (typeof value === "string" ? value.slice(0, max) : ""); -const VERSION_TAG = /^v\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/; - -const releases = []; -const data = JSON.parse(raw); -for (const r of Array.isArray(data) ? data : []) { - if (typeof r !== "object" || r === null || r.draft !== false) continue; - const tag = text(r.tag_name, 64); - const url = repoLink(r.html_url); - const time = Date.parse(r.published_at); - if (!VERSION_TAG.test(tag) || !url || Number.isNaN(time)) continue; - const assets = []; - for (const a of Array.isArray(r.assets) ? r.assets.slice(0, 50) : []) { - const link = repoLink(a?.browser_download_url); - if (!link || typeof a.name !== "string" || !Number.isSafeInteger(a.size) || a.size < 0) continue; - assets.push({ name: text(a.name, 200), size: a.size, url: link }); - } - releases.push({ - tag, - name: text(r.name, 200), - date: new Date(time).toISOString(), - url, - prerelease: r.prerelease === true, - body: text(r.body, 50_000), - assets, - }); -} - -mkdirSync(dirname(output), { recursive: true }); -writeFileSync(output, `${JSON.stringify(releases, null, "\t")}\n`); -console.log(`Saved ${releases.length} releases of ${repository} to ${output}.`); diff --git a/site/e2e/releases.json b/site/e2e/releases.json index cd6dea2..512405f 100644 --- a/site/e2e/releases.json +++ b/site/e2e/releases.json @@ -1,147 +1,59 @@ [ { - "tag": "v1.3.0-beta.1", - "name": "Statsify 1.3.0-beta.1", - "date": "2026-12-10T09:00:00Z", - "url": "https://github.com/Kkkermit/Statsify/releases/tag/v1.3.0-beta.1", + "version": "1.3.0-beta.1", + "date": "2026-12-10T09:00:00.000Z", "prerelease": true, - "body": "## What's Changed\n### New features\n* feat: a year in review by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/30\n", - "assets": [ - { - "name": "SHA256SUMS.txt", - "size": 659, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/SHA256SUMS.txt" - }, - { - "name": "Statsify_1.3.0-beta.1_amd64.AppImage", - "size": 82115064, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_amd64.AppImage" - }, - { - "name": "Statsify_1.3.0-beta.1_amd64.deb", - "size": 3504044, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_amd64.deb" - }, - { - "name": "Statsify_1.3.0-beta.1_universal.dmg", - "size": 6710528, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_universal.dmg" - }, - { - "name": "Statsify_1.3.0-beta.1_web.zip", - "size": 584051, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_web.zip" - }, - { - "name": "Statsify_1.3.0-beta.1_x64-portable.exe", - "size": 5309440, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_x64-portable.exe" - }, - { - "name": "Statsify_1.3.0-beta.1_x64-setup.exe", - "size": 2431234, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.3.0-beta.1/Statsify_1.3.0-beta.1_x64-setup.exe" + "previous": "1.2.0", + "groups": [ + { + "title": "New features", + "changes": [ + { + "text": "A year in review", + "pr": 30 + } + ] } ] }, { - "tag": "v1.2.0", - "name": "Statsify 1.2.0", - "date": "2026-12-03T12:37:44Z", - "url": "https://github.com/Kkkermit/Statsify/releases/tag/v1.2.0", + "version": "1.2.0", + "date": "2026-12-03T12:37:44.000Z", "prerelease": false, - "body": "## Download\n\n| System | File |\n| --- | --- |\n| Windows | `Statsify_1.2.0_x64-setup.exe` |\n\n\n\n## What's Changed\n### New features\n* feat(lyrics): lyrics that follow the song word by word by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/21\n* feat: an `All time` range on Streams by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/22\n### Bug fixes\n* fix(desktop): the tray icon on Linux by @Kkkermit in https://github.com/Kkkermit/Statsify/pull/23\n\n**Full Changelog**: https://github.com/Kkkermit/Statsify/compare/v1.1.0...v1.2.0", - "assets": [ - { - "name": "SHA256SUMS.txt", - "size": 659, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/SHA256SUMS.txt" - }, - { - "name": "Statsify_1.2.0_amd64.AppImage", - "size": 82115064, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_amd64.AppImage" - }, - { - "name": "Statsify_1.2.0_amd64.deb", - "size": 3504044, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_amd64.deb" - }, - { - "name": "Statsify_1.2.0_universal.dmg", - "size": 6710528, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_universal.dmg" - }, - { - "name": "Statsify_1.2.0_web.zip", - "size": 584051, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_web.zip" - }, - { - "name": "Statsify_1.2.0_x64-portable.exe", - "size": 5309440, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_x64-portable.exe" - }, - { - "name": "Statsify_1.2.0_x64-setup.exe", - "size": 2431234, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_x64-setup.exe" - }, - { - "name": "Statsify_1.2.0_x64_en-US.msi", - "size": 3129344, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_x64_en-US.msi" + "previous": "1.1.0", + "groups": [ + { + "title": "New features", + "changes": [ + { + "text": "Lyrics that follow the song word by word", + "pr": 21 + }, + { + "text": "An `All time` range on Streams", + "pr": 22 + } + ] + }, + { + "title": "Bug fixes", + "changes": [ + { + "text": "The tray icon on Linux", + "pr": 23 + }, + { + "text": " in a title", + "pr": 24 + } + ] } ] }, { - "tag": "v1.1.0", - "name": "Statsify 1.1.0", - "date": "2026-11-20T10:00:00Z", - "url": "https://github.com/Kkkermit/Statsify/releases/tag/v1.1.0", + "version": "1.1.0", + "date": "2026-11-20T10:00:00.000Z", "prerelease": false, - "body": "", - "assets": [ - { - "name": "SHA256SUMS.txt", - "size": 659, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/SHA256SUMS.txt" - }, - { - "name": "Statsify_1.1.0_amd64.AppImage", - "size": 82115064, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_amd64.AppImage" - }, - { - "name": "Statsify_1.1.0_amd64.deb", - "size": 3504044, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_amd64.deb" - }, - { - "name": "Statsify_1.1.0_universal.dmg", - "size": 6710528, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_universal.dmg" - }, - { - "name": "Statsify_1.1.0_web.zip", - "size": 584051, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_web.zip" - }, - { - "name": "Statsify_1.1.0_x64-portable.exe", - "size": 5309440, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_x64-portable.exe" - }, - { - "name": "Statsify_1.1.0_x64-setup.exe", - "size": 2431234, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_x64-setup.exe" - }, - { - "name": "Statsify_1.1.0_x64_en-US.msi", - "size": 3129344, - "url": "https://github.com/Kkkermit/Statsify/releases/download/v1.1.0/Statsify_1.1.0_x64_en-US.msi" - } - ] + "groups": [] } ] diff --git a/site/e2e/site.spec.ts b/site/e2e/site.spec.ts index 12c2cd3..5d1c154 100644 --- a/site/e2e/site.spec.ts +++ b/site/e2e/site.spec.ts @@ -1,25 +1,18 @@ -import { readFileSync } from "node:fs"; import AxeBuilder from "@axe-core/playwright"; import { expect, test, type Page } from "@playwright/test"; -const RELEASES = readFileSync(new URL("./releases.json", import.meta.url), "utf8"); const WCAG_TAGS = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]; const MAC = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15"; const LINUX = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"; -/** Answers releases.json from the fixture, and fails the test on any page or console error. */ -async function open(page: Page, releases: string | null = RELEASES): Promise { +/** Opens the page and collects its errors (the build's releases come from e2e/releases.json). */ +async function open(page: Page): Promise { const errors: string[] = []; page.on("pageerror", (e) => errors.push(e.message)); page.on("console", (m) => { if (m.type() === "error") errors.push(m.text()); }); - await page.route("**/releases.json", (route) => - releases === null - ? route.fulfill({ status: 404, body: "Not found" }) - : route.fulfill({ contentType: "application/json", body: releases }), - ); await page.goto("/"); return errors; } @@ -72,12 +65,12 @@ test.describe("downloads", () => { await open(page); const hero = page.getByRole("link", { name: "Download for Windows" }); await expect(hero).toHaveAttribute("href", /\/v1\.2\.0\/Statsify_1\.2\.0_x64-setup\.exe$/); - await expect(page.getByText("Version 1.2.0 for Windows 10 and 11, 2.4 MB", { exact: true })).toBeVisible(); + await expect(page.getByText("Version 1.2.0 for Windows 10 and 11", { exact: true })).toBeVisible(); const windows = page.getByRole("region", { name: "Windows" }); await expect(windows.getByText("Your system")).toBeVisible(); const files = windows.getByRole("link", { name: /^Download/ }); await expect(files).toHaveCount(3); - await expect(files.nth(0)).toHaveAccessibleName("Download Installer for Windows (.exe, 2.4 MB)"); + await expect(files.nth(0)).toHaveAccessibleName("Download Installer for Windows (.exe)"); await expect(files.nth(0)).toHaveClass(/button-primary/); await expect(files.nth(1)).toHaveAccessibleName(/^Download MSI package/); await expect(files.nth(2)).toHaveAccessibleName(/^Download Portable/); @@ -127,17 +120,47 @@ test.describe("downloads", () => { ); }); - test("fall back to GitHub when the release list can't be loaded", async ({ page }) => { - const errors = await open(page, null); - await expect(page.getByText("The release notes couldn't be loaded here.")).toBeVisible(); + test("ask for a star on GitHub", async ({ page }) => { + await open(page); + await expect(page.getByRole("link", { name: "Star Statsify on GitHub" })).toHaveAttribute( + "href", + "https://github.com/Kkkermit/Statsify", + ); + await expect(page.getByRole("banner").getByRole("link", { name: "Star on GitHub" })).toBeVisible(); + await expect(page.locator("[data-support]").getByRole("link", { name: "Buy me a coffee" })).toHaveAttribute( + "href", + "https://buymeacoffee.com/Kkermit", + ); + }); + + test("offer a coffee from the corner while reading, out of the way of the first screen and the support box", async ({ + page, + }) => { + await page.emulateMedia({ reducedMotion: "reduce" }); + await open(page); + const corner = page.locator("[data-coffee]"); + await expect(corner).toBeHidden(); + await page.evaluate(() => document.getElementById("features")?.scrollIntoView()); + await expect(corner).toBeVisible(); + await expect(corner).toHaveAccessibleName("Buy me a coffee"); + await page.locator("[data-support]").scrollIntoViewIfNeeded(); + await expect(corner).toBeHidden(); + }); +}); + +test.describe("without JavaScript", () => { + test.use({ javaScriptEnabled: false }); + test("every section reads, and downloads lead to GitHub Releases", async ({ page }) => { + await page.goto("/"); const windows = page.getByRole("region", { name: "Windows" }); await expect(windows.getByRole("link", { name: "Open Releases" })).toHaveAttribute( "href", "https://github.com/Kkkermit/Statsify/releases/latest", ); - await expect(page.getByRole("link", { name: "Download for Windows" })).toHaveCount(0); - // The 404 itself is the only error. - expect(errors.filter((e) => !e.includes("404"))).toEqual([]); + await expect(page.getByText("The release notes are on")).toBeVisible(); + for (const panel of ["Windows protected your PC", "Privacy & Security", "sudo apt install"]) { + await expect(page.locator(".tab-panel", { hasText: panel })).toBeVisible(); + } }); }); @@ -163,18 +186,17 @@ test.describe("what's new", () => { "href", /compare\/v1\.1\.0\.\.\.v1\.2\.0$/, ); - await expect(releases.nth(2)).toContainText("No notes for this release"); + await releases.nth(2).locator("summary").click(); + await expect(releases.nth(2)).toContainText("The first release"); + await expect(releases.nth(2).getByRole("link", { name: "Every commit" })).toHaveCount(0); }); - test("shows release notes as text, never as markup", async ({ page }) => { - const hostile = JSON.parse(RELEASES) as { body: string }[]; - hostile[0].body = - '* [link](javascript:alert(1)) by @x in https://evil.example/pull/1'; - await open(page, JSON.stringify(hostile)); - const first = page.locator(".release").first(); - await expect(first.getByRole("listitem")).toContainText(''); - await expect(first.locator("img")).toHaveCount(0); - await expect(first.locator('a[href^="javascript:"]')).toHaveCount(0); + test("shows change titles as text, never as markup", async ({ page }) => { + await open(page); + const latest = page.locator(".release").nth(1); + await latest.locator("summary").click(); + await expect(latest.getByRole("listitem").last()).toContainText(' in a title'); + await expect(latest.locator("img")).toHaveCount(0); expect(await page.evaluate(() => "pwned" in window)).toBe(false); }); }); diff --git a/site/env.d.ts b/site/env.d.ts new file mode 100644 index 0000000..961dc56 --- /dev/null +++ b/site/env.d.ts @@ -0,0 +1,8 @@ +/// + +declare module "virtual:releases" { + import type { Release } from "./releases"; + + const releases: Release[]; + export default releases; +} diff --git a/site/index.html b/site/index.html index d7a69fc..841d83a 100644 --- a/site/index.html +++ b/site/index.html @@ -19,7 +19,7 @@ /> - + @@ -49,6 +49,17 @@ + + + + + + + + + @@ -83,7 +94,7 @@ - GitHub + Star on GitHub @@ -349,6 +360,22 @@

Web

+
+

+ Thank you for checking out Statsify. It's free and open source, so if you like it, give it a star on + GitHub to help other people find it, or buy me a coffee. +

+ +
@@ -882,7 +909,8 @@

FAQ

Yes. It's open source under the Apache-2.0 licence, with no ads and no subscription. If you'd like to - support it, you can buy me a coffee. + support it, star it on GitHub or + buy me a coffee.

@@ -999,7 +1027,8 @@

FAQ