
[![crates.io](https://img.shields.io/crates/v/oth_pumlv.svg)](https://crates.io/crates/oth_pumlv)
[![Docker Hub](https://img.shields.io/badge/docker-okieoth%2Fpumlv-blue?logo=docker)](https://hub.docker.com/r/okieoth/pumlv)

# pumlv

A browser-based PlantUML diagram viewer with pan, zoom, SVG export, and live reload on file change.

## Features

- Render `.puml` files as SVG in the browser
- Pan (drag or hold Space) and zoom (scroll wheel, buttons, keyboard)
- Cursor-centred wheel zoom
- Minimap overview
- SVG export
- Auto-reload when the source file changes on disk (Server-Sent Events)
- File browser sidebar — switch between diagrams without uploading files
- Path traversal protection — only serves `.puml` files under configured roots
- Runs in Docker (JRE + PlantUML bundled)

## Usage

### Docker (recommended)

```sh
docker run -p 8080:8080 -v $(pwd)/diagrams:/data okieoth/pumlv /data
```

Open <http://localhost:8080>

### Local (requires Java + PlantUML jar)

```sh
cargo build --release
./target/release/pumlv --plantuml /path/to/plantuml.jar ./diagrams
./target/release/pumlv --plantuml /path/to/plantuml.jar diagram.puml   # pre-select a file
```

### Options

| Flag / Env var              | Default              | Description                         |
|-----------------------------|----------------------|-------------------------------------|
| `--port` / `PUMLV_PORT`     | `8080`               | HTTP listen port                    |
| `--root` / `PUMLV_ROOT`     | first path arg / cwd | Root directory for `.puml` files    |
| `--plantuml` / `PLANTUML_JAR` | `/opt/plantuml.jar` | Path to `plantuml.jar`             |

### Positional arguments

```
pumlv [path...]
```

- A **directory** → becomes the root; all `.puml` files inside are listed.
- A **file** → its parent becomes the root; the file is pre-selected in the viewer.
- Mix of both is supported; the first directory (or file parent) becomes the root.

## Keyboard shortcuts

| Key       | Action             |
|-----------|--------------------|
| `+` / `=` | Zoom in            |
| `-`       | Zoom out           |
| `f`       | Fit to window      |
| `p`       | Toggle pan tool    |
| `Space`   | Hold to pan        |

## Building the Docker image

```sh
docker build -t pumlv .
# or with a specific PlantUML version
docker build --build-arg PLANTUML_VERSION=1.2024.7 -t pumlv .
```

## Development

```sh
cargo test
cargo run -- --plantuml /path/to/plantuml.jar ./diagrams
```
