init commit

This commit is contained in:
2025-08-10 15:31:47 +09:00
commit 377edb22d8
25 changed files with 1922 additions and 0 deletions

74
templates/base.html Normal file
View File

@@ -0,0 +1,74 @@
{% load static %}
<!doctype html>
<html lang="ru" class="h-full">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Брачное агентство — MatchAgency{% endblock %}</title>
<link rel="stylesheet" href="{% static 'style.css' %}">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
</head>
<body class="min-h-full bg-gradient-to-br from-sky-50 to-rose-50">
<header class="bg-white/80 backdrop-blur border-b">
<nav class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-3 flex items-center justify-between">
<a href="/" class="font-semibold text-xl tracking-tight">💍 MatchAgency</a>
<div class="flex items-center gap-4">
<a href="/profiles/" class="text-sm font-medium hover:underline">Профили</a>
{% if api_user %}
<span class="text-sm text-gray-600">Здравствуйте, {{ api_user.name|default:api_user.email }}</span>
<form action="/logout/" method="post">
{% csrf_token %}
<button class="text-sm text-white bg-gray-800 hover:bg-black rounded-md px-3 py-1.5">Выйти</button>
</form>
{% else %}
<a href="/login/" class="text-sm text-white bg-indigo-600 hover:bg-indigo-700 rounded-md px-3 py-1.5">Войти</a>
{% endif %}
</div>
</nav>
</header>
<main class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-6">
{% if messages %}
<div class="space-y-2 mb-4">
{% for m in messages %}
<div class="rounded-md border px-3 py-2 {% if m.tags == 'error' %}bg-rose-50 border-rose-200 text-rose-900{% elif m.tags == 'success' %}bg-emerald-50 border-emerald-200 text-emerald-900{% else %}bg-white/70{% endif %}">
{{ m }}
</div>
{% endfor %}
</div>
{% endif %}
{% block content %}{% endblock %}
</main>
<footer class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-10 text-sm text-gray-500">
<div class="border-t pt-6 flex items-center justify-between">
<p>© {{ now|default:2025 }} MatchAgency. Все права защищены.</p>
<p><a href="/profiles/" class="hover:underline">Каталог</a> · <a href="/login/" class="hover:underline">Войти</a></p>
</div>
</footer>
<script>
// CSRF для htmx через cookie
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
document.body.addEventListener('htmx:configRequest', function (evt) {
const token = getCookie('csrftoken');
if (token) evt.detail.headers['X-CSRFToken'] = token;
});
</script>
</body>
</html>