documents/ipop.md
2025-01-29 07:28:55 +00:00

107 lines
2.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Workflow: Markdown → Gitea → HTTP + PDF
Aquest document explica com automatitzar la publicació d'informes d'orientació professional en un site estàtic, utilitzant **Markdown**, **Gitea**, **hooks** i **generació de PDF**.
## 1⃣ Escriu el contingut en Markdown
Crea els teus informes **IPOP** en `.md` i puja'ls a un repositori de **Gitea**.
### Exemple de `informe.md`
```md
# Informe Personal dOrientació Professional
## Joan Garcia
- **Àrees professionals:** Enginyeria, Disseny Gràfic
- **Competències destacades:** Anàlisi, Creativitat, Resolució de Problemes
```
---
## 2⃣ Puja els fitxers a Gitea
Executa:
```sh
git add informe.md
git commit -m "Afegit informe Joan Garcia"
git push origin main
```
---
## 3⃣ Automatització amb Gitea Webhooks
Quan es detecta un canvi en el repo, un **hook automàtic** executa el generador de site estàtic.
### Exemple de Hook (`gitea-hooks.sh`)
```sh
#!/bin/bash
cd /var/www/informes
git pull origin main
hugo -D # O jekyll build
systemctl restart nginx # Si cal refrescar el servidor
```
Configura el webhook a **Gitea** per executar aquest script.
---
## 4⃣ Site estàtic accessible via HTTP
Ara el teu site està **publicat automàticament** en:
- `http://empresa.com/informes/joan-garcia`
- `http://intranet/informes/`
**Frameworks recomanats:**
- **Hugo** → Lleuger i ràpid
- **Jekyll** → Suporta directament Markdown
- **Eleventy** → Molt flexible
---
## 5⃣ Generació de PDFs sota demanda
Opcions per a la generació de PDF:
### ✅ Opció 1: Client-side (JavaScript - jsPDF)
```html
<button id="pdf">Descarrega PDF</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.4.0/jspdf.umd.min.js"></script>
<script>
document.getElementById('pdf').addEventListener('click', function () {
var doc = new window.jspdf.jsPDF();
doc.text(document.body.innerText, 10, 10);
doc.save("informe.pdf");
});
</script>
```
✔️ No requereix backend, tot passa al navegador.
### ✅ Opció 2: Server-side (Puppeteer o Pandoc)
Generació amb Puppeteer (Node.js):
```js
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://empresa.com/informes/joan-garcia', {waitUntil: 'networkidle2'});
await page.pdf({path: 'informe.pdf', format: 'A4'});
await browser.close();
})();
```
✔️ Millor formatació, però requereix configuració de servidor.
---
## 🔁 Flux del Workflow
```
Markdown (Gitea Repo) --> Webhook --> Site Estàtic (Hugo/Jekyll) --> Web HTML
\
--> API PDF (Puppeteer o jsPDF)
```
## 📌 Conclusió
**Automatitzat**: `git push` i la web s'actualitza sola.
**Offline-ready**: HTML navegable + PDFs generats sota demanda.
**Eficient i segur**: Sense bases de dades, tot en fitxers.