Files

141 lines
7.7 KiB
HTML

{% extends "base.html" %}
{% block title %}Архив — Опубликовано{% endblock %}
{% block content %}
<div class="grid grid-cols-1 lg:grid-cols-4 gap-4 items-start">
<!-- Левая колонка: список постов за выбранный период -->
<div class="lg:col-span-3 min-w-0">
<h4 class="text-xl font-semibold mb-4 flex items-center gap-2 flex-wrap">
Опубликованные посты
{% set filter_label = '' %}
{% if nodate %}
{% set filter_label = 'Без даты' %}
{% elif year and month %}
{% set filter_label = year ~ '-' ~ month %}
{% elif year %}
{% set filter_label = year %}
{% endif %}
{% if filter_label %}
<span class="badge badge-neutral">{{ filter_label }}</span>
{% endif %}
<small class="text-neutral-500 text-sm font-normal">({{ total }})</small>
</h4>
{% for p in posts %}
<div class="card card-outline mb-4 bg-white">
<div class="card-content">
<div class="flex justify-between gap-2 flex-wrap">
<span class="badge badge-neutral">#{{ p.id }} · {{ p.direction or '?' }}</span>
<small class="text-neutral-500">{{ p.source_name }} · {{ p.published_at | dt }}</small>
</div>
<div class="post-text mt-2">{{ (p.summary or p.text or '')[:2000] | markdown }}</div>
{% if p.media_path %}
{% set media_src = '/media/' ~ p.media_path.split('/')[-1] %}
{% set media_ext = p.media_path.lower().rsplit('.', 1)[-1] if '.' in p.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:180px" alt="медиа поста">
</a>
{% elif media_ext in ['mp4','webm','mov'] %}
<video src="{{ media_src }}" controls class="mt-2 block" style="max-height:180px"></video>
{% endif %}
{% endif %}
<div class="flex flex-wrap items-center gap-1 mt-1">
{% if p.is_own %}<span class="badge badge-warning">⭐ СВОЙ</span>{% endif %}
<small class="text-neutral-500">👁 {{ p.pub_views or p.views or 0 }}</small>
{% if p.tg_message_id %}<span class="badge badge-ghost">msg #{{ p.tg_message_id }}</span>{% endif %}
{% if p.bundle_path %}
<a class="btn btn-sm btn-outline text-blue-600" href="/bundle/{{ p.bundle_path }}" target="_blank">📄 Бандл</a>
{% endif %}
</div>
{% if p.distributed_dirs %}
<div class="mt-2 flex flex-wrap items-center gap-1">
<small class="text-neutral-500">Разослан в:</small>
{% for d in (p.distributed_dirs | from_json) %}
<span class="badge badge-info">@dedinit_vesti_{{ d }}_ru_bot</span>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% else %}
<div class="alert alert-info">Нет постов за этот период</div>
{% endfor %}
{% if pages > 1 %}
<nav aria-label="Пагинация архива" class="flex justify-center mt-4">
<div class="join">
<a class="join-item btn btn-sm{% if page <= 1 %} btn-disabled{% endif %}"
href="{{ _archive_href(year, month, nodate, page-1) }}" aria-label="Назад">&laquo;</a>
{% set from = [1, page - 3] | max %}
{% set to = [pages, page + 3] | min %}
{% if from > 1 %}
<a class="join-item btn btn-sm" href="{{ _archive_href(year, month, nodate, 1) }}">1</a>
{% if from > 2 %}<span class="join-item btn btn-sm btn-disabled">…</span>{% endif %}
{% endif %}
{% for n in range(from, to + 1) %}
<a class="join-item btn btn-sm{% if n == page %} btn-primary{% endif %}"
href="{{ _archive_href(year, month, nodate, n) }}">{{ n }}</a>
{% endfor %}
{% if to < pages %}
{% if to < pages - 1 %}<span class="join-item btn btn-sm btn-disabled">…</span>{% endif %}
<a class="join-item btn btn-sm" href="{{ _archive_href(year, month, nodate, pages) }}">{{ pages }}</a>
{% endif %}
<a class="join-item btn btn-sm{% if page >= pages %} btn-disabled{% endif %}"
href="{{ _archive_href(year, month, nodate, page+1) }}" aria-label="Вперёд">&raquo;</a>
</div>
</nav>
{% endif %}
</div>
<!-- Правая колонка: дерево навигации по годам/месяцам (CSS-only collapsible, без JS) -->
<div class="lg:col-span-1 min-w-0">
<div class="collapsible">
<input type="checkbox" id="archive-toggle" class="collapsible-toggle">
<!-- На мобильных — переключатель под кнопку; на десктопе дерево раскрыто всегда -->
<label class="btn btn-outline w-full mb-2 lg:hidden" for="archive-toggle" aria-controls="archive-tree">
🗂 Архив <span class="collapsible-arrow"></span>
</label>
<div id="archive-tree" class="collapsible-content lg:[grid-template-rows:1fr]">
<div>
<div class="card card-outline bg-white lg:sticky lg:top-16">
<div class="card-content p-3">
<h6 class="card-title text-base mb-2">🗂 Архив</h6>
<div class="divide-y divide-neutral-200 text-sm">
<a href="/published"
class="flex justify-between items-center gap-2 py-2 px-1 no-underline text-inherit hover:bg-neutral-100 {% if not year and not month and not nodate %}font-semibold bg-neutral-100{% endif %}">
Все посты
<span class="badge badge-pill {% if not year and not month and not nodate %}badge-outline{% else %}badge-neutral{% endif %}">{{ tree.years | sum(attribute='n') + tree.no_date }}</span>
</a>
{% for y in tree.years %}
<a href="/published?year={{ y.year }}"
class="flex justify-between items-center gap-2 py-2 px-1 no-underline text-inherit hover:bg-neutral-100 {% if year == y.year and not month and not nodate %}font-semibold bg-neutral-100{% endif %}">
{{ y.year }}
<span class="badge badge-pill {% if year == y.year and not month and not nodate %}badge-outline{% else %}badge-neutral{% endif %}">{{ y.n }}</span>
</a>
{% if year == y.year %}
{% for m in y.months %}
<a href="/published?year={{ y.year }}&month={{ m.m }}"
class="flex justify-between items-center gap-2 py-2 pl-5 pr-1 no-underline text-inherit hover:bg-neutral-100 {% if month == m.m and not nodate %}font-semibold bg-neutral-100{% endif %}">
{{ m.label }}
<span class="badge badge-pill {% if month == m.m and not nodate %}badge-outline{% else %}badge-neutral{% endif %}">{{ m.n }}</span>
</a>
{% endfor %}
{% endif %}
{% endfor %}
{% if tree.no_date > 0 %}
<a href="/published?nodate=1"
class="flex justify-between items-center gap-2 py-2 px-1 no-underline text-inherit hover:bg-neutral-100 {% if nodate %}font-semibold bg-neutral-100{% endif %}">
Без даты
<span class="badge badge-pill {% if nodate %}badge-outline{% else %}badge-neutral{% endif %}">{{ tree.no_date }}</span>
</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}