mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-08 02:28:25 -05:00
[PR #1405] [MERGED] PR-2: Visual polish (announcement bars, theme persistence, dev-mirror fix, audit script) #8172
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1405
Author: @profvjreddi
Created: 4/19/2026
Status: ✅ Merged
Merged: 4/20/2026
Merged by: @profvjreddi
Base:
dev← Head:release-prep/visual-polish📝 Commits (4)
59e6c64fix(dev-mirror): compute prefix from dev-side depth in rewrite-dev-urls.sh0376381feat(book): per-volume announcement bars (Crimson / ETH-Blue)33a4a52feat(theme): cross-site dark-mode persistence + FOUC guard83f249ctest(audit): Playwright site-audit script (sidebar / darkmode / assets)📊 Changes
11 files changed (+557 additions, -32 deletions)
View changed files
📝
.github/scripts/rewrite-dev-urls.sh(+32 -8)📝
book/quarto/config/_quarto-html-vol1.yml(+1 -1)📝
book/quarto/config/_quarto-html-vol2.yml(+1 -1)➕
book/quarto/config/shared/html/announcement-vol1.yml(+24 -0)➕
book/quarto/config/shared/html/announcement-vol2.yml(+24 -0)📝
book/quarto/config/shared/html/announcement.yml(+12 -13)📝
interviews/staffml/public/theme-bootstrap.js(+26 -8)📝
interviews/staffml/src/components/ThemeProvider.tsx(+18 -1)📝
shared/config/site-head.html(+46 -0)➕
shared/scripts/site-audit.mjs(+269 -0)➕
shared/scripts/theme-persist.js(+104 -0)📄 Description
Summary
Visible-on-the-dev-mirror improvements that close several of the
visual/UX gaps the maintainer flagged during the staged-rollout review.
Independent of PR-1 (the safety-net) — can be merged in either order.
What's in this PR
Per-volume announcement bars (Crimson / ETH-Blue). The shared
announcement.ymlwas a single voice for both volumes; Vol II shouldread in the ETH-Blue accent (since it's Machine Learning Systems at
Scale). Split into:
book/quarto/config/shared/html/announcement-vol1.yml(Vol I,inherits Harvard Crimson via theme accent)
book/quarto/config/shared/html/announcement-vol2.yml(Vol II,inherits ETH Blue)
The legacy file is left in place as a deprecated no-op pointing at
the two new files. Vol I and Vol II
_quarto-html-vol{1,2}.ymlconfigs now reference the right one.
Cross-site dark-mode persistence + FOUC guard. Today, switching
dark mode on Vol I doesn't carry to TinyTorch / labs / kits / staffml
because each subsite tracks its own preference. New
shared/scripts/theme-persist.js(inlined intoshared/config/site-head.htmlso it runs synchronously in<head>,no FOUC) reads
quarto-color-schemefromlocalStorageand appliesdata-bs-theme/data-quarto-color-scheme/html.style.colorSchemebefore first paint. StaffML'sThemeProvider.tsxandtheme-bootstrap.jsupdated to read/writethe same key as a fallback so the Next.js property participates in
the shared preference. Listens for storage events too, so a tab that
toggles dark mode propagates to other open tabs in the same domain.
Dev-mirror nested-path bug fix.
rewrite-dev-urls.shhad ahard-coded
PREFIX="../"which broke nested subsites likebook/vol1/andbook/vol2/— they were getting URLs that walkedup one too few directories. Fixed to compute
PREFIXfrom theactual depth of the subsite's dev-side path. Also fixed an
associative-array key check that wasn't portable to the macOS
default bash 3.2.
Playwright audit script (subcommands: sidebar / darkmode /
assets). New
shared/scripts/site-audit.mjsthat opens eachdeployed subsite in a headless browser and:
sidebar— verifies every Quarto subsite has a visible sidebar(was missing on a few Vol I / Vol II combinations after the
split).
darkmode— toggles dark mode, screenshots before/after,flags pages that don't repaint cleanly.
assets— fetches every<img src>and<link rel="stylesheet">and reports broken ones (catches the "PDF viewer iframe shows a
404" class of issue the maintainer flagged).
Output goes to
.audit/(added to.gitignorein PR-3).Risk surface
defanged but not deleted, so any forgotten reference still resolves).
<head>-inlined, so it runs before anyuser-visible content. Worst case if the script throws: nothing
happens, the user falls back to OS preference (which is the current
behavior).
paths and the depth math verified; included a comment in the script
explaining the depth derivation.
node shared/scripts/site-audit.mjs <cmd>);no CI integration in this PR.
Test plan
node shared/scripts/site-audit.mjs sidebarproducesa JSON report covering vol1, vol2, tinytorch, labs, kits,
slides, instructors, mlsysim, site, staffml.
verify dark mode is preserved (no flash of light theme).
Followup
the dedup-finder follow-up; the audit script could share the same
workflow shell).
edition is rolling out"; tighten language for actual launch.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.