mejora de la semantica

This commit is contained in:
jlimolina 2025-11-19 21:29:15 +01:00
parent d508dc2058
commit cb8f69fb93
10 changed files with 191 additions and 227 deletions

View file

@ -1,15 +1,14 @@
{% extends "base.html" %}
{% block title %}
{% set d = dato if dato is defined else (r if r is defined else None) %}
{% if d %}
{{ d.titulo_trad or d.titulo_orig or d.titulo_traducido or d.titulo_original or 'Detalle de Noticia' }}
{% if dato %}
{{ dato.titulo_trad or dato.titulo_orig or 'Detalle de Noticia' }}
{% else %}
Detalle de Noticia
{% endif %}
{% endblock %}
{% block content %}
{% set d = dato if dato is defined else (r if r is defined else None) %}
{% set d = dato %}
{% if not d %}
<div class="card">
@ -21,12 +20,14 @@
<div class="card">
<div class="feed-header">
<h2 style="margin:0;">
{{ d.titulo_trad or d.titulo_orig or d.titulo_traducido or d.titulo_original }}
{% if d.lang_to %}<span class="badge" title="Traducción">{{ d.lang_to|upper }}</span>{% endif %}
{{ d.titulo_trad or d.titulo_orig }}
{% if d.lang_to %}
<span class="badge" title="Traducción">{{ d.lang_to|upper }}</span>
{% endif %}
</h2>
{% if d.fuente_url or d.url %}
{% if d.url %}
<div>
<a class="btn btn-small" href="{{ d.fuente_url or d.url }}" target="_blank" rel="noopener">Ver fuente</a>
<a class="btn btn-small" href="{{ d.url }}" target="_blank" rel="noopener">Ver fuente</a>
</div>
{% endif %}
</div>
@ -36,46 +37,52 @@
{% set fecha_ = d.fecha %}
{% if fecha_ %}
<i class="far fa-calendar-alt"></i>
{% if fecha_ is string %}{{ fecha_ }}{% else %}{{ fecha_.strftime('%d-%m-%Y %H:%M') }}{% endif %}
{% if fecha_ is string %}
{{ fecha_ }}
{% else %}
{{ fecha_.strftime('%d-%m-%Y %H:%M') }}
{% endif %}
{% endif %}
{% if d.fuente_nombre %} | <i class="fas fa-newspaper"></i> {{ d.fuente_nombre }}{% endif %}
{% if d.categoria %} | <i class="fas fa-tag"></i> {{ d.categoria }}{% endif %}
{% if d.pais %} | <i class="fas fa-globe-americas"></i> {{ d.pais }}{% endif %}
</div>
{% if d.resumen_trad or d.cuerpo_traducido %}
{% if d.imagen_url %}
<div style="margin-bottom:16px; text-align:center;">
<img src="{{ d.imagen_url }}" alt="Imagen de la noticia" style="max-width:100%; height:auto;" loading="lazy">
</div>
{% endif %}
{% if d.resumen_trad %}
<h3>Resumen (traducido)</h3>
<div>{{ (d.resumen_trad or d.cuerpo_traducido)|safe_html }}</div>
<div>{{ d.resumen_trad|safe_html }}</div>
<hr>
{% endif %}
{% if d.resumen_orig or d.cuerpo_original or d.resumen or d.titulo_original %}
{% if d.resumen_orig %}
<h3>Resumen (original)</h3>
<div>{{ (d.resumen_orig or d.cuerpo_original or d.resumen)|safe_html }}</div>
<div>{{ d.resumen_orig|safe_html }}</div>
{% endif %}
{% if tags is defined and tags and tags|length %}
{% if tags and tags|length %}
<div style="margin-top:16px;">
{% for t in tags %}
{# t puede ser DictRow (t['valor']) o tupla (t.0) #}
{% set valor = t.valor if t.valor is defined else (t[0] if t[0] is defined else '') %}
{% set tipo = t.tipo if t.tipo is defined else (t[1] if t[1] is defined else '') %}
<span class="badge" title="{{ (tipo or '')|capitalize }}">{{ valor }}</span>
<span class="badge" title="{{ (t.tipo or '')|capitalize }}">{{ t.valor }}</span>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% set rels = relacionadas if relacionadas is defined else None %}
{% if rels and rels|length %}
{% if relacionadas and relacionadas|length %}
<div class="card" style="margin-top:18px;">
<div class="card-header">
<h3 style="margin:0;">Noticias relacionadas</h3>
</div>
<div class="feed-body">
<ul class="noticias-list">
{% for r in rels %}
{% for r in relacionadas %}
<li class="noticia-item">
{% if r.imagen_url %}
<div class="noticia-imagen">
@ -91,14 +98,17 @@
<div class="noticia-meta">
{% if r.fecha %}
<i class="far fa-calendar-alt"></i>
{% if r.fecha is string %}{{ r.fecha }}{% else %}{{ r.fecha.strftime('%d-%m-%Y %H:%M') }}{% endif %}
{% if r.fecha is string %}
{{ r.fecha }}
{% else %}
{{ r.fecha.strftime('%d-%m-%Y %H:%M') }}
{% endif %}
{% endif %}
{% if r.fuente_nombre %} | <i class="fas fa-newspaper"></i> {{ r.fuente_nombre }}{% endif %}
{% if r.score is defined %} | <span title="Similitud coseno">score: {{ "%.3f"|format(r.score) }}</span>{% endif %}
{% if r.score is defined %}
| <span title="Similitud coseno">score: {{ "%.3f"|format(r.score) }}</span>
{% endif %}
</div>
{% if r.resumen %}
<div class="clamp">{{ r.resumen }}</div>
{% endif %}
</div>
</li>
{% endfor %}