[PR #1944] feat(tinytorch): make the website an installable PWA #36554

Open
opened 2026-07-16 00:28:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1944
Author: @farhan523
Created: 7/7/2026
Status: 🔄 Open

Base: devHead: feat/tinytorch-pwa


📝 Commits (1)

  • be03057 feat(tinytorch): make the website an installable PWA

📊 Changes

9 files changed (+235 additions, -1 deletions)

View changed files

📝 tinytorch/quarto/_quarto.yml (+14 -1)
tinytorch/quarto/assets/images/icons/apple-touch-icon.png (+0 -0)
tinytorch/quarto/assets/images/icons/icon-192.png (+0 -0)
tinytorch/quarto/assets/images/icons/icon-512.png (+0 -0)
tinytorch/quarto/assets/images/icons/icon-maskable-192.png (+0 -0)
tinytorch/quarto/assets/images/icons/icon-maskable-512.png (+0 -0)
tinytorch/quarto/assets/scripts/pwa.html (+28 -0)
tinytorch/quarto/manifest.webmanifest (+38 -0)
tinytorch/quarto/sw.js (+155 -0)

📄 Description

Summary

Makes the TinyTorch site (mlsysbook.ai/tinytorch/) an installable Progressive Web App with offline reading support.

  • manifest.webmanifest — installability metadata with relative start_url/scope so it resolves correctly both under /tinytorch/ in production and in local previews served at the root. Includes any + maskable icons (192/512) generated from the flame mark in logo-tinytorch-simple.png, themed with the existing #D4740C brand color.
  • sw.js (service worker) — conservative caching tuned for a frequently-deployed docs site:
    • Pages: network-first. A deploy is picked up immediately; the cache is only an offline fallback, with a branded offline page as the last resort.
    • Same-origin static assets (css/js/images/fonts): stale-while-revalidate, capped at 200 entries.
    • JSON/data passthroughrelease-manifest.json, search.json, and any fetch/XHR always hit the network, so the release pill and search never go stale.
    • Cross-origin CDN requests (Google Fonts, cdnjs) are left to the browser.
  • assets/scripts/pwa.html — registers the worker at the site base path, derived at runtime because pages render at several directory depths and the site root differs between production (/tinytorch/) and previews (/). Registration is skipped silently on insecure contexts.
  • apple-touch-icon fix — the previous href pointed at the 583×328 wordmark; iOS home screens now get a proper 180×180 icon. The manifest <link> and icon use leading-/ project-relative hrefs, which Quarto relativizes per page depth.

No changes to page content or build tooling; quarto render output just gains the manifest, worker, and icons via the existing resources: mechanism, so the publish workflow deploys them as-is.

Testing

  • quarto render passes; verified the manifest link and icon hrefs relativize correctly at all page depths (index.html, modules/, tito/).
  • Served _build locally: all PWA URLs return 200, manifest parses, node --check sw.js passes.
  • Verified in Chrome: install prompt appears, worker activates with site-wide scope, visited pages load offline, unvisited pages show the offline fallback.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1944 **Author:** [@farhan523](https://github.com/farhan523) **Created:** 7/7/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `feat/tinytorch-pwa` --- ### 📝 Commits (1) - [`be03057`](https://github.com/harvard-edge/cs249r_book/commit/be0305762f7045d9b16791876cb85a186c5f8896) feat(tinytorch): make the website an installable PWA ### 📊 Changes **9 files changed** (+235 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tinytorch/quarto/_quarto.yml` (+14 -1) ➕ `tinytorch/quarto/assets/images/icons/apple-touch-icon.png` (+0 -0) ➕ `tinytorch/quarto/assets/images/icons/icon-192.png` (+0 -0) ➕ `tinytorch/quarto/assets/images/icons/icon-512.png` (+0 -0) ➕ `tinytorch/quarto/assets/images/icons/icon-maskable-192.png` (+0 -0) ➕ `tinytorch/quarto/assets/images/icons/icon-maskable-512.png` (+0 -0) ➕ `tinytorch/quarto/assets/scripts/pwa.html` (+28 -0) ➕ `tinytorch/quarto/manifest.webmanifest` (+38 -0) ➕ `tinytorch/quarto/sw.js` (+155 -0) </details> ### 📄 Description ## Summary Makes the TinyTorch site (mlsysbook.ai/tinytorch/) an installable Progressive Web App with offline reading support. - **`manifest.webmanifest`** — installability metadata with relative `start_url`/`scope` so it resolves correctly both under `/tinytorch/` in production and in local previews served at the root. Includes `any` + `maskable` icons (192/512) generated from the flame mark in `logo-tinytorch-simple.png`, themed with the existing `#D4740C` brand color. - **`sw.js`** (service worker) — conservative caching tuned for a frequently-deployed docs site: - **Pages: network-first.** A deploy is picked up immediately; the cache is only an offline fallback, with a branded offline page as the last resort. - **Same-origin static assets (css/js/images/fonts): stale-while-revalidate**, capped at 200 entries. - **JSON/data passthrough** — `release-manifest.json`, `search.json`, and any fetch/XHR always hit the network, so the release pill and search never go stale. - Cross-origin CDN requests (Google Fonts, cdnjs) are left to the browser. - **`assets/scripts/pwa.html`** — registers the worker at the site base path, derived at runtime because pages render at several directory depths and the site root differs between production (`/tinytorch/`) and previews (`/`). Registration is skipped silently on insecure contexts. - **apple-touch-icon fix** — the previous href pointed at the 583×328 wordmark; iOS home screens now get a proper 180×180 icon. The manifest `<link>` and icon use leading-`/` project-relative hrefs, which Quarto relativizes per page depth. No changes to page content or build tooling; `quarto render` output just gains the manifest, worker, and icons via the existing `resources:` mechanism, so the publish workflow deploys them as-is. ## Testing - `quarto render` passes; verified the manifest link and icon hrefs relativize correctly at all page depths (`index.html`, `modules/`, `tito/`). - Served `_build` locally: all PWA URLs return 200, manifest parses, `node --check sw.js` passes. - Verified in Chrome: install prompt appears, worker activates with site-wide scope, visited pages load offline, unvisited pages show the offline fallback. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-07-16 00:28:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#36554