Admin: add edit page (GET/POST), live preview; list shows Edit button; inject page title + watermark on public pages; clean header (only one logout); alignment via flex; add Dockerfile and docker-compose.yml; add gunicorn

This commit is contained in:
2025-09-03 15:46:19 +03:00
parent c87f4fb0d6
commit d2a65dedb3
8 changed files with 144 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% block content %}
<h1>Публикация HTML-страниц</h1>
<h1>Публикация HTML-страницы</h1>
<form method="post">
<div class="row">
@@ -11,8 +11,10 @@
<label for="html">HTML-код</label>
<textarea id="html" name="html" placeholder="<h1>Заголовок</h1>\n<p>Мой контент...</p>" required></textarea>
</div>
<button class="btn" type="submit">Опубликовать</button>
<span class="muted">После публикации создаётся ссылка с UUID.</span>
<div class="row">
<button class="btn" type="submit">Опубликовать</button>
<span class="muted" style="margin-left:10px;">После публикации создаётся ссылка с UUID.</span>
</div>
</form>
<div class="row" style="margin-top: 1.25rem;">
@@ -42,7 +44,8 @@
<td><a href="{{ base_url }}/p/{{ p.uuid }}" target="_blank">{{ base_url }}/p/{{ p.uuid }}</a></td>
<td>{{ p.created_at }}</td>
<td>
<form method="post" action="{{ url_for('admin_delete', pid=p.id) }}" onsubmit="return confirm('Удалить страницу #' + {{ p.id }} + '?');">
<a class="btn secondary" href="{{ url_for('admin_edit', pid=p.id) }}" style="margin-right:6px;">Редактировать</a>
<form style="display:inline" method="post" action="{{ url_for('admin_delete', pid=p.id) }}" onsubmit="return confirm('Удалить страницу #{{ p.id }}?');">
<button class="btn secondary" type="submit">Удалить</button>
</form>
</td>
@@ -51,8 +54,9 @@
</tbody>
</table>
{% else %}
<p class="muted">Страниц пока нет.</p>
<p class="muted">Пока нет опубликованных страниц.</p>
{% endif %}
<script>
(function(){
const htmlEl = document.getElementById('html');
@@ -63,7 +67,7 @@
const doc = iframe.contentDocument || iframe.contentWindow.document;
const t = (titleEl && titleEl.value) ? `<title>${titleEl.value}</title>` : '';
doc.open();
doc.write(`<!doctype html><html lang="ru"><head><meta charset="utf-8">${t}</head><body>${htmlEl.value}</body></html>`);
doc.write(`<!doctype html><html lang=\"ru\"><head><meta charset=\"utf-8\">${t}</head><body>${htmlEl.value}</body></html>`);
doc.close();
}
if (htmlEl){