# Deploying the teaching site

This project is **static HTML**: any host that can serve files over HTTP works. Same files for **home server** or **GitHub Pages**.

## Preview locally

From the project root:

```bash
python -m http.server 8080
```

Open `http://127.0.0.1:8080/`. A plain `file://` open of `index.html` may load, but relative paths and some browsers’ script policies are less predictable—use a tiny server for day-to-day editing.

### Practice bank and quizzes (`fetch`)

The **Practice** sections load `practice/data/bank.json` via `fetch()`. **Quiz mode** on each topic page loads the JSON named in `data-quiz` (for example `quiz/data/limits.json`). Both **require** serving the site over **`http://` or `https://`**. If you open HTML from the filesystem (`file://`), those panels will show a load error.

### MathLive (CDN)

Topic pages load **MathLive** from jsDelivr for `<math-field>` input (with a plain `<textarea>` fallback if the script is blocked). KaTeX remains the renderer for static math in HTML and in solutions. Current pin: `mathlive@0.102.0` — CSS `dist/mathlive-static.css`, script `dist/mathlive.min.js`. If you self-host, mirror those files or vendor them under this repo and update the `<link>` / `<script>` tags.

### Regenerating data

From the repo root:

```bash
python3 scripts/gen_practice_bank.py   # practice/data/bank.json
python3 scripts/gen_hw_quiz.py         # quiz/data/*.json (homework PDF links)
python3 scripts/validate_data.py       # sanity-check JSON
```

Optional: merge permission-verified prompts from `quiz/transcripts/<unit>.jsonl` with `python3 scripts/merge_quiz_transcripts.py <unit>`.

### Verbatim homework in quiz JSON

Default quiz rows **link** to the same `materials/` PDFs as the semester map; they do not paste WebAssign text. If you merge **copyrighted** homework text into JSON, keep that material **non-public** or obtain permission; see `quiz/data/README.md` and `CONTENT.md`.

### Reduced motion

If the learner’s OS has **prefers-reduced-motion** enabled, confetti celebrations are **skipped**; correct answers still show the green “Correct” text feedback.

## Home server (Caddy)

Example `Caddyfile` snippet serving only this site (adjust the domain and path):

```caddy
calc.example.com {
	root * /var/www/teachmath
	file_server
	encode gzip zstd
}
```

Reload Caddy, then place the **contents** of this repo (including `index.html`, `css/`, `js/`, `topics/`, `materials/`) under `/var/www/teachmath` or your chosen directory.

- **HTTPS on LAN:** use a split-horizon DNS name with internal TLS, or terminate TLS at your router / reverse proxy.
- **HTTPS on the public internet:** use a real DNS name and Let’s Encrypt (Caddy obtains certificates automatically when `calc.example.com` points to your server).

## Home server (nginx)

```nginx
server {
	listen 80;
	server_name calc.example.com;
	root /var/www/teachmath;
	index index.html;
	location / {
		try_files $uri $uri/ =404;
	}
}
```

Add `listen 443 ssl` and certificate directives when ready, or put nginx behind another TLS terminator.

## GitHub Pages

1. Push this repository to GitHub.
2. **Settings → Pages → Build and deployment:** Source = **Deploy from a branch**, branch = `main` (or `master`), folder = **`/` (root)**.
3. The site URL will be `https://<user>.github.io/<repo>/`.

If the site lives in a **project** URL (`/repo/`), relative links in this project already use **relative paths** (`css/`, `topics/`), so they resolve correctly under a subpath as long as you open `index.html` via that base URL.

## Updates during the semester

Edit HTML, add PDFs under `materials/`, then redeploy (git pull on the server, or push to GitHub Pages). No build step required.
