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..d57c446 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/' <<< "$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..0ee9056 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,85 @@ +name: Website + +# 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] + paths: + - "site/**" + - "public/favicon.svg" + - "public/logo.svg" + - "public/apple-touch-icon.png" + - "docs/screenshots/**" + - "package-lock.json" + - ".github/workflows/pages.yml" + pull_request: + paths: + - "site/**" + - "public/favicon.svg" + - "public/logo.svg" + - "public/apple-touch-icon.png" + - "docs/screenshots/**" + - "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 + # 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: Install Playwright's browser + run: npx playwright install --with-deps --only-shell chromium + - 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() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + 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 + 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..366b4be 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 build its tests use +/site/dist/ +/site/dist-test/ *.tsbuildinfo # Tests and coverage diff --git a/AGENTS.md b/AGENTS.md index 81e7dba..74625dc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -62,6 +62,9 @@ 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: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 +73,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 +82,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 +138,17 @@ 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 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. @@ -848,6 +864,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/` 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 + 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..e03be12 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -135,6 +135,23 @@ 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: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) +``` + +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 The ports are fixed (`strictPort`), because Spotify needs the exact redirect address. If one is @@ -144,6 +161,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 +274,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 +290,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..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", "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}"], @@ -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..5ae8f80 100644 --- a/package.json +++ b/package.json @@ -33,13 +33,17 @@ "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:test": "playwright test --config site/playwright.config.ts", "tauri": "tauri", "desktop:dev": "tauri dev", "desktop:build": "tauri build" diff --git a/site/e2e/releases.json b/site/e2e/releases.json new file mode 100644 index 0000000..512405f --- /dev/null +++ b/site/e2e/releases.json @@ -0,0 +1,59 @@ +[ + { + "version": "1.3.0-beta.1", + "date": "2026-12-10T09:00:00.000Z", + "prerelease": true, + "previous": "1.2.0", + "groups": [ + { + "title": "New features", + "changes": [ + { + "text": "A year in review", + "pr": 30 + } + ] + } + ] + }, + { + "version": "1.2.0", + "date": "2026-12-03T12:37:44.000Z", + "prerelease": false, + "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 + } + ] + } + ] + }, + { + "version": "1.1.0", + "date": "2026-11-20T10:00:00.000Z", + "prerelease": false, + "groups": [] + } +] diff --git a/site/e2e/site.spec.ts b/site/e2e/site.spec.ts new file mode 100644 index 0000000..5d1c154 --- /dev/null +++ b/site/e2e/site.spec.ts @@ -0,0 +1,298 @@ +import AxeBuilder from "@axe-core/playwright"; +import { expect, test, type Page } from "@playwright/test"; + +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"; + +/** 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.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", { 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)"); + 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("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.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(); + } + }); +}); + +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 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 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); + }); +}); + +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/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 new file mode 100644 index 0000000..841d83a --- /dev/null +++ b/site/index.html @@ -0,0 +1,1054 @@ + + + + + + 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
+
+
+
+
+
+
+

+ 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. +

+ +
+
+
+ +
+
+
+

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, star it on GitHub or + 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. +

+
+
+
+
+
+
+ + + + + + Buy me a coffee + + +

