Primer commit del proyecto RSS

This commit is contained in:
jlimolina 2025-05-24 14:37:58 +02:00
commit 27c9515d29
1568 changed files with 252311 additions and 0 deletions

76
templates/index.html Normal file
View file

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<title>Mis Feeds RSS</title>
<script>
// Script para filtrar países según continente elegido
function filtrarPaisesPorContinente() {
const continenteId = document.getElementById('continente_id').value;
const paises = JSON.parse(document.getElementById('paises-data').textContent);
const selectPais = document.getElementById('pais_id');
selectPais.innerHTML = '';
// Opción N/A siempre presente
const optionNA = document.createElement('option');
optionNA.value = '';
optionNA.textContent = '— N/A —';
selectPais.appendChild(optionNA);
paises.forEach(([id, nombre, contId]) => {
if (!continenteId || contId == continenteId) {
const opt = document.createElement('option');
opt.value = id;
opt.textContent = nombre;
selectPais.appendChild(opt);
}
});
}
</script>
</head>
<body>
<h1>Feeds configurados</h1>
<p><a href="/noticias">📄 Ver últimas noticias</a></p>
<h2>Añadir un nuevo feed</h2>
<form action="/add" method="post">
<input name="nombre" placeholder="Nombre del feed" required>
<input name="url" placeholder="URL del RSS" required>
<select name="categoria_id" required>
<option value="">— Elige categoría —</option>
{% for cid, cnom in categorias %}
<option value="{{ cid }}">{{ cnom }}</option>
{% endfor %}
</select>
<select name="continente_id" id="continente_id" onchange="filtrarPaisesPorContinente()">
<option value="">— Elige continente —</option>
{% for coid, conom in continentes %}
<option value="{{ coid }}">{{ conom }}</option>
{% endfor %}
</select>
<select name="pais_id" id="pais_id">
<option value="">— N/A —</option>
{% for pid, pnom, contid in paises %}
<option value="{{ pid }}">{{ pnom }}</option>
{% endfor %}
</select>
<button type="submit">Añadir</button>
<!-- Datos en JSON para el filtro dinámico de países -->
<script type="application/json" id="paises-data">{{ paises|tojson }}</script>
</form>
<h2>Lista de Feeds</h2>
<ul>
{% for id, nombre, url, categoria_id, pais_id, activo, cat_nom, pais_nom in feeds %}
<li>
<strong>{{ nombre }}</strong>
(<a href="{{ url }}" target="_blank">{{ url }}</a>)
— Categoría: {{ cat_nom or 'N/A' }}
— País: {{ pais_nom or 'N/A' }}
— Activo: {{ 'Sí' if activo else 'No' }}
</li>
{% else %}
<li>No hay feeds aún.</li>
{% endfor %}
</ul>
</body>
</html>

82
templates/noticias.html Normal file
View file

@ -0,0 +1,82 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<title>Últimas Noticias RSS</title>
<script>
function filtrarPaisesPorContinente() {
const continenteId = document.getElementById('continente_id').value;
const paises = JSON.parse(document.getElementById('paises-data').textContent);
const selectPais = document.getElementById('pais_id');
selectPais.innerHTML = '';
// Opción N/A siempre presente
const optionNA = document.createElement('option');
optionNA.value = '';
optionNA.textContent = '— N/A —';
selectPais.appendChild(optionNA);
paises.forEach(([id, nombre, contId]) => {
if (!continenteId || contId == continenteId) {
const opt = document.createElement('option');
opt.value = id;
opt.textContent = nombre;
selectPais.appendChild(opt);
}
});
}
</script>
</head>
<body>
<h1>Últimas Noticias Recopiladas</h1>
<p><a href="/">← Volver a feeds</a></p>
<form method="get" action="/noticias">
<select name="categoria_id">
<option value="">— Categoría —</option>
{% for cid, cnom in categorias %}
<option value="{{ cid }}" {% if cat_id == cid %}selected{% endif %}>{{ cnom }}</option>
{% endfor %}
</select>
<select name="continente_id" id="continente_id" onchange="filtrarPaisesPorContinente()">
<option value="">— Continente —</option>
{% for coid, conom in continentes %}
<option value="{{ coid }}" {% if cont_id == coid %}selected{% endif %}>{{ conom }}</option>
{% endfor %}
</select>
<select name="pais_id" id="pais_id">
<option value="">— País —</option>
{% for pid, pnom, contid in paises %}
<option value="{{ pid }}"
{% if pais_id == pid %}selected{% endif %}
{% if cont_id and contid != cont_id %}style="display:none"{% endif %}>
{{ pnom }}
</option>
{% endfor %}
</select>
<button type="submit">Filtrar</button>
<script type="application/json" id="paises-data">{{ paises|tojson }}</script>
</form>
<hr>
<ul>
{% for fecha, titulo, resumen, url, imagen_url, cat_nom, pais_nom, cont_nom in noticias %}
<li style="margin-bottom: 2em;">
<small><b>{{ fecha }}</b></small><br>
<a href="{{ url }}" target="_blank"><strong>{{ titulo }}</strong></a><br>
{% if imagen_url %}
<img src="{{ imagen_url }}" alt="img" style="max-width:200px; max-height:120px;"><br>
{% endif %}
<span>{{ resumen|safe }}</span><br>
<small>
Categoría: {{ cat_nom or 'N/A' }} |
País: {{ pais_nom or 'N/A' }} |
Continente: {{ cont_nom or 'N/A' }}
</small>
</li>
{% else %}
<li>No hay noticias que mostrar con estos filtros.</li>
{% endfor %}
</ul>
</body>
</html>