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
File diff suppressed because one or more lines are too long
+78 -75
View File
@@ -1,10 +1,10 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Архив — Опубликовано{% endblock %} {% block title %}Архив — Опубликовано{% endblock %}
{% block content %} {% block content %}
<div class="row"> <div class="grid grid-cols-1 lg:grid-cols-4 gap-4 items-start">
<!-- Левая колонка: список постов за выбранный период --> <!-- Левая колонка: список постов за выбранный период -->
<div class="col-lg-9"> <div class="lg:col-span-3 min-w-0">
<h4 class="mb-3"> <h4 class="text-xl font-semibold mb-4 flex items-center gap-2 flex-wrap">
Опубликованные посты Опубликованные посты
{% set filter_label = '' %} {% set filter_label = '' %}
{% if nodate %} {% if nodate %}
@@ -15,17 +15,17 @@
{% set filter_label = year %} {% set filter_label = year %}
{% endif %} {% endif %}
{% if filter_label %} {% if filter_label %}
<span class="badge bg-secondary ms-2">{{ filter_label }}</span> <span class="badge badge-neutral">{{ filter_label }}</span>
{% endif %} {% endif %}
<small class="text-muted fs-6 fw-normal">({{ total }})</small> <small class="text-neutral-500 text-sm font-normal">({{ total }})</small>
</h4> </h4>
{% for p in posts %} {% for p in posts %}
<div class="card mb-3"> <div class="card card-outline mb-4 bg-white">
<div class="card-body"> <div class="card-content">
<div class="d-flex justify-content-between"> <div class="flex justify-between gap-2 flex-wrap">
<span class="badge bg-secondary">#{{ p.id }} · {{ p.direction or '?' }}</span> <span class="badge badge-neutral">#{{ p.id }} · {{ p.direction or '?' }}</span>
<small class="text-muted">{{ p.source_name }} · {{ p.published_at | dt }}</small> <small class="text-neutral-500">{{ p.source_name }} · {{ p.published_at | dt }}</small>
</div> </div>
<div class="post-text mt-2">{{ (p.summary or p.text or '')[:2000] | markdown }}</div> <div class="post-text mt-2">{{ (p.summary or p.text or '')[:2000] | markdown }}</div>
{% if p.media_path %} {% if p.media_path %}
@@ -33,26 +33,28 @@
{% set media_ext = p.media_path.lower().rsplit('.', 1)[-1] if '.' in p.media_path else '' %} {% 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'] %} {% if media_ext in ['jpg','jpeg','png','gif','webp'] %}
<a href="{{ media_src }}" target="_blank" title="Открыть полноразмер"> <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> </a>
{% elif media_ext in ['mp4','webm','mov'] %} {% 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 %}
{% endif %} {% endif %}
{% if p.is_own %}<span class="badge bg-warning text-dark">⭐ СВОЙ</span>{% endif %} <div class="flex flex-wrap items-center gap-1 mt-1">
<small class="text-muted">👁 {{ p.pub_views or p.views or 0 }}</small> {% 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 %} {% if p.distributed_dirs %}
<div class="mt-2"> <div class="mt-2 flex flex-wrap items-center gap-1">
<small class="text-muted">Разослан в:</small> <small class="text-neutral-500">Разослан в:</small>
{% for d in (p.distributed_dirs | from_json) %} {% 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 %} {% endfor %}
</div> </div>
{% endif %} {% 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>
</div> </div>
{% else %} {% else %}
@@ -60,76 +62,77 @@
{% endfor %} {% endfor %}
{% if pages > 1 %} {% if pages > 1 %}
<nav aria-label="Пагинация архива"> <nav aria-label="Пагинация архива" class="flex justify-center mt-4">
<ul class="pagination justify-content-center"> <div class="join">
<li class="page-item {% if page <= 1 %}disabled{% endif %}"> <a class="join-item btn btn-sm{% if page <= 1 %} btn-disabled{% endif %}"
<a class="page-link" href="{{ _archive_href(year, month, nodate, page-1) }}" aria-label="Назад">&laquo;</a> href="{{ _archive_href(year, month, nodate, page-1) }}" aria-label="Назад">&laquo;</a>
</li>
{% set from = [1, page - 3] | max %} {% set from = [1, page - 3] | max %}
{% set to = [pages, page + 3] | min %} {% set to = [pages, page + 3] | min %}
{% if from > 1 %} {% if from > 1 %}
<li class="page-item"><a class="page-link" href="{{ _archive_href(year, month, nodate, 1) }}">1</a></li> <a class="join-item btn btn-sm" href="{{ _archive_href(year, month, nodate, 1) }}">1</a>
{% if from > 2 %}<li class="page-item disabled"><span class="page-link">…</span></li>{% endif %} {% if from > 2 %}<span class="join-item btn btn-sm btn-disabled">…</span>{% endif %}
{% endif %} {% endif %}
{% for n in range(from, to + 1) %} {% for n in range(from, to + 1) %}
<li class="page-item {% if n == page %}active{% endif %}"> <a class="join-item btn btn-sm{% if n == page %} btn-primary{% endif %}"
<a class="page-link" href="{{ _archive_href(year, month, nodate, n) }}">{{ n }}</a> href="{{ _archive_href(year, month, nodate, n) }}">{{ n }}</a>
</li>
{% endfor %} {% endfor %}
{% if to < pages %} {% if to < pages %}
{% if to < pages - 1 %}<li class="page-item disabled"><span class="page-link">…</span></li>{% endif %} {% if to < pages - 1 %}<span class="join-item btn btn-sm btn-disabled">…</span>{% endif %}
<li class="page-item"><a class="page-link" href="{{ _archive_href(year, month, nodate, pages) }}">{{ pages }}</a></li> <a class="join-item btn btn-sm" href="{{ _archive_href(year, month, nodate, pages) }}">{{ pages }}</a>
{% endif %} {% endif %}
<li class="page-item {% if page >= pages %}disabled{% endif %}"> <a class="join-item btn btn-sm{% if page >= pages %} btn-disabled{% endif %}"
<a class="page-link" href="{{ _archive_href(year, month, nodate, page+1) }}" aria-label="Вперёд">&raquo;</a> href="{{ _archive_href(year, month, nodate, page+1) }}" aria-label="Вперёд">&raquo;</a>
</li> </div>
</ul>
</nav> </nav>
{% endif %} {% endif %}
</div> </div>
<!-- Правая колонка: дерево навигации по годам/месяцам --> <!-- Правая колонка: дерево навигации по годам/месяцам (CSS-only collapsible, без JS) -->
<div class="col-lg-3"> <div class="lg:col-span-1 min-w-0">
<!-- На мобильных — сворачивается под кнопку --> <div class="collapsible">
<button class="btn btn-outline-secondary d-lg-none w-100 mb-2" type="button" <input type="checkbox" id="archive-toggle" class="collapsible-toggle">
data-bs-toggle="collapse" data-bs-target="#archive-tree" aria-expanded="false" aria-controls="archive-tree"> <!-- На мобильных — переключатель под кнопку; на десктопе дерево раскрыто всегда -->
🗂 Архив <label class="btn btn-outline w-full mb-2 lg:hidden" for="archive-toggle" aria-controls="archive-tree">
</button> 🗂 Архив <span class="collapsible-arrow"></span>
<div id="archive-tree" class="collapse d-lg-block position-sticky" style="top: 5rem;"> </label>
<div class="card shadow-sm"> <div id="archive-tree" class="collapsible-content lg:[grid-template-rows:1fr]">
<div class="card-body py-3"> <div>
<h6 class="card-title mb-2">🗂 Архив</h6> <div class="card card-outline bg-white lg:sticky lg:top-16">
<div class="list-group list-group-flush"> <div class="card-content p-3">
<a href="/published" <h6 class="card-title text-base mb-2">🗂 Архив</h6>
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 %}"> <div class="divide-y divide-neutral-200 text-sm">
Все посты <a href="/published"
<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> 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 %}">
</a> Все посты
{% for y in tree.years %} <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 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>
</a> </a>
{% if year == y.year %} {% for y in tree.years %}
{% for m in y.months %} <a href="/published?year={{ y.year }}"
<a href="/published?year={{ y.year }}&month={{ m.m }}" 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 %}">
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 %}"> {{ y.year }}
{{ m.label }} <span class="badge badge-pill {% if year == y.year and not month and not nodate %}badge-outline{% else %}badge-neutral{% endif %}">{{ y.n }}</span>
<span class="badge rounded-pill {% if month == m.m and not nodate %}bg-light text-dark{% else %}bg-secondary{% endif %}">{{ m.n }}</span> </a>
</a> {% if year == y.year %}
{% endfor %} {% 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 %} {% endif %}
{% endfor %} </div>
{% 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> </div>
</div> </div>