Initial parser admin implementation

This commit is contained in:
Your Name
2026-06-15 21:14:07 +05:00
commit 59c899dc9c
51 changed files with 7052 additions and 0 deletions
+123
View File
@@ -0,0 +1,123 @@
{% extends "base.html" %}
{% block body %}
<div class="toolbar">
<div>
<h1>Источники</h1>
<div class="muted">VK-источники для парсинга. Название идёт в prompt, тэг — в будущие хэштеги.</div>
</div>
</div>
<details class="panel" {% if source_preview %}open{% endif %}>
<summary><strong>Добавить источники</strong></summary>
<div class="source-add-grid">
<form method="post" action="/sources/new">
<input type="hidden" name="csrf_token" value="{{ user.csrf_token }}">
<input type="hidden" name="platform" value="vk">
<input type="hidden" name="priority" value="100">
<label><span>Название</span><input name="name" placeholder="Можно оставить как в VK"></label>
<label><span>Тэг</span><input name="tag" placeholder="academy_gear"></label>
<label><span>Ссылка</span><input name="url" placeholder="https://vk.com/academy_gear" required></label>
<label class="checkline"><input name="active" type="checkbox" checked> <span>Включить сразу</span></label>
<button class="btn primary" type="submit">Добавить</button>
</form>
<form method="post" action="/sources/preview">
<input type="hidden" name="csrf_token" value="{{ user.csrf_token }}">
<input type="hidden" name="q" value="{{ q }}">
<input type="hidden" name="status_filter" value="{{ status_filter }}">
<input type="hidden" name="per_page" value="{{ pagination.per_page }}">
<label><span>Список источников</span>
<textarea name="bulk_text" rows="7" placeholder="Academy Gear academy_gear https://vk.com/academy_gear&#10;A2 Technologies a2technologies https://vk.com/a2technologies">{{ bulk_text }}</textarea>
</label>
<label class="checkline"><input name="bulk_active" type="checkbox" {% if bulk_active %}checked{% endif %}> <span>Включить после добавления</span></label>
<button class="btn" type="submit">Проверить список</button>
</form>
</div>
{% if source_preview %}
<div class="preview-block">
<h3>Предпросмотр</h3>
<table>
<tr><th>#</th><th>Название</th><th>Тэг</th><th>Ссылка</th><th>VK id</th><th>Проверка</th></tr>
{% for item in source_preview %}
<tr>
<td>{{ item.line_no }}</td>
<td>{{ item.name or "—" }}</td>
<td class="mono">#{{ item.tag or "—" }}</td>
<td><a href="{{ item.url }}" target="_blank">{{ item.url }}</a></td>
<td class="mono">{{ item.external_id }}<br>{{ item.external_owner_id or "" }}</td>
<td>{% if item.ok %}<span class="pill ok">готов</span>{% else %}<span class="pill bad">{{ item.error }}</span>{% endif %}</td>
</tr>
{% endfor %}
</table>
<form method="post" action="/sources/bulk" class="row">
<input type="hidden" name="csrf_token" value="{{ user.csrf_token }}">
<input type="hidden" name="bulk_payload" value='{{ source_preview|tojson }}'>
<button class="btn primary" type="submit">Добавить прошедшие проверку</button>
<span class="muted">Строки с ошибками и дубли будут пропущены.</span>
</form>
</div>
{% endif %}
</details>
<div class="panel">
<form class="filter-grid sources-filter" method="get" action="/sources">
<label><span>Поиск</span><input name="q" value="{{ q }}" placeholder="название, ссылка, id"></label>
<label><span>Статус</span>
<select name="status_filter">
<option value="">Все</option>
{% for st in ["new","ok","paused","error"] %}
<option value="{{ st }}" {% if status_filter == st %}selected{% endif %}>{{ st }}</option>
{% endfor %}
</select>
</label>
<label><span>На странице</span>
<select name="per_page">
{% for n in [25,50,100,200] %}
<option value="{{ n }}" {% if pagination.per_page == n %}selected{% endif %}>{{ n }}</option>
{% endfor %}
</select>
</label>
{% include "table_tools.html" %}
<button class="btn filter-submit" type="submit">Показать</button>
</form>
</div>
<div class="panel">
<table class="compact-table">
<tr>
<th>#</th><th>Площадка</th><th>Название</th><th>Тэг</th><th>Ссылка</th><th>Статус</th><th>Посты</th><th>Последний парсинг</th><th></th>
</tr>
{% for s in sources %}
<tr>
<td>{{ s.id }}</td>
<td>{{ s.platform }}</td>
<td>
<b>{{ s.name }}</b>
{% if s.active %}<span class="pill ok source-state">on</span>{% else %}<span class="pill bad source-state">off</span>{% endif %}
<div class="muted mono">{{ s.external_id or "" }}</div>
</td>
<td class="mono">#{{ s.tag or "—" }}</td>
<td class="source-url"><a href="{{ s.url }}" target="_blank">{{ s.url }}</a></td>
<td><span class="pill {% if s.status == 'ok' %}ok{% elif s.status == 'error' %}bad{% endif %}">{{ s.status }}</span>{% if s.status_msg %}<div class="muted status-msg">{{ s.status_msg }}</div>{% endif %}</td>
<td>{{ s.posts_count }} <span class="muted">+{{ s.posts_24h }}/24ч</span></td>
<td>{{ s.last_parsed_at_fmt or "нет" }}</td>
<td>
<div class="icon-actions">
<a class="icon-btn" href="/sources/{{ s.id }}/edit" title="Править" aria-label="Править"></a>
<form method="post" action="/sources/{{ s.id }}/toggle">
<input type="hidden" name="csrf_token" value="{{ user.csrf_token }}">
<button class="icon-btn" type="submit" title="{% if s.active %}Выключить{% else %}Включить{% endif %}" aria-label="Вкл/выкл"></button>
</form>
<form method="post" action="/sources/{{ s.id }}/delete" onsubmit="return confirm('Удалить источник {{ s.name }}?');">
<input type="hidden" name="csrf_token" value="{{ user.csrf_token }}">
<button class="icon-btn danger" type="submit" title="Удалить" aria-label="Удалить">×</button>
</form>
</div>
</td>
</tr>
{% endfor %}
</table>
{% include "pagination.html" %}
</div>
{% endblock %}