poli0981andClaude Opus 5.5 484907439a feat(content): content labels, an age check, blurred images and a warning banner (#138)
* feat(content): content labels, an age check, blurred images and a warning banner

Posts, chapters and albums can carry content labels and an age rating:
- Labels (src/lib/content-labels.ts, names in src/i18n `labels`): horror, blood,
  jumpscare, violence, self-harm, death — banner and blurred images; politics,
  religion, strong-language, flashing-lights, spoilers — banner only. `contentWarning`
  moves from stories to every long-form entry and albums, and single gallery photos can
  carry their own (R2 list or captions.json). Unknown labels fail the build.
- Banner (ContentNotice.astro, replaces ContentWarning.astro): names every label in the
  page's language, skipped by search. Images in a labelled region are blurred in plain
  CSS by default — nothing sharp flashes before a script — and a real "Hiện ảnh"
  checkbox un-blurs them through :has(), so it works with the keyboard and with
  JavaScript off. A region without pictures shows no such line.
- Age check (AgeGate.astro, src/lib/age-gate.ts) for `ageRating` 13+/16+/18+: the text
  sits in a closed <details> (search indexes the title, not the text); its summary asks
  in a native modal <dialog> — focus starts on "No", Esc cancels and never means yes,
  "No" explains and offers to choose again — and the answer is kept in localStorage
  only (age thresholds, never an age or birth date). It never pops up on its own, and
  without JavaScript the summary simply opens the text.
- Everywhere else: story/post/album cards name the labels (blurred covers), the lightbox
  shows labelled photos blurred behind "Hiện ảnh", RSS descriptions start with the
  warning in the item's language, OG cards carry it for blog posts too, JSON-LD
  contentRating. The post page now uses the cover's alt text when there is one.
- Admin: a `multiselect` field for labels (with Vietnamese names), an age-rating select,
  and per-photo labels in the gallery manager.
- Content (poli0981/content 98f7692): privacy policy §6 lists the age-check answer;
  "Đêm không tiếng" chapters 1–2 are rated 16+.
- Tests: label and age-check logic, admin validation, labels kept on album save, RSS
  prefix; the accessibility suite scans the gate folded and asked, checks focus, Esc,
  No/Yes/reset and the keyboard reveal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(a11y): appendChild for the blur probe (astro check's DOM typing)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(content): findings from an independent review of the labels branch

- Album pages: the lightbox now sits outside the labelled section, whose blur rule also
  blurred the viewer's photo — its "show" button removed the veil but not the blur.
- Age check: the browser opens a <details> by itself (find-in-page, a #:~:text= link
  from a search engine, an #id inside the text); without a "yes" on record the gate now
  folds it straight back. After "Chọn lại" → "Có", focus moves to the summary instead of
  being lost with the row that just hid.
- Search indexes nothing inside the gate, not even its status lines, which could have
  become the excerpt of a page the reader has not been let into.
- Albums take their labels and age rating from BOTH language entries (same photos, two
  pages; the stricter rating wins), on the album page and on its card.
- An age-rated post folds its cover away with the text (PostCover.astro), and post and
  album cards blur the cover of age-rated items too. The album card names the cover
  photo's own labels, not only the album's.
- Tests: the gate re-folds an unasked open and keeps focus after choosing again;
  albumWarning merges both languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 08:30:09 +07:00

poli0981.dev

CI Quality Gate Qodana License: GPL-3.0

The personal site of Kokone (SkullMute) — dev portfolio, blog, short fiction and a hub for the SkullMute channel, in Vietnamese and English. Live at poli0981.dev.

Trang cá nhân của Kokone (SkullMute): dự án, blog, truyện ngắn và kênh SkullMute — song ngữ Việt/Anh. Tài liệu thiết kế đầy đủ (tiếng Việt) nằm trong poli0981.dev-docs/.

Stack

Layer Choice
Framework Astro 7 (static-first) with Svelte 5 islands
Styling Tailwind CSS 4, design tokens in src/styles/global.css ("Glacier Teal" palette)
Hosting Cloudflare Workers + Static Assets; KV, R2, Images, Rate Limiting, Access, Turnstile
Content Markdown/MDX in poli0981/content (git submodule src/content)
Search Pagefind (built after astro build)
Tooling Node 26 · TypeScript 7 (tsc) next to TypeScript 6 (astro check, typescript-eslint) · node:test · ESLint · Prettier · knip
Quality SonarCloud quality gate · Qodana · CodeQL · OSV-Scanner · Snyk · Dependabot (3-day cooldown) · axe-core gate · licence check

How it fits together

visitor ─▶ Cloudflare edge ─▶ src/worker.ts (every request, pages included)
            www → apex · IP denylist (KV) · admin host split · /media (R2) · /ext-img (KV)
            Turnstile gate (48-hour pass) · static pages from ASSETS · the rest → Astro app
                                                                      ├─ /api/report, /api/gate, /api/widgets, /api/health
                                                                      └─ admin.poli0981.dev (Cloudflare Access + JWT check)
workers/widgets (cron, every 45 min) ─▶ YouTube / Steam / GitHub ─▶ KV (data + mirrored images)

Almost every page is prerendered. The Worker entry runs first for every route so the bot gate, the denylist and the security headers also cover static pages. Details: 02_ARCHITECTURE.md and 06_SECURITY.md.

Getting started

Requirements: Node 26 (.nvmrc) and npm 11. The content submodule is public, so a plain clone works.

git clone --recurse-submodules https://github.com/poli0981/poli0981-dev.git
cd poli0981-dev
npm ci --ignore-scripts && npm run check-install-scripts
npx lefthook install
npm run types && npm run types:widgets
npm run dev

npm run dev runs Astro on workerd with local bindings. The admin works locally with a stand-in identity (dev@localhost); saving content needs a GITHUB_CONTENT_TOKEN in .dev.vars.

Commands

Command What it does
npm run dev Dev server (workerd, local KV/R2)
npm run build astro build → OG images → Pagefind index → CSP hash check
npm run preview Serve the build
npm run check astro check (TypeScript 6 language service)
npm run typecheck tsc from TypeScript 7 for the site and the widgets worker
npm run lint · npm run format:check · npm run knip ESLint · Prettier · unused files/exports
npm test · npm run test:coverage node:test suites; coverage writes coverage/lcov.info (80% line floor)
npm run smoke Runs the built Worker with wrangler dev and probes pages, headers, the gate and the denylist
npm run test:a11y axe-core, keyboard, reflow and forced-colours checks against npm run preview (Chrome)
npm run probe:ratelimit -- [url] [requests] [parallel] Spams a live URL and counts 429s from the Worker's site-wide limit vs. the WAF rule
npm run new:post Scaffold a post or story from docs/templates/
npm run check-exif · npm run strip-exif Refuse / remove GPS and camera metadata in images
npm run gen-notices Regenerate THIRD-PARTY-NOTICES.md (CI checks it)

Deploying

Cloudflare Workers Builds builds every push: main runs npx wrangler deploy, any other branch only npx wrangler versions upload (a preview version that takes no traffic). After a merge, https://poli0981.dev/api/health reports the running version and commit. The widgets worker deploys by hand: npx wrangler deploy --config workers/widgets/wrangler.jsonc. Setup from scratch: 07_CLOUDFLARE_SETUP.md; pipeline: 08_CI_CD.md; changes per release: CHANGELOG.md.

Admin

admin.poli0981.dev is the owner's editor: write and edit posts (commits to the content repo), upload images (transformed once into AVIF/WebP and stored in R2), manage gallery albums, publish (opens a submodule-bump PR that CI must pass), review an audit log and manage the IP denylist. It sits behind Cloudflare Access, and the Worker independently verifies the Access JWT (≤ 24 hours old) and an email allowlist on every request.

Security

Please report vulnerabilities privately — see SECURITY.md. Bug reports from the site's "Report a bug" button land in a private repository, not in this one's issues.

Accessibility

The site aims for WCAG 2.2 AA and checks it on every pull request (axe-core over every page, plus keyboard, reflow and forced-colours tests). What is in place, what is known not to work and how to report a barrier: ACCESSIBILITY.md; the statement for visitors is at /legal/accessibility. Barriers can be reported to accessibility@poli0981.dev.

License

S
Description
No description provided
Readme GPL-3.0
7.9 MiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 51.9%
Astro 19.4%
Svelte 16.3%
JavaScript 9.9%
CSS 2.5%