Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 11452ea7a7 | |||
| d8862ba8ec | |||
| b7f4a7948c | |||
| 5590a552cc | |||
| 770073c45c | |||
| 6a97a98325 | |||
| 59d6246c77 | |||
| 15924544b4 | |||
| 03510d3940 | |||
| 8207627425 | |||
| 3cda76b4c4 | |||
| c4eb598a3a | |||
| 78a920b4e2 | |||
| e8e24e086b | |||
| 2f0df9c92c | |||
| f534263c9c | |||
| 6b00b2cb28 | |||
| d8579c0a59 | |||
| 98beccb0cd | |||
| c4107b84a5 | |||
| 7baebebc09 | |||
| a7d918d241 | |||
| 20f7cf4003 | |||
| 669fd2978f | |||
| b17b5c831a | |||
| 22c9cadb43 | |||
| 21d9755e37 | |||
| ee54e9a1f4 | |||
| 62e0120ea2 | |||
| 2f94fc0373 | |||
| e6c493b756 | |||
| 1522d97f54 | |||
| cc21cb7627 | |||
| 27fdf1fc30 | |||
| ae5eef037b | |||
| 931c1e43ad | |||
| a7b05d703a | |||
| 4cee8cdd7a | |||
| 1742c1d666 | |||
| 0b938d7d09 |
@@ -11,3 +11,7 @@ CONTACT_FROM=postmaster@insanitylab.it
|
||||
CONTACT_TO=info@insanitylab.it
|
||||
DB_PATH=data/insanitylab.db
|
||||
UPLOADS_DIR=uploads
|
||||
|
||||
# Google Tag Manager: ID container preso da tagmanager.google.com (accanto al nome container).
|
||||
# Formato GTM-XXXXXXX. Lascia vuoto per non caricare GTM (es. in locale/staging).
|
||||
GTM_ID=GTM-XXXXXXX
|
||||
|
||||
@@ -14,6 +14,8 @@ COPY package.json package-lock.json ./
|
||||
RUN npm ci --omit=dev && npm cache clean --force
|
||||
COPY --from=build /app/dist ./dist
|
||||
COPY scripts ./scripts
|
||||
# Contenuti della sezione Campus (generati con `npm run sync-campus` e committati)
|
||||
COPY campus-content ./campus-content
|
||||
|
||||
ENV HOST=0.0.0.0 \
|
||||
PORT=4321 \
|
||||
|
||||
@@ -26,7 +26,8 @@ Il sito è costruito su **Astro 7** in modalità server (SSR) con adapter **Node
|
||||
- **Contenuti taggati**: ogni testo/immagine ha un tag (es. `home.hero.title-line-1`) modificabile dal pannello o in pagina.
|
||||
- **Modifica inline**: chi ha i permessi può attivare l'overlay dei tag e modificare i contenuti direttamente mentre naviga il sito.
|
||||
- **Blog** con editor TipTap, immagini caricate, firma autore e proprietà degli articoli per ruolo.
|
||||
- **Gestione utenti** con tre ruoli (`admin`, `superuser`, `user`).
|
||||
- **Gestione utenti** con quattro ruoli (`admin`, `superuser`, `user`, `campus`).
|
||||
- **Campus**: sezione riservata con le guide di studio del corso Biohacking Campus, accessibile solo dopo il login e con navigazione autonoma.
|
||||
- **Form contatti** con validazione, honeypot anti‑spam, rate‑limit e invio email via SMTP.
|
||||
|
||||
## Installazione (sviluppo)
|
||||
@@ -53,7 +54,8 @@ Il database `data/insanitylab.db` viene creato al primo avvio ed è popolato aut
|
||||
| `npm run preview` | Anteprima locale della build |
|
||||
| `npm run start` | Server di produzione (`node --env-file=.env`) |
|
||||
| `npm run test` | Test con Vitest |
|
||||
| `npm run create-user` | Crea/aggiorna utente: `-- <nome> <password> [admin\|superuser\|user]` |
|
||||
| `npm run create-user` | Crea/aggiorna utente: `-- <nome> <password> [admin\|superuser\|user\|campus]` |
|
||||
| `npm run sync-campus` | Rigenera i contenuti del Campus: `-- <path-progetto-biohacking-campus>` |
|
||||
|
||||
## Gestione contenuti
|
||||
|
||||
@@ -69,31 +71,41 @@ Il seed dei contenuti è in `src/data/content-seed.ts`; le variazioni sui conten
|
||||
|
||||
## Ruoli e accessi
|
||||
|
||||
Tre ruoli, con autorizzazione a matrice di prefissi in `src/lib/auth.ts`:
|
||||
Quattro ruoli, con autorizzazione a matrice di prefissi in `src/lib/auth.ts`:
|
||||
|
||||
| Ruolo | Può fare |
|
||||
|-------|----------|
|
||||
| `admin` | Tutto: contenuti, blog, upload, **gestione utenti** (`/admin/users`) |
|
||||
| `admin` | Tutto: contenuti, blog, upload, **gestione utenti** (`/admin/users`), Campus |
|
||||
| `superuser` | Pannello contenuti + blog |
|
||||
| `user` | Solo i **propri** articoli del blog |
|
||||
| `campus` | Solo la sezione riservata `/campus`; nessun accesso al pannello |
|
||||
|
||||
Login pubblico su `/login` (`?next` sanitizzato contro open redirect). La gestione utenti (`/admin/users`, solo admin) consente creazione, reset password una‑tantum, cambio ruolo ed eliminazione, con guardie contro l'auto‑eliminazione e la rimozione dell'ultimo admin.
|
||||
Login pubblico su `/login` (`?next` sanitizzato contro open redirect). Dopo l'autenticazione ogni ruolo viene indirizzato alla propria pagina iniziale: il pannello per admin e user, i contenuti per superuser, il Campus per il ruolo omonimo. La gestione utenti (`/admin/users`, solo admin) consente creazione, reset password una‑tantum, cambio ruolo ed eliminazione, con guardie contro l'auto‑eliminazione e la rimozione dell'ultimo admin.
|
||||
|
||||
## Campus (sezione riservata)
|
||||
|
||||
La sezione `/campus` raccoglie le guide di studio del corso Biohacking Campus. È protetta dal middleware come il pannello: un visitatore anonimo viene mandato al login, un utente con ruolo non abilitato torna alla propria pagina iniziale. Le pagine non montano l'header e il footer del sito — la navigazione avviene attraverso la barra laterale delle aree, con un unico richiamo per tornare alla home — ma usano i font, i colori e il CSS globale di InsanityLab.
|
||||
|
||||
I contenuti non vengono scritti a mano: lo script `npm run sync-campus` legge le guide sorgente (`*.studio.md`) dal progetto Biohacking Campus, le converte in frammenti HTML e produce la cartella `campus-content/` (indice `nav.json`, pagine e immagini delle slide), che va committata perché il deploy la copia nell'immagine Docker. Lo script è idempotente: rigenerarlo dopo l'aggiunta di nuove lezioni aggiorna indice e pagine e rimuove quelle non più presenti. Le nuove guide vanno prima dichiarate nella struttura dei capitoli in `scripts/campus/structure.mjs`.
|
||||
|
||||
Le immagini delle slide sono servite dalla route `/campus/assets/...`, anch'essa protetta: non sono raggiungibili senza una sessione valida.
|
||||
|
||||
## Struttura del progetto
|
||||
|
||||
```
|
||||
insanitylab-website/
|
||||
├── src/
|
||||
│ ├── pages/ # Route Astro (vetrina, /admin, /api)
|
||||
│ ├── pages/ # Route Astro (vetrina, /admin, /api, /campus)
|
||||
│ ├── components/ # Componenti (home/, content/, Header, Footer, …)
|
||||
│ ├── layouts/ # Layout Base
|
||||
│ ├── layouts/ # Layout Base, Admin, Campus
|
||||
│ ├── data/ # Dati statici + seed contenuti (services, trainings, site, content-seed)
|
||||
│ ├── lib/ # db, auth, content, mailer, rate-limit, safe-next, env
|
||||
│ ├── assets/img/ # Immagini ottimizzate da Astro
|
||||
│ └── styles/ # global.css
|
||||
├── data/ # SQLite (volume in produzione)
|
||||
├── uploads/ # Upload immagini (volume in produzione)
|
||||
├── scripts/ # create-user, smoke test
|
||||
├── campus-content/ # Contenuti del Campus generati da sync-campus
|
||||
├── scripts/ # create-user, sync-campus, smoke test
|
||||
├── astro.config.mjs # Config Astro (site, allowedDomains, redirects)
|
||||
├── compose.yaml # Stack Docker + label Traefik
|
||||
├── Dockerfile # Build multi-stage
|
||||
@@ -115,6 +127,7 @@ Il file `.env` (non versionato) richiede:
|
||||
| `CONTACT_TO` | Destinatario dei messaggi del form |
|
||||
| `DB_PATH` | Percorso del database SQLite |
|
||||
| `UPLOADS_DIR` | Cartella degli upload |
|
||||
| `CAMPUS_DIR` | Cartella dei contenuti del Campus (default `./campus-content`) |
|
||||
|
||||
La posta del dominio `@insanitylab.it` è ospitata su **Aruba**; l'invio del form usa l'SMTP autenticato Aruba (`smtps.aruba.it:465`). Aruba impone che il mittente sia la casella autenticata, quindi `CONTACT_FROM` deve essere uguale a `SMTP_USER`.
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { defineConfig } from 'astro/config';
|
||||
import node from '@astrojs/node';
|
||||
|
||||
import react from '@astrojs/react';
|
||||
|
||||
export default defineConfig({
|
||||
site: 'https://insanitylab.it',
|
||||
output: 'server',
|
||||
|
||||
// Dietro Traefik il TLS termina al proxy: senza allowedDomains Astro ignora
|
||||
// X-Forwarded-Proto/Host e il checkOrigin CSRF respinge i POST (403).
|
||||
// Dominio ufficiale insanitylab.it (canonico apex); www e il vecchio
|
||||
@@ -15,7 +18,9 @@ export default defineConfig({
|
||||
{ hostname: 'insanitylab.tielogic.xyz', protocol: 'https' },
|
||||
],
|
||||
},
|
||||
|
||||
adapter: node({ mode: 'standalone' }),
|
||||
|
||||
// La sezione "Programmi" è stata rinominata "Servizi": redirect permanenti dai vecchi URL.
|
||||
redirects: {
|
||||
'/programs': { status: 301, destination: '/services' },
|
||||
@@ -26,4 +31,6 @@ export default defineConfig({
|
||||
// "Personal Training" rinominato "One to One" (nuovo slug); Small Group è una pagina a sé.
|
||||
'/services/personal-training': { status: 301, destination: '/services/one-to-one' },
|
||||
},
|
||||
});
|
||||
|
||||
integrations: [react()],
|
||||
});
|
||||
|
After Width: | Height: | Size: 370 KiB |
|
After Width: | Height: | Size: 230 KiB |
|
After Width: | Height: | Size: 165 KiB |
|
After Width: | Height: | Size: 229 KiB |
|
After Width: | Height: | Size: 255 KiB |
|
After Width: | Height: | Size: 276 KiB |
|
After Width: | Height: | Size: 255 KiB |
|
After Width: | Height: | Size: 222 KiB |
|
After Width: | Height: | Size: 390 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 581 KiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 362 KiB |
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 551 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 170 KiB |
|
After Width: | Height: | Size: 380 KiB |
|
After Width: | Height: | Size: 676 KiB |
|
After Width: | Height: | Size: 542 KiB |
|
After Width: | Height: | Size: 384 KiB |
|
After Width: | Height: | Size: 363 KiB |
|
After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 560 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 247 KiB |
|
After Width: | Height: | Size: 632 KiB |
|
After Width: | Height: | Size: 452 KiB |
|
After Width: | Height: | Size: 374 KiB |
|
After Width: | Height: | Size: 575 KiB |
|
After Width: | Height: | Size: 410 KiB |
|
After Width: | Height: | Size: 347 KiB |
|
After Width: | Height: | Size: 357 KiB |
|
After Width: | Height: | Size: 258 KiB |
|
After Width: | Height: | Size: 837 KiB |
|
After Width: | Height: | Size: 268 KiB |
|
After Width: | Height: | Size: 323 KiB |
|
After Width: | Height: | Size: 350 KiB |
|
After Width: | Height: | Size: 212 KiB |
|
After Width: | Height: | Size: 405 KiB |
|
After Width: | Height: | Size: 283 KiB |
|
After Width: | Height: | Size: 408 KiB |
|
After Width: | Height: | Size: 765 KiB |
|
After Width: | Height: | Size: 370 KiB |
|
After Width: | Height: | Size: 439 KiB |
|
After Width: | Height: | Size: 224 KiB |
|
After Width: | Height: | Size: 531 KiB |
|
After Width: | Height: | Size: 791 KiB |
|
After Width: | Height: | Size: 408 KiB |
|
After Width: | Height: | Size: 702 KiB |
|
After Width: | Height: | Size: 551 KiB |
|
After Width: | Height: | Size: 308 KiB |
|
After Width: | Height: | Size: 196 KiB |
|
After Width: | Height: | Size: 257 KiB |
|
After Width: | Height: | Size: 300 KiB |
|
After Width: | Height: | Size: 229 KiB |
|
After Width: | Height: | Size: 294 KiB |
|
After Width: | Height: | Size: 394 KiB |
|
After Width: | Height: | Size: 397 KiB |
|
After Width: | Height: | Size: 172 KiB |
|
After Width: | Height: | Size: 377 KiB |
|
After Width: | Height: | Size: 230 KiB |
|
After Width: | Height: | Size: 247 KiB |
|
After Width: | Height: | Size: 256 KiB |
|
After Width: | Height: | Size: 231 KiB |
|
After Width: | Height: | Size: 939 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 365 KiB |
|
After Width: | Height: | Size: 329 KiB |
|
After Width: | Height: | Size: 489 KiB |
|
After Width: | Height: | Size: 397 KiB |
|
After Width: | Height: | Size: 654 KiB |
|
After Width: | Height: | Size: 494 KiB |
|
After Width: | Height: | Size: 413 KiB |
|
After Width: | Height: | Size: 371 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 550 KiB |
|
After Width: | Height: | Size: 639 KiB |
|
After Width: | Height: | Size: 388 KiB |
|
After Width: | Height: | Size: 400 KiB |
|
After Width: | Height: | Size: 654 KiB |
|
After Width: | Height: | Size: 611 KiB |
|
After Width: | Height: | Size: 593 KiB |
|
After Width: | Height: | Size: 149 KiB |
|
After Width: | Height: | Size: 202 KiB |
|
After Width: | Height: | Size: 162 KiB |
|
After Width: | Height: | Size: 443 KiB |
|
After Width: | Height: | Size: 393 KiB |
|
After Width: | Height: | Size: 284 KiB |
|
After Width: | Height: | Size: 157 KiB |
|
After Width: | Height: | Size: 203 KiB |
|
After Width: | Height: | Size: 353 KiB |
|
After Width: | Height: | Size: 400 KiB |