Split the inline CSS and JavaScript into styles.css and app.js. The static assets are served by texrra-engine. Use preview page dimensions for A4/Letter aspect ratios, refresh the UI screenshots, and document the API contract.
92 lines
4.0 KiB
Markdown
92 lines
4.0 KiB
Markdown
# 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 `<div>` 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 <http://127.0.0.1:4174>. 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/<id>` | Project metadata and file list |
|
|
| `DELETE /api/projects/<id>` | Delete a project |
|
|
| `GET /api/projects/<id>/zip` | Download the project as a ZIP |
|
|
| `GET /api/projects/<id>/raw?path=` | Read a file (`download=1` downloads it) |
|
|
| `PUT /api/projects/<id>/file?path=` | Write a text file |
|
|
| `POST /api/projects/<id>/files?path=` | Upload a file |
|
|
| `DELETE /api/projects/<id>/file?path=` | Delete a file |
|
|
| `POST /api/projects/<id>/preview` | Live preview of the main file |
|
|
| `POST /api/projects/<id>/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
|
|
`<textarea>`; all document state is owned by the engine.
|
|
- The route is hash-based (`#/` and `#/p/<id>`), so the static server needs no
|
|
fallback routing.
|
|
- Autosave is debounced at 450 ms; previews are debounced at 90 ms and previous
|
|
preview requests are aborted when a newer edit arrives.
|
|
- The UI is intentionally dense and keyboard-friendly: `Ctrl`/`Cmd+S` saves,
|
|
`Tab` inserts two spaces, and `Esc` closes the context menu.
|