Add user auth, personal cabinet, admin panel and first admin bootstrap
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-66
@@ -1,29 +1,21 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% macro format_size(bytes) %}
|
||||
{% set size = bytes|float %}
|
||||
{% if size < 1024 %}
|
||||
{{ size|int }} Б
|
||||
{% elif size < 1048576 %}
|
||||
{{ "%.1f"|format(size / 1024) }} КБ
|
||||
{% elif size < 1073741824 %}
|
||||
{{ "%.1f"|format(size / 1048576) }} МБ
|
||||
{% else %}
|
||||
{{ "%.1f"|format(size / 1073741824) }} ГБ
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
{% from "macros.html" import format_size %}
|
||||
|
||||
{% block content %}
|
||||
<section class="hero">
|
||||
<div class="container hero__inner">
|
||||
<div class="hero__badge">Бесплатно · Без регистрации</div>
|
||||
<div class="hero__badge">Регистрация · Личный кабинет · Админка</div>
|
||||
<h1 class="hero__title">
|
||||
Загружайте фото<br>
|
||||
<span class="hero__accent">мгновенно</span>
|
||||
</h1>
|
||||
<p class="hero__subtitle">
|
||||
Современный фото-хостинг на Python и PostgreSQL.
|
||||
Перетащите изображение — получите прямую ссылку за секунды.
|
||||
{% if current_user.is_authenticated %}
|
||||
Загружайте изображения в личном кабинете и делитесь ссылками.
|
||||
{% else %}
|
||||
Зарегистрируйтесь, чтобы загружать фото и управлять галереей.
|
||||
{% endif %}
|
||||
</p>
|
||||
<div class="stats">
|
||||
<div class="stat-card">
|
||||
@@ -39,19 +31,18 @@
|
||||
<span class="stat-card__label">на файл</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if not current_user.is_authenticated %}
|
||||
<div class="hero__actions">
|
||||
<a href="{{ url_for('auth.register') }}" class="btn btn--primary">Создать аккаунт</a>
|
||||
<a href="{{ url_for('auth.login') }}" class="btn btn--ghost">Войти</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<section class="container alerts">
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert--{{ category }}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% include "partials/alerts.html" %}
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
<section id="upload" class="upload-section">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Загрузить фото</h2>
|
||||
@@ -81,53 +72,17 @@
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section id="gallery" class="gallery-section">
|
||||
<div class="container">
|
||||
<div class="gallery-header">
|
||||
<h2 class="section-title">Галерея</h2>
|
||||
<span class="gallery-count">{{ total_photos }} {{ 'фото' if total_photos != 1 else 'фото' }}</span>
|
||||
<h2 class="section-title">Последние фото</h2>
|
||||
<span class="gallery-count">{{ total_photos }} фото</span>
|
||||
</div>
|
||||
|
||||
{% if photos %}
|
||||
<div class="gallery">
|
||||
{% for photo in photos %}
|
||||
<article class="photo-card" data-id="{{ photo.id }}">
|
||||
<div class="photo-card__image-wrap">
|
||||
<img
|
||||
src="{{ photo.url }}"
|
||||
alt="{{ photo.original_name }}"
|
||||
class="photo-card__image"
|
||||
loading="lazy"
|
||||
>
|
||||
<div class="photo-card__overlay">
|
||||
<button type="button" class="btn btn--ghost btn--sm copy-btn" data-url="{{ request.url_root.rstrip('/') }}{{ photo.url }}">
|
||||
Копировать ссылку
|
||||
</button>
|
||||
<a href="{{ photo.url }}" target="_blank" class="btn btn--ghost btn--sm">Открыть</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="photo-card__info">
|
||||
<span class="photo-card__name" title="{{ photo.original_name }}">{{ photo.original_name }}</span>
|
||||
<div class="photo-card__meta">
|
||||
<span>{{ photo.size_human }}</span>
|
||||
<span>{{ photo.created_at.strftime('%d.%m.%Y %H:%M') }}</span>
|
||||
</div>
|
||||
<form action="{{ url_for('main.delete_photo', photo_id=photo.id) }}" method="post" class="photo-card__delete" onsubmit="return confirm('Удалить это фото?');">
|
||||
<button type="submit" class="btn btn--danger btn--sm">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-state__icon">🖼️</div>
|
||||
<h3>Пока нет фотографий</h3>
|
||||
<p>Загрузите первое изображение — оно появится здесь</p>
|
||||
<a href="#upload" class="btn btn--primary">Загрузить фото</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% with photos=photos, show_owner=true, empty_title='Пока нет фотографий', empty_text='Будьте первым — зарегистрируйтесь и загрузите фото', empty_link=url_for('auth.register') if not current_user.is_authenticated else url_for('cabinet.index'), empty_link_text='Загрузить фото' %}
|
||||
{% include "partials/photo_gallery.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user