feedback: поддержка freeimage.host (Chevereto), линки-картинки в тексте отзыва

- resolveImgbbEndpoint/friendlyApiError в lib/feedback-imgbb.js: нормализация адреса сервиса (сайт или полный эндпоинт), поле source+action для Chevereto
- линки-картинки в тексте отзыва: linkifyTextHtml в admin.js, инлайн-миниатюры до 12 ссылок (feedback.js, student.js)
- «Картинка из работ» → «Работа резидента», блок «Последнее занятие» перенесён в шапку модалки
- нейтральные подписи «ImgBB» → «загрузка картинок» в настройках и подсказках
This commit is contained in:
dev
2026-10-31 10:20:01 +03:00
parent e42694bbed
commit 00b7e96260
10 changed files with 100 additions and 25 deletions
+1
View File
@@ -1029,6 +1029,7 @@ body[data-page=settings] .page-head{align-items:flex-end}
.lesson-badge.today{background:rgba(16,185,129,.14);color:#059669}
.lesson-topic{font-size:.85rem;font-weight:600;color:var(--accent)}
.lesson-text{font-size:.88rem;color:var(--text);white-space:pre-wrap;word-break:break-word;line-height:1.55}
.lesson-text .text-inline-img{display:block;margin:6px 0 2px;max-width:min(360px,100%);max-height:270px;border-radius:10px;border:1px solid var(--border);cursor:pointer}
.lesson-author{font-size:.75rem;color:var(--muted)}
.lesson-actions{display:flex;gap:8px;flex-wrap:wrap;margin-left:auto}
.lesson-item .btn-link{padding:6px 12px;font-size:.78rem}
+17
View File
@@ -4,6 +4,23 @@ let currentUser = null;
function hdr() { return { 'X-Auth-Token': token }; }
function hdrJson() { return { 'Content-Type': 'application/json', 'X-Auth-Token': token }; }
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
function linkifyTextHtml(text) {
const escaped = esc(String(text == null ? '' : text));
let inlined = 0;
return escaped.replace(/https?:\/\/[^\s"'`<>()]+/g, function (m) {
let tail = '';
const t = m.match(/[.,;:!?]+$/);
let url = m;
if (t) { tail = t[0]; url = m.slice(0, m.length - tail.length); }
let html = `<a href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>${tail}`;
if (inlined < 12 && /\.(jpe?g|png|webp|gif|bmp)(\?|$)/i.test(url)) {
inlined++;
html += `<br><img class="text-inline-img" src="${url}" data-img="${url}" loading="lazy" alt="">`;
}
return html;
});
}
function thumbSrc(p) {
if (!p) return p;
if (p.startsWith('/uploads/.originals/')) return `${API}${p}`;
+2 -2
View File
@@ -76,7 +76,7 @@
.fb-ai-pop pre { margin:0; max-height:240px; overflow:auto; white-space:pre-wrap; word-break:break-word; font-size:12px; line-height:1.45; background:rgba(127,127,127,.08); border:1px solid var(--border); border-radius:8px; padding:8px 10px; }
.fb-ai-err { font-size:.83rem; line-height:1.4; color:#ef4444; background:rgba(239,68,68,.08); border:1px solid rgba(239,68,68,.3); border-radius:8px; padding:8px 10px; white-space:pre-wrap; }
.fb-ai-empty { font-size:.83rem; color:var(--muted); }
.fb-att-info { font-size:.82rem; color:var(--muted); margin-top:4px; }
.fb-att-info { font-size:.82rem; color:var(--muted); margin:2px 0 0 0; }
.fb-att-info a { color:var(--accent); text-decoration:underline; }
.fb-works { display:flex; flex-wrap:wrap; gap:8px; }
.fb-works .fb-work { position:relative; display:flex; flex-direction:column; gap:6px; border:1px solid var(--border); border-radius:10px; padding:8px; background:rgba(127,127,127,.05); flex:1 1 160px; min-width:0; }
@@ -134,6 +134,7 @@
<div class="edit-modal" style="max-width:960px;width:96%;max-height:92dvh;overflow-y:auto">
<div class="fb-modal-head">
<h3 id="fbModalTitle">Добавить отзыв</h3>
<div class="fb-att-info" id="fbResidentAtt" hidden></div>
<button type="button" class="icon-btn" id="fbPromptBtn" title="Настройки ИИ-промпта"><i data-lucide="settings"></i></button>
</div>
<form id="fbForm" class="settings-stack" autocomplete="off">
@@ -156,7 +157,6 @@
<button type="button" id="fbResidentPhoto" class="fb-resident-photo" hidden title="Увеличить фото"><span class="fb-mark-stripe" id="fbMarkStripe" hidden></span><img src="" alt="" loading="lazy"></button>
</div>
<datalist id="fbResidentList"></datalist>
<div class="fb-att-info" id="fbResidentAtt" hidden></div>
</div>
<div class="settings-field">
<label>Тема занятия</label>
+3 -3
View File
@@ -60,7 +60,7 @@
${f.topic ? `<div class="lesson-topic">${escapeHtml(f.topic)}</div>` : ''}
</div>
</div>
${text ? `<div class="lesson-text">${escapeHtml(text)}</div>` : ''}
${text ? `<div class="lesson-text">${linkifyTextHtml(text)}</div>` : ''}
<div class="fb-card-foot">
${aiBadge(f.ai_status)}
${f.sent_at ? '<span class="ai-badge ai-badge-sent">Отправлено</span>' : ''}
@@ -1109,7 +1109,7 @@
const ok = document.getElementById('fbImgbbModalOk');
const btn = document.getElementById('fbImgbbBtn');
if (!window.WhatIDoImgBB || !window.WhatIDoImgBB.configured()) {
alert('ImgBB не настроен: укажите URL и ключ API в настройках системы (feedback_imgbb_url / feedback_imgbb_key).');
alert('Загрузка картинок не настроена: укажите URL и ключ API в настройках системы.');
return;
}
const prev = ok.textContent;
@@ -1119,7 +1119,7 @@
const res = await window.WhatIDoImgBB.uploadFromUrl(fbImgbbSelected.url, fbImgbbSelected.name);
closeImgbbPicker();
const cur = text.value || '';
const add = (cur ? '\n' : '') + 'Последня работа.\n' + res.url;
const add = (cur ? '\n' : '') + 'Работа резидента:\n' + res.url;
text.value = cur + add;
if (hint) hint.textContent = `${text.value.length} / 5000`;
} catch (err) {
+1 -1
View File
@@ -13,7 +13,7 @@
},
upload: function(file) {
if (!this.configured()) {
return Promise.reject(new Error('ImgBB не настроен: укажите URL и ключ API в настройках системы'));
return Promise.reject(new Error('Загрузка картинок не настроена: укажите URL и ключ API в настройках системы'));
}
if (!file || !(file instanceof File)) {
return Promise.reject(new Error('Нет файла для загрузки'));
+1 -1
View File
@@ -198,7 +198,7 @@
${f.group_name ? `<span class="lesson-group">${esc(f.group_name)}</span>` : ''}
${f.sent_at ? '<span class="ai-badge ai-badge-sent">Отправлено</span>' : aiBadge(f.ai_status)}
</div>
${f.text ? `<div class="lesson-text">${esc(f.text)}</div>` : '<div class="lesson-text" style="color:var(--muted)">Без текста</div>'}
${f.text ? `<div class="lesson-text">${linkifyTextHtml(f.text)}</div>` : '<div class="lesson-text" style="color:var(--muted)">Без текста</div>'}
</div>`).join('')}</div>${moreHint(data.feedbacks.total, items.length)}`;
}
+6 -6
View File
@@ -525,14 +525,14 @@
</div>
<p class="hint">Настройки интеграции с внешними сервисами. Используются в модалке обратной связи для загрузки картинок работ учеников.</p>
<div class="settings-field">
<label for="imgbbUrl">ImgBB URL API</label>
<input type="text" id="imgbbUrl" class="settings-input" placeholder="https://api.imgbb.com/1/upload">
<span class="hint">Адрес сервиса загрузки картинок (по умолчанию https://api.imgbb.com/1/upload)</span>
<label for="imgbbUrl">URL API загрузки картинок</label>
<input type="text" id="imgbbUrl" class="settings-input" placeholder="https://freeimage.host/api/1/upload">
<span class="hint">Адрес сервиса загрузки картинок, например https://freeimage.host/api/1/upload</span>
</div>
<div class="settings-field">
<label for="imgbbKey">ImgBB API-ключ</label>
<input type="text" id="imgbbKey" class="settings-input" placeholder="ключ из личного кабинета ImgBB">
<span class="hint">Ключ API сервиса загрузки картинок. Возвращается только при создании ключа на imgbb.com</span>
<label for="imgbbKey">API-ключ загрузки</label>
<input type="text" id="imgbbKey" class="settings-input" placeholder="ключ из личного кабинета сервиса">
<span class="hint">Ключ API сервиса загрузки картинок. Возвращается только при создании ключа в кабинете сервиса</span>
</div>
</div>
<div class="settings-card" id="sec-bans">