Add slug-based URLs for notes

This commit is contained in:
2026-08-04 09:30:47 -04:00
parent 99ffddc078
commit 7817336754
2 changed files with 104 additions and 33 deletions

View File

@ -24,7 +24,7 @@ The app is implemented as a single Python server (`main.py`) plus one HTML templ
## How's it work?
1. `main.py` starts an HTTP server.
2. On each page request (`GET /`), it rescans the notes directory for `.org` files.
2. On each page request (e.g. `GET /` or `GET /n/<slug>`), it rescans the notes directory for `.org` files.
3. It resolves links/backlinks and builds HTML fragments.
4. It injects those fragments into `templates/index.html` placeholders:
- `{{NAV_ITEMS}}`
@ -34,6 +34,12 @@ The app is implemented as a single Python server (`main.py`) plus one HTML templ
## Server-side components (`main.py`)
- URLs:
- `/` renders the index (defaults to the most recent note).
- `/n/<slug>` renders a single note, where `<slug>` is the note's `:ID:` value when present, otherwise its relative path (percent-encoded as one segment, e.g. `/n/sub%2Fnote.org`).
- `/n/<slug>?edit=1` switches to edit mode for that note.
- `/n/<slug>/backlinks` returns a standalone backlinks pane for embedding.
- `POST /capture`, `POST /edit`, and `POST /webhook` handle their respective actions and redirect back to the note's URL.
- File discovery and parsing:
- `scan_org_files(...)` recursively finds `.org` files.
- Extracts title from `#+TITLE:` and ID from `:ID:`.