199 lines
13 KiB
HTML
199 lines
13 KiB
HTML
{% extends "base.html" %}
|
||
{% block page %}selected{% endblock %}
|
||
{% block title %}Отобранные{% endblock %}
|
||
{% block content %}
|
||
<div class="flex items-center justify-between mb-3 gap-2">
|
||
<h4 class="text-xl font-semibold m-0">⭐ Отобранные</h4>
|
||
<div class="text-neutral-500 text-sm">
|
||
{% if selected %}
|
||
#{{ selected.id }} · {{ selected.source_name or selected.tg_channel or '?' }}
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
|
||
{% if error %}
|
||
<div class="alert alert-error mb-3">❌ {{ error }}</div>
|
||
{% endif %}
|
||
|
||
<form class="flex flex-wrap items-center gap-2 mb-3" method="get" action="/selected"
|
||
hx-get="/selected" hx-target="#list-panel" hx-swap="outerHTML"
|
||
hx-trigger="submit, change delay:600ms from:select, keyup delay:500ms from:input[name='q']">
|
||
<input type="text" name="q" value="{{ q }}" class="input input-sm w-56 max-w-full" placeholder="поиск…">
|
||
<select name="direction" class="select select-sm w-48 max-w-full">
|
||
<option value="">Все направления</option>
|
||
{% for d in directions %}
|
||
<option value="{{ d }}" {% if direction == d %}selected{% endif %}>{{ d }}</option>
|
||
{% endfor %}
|
||
</select>
|
||
<select name="own" class="select select-sm w-40 max-w-full">
|
||
<option value="">Все посты</option>
|
||
<option value="1" {% if own == '1' %}selected{% endif %}>⭐ Свои</option>
|
||
<option value="0" {% if own == '0' %}selected{% endif %}>Внешние</option>
|
||
</select>
|
||
<button class="btn btn-sm btn-outline" type="submit">Применить</button>
|
||
</form>
|
||
|
||
{% set selected_qs = '&selected=' ~ selected.id if selected else '' %}
|
||
|
||
<div class="grid grid-cols-1 md:grid-cols-3 gap-2 items-start">
|
||
<!-- ЛЕВАЯ ПАНЕЛЬ: список отобранных -->
|
||
<div class="md:col-span-1 min-w-0">
|
||
{% include "_selected_list.html" %}
|
||
</div>
|
||
|
||
<!-- ПРАВАЯ ПАНЕЛЬ: детали отобранного + подготовка своего поста -->
|
||
<div class="md:col-span-2 min-w-0">
|
||
<div class="border border-neutral-200 rounded-md p-3 bg-white flex flex-col" style="height: calc(100vh - 160px);">
|
||
{% if selected %}
|
||
<div class="flex justify-between items-start shrink-0 gap-2">
|
||
<h5 class="text-lg font-semibold m-0">#{{ selected.id }} {{ selected.source_name or '?' }}</h5>
|
||
<small class="text-neutral-500">{{ (selected.published_at or selected.fetched_at) | dt }}</small>
|
||
</div>
|
||
<div class="mb-2 flex flex-wrap items-center gap-1 shrink-0">
|
||
{% if selected.direction %}<span class="badge badge-neutral">{{ selected.direction }}</span>{% endif %}
|
||
{% if selected.relevance %}<span class="badge badge-{{ 'success' if selected.relevance=='critical' else 'info' }}">{{ selected.relevance }}</span>{% endif %}
|
||
{% if selected.interest %}<span class="badge badge-warning">interest {{ selected.interest }}</span>{% endif %}
|
||
{% if selected.is_own %}<span class="badge badge-warning">⭐ СВОЙ</span>{% endif %}
|
||
{% if selected.fwd_from_channel_id %}<span class="badge badge-ghost">↩︎ форвард</span>{% endif %}
|
||
<small class="text-neutral-500 ms-2">👁 {{ selected.views }} 💬 {{ selected.reactions_total }}</small>
|
||
{% if selected.url %}<a class="btn btn-sm btn-outline ms-2" href="{{ selected.url }}" target="_blank">Исходник</a>{% endif %}
|
||
</div>
|
||
{% set hid %}<input type="hidden" name="group_by" value="{{ group_by }}"><input type="hidden" name="direction" value="{{ direction }}"><input type="hidden" name="own" value="{{ own }}"><input type="hidden" name="q" value="{{ q }}"><input type="hidden" name="src" value="selected">{% endset %}
|
||
<!-- Кнопки действий -->
|
||
<div class="flex flex-wrap gap-2 mb-2 shrink-0">
|
||
{% if selected.status != 'published' %}
|
||
<form method="post" action="/posts/{{ selected.id }}/reclassify" class="inline-flex gap-1 items-center">
|
||
{{ hid }}
|
||
<select name="manual_direction" class="select select-sm w-auto" title="Направление: выберите — задастся без модели; «— модель —» = классификация LLM">
|
||
<option value="">— модель —</option>
|
||
{% for d in directions %}
|
||
<option value="{{ d }}" {% if d == selected.direction %}selected{% endif %}>{{ d }}</option>
|
||
{% endfor %}
|
||
</select>
|
||
<button class="btn btn-info" type="submit" title="Прогнать через модель (qwen3:8b): направление, релевантность, интерес, резюме; или установить выбранное направление вручную">🤖 Обработать моделью</button>
|
||
</form>
|
||
{% endif %}
|
||
{% if selected.status != 'published' %}
|
||
<form method="post" action="/posts/{{ selected.id }}/rewrite">
|
||
{{ hid }}
|
||
<button class="btn btn-outline text-blue-600" type="submit" title="Сгенерировать черновик своего поста через модель — затем отредактируйте в поле справа">✍️ Переписать</button>
|
||
</form>
|
||
{% endif %}
|
||
{% if selected.status != 'published' %}
|
||
<form method="post" action="/posts/{{ selected.id }}/enqueue"
|
||
hx-post="/posts/{{ selected.id }}/enqueue" hx-swap="none">
|
||
{{ hid }}
|
||
<button class="btn btn-info" type="submit" title="Поставить в план публикации — пост уйдёт из «Отобранных» в очередь и будет опубликован в ближайший свободный слот">🗓 В очередь</button>
|
||
</form>
|
||
{% endif %}
|
||
{% if selected.status != 'rejected' and selected.status != 'published' %}
|
||
<form method="post" action="/posts/{{ selected.id }}/reject"
|
||
hx-post="/posts/{{ selected.id }}/reject" hx-swap="none">
|
||
{{ hid }}
|
||
<button class="btn btn-outline text-red-600" type="submit">🚫 Отклонить</button>
|
||
</form>
|
||
{% endif %}
|
||
</div>
|
||
{% with post = selected, candidates = src_candidates, did = '', error = '', enabled = find_enabled %}
|
||
{% include "_post_sources.html" %}
|
||
{% endwith %}
|
||
<!-- Резюме — сразу под кнопками -->
|
||
{% if selected.summary %}
|
||
<div class="shrink-0 mb-2">
|
||
<div class="border border-neutral-200 rounded-md bg-neutral-100 p-2 text-sm">
|
||
<span class="badge badge-neutral">резюме</span> {{ selected.summary }}
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
<hr class="shrink-0 my-2 border-neutral-200">
|
||
<!-- подготовка своего поста: редактор + оригинал рядом, на всю оставшуюся высоту -->
|
||
<div class="grid grid-cols-1 md:grid-cols-2 gap-2 grow" style="min-height:0;">
|
||
<div class="flex flex-col min-w-0" style="min-height:0;">
|
||
<h6 class="text-neutral-500 text-sm mt-0 mb-1">✍️ Мой пост (редактируйте/сохраните — пойдёт в канал от вашего имени)</h6>
|
||
<form method="post" action="/posts/{{ selected.id }}/rewrite-save" class="flex flex-col grow gap-1" style="min-height:0;">
|
||
{{ hid }}
|
||
<textarea class="input input-sm grow self-stretch w-full" name="rewritten_text" rows="8" style="flex-grow:1; min-height:140px; resize:vertical;">{{ selected.rewritten_text or '' }}</textarea>
|
||
<div class="mt-1">
|
||
<button class="btn btn-sm btn-outline text-blue-600" type="submit">💾 Сохранить</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="flex flex-col min-w-0" style="min-height:0;" x-data="{ tab: '{{ 'tr' if selected.translated_text else 'orig' }}' }">
|
||
<div class="flex items-center justify-between shrink-0 mb-1 gap-2">
|
||
<h6 class="text-neutral-500 text-sm mt-0 mb-0">Оригинальный пост</h6>
|
||
{% if not selected.translated_text %}
|
||
<form method="post" action="/posts/{{ selected.id }}/translate" class="m-0"
|
||
hx-post="/posts/{{ selected.id }}/translate" hx-swap="none">
|
||
{{ hid }}
|
||
<button class="btn btn-sm btn-outline text-blue-600" type="submit" title="Перевести пост на русский локальной моделью (qwen3:8b)">🌐 Перевести</button>
|
||
</form>
|
||
{% endif %}
|
||
</div>
|
||
{% if selected.translated_text %}
|
||
<div class="flex items-center gap-1 mb-1 shrink-0">
|
||
<button class="btn btn-xs" type="button" @click="tab='orig'"
|
||
:class="{ 'btn-primary': tab==='orig', 'btn-ghost': tab!=='orig' }">Оригинал</button>
|
||
<button class="btn btn-xs" type="button" @click="tab='tr'"
|
||
:class="{ 'btn-primary': tab==='tr', 'btn-ghost': tab!=='tr' }">Перевод</button>
|
||
</div>
|
||
{% endif %}
|
||
<div class="grow overflow-auto" style="min-height:0;">
|
||
<div :class="{ 'hidden': tab!=='orig' }">
|
||
<div class="border border-neutral-200 rounded-md p-2 bg-neutral-100 text-sm overflow-auto" style="min-height:0;">
|
||
{% if selected.text %}
|
||
<div class="post-text">{{ selected.text | safe_html }}</div>
|
||
{% endif %}
|
||
{% if selected.media_path %}
|
||
{% set media_src = '/media/' ~ selected.media_path.split('/')[-1] %}
|
||
{% set media_ext = selected.media_path.lower().rsplit('.', 1)[-1] if '.' in selected.media_path else '' %}
|
||
{% if media_ext in ['jpg','jpeg','png','gif','webp'] %}
|
||
<a href="{{ media_src }}" target="_blank" title="Открыть полноразмер">
|
||
<img src="{{ media_src }}" class="max-w-full h-auto rounded-md mt-2 block" style="max-height:50vh" alt="медиа поста">
|
||
</a>
|
||
{% elif media_ext in ['mp4','webm','mov'] %}
|
||
<video src="{{ media_src }}" controls class="mt-2 block" style="max-height:50vh"></video>
|
||
{% else %}
|
||
<a class="btn btn-sm btn-outline mt-2" href="{{ media_src }}" target="_blank">📎 Медиафайл</a>
|
||
{% endif %}
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
{% if selected.translated_text %}
|
||
<div :class="{ 'hidden': tab!=='tr' }">
|
||
<div class="border border-neutral-200 rounded-md p-2 bg-neutral-100 text-sm overflow-auto" style="min-height:0;">
|
||
<div class="post-text">{{ selected.translated_text | safe_html }}</div>
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<hr class="shrink-0 my-2 border-neutral-200">
|
||
<!-- Комментарий + публикация — в самом низу -->
|
||
{% if selected.status != 'published' %}
|
||
<div class="shrink-0 pt-2 border-t border-neutral-200">
|
||
<form method="post" action="/posts/{{ selected.id }}/approve" id="approve-form"
|
||
hx-post="/posts/{{ selected.id }}/approve" hx-swap="none">
|
||
{{ hid }}
|
||
<label class="text-sm text-neutral-500 mb-0 block" for="comment">💬 Мой комментарий (будет первым в канале):</label>
|
||
<textarea id="comment" class="input input-sm w-full mt-1" name="comment" rows="2"
|
||
placeholder="Комментарий/анонс…">{{ selected.comment or '' }}</textarea>
|
||
<div class="mt-2 flex flex-wrap gap-2">
|
||
<button class="btn btn-success" type="submit" hx-disabled-elt="this"
|
||
title="Опубликовать в канал: комментарий (если есть) первым, затем ваш текст (поле справа)/пересказ, картинка/видео, ссылка">✅ Опубликовать</button>
|
||
<button class="btn btn-sm btn-outline" type="submit"
|
||
formaction="/posts/{{ selected.id }}/comment"
|
||
title="Сохранить комментарий в черновик (не публикует). Он подтянется при следующей публикации">💾 Сохранить комментарий</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
{% endif %}
|
||
|
||
{% else %}
|
||
<div class="alert alert-info">Выберите отобранный пост слева</div>
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
{% endblock %}
|