feat(web): published page on tailwind with css-only archive toggle

This commit is contained in:
kpa39l
2026-10-28 13:07:51 +00:00
parent 0e1462c6a8
commit 4f233d0ab2
2 changed files with 80 additions and 77 deletions
+79 -76
View File
@@ -1,10 +1,10 @@
{% extends "base.html" %}
{% block title %}Архив — Опубликовано{% endblock %}
{% block content %}
<div class="row">
<div class="grid grid-cols-1 lg:grid-cols-4 gap-4 items-start">
<!-- Левая колонка: список постов за выбранный период -->
<div class="col-lg-9">
<h4 class="mb-3">
<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 %}
@@ -15,17 +15,17 @@
{% set filter_label = year %}
{% endif %}
{% if filter_label %}
<span class="badge bg-secondary ms-2">{{ filter_label }}</span>
<span class="badge badge-neutral">{{ filter_label }}</span>
{% endif %}
<small class="text-muted fs-6 fw-normal">({{ total }})</small>
<small class="text-neutral-500 text-sm font-normal">({{ total }})</small>
</h4>
{% for p in posts %}
<div class="card mb-3">
<div class="card-body">
<div class="d-flex justify-content-between">
<span class="badge bg-secondary">#{{ p.id }} · {{ p.direction or '?' }}</span>
<small class="text-muted">{{ p.source_name }} · {{ p.published_at | dt }}</small>
<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 %}
@@ -33,26 +33,28 @@
{% 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="img-fluid rounded mt-2 d-block" style="max-height:180px" alt="медиа поста">
<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 d-block" style="max-height:180px"></video>
<video src="{{ media_src }}" controls class="mt-2 block" style="max-height:180px"></video>
{% endif %}
{% endif %}
{% if p.is_own %}<span class="badge bg-warning text-dark">⭐ СВОЙ</span>{% endif %}
<small class="text-muted">👁 {{ p.pub_views or p.views or 0 }}</small>
<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">
<small class="text-muted">Разослан в:</small>
<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 bg-info text-dark">@dedinit_vesti_{{ d }}_ru_bot</span>
<span class="badge badge-info">@dedinit_vesti_{{ d }}_ru_bot</span>
{% endfor %}
</div>
{% endif %}
{% if p.bundle_path %}
<a class="btn btn-sm btn-outline-primary ms-2" href="/bundle/{{ p.bundle_path }}" target="_blank">📄 Бандл</a>
{% endif %}
{% if p.tg_message_id %}<span class="badge bg-light text-dark ms-2">msg #{{ p.tg_message_id }}</span>{% endif %}
</div>
</div>
{% else %}
@@ -60,78 +62,79 @@
{% endfor %}
{% if pages > 1 %}
<nav aria-label="Пагинация архива">
<ul class="pagination justify-content-center">
<li class="page-item {% if page <= 1 %}disabled{% endif %}">
<a class="page-link" href="{{ _archive_href(year, month, nodate, page-1) }}" aria-label="Назад">&laquo;</a>
</li>
<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 %}
<li class="page-item"><a class="page-link" href="{{ _archive_href(year, month, nodate, 1) }}">1</a></li>
{% if from > 2 %}<li class="page-item disabled"><span class="page-link">…</span></li>{% endif %}
<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) %}
<li class="page-item {% if n == page %}active{% endif %}">
<a class="page-link" href="{{ _archive_href(year, month, nodate, n) }}">{{ n }}</a>
</li>
<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 %}<li class="page-item disabled"><span class="page-link">…</span></li>{% endif %}
<li class="page-item"><a class="page-link" href="{{ _archive_href(year, month, nodate, pages) }}">{{ pages }}</a></li>
{% 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 %}
<li class="page-item {% if page >= pages %}disabled{% endif %}">
<a class="page-link" href="{{ _archive_href(year, month, nodate, page+1) }}" aria-label="Вперёд">&raquo;</a>
</li>
</ul>
<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>
<!-- Правая колонка: дерево навигации по годам/месяцам -->
<div class="col-lg-3">
<!-- На мобильных — сворачивается под кнопку -->
<button class="btn btn-outline-secondary d-lg-none w-100 mb-2" type="button"
data-bs-toggle="collapse" data-bs-target="#archive-tree" aria-expanded="false" aria-controls="archive-tree">
🗂 Архив
</button>
<div id="archive-tree" class="collapse d-lg-block position-sticky" style="top: 5rem;">
<div class="card shadow-sm">
<div class="card-body py-3">
<h6 class="card-title mb-2">🗂 Архив</h6>
<div class="list-group list-group-flush">
<a href="/published"
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center {% if not year and not month and not nodate %}active{% endif %}">
Все посты
<span class="badge rounded-pill {% if not year and not month and not nodate %}bg-light text-dark{% else %}bg-secondary{% endif %}">{{ tree.years | sum(attribute='n') + tree.no_date }}</span>
</a>
{% for y in tree.years %}
<a href="/published?year={{ y.year }}"
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center {% if year == y.year and not month and not nodate %}active{% endif %}">
{{ y.year }}
<span class="badge rounded-pill {% if year == y.year and not month and not nodate %}bg-light text-dark{% else %}bg-secondary{% endif %}">{{ y.n }}</span>
<!-- Правая колонка: дерево навигации по годам/месяцам (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>
{% if year == y.year %}
{% for m in y.months %}
<a href="/published?year={{ y.year }}&month={{ m.m }}"
class="list-group-item list-group-item-action ps-4 d-flex justify-content-between align-items-center {% if month == m.m and not nodate %}active{% endif %}">
{{ m.label }}
<span class="badge rounded-pill {% if month == m.m and not nodate %}bg-light text-dark{% else %}bg-secondary{% endif %}">{{ m.n }}</span>
</a>
{% endfor %}
{% 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 %}
{% endfor %}
{% if tree.no_date > 0 %}
<a href="/published?nodate=1"
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center {% if nodate %}active{% endif %}">
Без даты
<span class="badge rounded-pill {% if nodate %}bg-light text-dark{% else %}bg-secondary{% endif %}">{{ tree.no_date }}</span>
</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}