51 lines
3.4 KiB
HTML
51 lines
3.4 KiB
HTML
{# Блок «🔎 Источники» в карточке поста (кандидат и отобранный).
|
||
Рендерится и как часть страницы, и как htmx-фрагмент (hx-target="#sources-panel", outerHTML). #}
|
||
<div id="sources-panel" class="border-t border-neutral-200 pt-2 mt-2 shrink-0">
|
||
<div class="flex items-center justify-between gap-2 mb-1">
|
||
<span class="text-sm font-medium">🔎 Источники</span>
|
||
{% if enabled %}
|
||
<form hx-post="/posts/{{ post.id }}/find-sources" hx-target="#sources-panel" hx-swap="outerHTML"
|
||
hx-indicator="#src-spin" hx-disabled-elt="find button" method="post"
|
||
action="/posts/{{ post.id }}/find-sources">
|
||
<button class="btn btn-xs btn-outline" type="submit"
|
||
title="Найти первоисточник: ссылки из текста, затем поиск и оценка локальной моделью">Найти источники</button>
|
||
<span id="src-spin" class="htmx-indicator text-xs text-neutral-500">⏳ ищу…</span>
|
||
</form>
|
||
{% endif %}
|
||
</div>
|
||
|
||
{% if did %}<div class="text-xs text-green-700 mb-1">✅ {{ did }}</div>{% endif %}
|
||
{% if error %}<div class="text-xs text-red-600 mb-1">⚠ {{ error }}</div>{% endif %}
|
||
|
||
{% if candidates %}
|
||
<div class="flex flex-col gap-1 overflow-y-auto" style="max-height: 12rem;">
|
||
{% for c in candidates %}
|
||
<div class="flex items-start gap-2 text-xs border border-neutral-200 rounded-md px-2 py-1">
|
||
<div class="grow min-w-0">
|
||
<div class="flex items-center gap-1 flex-wrap">
|
||
<span class="badge badge-{{ 'info' if c.kind == 'telegram' else 'neutral' }}">{{ c.kind }}</span>
|
||
{% if c.score is not none %}<span class="badge badge-{{ 'success' if c.score >= 0.7 else 'warning' }}">{{ '%.1f'|format(c.score) }}</span>{% endif %}
|
||
<a href="{{ c.url }}" target="_blank" class="no-underline font-medium truncate">{{ c.domain or c.url }}</a>
|
||
</div>
|
||
<div class="text-neutral-600 truncate">{{ c.title or '' }}</div>
|
||
{% if c.reason %}<div class="text-neutral-500">{{ c.reason }}</div>{% endif %}
|
||
{% if c.snippet %}<details class="text-neutral-500"><summary class="cursor-pointer">сниппет</summary>{{ c.snippet }}</details>{% endif %}
|
||
</div>
|
||
<div class="flex flex-col gap-1 shrink-0">
|
||
<form hx-post="/posts/{{ post.id }}/sources/{{ c.id }}/accept" hx-target="#sources-panel" hx-swap="outerHTML"
|
||
method="post" action="/posts/{{ post.id }}/sources/{{ c.id }}/accept">
|
||
<button class="btn btn-xs btn-success" type="submit" title="Добавить в реестр источников (Telegram-канал или RSS-лента)">➕</button>
|
||
</form>
|
||
<form hx-post="/posts/{{ post.id }}/sources/{{ c.id }}/reject" hx-target="#sources-panel" hx-swap="outerHTML"
|
||
method="post" action="/posts/{{ post.id }}/sources/{{ c.id }}/reject">
|
||
<button class="btn btn-xs btn-outline text-red-600" type="submit" title="Не источник — больше не предлагать">❌</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
{% endfor %}
|
||
</div>
|
||
{% else %}
|
||
<div class="text-xs text-neutral-500">Источники не искали. «Найти источники» — ссылки из текста, затем поиск.</div>
|
||
{% endif %}
|
||
</div>
|