# texrra web
Build-free editor frontend for the [texrra engine](https://git.iloveuulove.me/gloamxun/texrra-engine).
It is plain HTML, CSS, and JavaScript: there is no bundler and no dependency
install. The engine serves these files and provides the same-origin API.

The landing page manages uploaded projects; opening one switches to the editor.

## Features
- **Upload ZIP** creates a project from an archive. Extraction rejects absolute
paths and `..`, ignores directory entries, rejects encrypted and ZIP64
archives, and caps a project at 64 MB / 2000 files.
- **New project** creates a minimal `main.tex`.
- Each project card offers **open / download / delete**; the editor header also
downloads the project ZIP.
- The sidebar lists every project file with type badges and folders. Right-click
a file for **open / download / delete**.
- **Upload files** adds files to the project root (drag and drop works too);
**new file** creates nested paths such as `sections/intro.tex`.
- Text files open with debounced autosave and a live preview of the project's
main file. Images render in the preview pane; other binary files show a
download action.
- The preview keeps one `
` per page and replaces only pages whose content
hash changed, so typing does not reload the view or jump the scroll position.
- Page cards take their aspect ratio and width from the preview payload, so A4
and Letter documents are both displayed without distortion.
## Run
Clone both repositories as siblings and start the engine:
```sh
git clone https://git.iloveuulove.me/gloamxun/texrra-engine.git engine
git clone https://git.iloveuulove.me/gloamxun/texrra-web.git web
cd engine
cargo run --release -- serve examples/hello.tex 4174
```
Open . The engine discovers `../web` automatically;
`TEXRRA_WEB_DIR` can point at this checkout from elsewhere. The same files can
be edited in place while the engine is running and a browser reload picks them
up (the server sends `Cache-Control: no-cache`).
## Files
| Path | Purpose |
| --- | --- |
| `index.html` | Page shell and markup |
| `styles.css` | Layout, editor, preview, and context-menu styling |
| `app.js` | Project API client, editor state, autosave, preview diffing |
| `favicon.svg` | Browser icon |
| `docs/screenshots/` | UI screenshots used by this README |
## API contract
The frontend assumes the engine is the same origin and exposes:
| Endpoint | Purpose |
| --- | --- |
| `GET /api/projects` | Project list |
| `POST /api/projects?name=` | Create a project from a ZIP body |
| `POST /api/projects/new?name=` | Create an empty project |
| `GET /api/projects/` | Project metadata and file list |
| `DELETE /api/projects/` | Delete a project |
| `GET /api/projects//zip` | Download the project as a ZIP |
| `GET /api/projects//raw?path=` | Read a file (`download=1` downloads it) |
| `PUT /api/projects//file?path=` | Write a text file |
| `POST /api/projects//files?path=` | Upload a file |
| `DELETE /api/projects//file?path=` | Delete a file |
| `POST /api/projects//preview` | Live preview of the main file |
| `POST /api/projects//pdf` | PDF of the main file |
The preview response is a JSON object with `status`, `durationMs`,
`pageWidthMm`, `pageHeightMm`, and `pages` (one inline SVG and hash per page).
Font faces are loaded from `/fonts.css` and `/fonts/*.ttf`.
## Design notes
- No framework or build step: the shell is static and the editor is a
`