rss/templates/noticias.html

86 lines
2.9 KiB
HTML

<!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>
<!-- Enlace de gestión de feeds -->
<p><a href="/feeds">⚙️ Gestionar feeds RSS</a></p>
<form method="get" action="">
<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>
<p><a href="/feeds">← Volver a gestión de feeds</a></p>
</body>
</html>