Update digest page and logic

This commit is contained in:
dev
2026-11-05 13:34:05 +03:00
parent f07898721c
commit 67fcaf452a
2 changed files with 161 additions and 89 deletions
+108 -56
View File
@@ -6,86 +6,136 @@
<title>Дайджест — Админ-панель</title>
<link rel="stylesheet" href="admin.css">
<style>
.digest-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.digest-toolbar .search-input { flex: 1; min-width: 240px; max-width: 420px; }
.digest-count { font-size: .82rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.digest-list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.digest-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.digest-card.pinned { border-left: 4px solid #f59e0b; background: rgba(245,158,11,.04); }
.digest-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.digest-title { font-weight: 600; font-size: 1.05rem; word-break: break-word; margin: 0; }
.digest-meta { font-size: .82rem; color: var(--muted); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.digest-meta-item { display: inline-flex; align-items: center; gap: 5px; }
.digest-meta-item svg { width: 13px; height: 13px; opacity: .7; }
.digest-badge { padding: 2px 9px; border-radius: 999px; font-size: .68rem; font-weight: 600; background: rgba(245,158,11,.12); color: #b45309; white-space: nowrap; }
.digest-badge.scheduled { background: rgba(37,99,235,.12); color: var(--accent); }
.digest-page { max-width: 1080px; width: 100%; margin: 0 auto; }
.digest-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.digest-search { position: relative; flex: 1; min-width: 240px; max-width: 460px; display: flex; align-items: center; }
.digest-search > svg { position: absolute; left: 14px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.digest-search input { width: 100%; background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 11px; padding: 11px 14px 11px 40px; font-size: .9rem; font-family: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
.digest-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.digest-count { font-size: .82rem; font-weight: 500; color: var(--muted); margin-left: auto; white-space: nowrap; }
.digest-list { display: flex; flex-direction: column; gap: 20px; margin-top: 18px; }
.digest-card { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; min-width: 0; overflow: hidden; transition: box-shadow .18s, border-color .18s; }
.digest-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.digest-card.pinned { border-left: 3px solid #f59e0b; background: linear-gradient(180deg, rgba(245,158,11,.055), var(--card) 180px); }
.digest-card.digest-hidden { opacity: .62; }
.digest-card-top { padding: 24px 28px 0; display: flex; flex-direction: column; gap: 12px; }
.digest-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.digest-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .02em; background: rgba(245,158,11,.12); color: #b45309; white-space: nowrap; }
.digest-badge svg { width: 12px; height: 12px; }
.digest-badge.scheduled { background: rgba(37,99,235,.1); color: var(--accent); }
.digest-badge.dim { background: var(--bg); color: var(--muted); }
.digest-body { font-size: .95rem; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; }
.digest-body.clamp { max-height: 150px; overflow: hidden; position: relative; }
.digest-body.clamp::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 38px; background: linear-gradient(transparent, var(--card)); pointer-events: none; }
.digest-body-toggle { align-self: flex-start; background: none; border: none; color: var(--accent); font-size: .8rem; font-weight: 600; cursor: pointer; padding: 0; }
.digest-body-toggle:hover { text-decoration: underline; }
.digest-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; }
.digest-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.digest-empty { border: 1px dashed var(--border); border-radius: 12px; padding: 44px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--muted); }
.digest-empty svg { width: 28px; height: 28px; opacity: .55; }
.digest-title { margin: 0; font-size: 1.35rem; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; word-break: break-word; }
.digest-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.digest-avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(37,99,235,.1); color: var(--accent); font-weight: 700; font-size: .85rem; text-transform: uppercase; }
.digest-meta-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.digest-author { font-size: .85rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.digest-date { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--muted); }
.digest-date svg { width: 12px; height: 12px; opacity: .75; }
.digest-main { display: flex; align-items: flex-start; gap: 22px; padding: 20px 28px 0; }
.digest-cover { flex: 0 0 34%; min-width: 200px; max-width: 360px; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.digest-cover button { display: block; width: 100%; height: 100%; padding: 0; border: none; background: none; cursor: zoom-in; }
.digest-cover img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.digest-cover:hover img { transform: scale(1.015); }
.digest-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.digest-body { font-size: 1rem; line-height: 1.72; color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; }
.digest-body.clamp { max-height: 260px; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 76%, transparent); mask-image: linear-gradient(to bottom, #000 76%, transparent); }
.digest-body-toggle { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; margin: 0 0 0 -8px; padding: 5px 8px; background: none; border: none; border-radius: 8px; color: var(--accent); font-size: .84rem; font-weight: 600; font-family: inherit; cursor: pointer; }
.digest-body-toggle:hover { background: rgba(37,99,235,.08); }
.digest-body-toggle svg { width: 14px; height: 14px; transition: transform .18s; }
.digest-body-toggle.open svg { transform: rotate(180deg); }
.digest-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.digest-shot { position: relative; display: block; width: 100%; aspect-ratio: 4/3; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); cursor: zoom-in; }
.digest-shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.digest-shot:hover img { transform: scale(1.05); }
.digest-more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(17,24,39,.55); color: #fff; font-size: 1.05rem; font-weight: 700; pointer-events: none; }
.digest-foot { margin-top: 20px; padding: 14px 28px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.digest-foot-note { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; color: var(--muted); }
.digest-foot-note svg { width: 12px; height: 12px; }
.digest-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.digest-act { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; background: transparent; border: 1px solid transparent; border-radius: 9px; color: var(--muted); font-size: .82rem; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.digest-act svg { width: 14px; height: 14px; }
.digest-act:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.digest-act.is-pinned { color: #b45309; background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.28); }
.digest-act.is-pinned:hover { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.45); color: #b45309; }
.digest-act.danger:hover { color: #ef4444; background: rgba(239,68,68,.06); border-color: rgba(239,68,68,.3); }
.digest-empty { border: 1px dashed var(--border); border-radius: 16px; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--muted); background: var(--card); }
.digest-empty svg { width: 30px; height: 30px; opacity: .5; }
.digest-empty.error svg { color: #ef4444; opacity: .8; }
.digest-empty p { margin: 0; font-size: .95rem; }
.digest-empty .sub { font-size: .82rem; opacity: .8; max-width: 420px; }
.digest-empty p { margin: 0; font-size: 1rem; color: var(--text); font-weight: 600; }
.digest-empty .sub { font-size: .85rem; opacity: .85; max-width: 440px; font-weight: 400; color: var(--muted); }
.digest-empty .btn-primary { margin-top: 10px; }
.digest-none { color: var(--muted); font-size: .85rem; font-style: italic; }
.digest-hidden { opacity: 0.72; }
.digest-highlight { outline: 2px solid #f59e0b; outline-offset: 2px; border-radius: 8px; }
.digest-highlight { outline: 2px solid #f59e0b; outline-offset: 3px; }
.digest-new-btn { margin-left: auto; }
.digest-preview-img { max-width: 240px; max-height: 150px; border: 1px solid var(--border); border-radius: 8px; margin: 8px 0 4px 0; display: block; }
.digest-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.digest-image { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: 130px; height: 95px; flex-shrink: 0; }
.digest-image img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.digest-image-remove { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.7); color: #fff; border: none; border-radius: 6px; padding: 2px 7px; font-size: .75rem; cursor: pointer; }
.digest-image-remove:hover { background: #ef4444; }
.digest-head-img { margin: 8px 0 10px 0; }
.digest-images-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.digest-card-thumb { width: 70px; height: 55px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; flex-shrink: 0; display: block; }
.digest-shot { position: relative; display: inline-flex; align-items: center; justify-content: center; border: none; background: transparent; padding: 0; cursor: pointer; border-radius: 6px; overflow: hidden; }
.digest-shot-zoom { position: absolute; bottom: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff; border-radius: 4px; padding: 2px 5px; font-size: .65rem; opacity: 0; transition: opacity .15s; }
.digest-shot:hover .digest-shot-zoom { opacity: 1; }
.field-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; display: block; }
.digest-file-hidden { display: none; }
.digest-file-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.digest-pick { cursor: pointer; }
#digestModal .edit-modal { width: 1000px; max-width: none; }
.digest-preview-wrap { display: block; margin-top: 8px; }
.digest-preview-img { display: block; width: 100%; max-width: 100%; max-height: 220px; object-fit: cover; border: 1px solid var(--border); border-radius: 10px; }
.digest-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.digest-image { position: relative; width: 132px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; aspect-ratio: 4/3; }
.digest-image img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.digest-image-remove { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.7); color: #fff; border: none; border-radius: 6px; padding: 3px 8px; font-size: .75rem; cursor: pointer; }
.digest-image-remove:hover { background: #ef4444; }
#digestModal .edit-modal { width: 1000px; max-width: none; display: flex; flex-direction: column; max-height: 85vh; }
#digestModal .bookmark-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
#digestModal .digest-modal-body { flex: 0 0 auto; max-height: 62vh; overflow-y: auto; padding: 12px 0 8px 0; }
.digest-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 720px) { .digest-modal-grid { grid-template-columns: 1fr; } }
.digest-modal-col { display: flex; flex-direction: column; gap: 12px; }
.digest-modal-col .settings-field { margin: 0; }
.digest-counter { font-size: .75rem; font-weight: 400; color: var(--muted); margin-left: auto; }
.digest-section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 4px; border-top: 1px solid var(--border); }
.digest-modal-col > .digest-section-title:first-child { padding-top: 0; border-top: none; }
.digest-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400 !important; }
.digest-check input { width: auto; }
#digestModal .edit-modal { display: flex; flex-direction: column; max-height: 85vh; }
#digestModal .card-foot { flex: 0 0 auto; margin-top: 10px; }
#digestModal .card-foot { flex: 0 0 auto; margin-top: 10px; justify-content: flex-end; }
@media (max-width: 720px) {
.digest-card-top { padding: 20px 18px 0; }
.digest-main { flex-direction: column; gap: 16px; padding: 16px 18px 0; }
.digest-cover { flex: none; width: 100%; max-width: none; }
.digest-foot { padding: 12px 18px; }
.digest-title { font-size: 1.18rem; }
.digest-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.digest-modal-grid { grid-template-columns: 1fr; }
.digest-count { margin-left: 0; }
}
</style>
</head>
<body data-page="digest">
<div class="layout">
<div class="sidebar" id="sidebar"></div>
<div class="main">
<div class="page-head">
<h2>Дайджест</h2>
<p class="page-sub">Важные сообщения для команды</p>
<button type="button" class="btn-primary digest-new-btn" id="digestNewBtn"><i data-lucide="plus"></i> Новое сообщение</button>
<div class="digest-page">
<div class="page-head">
<h2>Дайджест</h2>
<p class="page-sub">Важные сообщения для команды</p>
<button type="button" class="btn-primary digest-new-btn" id="digestNewBtn"><i data-lucide="plus"></i> Новое сообщение</button>
</div>
<div class="digest-toolbar">
<div class="digest-search">
<i data-lucide="search"></i>
<input type="search" id="digestSearch" placeholder="Поиск по заголовку, тексту или автору" autocomplete="off">
</div>
<span id="digestCount" class="digest-count"></span>
</div>
<div id="digestList" class="digest-list"></div>
</div>
<div class="digest-toolbar">
<input type="search" id="digestSearch" class="search-input" placeholder="Поиск по заголовку, тексту или автору" autocomplete="off">
<span id="digestCount" class="digest-count"></span>
</div>
<div id="digestList" class="digest-list"></div>
</div>
</div>
<div class="modal-overlay" id="digestModal">
<div class="edit-modal" style="width:1000px">
<div class="edit-modal">
<div class="bookmark-modal-head">
<h3 id="digestModalTitle">Новое сообщение</h3>
<button type="button" class="icon-btn" id="digestModalClose"><i data-lucide="x"></i></button>
@@ -102,25 +152,27 @@
<textarea id="digestBody" class="settings-input" rows="10" maxlength="5000" placeholder="Что нужно сообщить ученикам и тьюторам..."></textarea>
<span class="field-hint">Курсор в поле текста + Ctrl+V — вставит картинку из буфера обмена.</span>
</div>
<div class="digest-section-title">Публикация</div>
<div class="settings-field">
<label class="digest-check"><input type="checkbox" id="digestPinned"> Закрепить в начале списка</label>
<span class="field-hint">Доступно администраторам. Закреплённые сообщения всегда сверху.</span>
<span class="field-hint">Закреплённые сообщения всегда сверху. Доступно администраторам.</span>
</div>
<div class="settings-field">
<label>Дата публикации</label>
<input type="datetime-local" id="digestPostAt">
<span class="field-hint">Пусто — опубликовано сразу. Будущая дата — появится автоматически для всех и придёт уведомление.</span>
<span class="field-hint">Пусто — опубликовать сразу. Будущая дата — публикация и уведомление произойдут автоматически.</span>
</div>
<div class="settings-field">
<label>Скрыть после</label>
<input type="datetime-local" id="digestHideAt">
<span class="field-hint">После этой даты дайджест перестанет показываться (кроме администратора).</span>
<span class="field-hint">После этой даты сообщение скрывается для всех, кроме администратора.</span>
</div>
</div>
<div class="digest-modal-col">
<div class="digest-section-title">Медиа</div>
<div class="settings-field">
<label>Превью / обложка сообщения</label>
<div id="digestPreviewWrap" style="position:relative;display:inline-block;margin-top:6px">
<div id="digestPreviewWrap" class="digest-preview-wrap">
<img id="digestPreviewImg" class="digest-preview-img" src="" alt="превью">
</div>
<div class="digest-file-row">
+53 -33
View File
@@ -110,6 +110,11 @@
} catch { return null; }
}
function digestInitial(name) {
const s = String(name || '').trim();
return s ? s.charAt(0).toUpperCase() : '?';
}
function digestCardHtml(d) {
const admin = isAdmin();
const mine = currentUser && d.author_id === currentUser.id;
@@ -119,57 +124,68 @@
const postFuture = d.post_at && new Date(d.post_at).getTime() > nowTs;
const hidden = d.hide_at && new Date(d.hide_at) <= nowTs;
const badge = [];
if (pinned) badge.push('<span class="digest-badge">Закреплено</span>');
if (postFuture) badge.push('<span class="digest-badge scheduled">Запланировано на ' + esc(fmtDateTimeY(d.post_at)) + '</span>');
if (hidden) badge.push('<span class="digest-badge dim">Скрыто</span>');
else if (d.hide_at) badge.push('<span class="digest-badge dim">Скроется ' + esc(fmtDateTimeY(d.hide_at)) + '</span>');
const badges = [];
if (pinned) badges.push('<span class="digest-badge"><i data-lucide="pin"></i>Закреплено</span>');
if (postFuture) badges.push('<span class="digest-badge scheduled"><i data-lucide="clock"></i>Запланировано на ' + esc(fmtDateTimeY(d.post_at)) + '</span>');
if (hidden) badges.push('<span class="digest-badge dim"><i data-lucide="eye-off"></i>Скрыто</span>');
else if (d.hide_at) badges.push('<span class="digest-badge dim"><i data-lucide="clock"></i>Скроется ' + esc(fmtDateTimeY(d.hide_at)) + '</span>');
const preview = d.preview_path
? '<div class="digest-head-img"><button type="button" class="digest-shot" data-img="' + esc(d.preview_path) + '" title="Открыть превью"><img class="digest-preview-img" src="' + esc(thumbSrc(d.preview_path)) + '" alt="превью"></button></div>'
const cover = d.preview_path
? '<div class="digest-cover"><button type="button" data-img="' + esc(d.preview_path) + '" title="Открыть обложку"><img src="' + esc(thumbSrc(d.preview_path)) + '" alt="' + esc(d.title) + '" loading="lazy" decoding="async"></button></div>'
: '';
const images = Array.isArray(d.images) ? d.images : [];
let imagesHtml = '';
let galleryHtml = '';
if (images.length) {
imagesHtml = '<div class="digest-images-row">' + images.slice(0, 4).map(function(img, i) {
return '<button type="button" class="digest-shot" data-img="' + esc(img.path) + '" data-gal-index="' + i + '" title="' + esc(img.name || '') + '" aria-label="' + esc(img.name || '') + '">' +
'<img class="digest-card-thumb" src="' + esc(thumbSrc(img.path)) + '" alt="' + esc(img.name || '') + '" loading="lazy" decoding="async">' +
'<span class="digest-shot-zoom" aria-hidden="true"><i data-lucide="maximize-2"></i></span>' +
galleryHtml = '<div class="digest-gallery">' + images.slice(0, 4).map(function(img, i) {
const more = (i === 3 && images.length > 4) ? '<span class="digest-more">+' + (images.length - 4) + '</span>' : '';
return '<button type="button" class="digest-shot" data-img="' + esc(img.path) + '" title="' + esc(img.name || '') + '" aria-label="' + esc(img.name || '') + '">' +
'<img src="' + esc(thumbSrc(img.path)) + '" alt="' + esc(img.name || '') + '" loading="lazy" decoding="async">' +
more +
'</button>';
}).join('') + (images.length > 4 ? '<span class="digest-none">+ ' + (images.length - 4) + '</span>' : '') + '</div>';
}).join('') + '</div>';
}
const actions = [];
if (canEdit) {
actions.push('<button type="button" class="btn-link" data-action="edit" data-id="' + d.id + '">Изменить</button>');
actions.push('<button type="button" class="btn-link danger" data-action="delete" data-id="' + d.id + '">Удалить</button>');
}
if (admin) {
actions.push('<button type="button" class="btn-link" data-action="pin" data-id="' + d.id + '" data-pin="' + (pinned ? '0' : '1') + '">' + (pinned ? 'Открепить' : 'Закрепить') + '</button>');
actions.push('<button type="button" class="digest-act' + (pinned ? ' is-pinned' : '') + '" data-action="pin" data-id="' + d.id + '" data-pin="' + (pinned ? '0' : '1') + '"><i data-lucide="pin"></i>' + (pinned ? 'Открепить' : 'Закрепить') + '</button>');
}
if (canEdit) {
actions.push('<button type="button" class="digest-act" data-action="edit" data-id="' + d.id + '"><i data-lucide="pencil"></i>Изменить</button>');
actions.push('<button type="button" class="digest-act danger" data-action="delete" data-id="' + d.id + '"><i data-lucide="trash-2"></i>Удалить</button>');
}
const bodyText = d.body || '';
const longBody = bodyText.length > 600;
const bodyHtml = '<div class="digest-body' + (longBody ? ' clamp' : '') + '">' + esc(bodyText) + '</div>' +
(longBody ? '<button type="button" class="digest-body-toggle" data-action="toggle-body" data-id="' + d.id + '">Показать полностью</button>' : '');
(longBody ? '<button type="button" class="digest-body-toggle" data-action="toggle-body" data-id="' + d.id + '"><span class="digest-toggle-label">Читать полностью</span><i data-lucide="chevron-down"></i></button>' : '');
return '<div class="digest-card' + (pinned ? ' pinned' : '') + (hidden ? ' digest-hidden' : '') + '" data-id="' + d.id + '">' +
'<div class="digest-head">' +
const createdTs = d.created_at ? new Date(d.created_at).getTime() : 0;
const updatedTs = d.updated_at ? new Date(d.updated_at).getTime() : 0;
const edited = createdTs && updatedTs && updatedTs - createdTs > 60000;
const note = edited ? '<span class="digest-foot-note"><i data-lucide="pencil"></i>Изменено ' + esc(fmtDateTimeY(d.updated_at)) + '</span>' : '';
const footHtml = (note || actions.length)
? '<footer class="digest-foot">' + note + '<div class="digest-actions">' + actions.join('') + '</div></footer>'
: '';
return '<article class="digest-card' + (pinned ? ' pinned' : '') + (hidden ? ' digest-hidden' : '') + '" data-id="' + d.id + '">' +
'<div class="digest-card-top">' +
(badges.length ? '<div class="digest-badges">' + badges.join('') + '</div>' : '') +
'<h3 class="digest-title">' + esc(d.title) + '</h3>' +
badge.join('') +
'<div class="digest-meta">' +
'<span class="digest-avatar" aria-hidden="true">' + esc(digestInitial(d.author_name)) + '</span>' +
'<div class="digest-meta-text">' +
'<span class="digest-author">' + esc(d.author_name || '—') + '</span>' +
'<span class="digest-date"><i data-lucide="calendar"></i>' + esc(fmtDateTimeY(d.published_at || d.created_at)) + '</span>' +
'</div>' +
'</div>' +
'</div>' +
preview +
'<div class="digest-meta">' +
'<span class="digest-meta-item"><i data-lucide="user"></i>' + esc(d.author_name || '—') + '</span>' +
'<span class="digest-meta-item"><i data-lucide="calendar"></i>' + esc(fmtDateTimeY(d.published_at || d.created_at)) + '</span>' +
'<div class="digest-main">' +
cover +
'<div class="digest-content">' + bodyHtml + galleryHtml + '</div>' +
'</div>' +
bodyHtml +
imagesHtml +
'<div class="digest-foot">' +
'<div class="digest-actions">' + actions.join('') + '</div>' +
'</div>' +
'</div>';
footHtml +
'</article>';
}
function filterDigests() {
@@ -200,6 +216,7 @@
el.innerHTML = '<div class="digest-empty"><i data-lucide="megaphone"></i>' +
'<p>Сообщений пока нет</p>' +
'<p class="sub">Опубликуйте важное объявление — его увидят все тьюторы и админы.</p>' +
(isAdmin() ? '<button type="button" class="btn-primary" data-action="new"><i data-lucide="plus"></i>Создать сообщение</button>' : '') +
'</div>';
renderIcons();
return;
@@ -679,11 +696,14 @@
const body = card.querySelector('.digest-body');
if (body) {
const clamped = body.classList.toggle('clamp');
actEl.textContent = clamped ? 'Показать полностью' : 'Свернуть';
actEl.classList.toggle('open', !clamped);
const label = actEl.querySelector('.digest-toggle-label');
if (label) label.textContent = clamped ? 'Читать полностью' : 'Свернуть';
}
}
return;
}
if (action === 'new') { openDigestModal(null); return; }
if (action === 'reload') { await loadDigests(); return; }
return;
}