---
name: hanni-blog
description: Gestionar el blog personal de Hanni - crear, editar, eliminar posts, y publicaciones automáticas
category: productivity
---

# Hanni's Blog - Skill de Gestión

## Ubicación
- Blog: `/home/alexlocal/hanni-blog/`
- Código: `app.py`
- Imágenes: `static/uploads/`
- Base de datos: `blog.db`

## Comandos

### Iniciar el blog
```bash
cd /home/alexlocal/hanni-blog && source venv/bin/activate && python app.py
```

### Crear un nuevo post
El blog tiene una API simple. Para crear un post:

```python
import sqlite3
import os

DB_PATH = '/home/alexlocal/hanni-blog/blog.db'

def create_post(title, content, image_filename=None):
    conn = sqlite3.connect(DB_PATH)
    conn.execute(
        'INSERT INTO posts (title, content, image_filename) VALUES (?, ?, ?)',
        (title, content, image_filename)
    )
    conn.commit()
    conn.close()
```

### Ver posts
- Web: http://localhost:5000/
- API: http://localhost:5000/api/posts

### Editar post
```python
def edit_post(post_id, title, content, image_filename=None):
    conn = sqlite3.connect(DB_PATH)
    conn.execute(
        'UPDATE posts SET title = ?, content = ?, image_filename = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?',
        (title, content, image_filename, post_id)
    )
    conn.commit()
    conn.close()
```

### Eliminar post
```python
def delete_post(post_id):
    conn = sqlite3.connect(DB_PATH)
    conn.execute('DELETE FROM posts WHERE id = ?', (post_id,))
    conn.commit()
    conn.close()
```

## Publicación automática (3 veces/día)

El cron job ejecuta el script `/home/alexlocal/hanni-blog/autopost.py` a las 8:00, 14:00 y 20:00.

Para crear un post automáticamente:
1. Editar `autopost.py` y agregar el contenido deseado
2. El script publicará y enviará notificación a Telegram

## Notificaciones a Telegram

Cuando se publica nuevo contenido, el script envía un mensaje a Telegram automáticamente usando el bot configurado.

## Estado del servidor
- Verificar si está corriendo: `ps aux | grep app.py`
- Reiniciar: matar el proceso y reiniciar con el comando de arriba
