157 lines
5.0 KiB
Markdown
157 lines
5.0 KiB
Markdown
# 📚 Bookish
|
||
|
||
**Convertitore e reader di ebook self-hostato** — Flask, Pandoc, WeasyPrint, SQLite.
|
||
|
||
Carica un ebook in qualsiasi formato, convertilo in un altro, o leggilo direttamente nel browser con un reader completo. I segnalibri e la posizione di lettura sono persistenti su database SQLite, identificati univocamente dal contenuto del file (SHA256).
|
||
|
||
---
|
||
|
||
## Funzionalità
|
||
|
||
### 🔄 Convertitore
|
||
| Formato | Input | Output |
|
||
|---------|-------|--------|
|
||
| EPUB | ✅ | ✅ |
|
||
| PDF | ✅ | ✅ |
|
||
| DOCX | ✅ | ✅ |
|
||
| Markdown | ✅ | ✅ |
|
||
| Testo (TXT) | ✅ | ✅ |
|
||
| HTML | ✅ | ✅ |
|
||
| FB2 | ✅ | ✅ |
|
||
| MOBI | ✅ | ❌ |
|
||
| LaTeX | ✅ | ✅ |
|
||
|
||
- Drag & drop upload
|
||
- Barra progresso in tempo reale (SSE)
|
||
- Download automatico del convertito
|
||
|
||
### 📖 Reader
|
||
- **EPUB** via [epub.js](https://github.com/futurepress/epub.js)
|
||
- **PDF** via [pdf.js](https://mozilla.github.io/pdf.js/)
|
||
- **Testo/Markdown/DOCX/FB2/HTML** renderizzati come HTML
|
||
|
||
Caratteristiche reader:
|
||
- Zoom e regolazione font
|
||
- Temi: chiaro, scuro, seppia
|
||
- Ricerca full-text con risultati navigabili
|
||
- Indice navigabile (TOC) per EPUB e PDF
|
||
- **Segnalibri** persistenti su SQLite con sync server + localStorage
|
||
- **Salvataggio posizione** lettura (server + localStorage)
|
||
- **Slider larghezza** area di lettura (40–100%)
|
||
- **Aiuto contestuale** con scorciatoie da tastiera
|
||
- Pulsante 🔖 con feedback visivo (toast + pulse)
|
||
- Navigazione tastiera (← →) e schermo intero
|
||
- Temi: chiaro, scuro, seppia
|
||
|
||
### ⚙️ Motore di conversione
|
||
- **Pandoc** come motore primario (decine di formati)
|
||
- **WeasyPrint** per PDF con layout avanzato
|
||
- **python-docx** per DOCX con stili
|
||
- **BeautifulSoup** per post-processing HTML/tabelle
|
||
|
||
### 🗄️ Archiviazione persistente
|
||
- **SQLite** (`bookish.db`) per segnalibri e posizioni di lettura
|
||
- **Content Hash** (SHA256) come identificatore univoco del libro
|
||
- **localStorage** come fallback offline
|
||
- Stessi segnalibri anche su PC diverso (stessa LAN)
|
||
|
||
---
|
||
|
||
## Requisiti
|
||
|
||
- Python 3.10+
|
||
- Pandoc (incluso via pypandoc-binary)
|
||
- Librerie di sistema per WeasyPrint (libpango, libcairo)
|
||
|
||
## Installazione
|
||
|
||
```bash
|
||
git clone http://192.168.0.183:8085/truetype/bookish.git
|
||
cd bookish
|
||
python3 -m venv .venv
|
||
source .venv/bin/activate
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
## Avvio
|
||
|
||
```bash
|
||
./run.sh
|
||
# oppure su porta specifica:
|
||
./run.sh 8080
|
||
```
|
||
|
||
L'app cerca automaticamente una porta libera a partire da quella specificata. Il database SQLite (`bookish.db`) viene creato automaticamente al primo avvio.
|
||
|
||
Apri il browser su `http://localhost:5000` (o la porta assegnata).
|
||
|
||
---
|
||
|
||
## Architettura
|
||
|
||
```
|
||
bookish/
|
||
├── app.py # Entry point
|
||
├── config.py # Configurazioni
|
||
├── requirements.txt
|
||
├── run.sh
|
||
├── bookish.db # SQLite (creato al primo avvio)
|
||
├── bookish/
|
||
│ ├── __init__.py # Flask factory + init DB
|
||
│ ├── routes/
|
||
│ │ ├── convert.py # Upload, SSE progress, download
|
||
│ │ ├── reader.py # Reader view + content_hash
|
||
│ │ └── api.py # API REST bookmarks + positions
|
||
│ ├── services/
|
||
│ │ ├── converter.py # Conversione Pandoc + pipeline
|
||
│ │ ├── sse_manager.py # SSE progress manager
|
||
│ │ ├── formatter.py # PDF/HTML post-processing
|
||
│ │ └── database.py # SQLite manager
|
||
│ ├── templates/
|
||
│ │ ├── base.html # Layout base
|
||
│ │ ├── index.html # Convertitore
|
||
│ │ └── reader.html # Reader
|
||
│ └── static/
|
||
│ ├── css/style.css
|
||
│ ├── js/main.js # Frontend convertitore
|
||
│ ├── js/reader.js # Frontend reader (oltre 800 righe)
|
||
│ └── logo.svg
|
||
├── uploads/ # File caricati (temporanei)
|
||
├── converted/ # File convertiti (temporanei)
|
||
└── docs/ # Documentazione
|
||
```
|
||
|
||
Vedi [docs/architecture.md](docs/architecture.md) per dettagli.
|
||
|
||
---
|
||
|
||
## API Endpoints
|
||
|
||
| Metodo | Path | Descrizione |
|
||
|--------|------|-------------|
|
||
| POST | `/upload` | Carica file e avvia conversione |
|
||
| GET | `/progress/<task_id>` | SSE stream progresso |
|
||
| GET | `/download/<filename>` | Scarica file convertito |
|
||
| GET | `/formats?input=<ext>` | Formati disponibili per input |
|
||
| GET | `/reader` | Pagina reader |
|
||
| GET | `/reader/<filename>` | Reader per file specifico |
|
||
| GET | `/reader/serve/<filename>` | Serve il file al reader |
|
||
| GET | `/reader/formats` | Formati supportati dal reader |
|
||
| GET | `/api/bookmarks/<hash>` | Segnalibri di un libro |
|
||
| POST | `/api/bookmarks` | Aggiunge segnalibro |
|
||
| DELETE | `/api/bookmarks/<id>` | Elimina segnalibro |
|
||
| GET | `/api/position/<hash>` | Posizione di lettura |
|
||
| PUT | `/api/position/<hash>` | Salva posizione di lettura |
|
||
|
||
---
|
||
|
||
## Deployment
|
||
|
||
Adatto per Proxmox LXC, Docker o VM leggera. Vedi [docs/deploy.md](docs/deploy.md).
|
||
|
||
---
|
||
|
||
## Licenza
|
||
|
||
MIT
|