+ + diff --git a/site/main.ts b/site/main.ts new file mode 100644 index 0000000..cb8ecb0 --- /dev/null +++ b/site/main.ts @@ -0,0 +1,363 @@ +import releases from "virtual:releases"; +import "./styles.css"; +import { + checksumsUrl, + codeSpans, + compareUrl, + detectSystem, + downloadsFor, + formatDate, + latestRelease, + pullUrl, + releaseUrl, + REPOSITORY, + type Download, + type Platform, + type Release, + type System, +} from "./releases"; + +const SYSTEM_NAMES: Record = { windows: "Windows", macos: "macOS", linux: "Linux", web: "the web" }; + +function el( + tag: K, + className = "", + ...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 = ""): HTMLAnchorElement { + const a = el("a", className, text); + a.href = href; + return a; +} + +function icon(name: string, className = "icon"): SVGSVGElement { + const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + svg.setAttribute("class", className); + svg.setAttribute("aria-hidden", "true"); + const use = document.createElementNS("http://www.w3.org/2000/svg", "use"); + use.setAttribute("href", `#i-${name}`); + svg.append(use); + return svg; +} + +const announcer = document.querySelector("[data-announcer]"); +function announce(message: string): void { + if (!announcer) return; + // Emptied first, so the same message twice is read out twice. + announcer.textContent = ""; + 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 */ + +function fileRow(download: Download, platform: Platform, primary: boolean): HTMLLIElement { + const type = download.file.slice(download.file.lastIndexOf(".")); + const name = el("span", "", el("strong", "", download.label)); + // "AppImage" already says what it is. + if (!download.label.toLowerCase().includes(type.slice(1).toLowerCase())) name.append(el("span", "file-ext", type)); + const button = link( + "Download", + download.url, + `button button-small ${primary ? "button-primary" : "button-secondary"}`, + ); + button.setAttribute("aria-label", `Download ${download.label} for ${SYSTEM_NAMES[platform]} (${type})`); + return el("li", "file", el("span", "file-name", name, el("span", "file-detail", download.detail)), button); +} + +function showDownloads(release: Release | undefined, system: System): void { + document.querySelector(`[data-platform="${system}"] .your-system`)?.removeAttribute("hidden"); + if (system === "mobile") document.querySelector("[data-mobile-note]")?.removeAttribute("hidden"); + if (!release) return; + + const { version } = release; + const files = downloadsFor(release); + for (const box of document.querySelectorAll("[data-files]")) { + const platform = box.dataset.files as Platform; + box.replaceChildren(...files[platform].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", `${REPOSITORY}/releases`), + ".", + ); + document.querySelector("[data-checksums]")?.setAttribute("href", checksumsUrl(version)); + + const hero = document.querySelector("[data-hero-download]"); + const meta = document.querySelector("[data-hero-meta]"); + if (!hero || !meta) return; + if (system === "windows" || system === "macos") { + hero.href = files[system][0].url; + hero.textContent = `Download for ${SYSTEM_NAMES[system]}`; + meta.textContent = + system === "windows" + ? `Version ${version} for Windows 10 and 11` + : `Version ${version} for Apple silicon and Intel Macs`; + } else if (system === "linux") { + // Two formats to choose from, so the button leads to the choice rather than a file. + 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 releaseCard(release: Release, open: boolean, latest: boolean): HTMLDetailsElement { + const count = release.groups.reduce((sum, g) => sum + g.changes.length, 0); + const title = el("span", "release-title", el("h3", "", release.version)); + 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", "icon chevron"), + ); + + const body = el("div", "release-body"); + for (const group of release.groups) { + const list = el("ul", "changes"); + for (const change of group.changes) { + const item = el("li", "", ...codeSpans(change.text).map((p) => (p.code ? el("code", "", p.text) : p.text))); + if (change.pr) { + const pr = link(`#${change.pr}`, pullUrl(change.pr), "pr"); + pr.setAttribute("aria-label", `Pull request ${change.pr}`); + item.append(" ", pr); + } + list.append(item); + } + body.append(el("h4", "change-group", group.title), list); + } + if (!release.previous) body.append(el("p", "placeholder", "The first release")); + + const links = el("p", "release-links", link("Downloads and full notes", releaseUrl(release.version))); + if (release.previous) links.append(link("Every commit", compareUrl(release.previous, release.version))); + body.append(links); + + const card = el("details", "release", summary, body); + card.open = open; + return card; +} + +function showChangelog(): void { + if (!releases.length) return; + const latest = latestRelease(releases); + document + .querySelector("[data-changelog]") + ?.replaceChildren(...releases.map((r, i) => releaseCard(r, i === 0, r === latest))); +} + +/* Header and menu */ + +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 isOpen = () => header.classList.contains("is-open"); + 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(!isOpen())); + nav.addEventListener("click", (event) => { + if ((event.target as Element).closest("a")) setOpen(false); + }); + document.addEventListener("keydown", (event) => { + if (event.key === "Escape" && isOpen()) setOpen(false, true); + }); + document.addEventListener("click", (event) => { + if (isOpen() && !header.contains(event.target as Node)) setOpen(false); + }); + // Tabbing out of the menu closes it, so it never covers what comes next. + header.addEventListener("focusout", (event) => { + if (isOpen() && !header.contains(event.relatedTarget as Node | null)) setOpen(false); + }); + matchMedia("(min-width: 64rem)").addEventListener("change", () => setOpen(false)); + + // The section being read is marked in the navigation. + const links = new Map([...nav.querySelectorAll('a[href^="#"]')].map((a) => [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); + } + 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(); + }; + const keys: Record number> = { + ArrowRight: (i) => (i + 1) % tabs.length, + ArrowLeft: (i) => (i - 1 + tabs.length) % tabs.length, + Home: () => 0, + End: () => tabs.length - 1, + }; + 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); + const move = keys[event.key]; + if (index < 0 || !move) return; + event.preventDefault(); + select(tabs[move(index)], 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 text = block.querySelector("code")?.textContent ?? ""; + const name = text.startsWith("http") ? "Copy address" : "Copy command"; + const label = el("span", "", "Copy"); + const button = el("button", "copy", icon("copy"), label); + button.type = "button"; + button.setAttribute("aria-label", name); + const show = (done: boolean) => { + button.classList.toggle("is-done", done); + button.replaceChildren(icon(done ? "check" : "copy"), label); + label.textContent = done ? "Copied" : "Copy"; + button.setAttribute("aria-label", done ? "Copied" : 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; + } + show(true); + announce("Copied"); + clearTimeout(timer); + timer = window.setTimeout(() => show(false), 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(); + + const run = () => { + const words = input.value.toLowerCase().trim().split(/\s+/).filter(Boolean); + const matches = items.filter(({ item, text }) => { + item.hidden = !words.every((w) => text.includes(w)); + return !item.hidden; + }); + for (const group of groups) group.hidden = !group.querySelector(".qa:not([hidden])"); + for (const item of opened) item.open = false; + opened.clear(); + empty.hidden = !words.length || matches.length > 0; + status.textContent = !words.length ? "" : matches.length === 1 ? "1 answer" : `${matches.length} answers`; + // A few matches open by themselves, so the answer is right there. + if (words.length && matches.length <= 3) { + for (const { item } of matches) { + if (item.open) continue; + item.open = true; + opened.add(item); + } + } + }; + let timer = 0; + input.addEventListener("input", () => { + clearTimeout(timer); + timer = window.setTimeout(run, 120); + }); +} + +/* Buy me a coffee, in the corner: shown while the hero, the support box and the footer are all out of view */ + +function setupCoffee(): void { + const coffee = document.querySelector("[data-coffee]"); + const blockers = [".hero", "[data-support]", ".site-footer"].flatMap((s) => [...document.querySelectorAll(s)]); + if (!coffee || !blockers.length) return; + const inView = new Set(); + const observer = new IntersectionObserver((entries) => { + for (const entry of entries) { + if (entry.isIntersecting) inView.add(entry.target); + else inView.delete(entry.target); + } + coffee.classList.toggle("is-shown", inView.size === 0); + }); + blockers.forEach((b) => observer.observe(b)); +} + +const system = currentSystem(); +setupHeader(); +setupTabs(system); +setupCopy(); +setupSearch(); +setupCoffee(); +showDownloads(latestRelease(releases), system); +showChangelog(); diff --git a/site/playwright.config.ts b/site/playwright.config.ts new file mode 100644 index 0000000..d54ef31 --- /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`). They build it with a fixture release list + * (e2e/releases.json) into site/dist-test, so they never depend on the repository's real tags. + */ +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: `npx vite build --config site/vite.config.ts --outDir dist-test && npx vite preview --config site/vite.config.ts --outDir dist-test --port ${port}`, + cwd: "..", + env: { SITE_RELEASES: "site/e2e/releases.json" }, + 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..8699191 --- /dev/null +++ b/site/releases.test.ts @@ -0,0 +1,150 @@ +import { describe, expect, it } from "vitest"; +import { + codeSpans, + detectSystem, + downloadsFor, + formatDate, + groupChanges, + latestRelease, + parseTags, + tidyTitle, + type Release, +} from "./releases"; + +const release = (version: string, extra: Partial = {}): Release => ({ + version, + date: "2026-12-03T12:32:33.000Z", + prerelease: version.includes("-"), + groups: [], + ...extra, +}); + +describe("parseTags", () => { + it("reads version tags and their dates as git lists them", () => { + const output = [ + "v1.3.0-beta.1 2026-12-10T09:00:00+01:00", + "v1.2.0 2026-12-03T12:32:33+00:00", + "latest 2026-12-01T00:00:00+00:00", + "v1.1 2026-11-01T00:00:00+00:00", + "v1.0.0 not-a-date", + "", + ].join("\n"); + expect(parseTags(output)).toEqual([ + { version: "1.3.0-beta.1", date: "2026-12-10T08:00:00.000Z" }, + { version: "1.2.0", date: "2026-12-03T12:32:33.000Z" }, + ]); + }); +}); + +describe("groupChanges", () => { + it("groups merged pull requests by their commit type, like the release notes", () => { + expect( + groupChanges([ + "feat: Statsify 1.2.0: faster CI, open-source docs and a hardened Rust shell (#21)", + "fix(deps): move to Tauri 2.13, off the unsound glib 0.18 (alert #198) (#20)", + "chore(deps-dev): Bump cross-spawn from 7.0.6 to 7.1.2 (#18)", + "build: Statsify 1.1.1 on Node 26 LTS (#19)", + "feat(lyrics)!: word-by-word `LRC` timing", + "chore(release): 1.2.0", + "Update README.md", + ]), + ).toEqual([ + { + title: "New features", + changes: [ + { text: "Faster CI, open-source docs and a hardened Rust shell", pr: 21 }, + { text: "Word-by-word `LRC` timing" }, + ], + }, + { title: "Bug fixes", changes: [{ text: "Move to Tauri 2.13, off the unsound glib 0.18 (alert #198)", pr: 20 }] }, + { title: "Dependencies", changes: [{ text: "Bump cross-spawn from 7.0.6 to 7.1.2", pr: 18 }] }, + { + title: "Other changes", + changes: [{ text: "Statsify 1.1.1 on Node 26 LTS", pr: 19 }, { text: "Update README.md" }], + }, + ]); + }); + + it("has no groups without changes", () => { + expect(groupChanges([])).toEqual([]); + expect(groupChanges(["chore(release): 1.3.0"])).toEqual([]); + }); +}); + +describe("tidyTitle", () => { + it("drops a version the title repeats, and starts with a capital", () => { + expect(tidyTitle("Statsify 2.0.0-rc.1: a new look")).toBe("A new look"); + expect(tidyTitle("statsify 1.1.1 on Node 26 LTS")).toBe("Statsify 1.1.1 on Node 26 LTS"); + expect(tidyTitle("lyrics: a synced view")).toBe("Lyrics: a synced view"); + }); +}); + +describe("latestRelease", () => { + it("skips pre-releases", () => { + expect(latestRelease([release("1.3.0-beta.1"), release("1.2.0")])?.version).toBe("1.2.0"); + expect(latestRelease([release("1.3.0-beta.1")])).toBeUndefined(); + }); +}); + +describe("downloadsFor", () => { + it("names each system's files as the release workflow does, the recommended one first", () => { + const files = downloadsFor(release("1.2.0")); + expect(files.windows.map((d) => d.file)).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].url).toBe( + "https://github.com/Kkkermit/Statsify/releases/download/v1.2.0/Statsify_1.2.0_x64-setup.exe", + ); + expect(files.macos.map((d) => d.file)).toEqual(["Statsify_1.2.0_universal.dmg"]); + expect(files.linux.map((d) => d.label)).toEqual(["Debian package", "AppImage"]); + expect(files.web.map((d) => d.file)).toEqual(["Statsify_1.2.0_web.zip"]); + }); + + it("has no MSI for a pre-release", () => { + expect(downloadsFor(release("1.3.0-beta.1")).windows.map((d) => d.label)).toEqual(["Installer", "Portable"]); + }); +}); + +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("goes by the platform the browser reports", () => { + expect(detectSystem("Mozilla/5.0", "Windows")).toBe("windows"); + expect(detectSystem("Mozilla/5.0", "macOS")).toBe("macos"); + }); +}); + +describe("formatting", () => { + 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"); + }); + + it("splits `code` out of a change's text", () => { + expect(codeSpans("Use `npm ci`, not `npm i`")).toEqual([ + { text: "Use ", code: false }, + { text: "npm ci", code: true }, + { text: ", not ", code: false }, + { text: "npm i", code: true }, + ]); + expect(codeSpans("")).toEqual([{ text: "", code: false }]); + }); +}); diff --git a/site/releases.ts b/site/releases.ts new file mode 100644 index 0000000..7c86ea8 --- /dev/null +++ b/site/releases.ts @@ -0,0 +1,156 @@ +/** + * The website's releases, worked out from the repository's own git history while the site builds + * (site/vite.config.ts): every version tag is a release, and the pull requests merged since the tag + * before it are its changes. Pure functions, shared by the build and the page. + */ + +export const REPOSITORY = "https://github.com/Kkkermit/Statsify"; + +export interface Change { + text: string; + pr?: number; +} + +export interface ChangeGroup { + title: string; + changes: Change[]; +} + +export interface Release { + version: string; + date: string; + prerelease: boolean; + /** The release its changes are counted from; none for the first. */ + previous?: string; + groups: ChangeGroup[]; +} + +export type System = "windows" | "macos" | "linux" | "mobile" | "unknown"; +export type Platform = "windows" | "macos" | "linux" | "web"; + +export interface Download { + label: string; + detail: string; + file: string; + url: string; +} + +const VERSION_TAG = /^v(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/; + +/** Version tags, one "v1.2.0 2026-12-03T12:32:33+00:00" per line as git lists them, in that order. */ +export function parseTags(output: string): { version: string; date: string }[] { + const tags = []; + for (const line of output.split("\n")) { + const [tag = "", date = ""] = line.trim().split(" "); + const version = VERSION_TAG.exec(tag)?.[1]; + if (version && !Number.isNaN(Date.parse(date))) tags.push({ version, date: new Date(date).toISOString() }); + } + return tags; +} + +const COMMIT = /^(\w+)(?:\(([^)]*)\))?!?:\s*(.+)$/; +const GROUPS = ["New features", "Bug fixes", "Performance", "Documentation", "Dependencies", "Other changes"]; + +function groupOf(type: string, scope: string): string | undefined { + if (type === "chore" && scope === "release") return undefined; + if (type === "feat") return "New features"; + if (type === "fix") return "Bug fixes"; + if (type === "perf") return "Performance"; + if (type === "docs") return "Documentation"; + if (scope.startsWith("deps")) return "Dependencies"; + return "Other changes"; +} + +/** + * A change's title as people read it: without the commit type or a version the release's pull + * request repeats ("feat: Statsify 1.2.0: faster CI" is "Faster CI"). + */ +export function tidyTitle(title: string): string { + const text = title.replace(/^Statsify \d+\.\d+\.\d+(-[\w.]+)?:\s*/i, "").trim(); + return text.charAt(0).toUpperCase() + text.slice(1); +} + +/** + * Commit subjects ("fix(deps): move to Tauri 2.13 (#20)") grouped like GitHub's release notes, + * by their Conventional Commits type. Version bumps (`chore(release)`) are left out. + */ +export function groupChanges(subjects: string[]): ChangeGroup[] { + const groups = new Map(); + for (const subject of subjects) { + const pr = /\s*\(#(\d+)\)$/.exec(subject); + const title = pr ? subject.slice(0, pr.index) : subject; + const commit = COMMIT.exec(title); + const group = commit ? groupOf(commit[1].toLowerCase(), commit[2]?.toLowerCase() ?? "") : "Other changes"; + const text = tidyTitle(commit ? commit[3] : title); + if (!group || !text) continue; + const change: Change = pr ? { text, pr: Number(pr[1]) } : { text }; + groups.set(group, [...(groups.get(group) ?? []), change]); + } + return GROUPS.filter((title) => groups.has(title)).map((title) => ({ title, changes: groups.get(title) ?? [] })); +} + +/** 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); +} + +export const releaseUrl = (version: string) => `${REPOSITORY}/releases/tag/v${version}`; +export const compareUrl = (from: string, to: string) => `${REPOSITORY}/compare/v${from}...v${to}`; +export const pullUrl = (pr: number) => `${REPOSITORY}/pull/${pr}`; +const fileUrl = (version: string, file: string) => `${REPOSITORY}/releases/download/v${version}/${file}`; + +/** + * Each system's files in a release, the recommended one first. The names are the ones + * .github/workflows/release.yml gives them; keep the two in step. + */ +export function downloadsFor(release: Release): Record { + const v = release.version; + const file = (label: string, detail: string, name: string): Download => ({ + label, + detail, + file: name, + url: fileUrl(v, name), + }); + return { + windows: [ + file("Installer", "Installs for you only, no admin needed", `Statsify_${v}_x64-setup.exe`), + // Windows Installer only takes numeric versions, so pre-releases have no MSI. + ...(release.prerelease ? [] : [file("MSI package", "For managed installs", `Statsify_${v}_x64_en-US.msi`)]), + file("Portable", "Runs without installing", `Statsify_${v}_x64-portable.exe`), + ], + macos: [file("Disk image", "Apple silicon and Intel", `Statsify_${v}_universal.dmg`)], + linux: [ + file("Debian package", "Debian, Ubuntu, Mint and others", `Statsify_${v}_amd64.deb`), + file("AppImage", "Most other distributions", `Statsify_${v}_amd64.AppImage`), + ], + web: [file("Web app", "To host on your own server", `Statsify_${v}_web.zip`)], + }; +} + +export const checksumsUrl = (version: string) => fileUrl(version, "SHA256SUMS.txt"); + +/** + * Which system the visitor is on. 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"; +} + +const DATE = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "long", year: "numeric", timeZone: "UTC" }); + +export const formatDate = (iso: string) => DATE.format(new Date(iso)); + +/** A change's text split into plain text and `code`, for rendering as text nodes. */ +export function codeSpans(text: string): { text: string; code: boolean }[] { + return text + .split(/`([^`]+)`/) + .map((part, i) => ({ text: part, code: i % 2 === 1 })) + .filter((part) => part.text); +} diff --git a/site/styles.css b/site/styles.css new file mode 100644 index 0000000..9cf2f42 --- /dev/null +++ b/site/styles.css @@ -0,0 +1,1494 @@ +@import "@fontsource-variable/figtree"; + +/* + * The app's own Midnight and Light colours, so its screenshots sit on the page without a seam. The + * logo's green marks only the main action, the selected tab and "your system". Sizes are multiples + * of 4px. Contrast on every surface: text and secondary text >= 7:1, muted 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; +} + +/* The GitHub mark is drawn filled, not outlined. */ +.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; + 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; +} + +.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; +} + +.support { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 1rem 2rem; + margin-top: 3rem; + padding: 1.5rem; + border: 1px solid var(--line); + border-radius: 0.75rem; + background: var(--surface); +} + +.support p { + max-width: 36rem; + color: var(--text-2); +} + +/* In the corner once the first screen is read, out of the way of the support box and footer. */ +.coffee { + position: fixed; + right: 1rem; + bottom: 1rem; + z-index: 40; + box-shadow: + var(--highlight), + 0 8px 24px rgb(0 0 0 / 0.24); + transition: + opacity 200ms var(--ease), + translate 200ms var(--ease), + visibility 0s; +} + +html.js .coffee:not(.is-shown) { + opacity: 0; + visibility: hidden; + translate: 0 0.5rem; + transition: + opacity 200ms var(--ease), + translate 200ms var(--ease), + visibility 0s 200ms; +} + +@media (max-width: 39.99rem) { + .coffee { + display: none; + } +} + +/* 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, each with a number and a length */ + +.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; +} + +/* 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, then only 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..b9f2168 --- /dev/null +++ b/site/vite.config.ts @@ -0,0 +1,112 @@ +import { execFileSync } from "node:child_process"; +import { createHash } from "node:crypto"; +import { readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; +import { defineConfig, type Plugin } from "vite"; +import { groupChanges, parseTags, type Release } from "./releases.ts"; + +const root = fileURLToPath(new URL(".", import.meta.url)); + +function git(...args: string[]): string { + return execFileSync("git", args, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }); +} + +/** + * The newest releases from the repository's version tags, each with the pull requests merged since + * the release before it. A clone without tags (or without git) gives none, and the page then links + * to GitHub Releases instead. + */ +function releasesFromGit(): Release[] { + let tags: ReturnType; + try { + // versionsort.suffix sorts v1.3.0-beta.1 before v1.3.0, not after it. + tags = parseTags( + git( + "-c", + "versionsort.suffix=-", + "tag", + "--list", + "v*", + "--sort=-v:refname", + "--format=%(refname:short) %(creatordate:iso-strict)", + ), + ); + } catch { + return []; + } + return tags.slice(0, 6).map((tag, i) => { + const prerelease = tag.version.includes("-"); + // A full release counts from the full release before it, over any pre-releases between. + const previous = tags.slice(i + 1).find((t) => prerelease || !t.version.includes("-"))?.version; + let subjects: string[] = []; + if (previous) { + try { + subjects = git("log", "--no-merges", "--format=%s", `v${previous}..v${tag.version}`) + .split("\n") + .filter(Boolean); + } catch { + // A shallow clone may not have the commits between two tags. + } + } + return { ...tag, prerelease, previous, groups: groupChanges(subjects) }; + }); +} + +/** `import releases from "virtual:releases"`. SITE_RELEASES names a JSON file to use instead (the tests' fixture). */ +function releases(): Plugin { + const id = "virtual:releases"; + return { + name: "statsify-site-releases", + resolveId: (source) => (source === id ? `\0${id}` : undefined), + load(resolved) { + if (resolved !== `\0${id}`) return undefined; + const fixture = process.env.SITE_RELEASES; + const data: Release[] = fixture ? JSON.parse(readFileSync(fixture, "utf8")) : releasesFromGit(); + return `export default ${JSON.stringify(data)};`; + }, + }; +} + +/** + * GitHub Pages can't send headers, so the policy is a tag: the page's own files only, and its + * one inline script allowed by its hash. + */ +function csp(): 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`); + }, + }; +} + +export default defineConfig({ + root, + // Relative links, so the site works at https://.github.io// or anywhere else. + base: "./", + publicDir: false, + plugins: [releases(), csp()], + 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", + 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..0fad3e1 --- /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", "site/dist-test"] +} 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: {