73 lines
3.4 KiB
Markdown
73 lines
3.4 KiB
Markdown
# RustPad 0.0.1
|
|
|
|
Collaborative Markdown editor with standalone notes and workspaces.
|
|
|
|
## Development setup
|
|
|
|
```bash
|
|
./dev.sh
|
|
```
|
|
|
|
The script creates `data/db` and `data/files`, builds the project, and runs it with Cargo. When Cargo is unavailable, it uses `docker compose up --build`.
|
|
|
|
## Functions (Workspaces)
|
|
|
|
- real-time collaborative editing over WebSocket,
|
|
- nickname remembered in `localStorage`,
|
|
- change authors in history,
|
|
- line numbering enabled by default with a persistent toggle,
|
|
- owner color next to each line,
|
|
- upload images and files to `data/files/pads/<id>_<token>/` lub `data/files/notes/<id>_<token>/`,
|
|
- automatic Markdown link insertion after upload,
|
|
- Markdown i diagramy Mermaid,
|
|
- history with snippets, previews, and version restore.
|
|
|
|
## Data
|
|
|
|
- SQLite: `data/db/rustpad.db`,
|
|
- files: `data/files/pads/<id>_<token>/` i `data/files/notes/<id>_<token>/`; the public URL has the form `/f/<token>/<nazwa>`.
|
|
|
|
In Docker, both directories are located under `/data`.
|
|
|
|
## Publishing a note as a page
|
|
|
|
Use the **Page** button in the editor. RustPad creates a permanent public `/s/<token>` address, copies it to the clipboard, and opens it in a new tab. The page displays the current note content and renders Markdown, images, links, and Mermaid. Publishing a protected note requires the password, but the published link itself is public.
|
|
|
|
## Limit uploadu
|
|
|
|
The maximum size of a single file is configured with `UPLOAD_MAX_SIZE_MB` w `.env`, np. `UPLOAD_MAX_SIZE_MB=50`. The default is 20 MB. After changing it, restart the project with `./dev.sh`.
|
|
|
|
## Wybór bazy danych
|
|
|
|
RustPad wybiera silnik na podstawie `DATABASE_URL`:
|
|
|
|
- SQLite: `sqlite:///data/db/rustpad.db?mode=rwc&journal_mode=WAL&busy_timeout=5000`
|
|
- PostgreSQL: `postgres://rustpad:rustpad@postgres:5432/rustpad`
|
|
- MySQL: `mysql://rustpad:rustpad@mysql:3306/rustpad`
|
|
|
|
SQLite pozostaje domyślną bazą dla developmentu i małych instalacji. Tryb WAL pozwala czytać podczas zapisu, ale SQLite nadal wykonuje tylko jeden zapis naraz. `busy_timeout=5000` powoduje krótkie oczekiwanie zamiast natychmiastowego błędu `database is locked`. Przy wielu równoczesnych edytorach lub wielu instancjach aplikacji zalecany jest PostgreSQL albo MySQL.
|
|
|
|
Opcjonalne bazy w Docker Compose:
|
|
|
|
```bash
|
|
# PostgreSQL
|
|
docker compose --profile postgres up -d postgres
|
|
DATABASE_URL=postgres://rustpad:rustpad@postgres:5432/rustpad docker compose up -d rustpad
|
|
|
|
# MySQL
|
|
docker compose --profile mysql up -d mysql
|
|
DATABASE_URL=mysql://rustpad:rustpad@mysql:3306/rustpad docker compose up -d rustpad
|
|
```
|
|
|
|
Migracje są rozdzielone w `migrations/sqlite`, `migrations/postgres` i `migrations/mysql`. Zapytania aplikacji znajdują się centralnie w `src/queries.rs`, a `src/database.rs` odpowiada za wybór sterownika i konfigurację połączenia.
|
|
|
|
|
|
## Optional user accounts and password reset
|
|
|
|
Nicknames can still be used anonymously while they remain unregistered. Registering a nickname reserves it and requires a valid login session before it can be used in editor WebSocket connections. Configure `PUBLIC_URL`, `SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD`, and `SMTP_FROM` to enable password-reset e-mails. Reset links expire after 30 minutes and are single-use.
|
|
|
|
## Database query layout
|
|
|
|
All runtime SQL statements are centralized in `src/queries.rs`. Backend modules reference named constants, which keeps database-specific debugging and query review in one place.
|
|
|