Claude 425e66a473 Add edit modals and image upload for admin dashboard
User Interface Improvements:
- Added edit modal for skills with activate/deactivate checkbox
- Added edit modal for social links with activate/deactivate checkbox
- Skills and social links now default to "active" when created
- Better UX with inline editing instead of separate pages

Image Upload Feature:
- Implemented file upload for project images
- Support for png, jpg, jpeg, gif, webp (max 16 MB)
- Automatic filename sanitization and timestamp prefixing
- Preview of current image in edit mode
- Option to upload file OR enter manual URL
- Files saved to static/img/ directory

Modified Files:
- app.py: Added upload configuration (MAX_CONTENT_LENGTH, UPLOAD_FOLDER, ALLOWED_EXTENSIONS)
- routes/admin.py: Added save_uploaded_file() helper and file handling in project routes
- templates/admin/skills.html: Added edit modal with is_active checkbox
- templates/admin/social_links.html: Added edit modal with is_active checkbox
- templates/admin/project_form.html: Added file upload input with preview

Benefits:
- No more "inactive" items when creating new entries
- Easy toggle of active/inactive state
- Professional image upload with validation
- Better user experience overall
2025-11-13 15:29:10 +00:00
2025-06-03 22:59:48 +02:00
2025-05-06 23:33:23 +02:00
2025-04-28 10:42:28 +02:00
2025-01-04 14:40:52 +01:00
2025-02-20 15:12:09 +01:00

Portfolio Dinamico - Hersel.it

Portfolio personale sviluppato con Flask e MariaDB, con gestione dinamica dei contenuti tramite API REST.

🚀 Caratteristiche

  • Framework: Flask (migrato da Quart per semplificare l'architettura)
  • Database: MariaDB per la gestione dinamica dei contenuti
  • ORM: SQLAlchemy con Flask-SQLAlchemy
  • API REST: Endpoint per gestire progetti, competenze, profilo e social links
  • Docker: Configurazione completa con Docker Compose
  • Responsive: Design responsive con Bootstrap 5

📋 Requisiti

  • Python 3.10 o superiore
  • MariaDB/MySQL 11.2 o superiore (o usa Docker Compose)
  • Pip (gestore dei pacchetti Python)

🔧 Installazione Locale

1. Clona il repository

git clone https://github.com/BluLupo/hersel.it.git
cd hersel.it

2. Crea e attiva ambiente virtuale

python3 -m venv env
source env/bin/activate  # Linux/Mac
# oppure
env\Scripts\activate  # Windows

3. Installa le dipendenze

pip install -r requirements.txt

4. Configura le variabili d'ambiente

cp .env.example .env
# Modifica .env con le tue credenziali del database

5. Configura MariaDB

Crea il database e l'utente:

CREATE DATABASE portfolio_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'portfolio_user'@'localhost' IDENTIFIED BY 'portfolio_password';
GRANT ALL PRIVILEGES ON portfolio_db.* TO 'portfolio_user'@'localhost';
FLUSH PRIVILEGES;

6. Inizializza il database

python init_db.py

7. Avvia l'applicazione

# Modalità sviluppo
python app.py

# Modalità produzione con Gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app

🐳 Installazione con Docker

Requisiti

  • Docker
  • Docker Compose

Avvio rapido

docker-compose up -d

L'applicazione sarà disponibile su http://localhost:5000

Docker Compose avvierà automaticamente:

  • Container MariaDB sulla porta 3306
  • Container Flask sulla porta 5000
  • Inizializzazione automatica del database

📁 Struttura del Progetto

hersel.it/
├── app.py                      # Applicazione Flask principale
├── config.py                   # Configurazione
├── models.py                   # Modelli SQLAlchemy
├── init_db.py                  # Script inizializzazione database
├── requirements.txt            # Dipendenze Python
├── docker-compose.yml          # Configurazione Docker
├── .env.example               # Esempio variabili d'ambiente
├── routes/
│   ├── home.py                # Route homepage
│   └── api.py                 # API REST endpoints
├── templates/                 # Template Jinja2
│   ├── index.html
│   ├── head.html
│   ├── navbar.html
│   └── content/
│       ├── about.html
│       ├── project.html
│       └── links.html
└── static/                    # File statici (CSS, JS, immagini)

🔌 API REST Endpoints

Profile

  • GET /api/profile - Ottieni informazioni profilo
  • PUT /api/profile - Aggiorna profilo

Skills

  • GET /api/skills - Lista competenze
  • POST /api/skills - Crea competenza
  • PUT /api/skills/<id> - Aggiorna competenza
  • DELETE /api/skills/<id> - Elimina competenza

Projects

  • GET /api/projects - Lista progetti
  • POST /api/projects - Crea progetto
  • PUT /api/projects/<id> - Aggiorna progetto
  • DELETE /api/projects/<id> - Elimina progetto
  • GET /api/social-links - Lista link social
  • POST /api/social-links - Crea link social
  • PUT /api/social-links/<id> - Aggiorna link social
  • DELETE /api/social-links/<id> - Elimina link social

📊 Schema Database

Tabelle

  • profile - Informazioni personali
  • skills - Competenze tecnologiche
  • projects - Portfolio progetti
  • project_tags - Tag/badge progetti
  • social_links - Link profili social

🔄 Migrazione da Quart a Flask

Questo progetto è stato migrato da Quart (framework asincrono) a Flask (framework sincrono) per:

  • Semplificare l'architettura
  • Migliorare la compatibilità con librerie esistenti
  • Facilitare il deployment con server WSGI standard (Gunicorn)
  • Ridurre la complessità per un portfolio che non richiede operazioni async intensive

🛠️ Sviluppo

Aggiungere un nuovo progetto via API

curl -X POST http://localhost:5000/api/projects \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Nuovo Progetto",
    "description": "Descrizione del progetto",
    "image_url": "img/project.webp",
    "github_url": "https://github.com/username/repo",
    "tags": [
      {"name": "Python", "color_class": "bg-primary"},
      {"name": "Flask", "color_class": "bg-info"}
    ]
  }'

📝 Licenza

Copyright Hersel Giannella

Description
Languages
HTML 58.3%
Python 38.3%
JavaScript 1.7%
CSS 1.3%
Dockerfile 0.4%