Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/bluesky.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Check if PR contains document changes
id: check
Expand All @@ -30,6 +32,7 @@ jobs:
else
echo "document_changes=false" >> "$GITHUB_OUTPUT"
fi
echo "commit_hash=$(git log -1 --format=%H HEAD)" >> "$GITHUB_OUTPUT"

- name: Extract commit description
if: steps.check.outputs.document_changes == 'true'
Expand All @@ -38,11 +41,20 @@ jobs:
DESC=$(git log -1 --format=%B HEAD | awk -v RS='' 'NR == 2' | sed ':a;N;$!ba;s/\n/ /g')
echo "raw_desc=$DESC" >> "$GITHUB_OUTPUT"

- name: Compute decree URL
if: steps.check.outputs.document_changes == 'true'
id: decree_url
run: |
# La página del decreto se genera con scripts/generar_reformas.js.
npm ci
DECREE_URL=$(node scripts/generar_reformas.js --url "${{ steps.check.outputs.commit_hash }}")
echo "url=$DECREE_URL" >> "$GITHUB_OUTPUT"

- name: Build Bluesky post
if: steps.check.outputs.document_changes == 'true'
id: post
run: |
URL="${{ github.event.pull_request._links.html.href }}"
URL="${{ steps.decree_url.outputs.url }}"
RAW_DESC='${{ steps.desc.outputs.raw_desc }}'
MAX=300
URL_LEN=$(printf '%s' "$URL" | wc -m)
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- '.github/workflows/main.yml'
- 'pyproject.toml'
- 'uv.lock'
- 'package.json'
- 'package-lock.json'
pull_request:
branches: [main]
paths:
Expand All @@ -18,6 +20,8 @@ on:
- '.github/workflows/main.yml'
- 'pyproject.toml'
- 'uv.lock'
- 'package.json'
- 'package-lock.json'
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -56,6 +60,9 @@ jobs:
- name: Check CSS syntax
run: npx --package @biomejs/biome@latest biome check css/

- name: Check JavaScript syntax
run: npx --package @biomejs/biome@latest biome check scripts/*.js

- name: Lint Python scripts
run: uv run ruff check scripts/

Expand Down Expand Up @@ -90,6 +97,18 @@ jobs:
uv run ../scripts/rst2html5.py toc.rst ../html/index.html
uv run ../scripts/rst2html5.py acercade.rst ../html/acercade.html

- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: 'npm'

- name: Install Node dependencies
run: npm ci

- name: Generate reformas diff
run: node scripts/generar_reformas.js

- name: Validate generated HTML
run: |
tidy -e -q html/index.html
Expand Down
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Node
node_modules/
npm-debug.log*

# Entorno
__pycache__/
*.pyc
.venv/
.ruff_cache/

# Salida generada
html/
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ repos:
rev: v2.5.5
hooks:
- id: biome-check
- id: biome-check
name: biome-check-javascript
files: '\.(js)$'
- repo: local
hooks:
- id: diccionario
Expand Down
32 changes: 32 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ partir de los decretos y otros cambios Constitucionales registrados en
uv run ../scripts/rst2html5.py toc.rst ../html/index.html
```

- `scripts/generar_reformas.js`: es un script en JavaScript que, usando
el paquete [`diff2html`](https://www.npmjs.com/package/diff2html),
genera una página HTML con el diff de cada reforma constitucional
(con una apariencia similar a la de GitHub) y un índice de todas las
reformas en `html/reformas/`.

Para ejecutar el script:

```bash
node scripts/generar_reformas.js
```

### Uso de Python

Python se usa a través de un entorno virtual controlado con `uv`. El
Expand All @@ -63,6 +75,26 @@ Usar `biome` para validar y corregir formato de archivos CSS.
npx @biomejs/biome lint --write css/
```

### JavaScript

Usar `biome` para validar y corregir formato de los scripts en
JavaScript.

```bash
npx @biomejs/biome check scripts/*.js
npx @biomejs/biome lint --write scripts/*.js
npx @biomejs/biome format --write scripts/*.js
```

Las dependencias de los scripts en JavaScript se gestionan con `npm` y
se describen en `package.json`. Para instalar las dependencias y
generar los diffs de reformas se ejecuta:

```bash
npm install
node scripts/generar_reformas.js
```

## pre-commit

El proyecto utiliza `pre-commit` para realizar revisiones automáticas a
Expand Down
28 changes: 14 additions & 14 deletions css/cpeum.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,6 @@ aside.sidebar .sidebar-title {
color: #222;
}

aside.sidebar ul {
margin: 0;
padding: 0;
list-style: none;
}

aside.sidebar ul > li {
border-bottom: thin solid #e0e0e0;
}

aside.sidebar ul > li:last-child {
border-bottom: none;
}

aside.sidebar :where(li) {
margin-bottom: 0;
padding: 6px 0;
Expand Down Expand Up @@ -431,3 +417,17 @@ main > p,
main > section:first-of-type {
display: block;
}

aside.sidebar ul {
margin: 0;
padding: 0;
list-style: none;
}

aside.sidebar ul > li {
border-bottom: thin solid #e0e0e0;
}

aside.sidebar ul > li:last-child {
border-bottom: none;
}
94 changes: 94 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "cpeum-diffs",
"version": "0.1.0",
"private": true,
"description": "Genera un diff HTML (estilo diff2html/github) por cada reforma constitucional",
"type": "commonjs",
"scripts": {
"reformas": "node scripts/generar_reformas.js"
},
"dependencies": {
"diff": "^9.0.0",
"diff2html": "^3.4.56"
}
}
9 changes: 7 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ cd "${SCRIPT_DIR}/CPEUM"
uv run "${SCRIPTS_DIR}/rst2html5.py" toc.rst "${HTML_DIR}/index.html"
uv run "${SCRIPTS_DIR}/rst2html5.py" acercade.rst "${HTML_DIR}/acercade.html"

# Paso 3: Iniciar servidor HTTP en segundo plano
# Paso 3: Generar los diffs de las reformas y su índice
echo "==> Generando reformas..."
cd "${SCRIPT_DIR}"
node "${SCRIPTS_DIR}/generar_reformas.js"

# Paso 4: Iniciar servidor HTTP en segundo plano
echo "==> Iniciando servidor HTTP en puerto 8000..."
cd "${HTML_DIR}"
python3 -m http.server 8000 &
Expand All @@ -39,7 +44,7 @@ echo "==> PID del servidor: ${SERVER_PID}"
# Limpiar al salir
trap 'echo "==> Deteniendo servidor..."; kill ${SERVER_PID} 2>/dev/null' EXIT

# Paso 3: Abrir navegador
# Paso 5: Abrir navegador
sleep 0.5
xdg-open http://127.0.0.1:8000

Expand Down
Loading