init
This commit is contained in:
156
rodchenko/app/templates/artwork_settings.html
Executable file
156
rodchenko/app/templates/artwork_settings.html
Executable file
@@ -0,0 +1,156 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 40px;">
|
||||
<div>
|
||||
<h2 class="section-title">{{ artwork.title }}</h2>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">◆ Превью</div>
|
||||
<div class="card-body">
|
||||
<div class="art-preview" style="height: 350px;">
|
||||
<canvas id="settings-art" width="500" height="350"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">◼ Информация</div>
|
||||
<div class="card-body">
|
||||
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; text-align: center;">
|
||||
<div>
|
||||
<p class="text-muted" style="margin-bottom: 5px;">ID</p>
|
||||
<p style="font-size: 24px; font-weight: 700; color: var(--red);">#{{ artwork.id }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-muted" style="margin-bottom: 5px;">Цена</p>
|
||||
<p style="font-size: 24px; font-weight: 700;">{{ artwork.price }} ₽</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-muted" style="margin-bottom: 5px;">Создано</p>
|
||||
<p style="font-size: 14px; font-weight: 500;">{{ artwork.created_at[:10] if artwork.created_at else 'Недавно' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 class="section-title">Настройки</h3>
|
||||
|
||||
{% if settings %}
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">▲ Текущее описание</div>
|
||||
<div class="card-body">
|
||||
{% if settings.error %}
|
||||
<div class="info-block" style="background: var(--red);">
|
||||
Ошибка: {{ settings.error }}
|
||||
</div>
|
||||
{% elif settings.description %}
|
||||
<p style="font-size: 16px; line-height: 1.6;">{{ settings.description }}</p>
|
||||
{% else %}
|
||||
<pre style="background: var(--black); color: var(--cream); padding: 15px; overflow-x: auto; font-family: monospace; font-size: 13px; white-space: pre-wrap; word-wrap: break-word;">{{ settings }}</pre>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">◉ Изменить описание</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url_for('update_settings') }}">
|
||||
<input type="hidden" name="artwork_id" value="{{ artwork.id }}">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="description" class="form-label">Описание работы</label>
|
||||
<textarea class="form-control" id="description" name="description"
|
||||
rows="6" placeholder="Опишите концепцию вашей работы...">{% if settings and settings.description %}{{ settings.description }}{% endif %}</textarea>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 15px;">
|
||||
<button type="submit" class="btn btn-primary">Сохранить</button>
|
||||
<a href="{{ url_for('index') }}" class="btn btn-secondary">Назад</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@media (max-width: 900px) {
|
||||
div[style*="grid-template-columns: 1fr 1fr"] {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
const artworkData = {{ artwork.data|tojson }};
|
||||
|
||||
function drawArt(canvas, artData) {
|
||||
try {
|
||||
const ctx = canvas.getContext('2d');
|
||||
const shapes = JSON.parse(artData);
|
||||
|
||||
ctx.fillStyle = '#F5F0E6';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
const scale = canvas.width / 100;
|
||||
|
||||
shapes.forEach(shape => {
|
||||
ctx.save();
|
||||
ctx.fillStyle = shape.color;
|
||||
ctx.strokeStyle = shape.color;
|
||||
ctx.lineWidth = 4;
|
||||
|
||||
const x = shape.x * scale;
|
||||
const y = shape.y * scale;
|
||||
const w = shape.width * scale;
|
||||
const h = shape.height * scale;
|
||||
const angle = (shape.angle || 0) * Math.PI / 180;
|
||||
|
||||
const cx = x + w / 2;
|
||||
const cy = y + h / 2;
|
||||
|
||||
if (shape.type === 'rectangle' || shape.type === 'rotated_rect') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.fillRect(-w/2, -h/2, w, h);
|
||||
} else if (shape.type === 'circle') {
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, Math.min(w, h) / 2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
} else if (shape.type === 'triangle') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, -h/2);
|
||||
ctx.lineTo(w/2, h/2);
|
||||
ctx.lineTo(-w/2, h/2);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
} else if (shape.type === 'line') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-w/2, 0);
|
||||
ctx.lineTo(w/2, 0);
|
||||
ctx.lineWidth = h || 4;
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.restore();
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Error:', e);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const canvas = document.getElementById('settings-art');
|
||||
if (canvas && artworkData) {
|
||||
drawArt(canvas, artworkData);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
628
rodchenko/app/templates/base.html
Executable file
628
rodchenko/app/templates/base.html
Executable file
@@ -0,0 +1,628 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>РОДЧЕНКО — Аукцион Супрематизма</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;700&family=Playfair+Display:wght@700;900&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--red: #E41E26;
|
||||
--black: #1A1A1A;
|
||||
--cream: #F5F0E6;
|
||||
--yellow: #FFD100;
|
||||
--blue: #003366;
|
||||
--white: #FFFFFF;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Oswald', sans-serif;
|
||||
background: var(--cream);
|
||||
color: var(--black);
|
||||
min-height: 100vh;
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: '';
|
||||
position: fixed;
|
||||
top: -100px;
|
||||
right: -100px;
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
background: var(--red);
|
||||
opacity: 0.1;
|
||||
transform: rotate(45deg);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
body::after {
|
||||
content: '';
|
||||
position: fixed;
|
||||
bottom: -50px;
|
||||
left: -50px;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: var(--black);
|
||||
border-radius: 50%;
|
||||
opacity: 0.05;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background: var(--black);
|
||||
padding: 0;
|
||||
position: relative;
|
||||
z-index: 100;
|
||||
box-shadow: 0 4px 0 var(--red);
|
||||
}
|
||||
|
||||
.navbar-inner {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 15px 30px;
|
||||
background: var(--red);
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 100%, 0 100%);
|
||||
padding-right: 50px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.logo:hover {
|
||||
background: #C41920;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
font-family: 'Playfair Display', serif;
|
||||
font-weight: 900;
|
||||
font-size: 28px;
|
||||
color: var(--white);
|
||||
letter-spacing: 4px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.logo-sub {
|
||||
font-size: 10px;
|
||||
color: var(--yellow);
|
||||
letter-spacing: 2px;
|
||||
margin-left: 15px;
|
||||
text-transform: uppercase;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 25px;
|
||||
color: var(--cream);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background: var(--red);
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
.nav-link::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
width: 0;
|
||||
height: 3px;
|
||||
background: var(--yellow);
|
||||
transition: all 0.2s ease;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.nav-link:hover::after {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-balance {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 30px;
|
||||
background: var(--yellow);
|
||||
color: var(--black);
|
||||
font-weight: 700;
|
||||
font-size: 16px;
|
||||
letter-spacing: 1px;
|
||||
clip-path: polygon(20px 0, 100% 0, 100% 100%, 0 100%);
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.balance-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
width: 100%;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 30px;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
flex: 1;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.alerts {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: 15px 25px;
|
||||
margin-bottom: 10px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 1px;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
animation: slideIn 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from {
|
||||
transform: translateX(-20px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.alert-success {
|
||||
background: var(--black);
|
||||
color: var(--yellow);
|
||||
border-left: 5px solid var(--yellow);
|
||||
}
|
||||
|
||||
.alert-danger {
|
||||
background: var(--red);
|
||||
color: var(--white);
|
||||
border-left: 5px solid var(--black);
|
||||
}
|
||||
|
||||
.alert-close {
|
||||
background: none;
|
||||
border: none;
|
||||
color: inherit;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.alert-close:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 12px 30px;
|
||||
font-family: 'Oswald', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--red);
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #C41920;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 0 var(--black);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--black);
|
||||
color: var(--cream);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #333;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 0 var(--red);
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: var(--yellow);
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.btn-success:hover {
|
||||
background: #E5BC00;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 0 var(--black);
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
background: transparent;
|
||||
color: var(--black);
|
||||
border: 2px solid var(--black);
|
||||
}
|
||||
|
||||
.btn-outline:hover {
|
||||
background: var(--black);
|
||||
color: var(--cream);
|
||||
}
|
||||
|
||||
.btn-small {
|
||||
padding: 8px 16px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--white);
|
||||
border: none;
|
||||
box-shadow: 8px 8px 0 var(--black);
|
||||
position: relative;
|
||||
transition: all 0.2s ease;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translate(-4px, -4px);
|
||||
box-shadow: 12px 12px 0 var(--black);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
background: var(--black);
|
||||
color: var(--cream);
|
||||
padding: 15px 20px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-family: 'Playfair Display', serif;
|
||||
font-weight: 700;
|
||||
font-size: 18px;
|
||||
margin-bottom: 15px;
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 1px;
|
||||
text-transform: uppercase;
|
||||
font-size: 12px;
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 12px 15px;
|
||||
font-family: 'Oswald', sans-serif;
|
||||
font-size: 16px;
|
||||
border: 2px solid var(--black);
|
||||
background: var(--cream);
|
||||
color: var(--black);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
outline: none;
|
||||
border-color: var(--red);
|
||||
box-shadow: 4px 4px 0 var(--red);
|
||||
}
|
||||
|
||||
.form-control::placeholder {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
textarea.form-control {
|
||||
resize: vertical;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.form-text {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 6px 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 1px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.badge-success {
|
||||
background: var(--yellow);
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.badge-info {
|
||||
background: var(--blue);
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-family: 'Playfair Display', serif;
|
||||
font-weight: 700;
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32px;
|
||||
margin-bottom: 30px;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.section-title::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -10px;
|
||||
left: 0;
|
||||
width: 60px;
|
||||
height: 5px;
|
||||
background: var(--red);
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: #666;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.text-price {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.text-price span {
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.grid-2 {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.grid-3 {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
.grid-4 {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.grid-4 {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.grid-3, .grid-4 {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.grid-2, .grid-3, .grid-4 {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.art-preview {
|
||||
background: var(--white);
|
||||
border: 3px solid var(--black);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.art-preview canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.decorative-line {
|
||||
width: 100%;
|
||||
height: 3px;
|
||||
background: repeating-linear-gradient(
|
||||
90deg,
|
||||
var(--red) 0px,
|
||||
var(--red) 20px,
|
||||
var(--black) 20px,
|
||||
var(--black) 40px
|
||||
);
|
||||
margin: 30px 0;
|
||||
}
|
||||
|
||||
.info-block {
|
||||
background: var(--black);
|
||||
color: var(--cream);
|
||||
padding: 15px 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.info-block code {
|
||||
background: var(--red);
|
||||
color: var(--white);
|
||||
padding: 2px 8px;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.layout-sidebar {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 380px;
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
.layout-sidebar {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.layout-center {
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.mb-1 { margin-bottom: 10px; }
|
||||
.mb-2 { margin-bottom: 20px; }
|
||||
.mb-3 { margin-bottom: 30px; }
|
||||
.mt-2 { margin-top: 20px; }
|
||||
.mt-3 { margin-top: 30px; }
|
||||
|
||||
.footer {
|
||||
background: var(--black);
|
||||
color: var(--cream);
|
||||
text-align: center;
|
||||
padding: 30px;
|
||||
margin-top: auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.footer::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 5px;
|
||||
background: var(--red);
|
||||
}
|
||||
|
||||
.footer-text {
|
||||
font-size: 12px;
|
||||
letter-spacing: 3px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.fade-in {
|
||||
animation: fadeIn 0.5s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(20px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.diagonal-stripe {
|
||||
position: absolute;
|
||||
width: 200%;
|
||||
height: 60px;
|
||||
background: var(--red);
|
||||
transform: rotate(-3deg);
|
||||
left: -50%;
|
||||
z-index: -1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar">
|
||||
<div class="navbar-inner">
|
||||
<a href="{{ url_for('index') }}" class="logo">
|
||||
<span class="logo-text">Родченко</span>
|
||||
<span class="logo-sub">Аукцион</span>
|
||||
</a>
|
||||
|
||||
<div class="nav-links">
|
||||
{% if session.user_id %}
|
||||
<a class="nav-link" href="{{ url_for('search') }}">Поиск</a>
|
||||
<a class="nav-link" href="{{ url_for('profile') }}">Профиль</a>
|
||||
<a class="nav-link" href="{{ url_for('logout') }}">Выход</a>
|
||||
<div class="nav-balance">
|
||||
<span class="balance-icon">◆</span>
|
||||
{{ balance if balance else 0 }} ₽
|
||||
</div>
|
||||
{% else %}
|
||||
<a class="nav-link" href="{{ url_for('login') }}">Вход</a>
|
||||
<a class="nav-link" href="{{ url_for('register') }}">Регистрация</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="main-content fade-in">
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<div class="alerts">
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ 'danger' if category == 'error' else 'success' }}">
|
||||
<span>{{ message }}</span>
|
||||
<button class="alert-close" onclick="this.parentElement.remove()">×</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer class="footer">
|
||||
<p class="footer-text">MCTF 2025 • Супрематизм • Искусство Будущего</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
57
rodchenko/app/templates/import_artwork.html
Executable file
57
rodchenko/app/templates/import_artwork.html
Executable file
@@ -0,0 +1,57 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container" style="max-width: 800px; margin: 0 auto;">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">◼ Импорт картины по URL</div>
|
||||
<div class="card-body">
|
||||
<p>Загрузите супрематическую композицию с внешнего ресурса.</p>
|
||||
|
||||
<form method="POST">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="artwork_url"
|
||||
placeholder="https://example.com/artwork.json" value="">
|
||||
<p class="text-muted" style="font-size: 12px; margin-top: 5px;">
|
||||
Укажите URL файла с данными картины в формате JSON.
|
||||
</p>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Загрузить</button>
|
||||
</form>
|
||||
|
||||
<div style="background: #f5f5f5; padding: 15px; font-family: monospace; font-size: 12px; margin-top: 20px;">
|
||||
<strong>Формат JSON:</strong><br>
|
||||
{"title": "Название", "price": 100, "signature": "Подпись",<br>
|
||||
"shapes": [{"type": "rectangle", "x": 10, "y": 10, "width": 30, "height": 20, "color": "#E41E26"}]}
|
||||
</div>
|
||||
|
||||
<p style="margin-top: 20px;">
|
||||
<a href="{{ url_for('index') }}" style="color: var(--red);">← Вернуться в галерею</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if success %}
|
||||
<div class="card mb-3" style="background: #28a745; color: white;">
|
||||
<div class="card-body">{{ success }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if error %}
|
||||
<div class="card mb-3" style="background: var(--red); color: white;">
|
||||
<div class="card-body">{{ error }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if preview_content and not success %}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Ответ сервера{% if fetched_url %} ({{ fetched_url }}){% endif %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<pre style="background: #1a1a1a; color: #f5f0e6; padding: 20px; max-height: 400px; overflow: auto; white-space: pre-wrap; word-break: break-all;">{{ preview_content }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
182
rodchenko/app/templates/index.html
Executable file
182
rodchenko/app/templates/index.html
Executable file
@@ -0,0 +1,182 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-sidebar">
|
||||
<div>
|
||||
<h2 class="section-title">Галерея</h2>
|
||||
|
||||
{% if artworks %}
|
||||
<div class="grid grid-2">
|
||||
{% for art in artworks %}
|
||||
<div class="card">
|
||||
<div class="card-header" style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<span>#{{ art.id }} • {{ art.created_at[:10] if art.created_at else 'Новое' }}</span>
|
||||
{% if art.is_private %}
|
||||
<span style="background: var(--red); color: white; padding: 2px 8px; font-size: 10px;">ПРИВАТНАЯ</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ art.title }}</h5>
|
||||
|
||||
<div class="art-preview mb-2" style="height: 180px;">
|
||||
<canvas id="art-{{ art.id }}" width="400" height="180"></canvas>
|
||||
</div>
|
||||
|
||||
{% if art.signature %}
|
||||
<div class="artwork-signature mb-2" style="padding: 10px; background: #f0f0f0; border-left: 3px solid var(--red); font-style: italic;">
|
||||
<small style="color: #666;">Подпись художника:</small><br>
|
||||
{{ art.signature }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="text-price mb-2">
|
||||
{{ art.price }} <span>₽</span>
|
||||
</div>
|
||||
|
||||
<p class="text-muted mb-2">
|
||||
Владелец:
|
||||
{% if art.owner_id == session.user_id %}
|
||||
<strong>Вы</strong>
|
||||
{% else %}
|
||||
{{ art.owner_name }}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if art.owner_id != session.user_id %}
|
||||
<a href="{{ url_for('buy_artwork', artwork_id=art.id) }}" class="btn btn-primary">Купить</a>
|
||||
{% else %}
|
||||
<span class="badge badge-success">Ваша работа</span>
|
||||
<a href="{{ url_for('artwork_settings', artwork_id=art.id) }}" class="btn btn-outline btn-small" style="margin-left: 10px;">Настройки</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="info-block">
|
||||
<p>Галерея пуста. Станьте первым художником — создайте свою супрематическую композицию!</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<aside>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">◼ Создать работу</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url_for('create_artwork') }}">
|
||||
<div class="form-group">
|
||||
<label for="price" class="form-label">Цена</label>
|
||||
<input type="number" class="form-control" id="price" name="price" value="100" min="1" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="signature" class="form-label">Подпись художника</label>
|
||||
<textarea class="form-control" id="signature" name="signature"
|
||||
rows="2" placeholder="Ваша творческая подпись..."></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="description" class="form-label">Описание (опционально)</label>
|
||||
<textarea class="form-control" id="description" name="description"
|
||||
rows="2" placeholder="Концепция работы..."></textarea>
|
||||
</div>
|
||||
<div class="form-group" style="display: flex; align-items: center; gap: 10px;">
|
||||
<input type="checkbox" id="is_private" name="is_private" value="1" style="width: 20px; height: 20px;">
|
||||
<label for="is_private" style="margin: 0; cursor: pointer;">Приватная работа</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success" style="width: 100%;">Создать композицию</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">◉ Поиск</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ url_for('search') }}" method="GET">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="q" placeholder="Название или данные...">
|
||||
</div>
|
||||
<button class="btn btn-secondary" type="submit" style="width: 100%;">Найти</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">▲ Действия</div>
|
||||
<div class="card-body">
|
||||
<a href="{{ url_for('profile') }}" class="btn btn-outline mb-1" style="width: 100%;">Мой профиль</a>
|
||||
<a href="{{ url_for('import_artwork') }}" class="btn btn-outline" style="width: 100%;">Импорт картины</a>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const artworksData = {{ artworks|tojson }};
|
||||
|
||||
function drawArt(canvas, artData) {
|
||||
try {
|
||||
const ctx = canvas.getContext('2d');
|
||||
const shapes = JSON.parse(artData);
|
||||
|
||||
ctx.fillStyle = '#F5F0E6';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
const scale = canvas.width / 100;
|
||||
|
||||
shapes.forEach(shape => {
|
||||
ctx.save();
|
||||
ctx.fillStyle = shape.color;
|
||||
ctx.strokeStyle = shape.color;
|
||||
ctx.lineWidth = 3;
|
||||
|
||||
const x = shape.x * scale;
|
||||
const y = shape.y * scale;
|
||||
const w = shape.width * scale;
|
||||
const h = shape.height * scale;
|
||||
const angle = (shape.angle || 0) * Math.PI / 180;
|
||||
|
||||
const cx = x + w / 2;
|
||||
const cy = y + h / 2;
|
||||
|
||||
if (shape.type === 'rectangle' || shape.type === 'rotated_rect') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.fillRect(-w/2, -h/2, w, h);
|
||||
} else if (shape.type === 'circle') {
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, Math.min(w, h) / 2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
} else if (shape.type === 'triangle') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, -h/2);
|
||||
ctx.lineTo(w/2, h/2);
|
||||
ctx.lineTo(-w/2, h/2);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
} else if (shape.type === 'line') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-w/2, 0);
|
||||
ctx.lineTo(w/2, 0);
|
||||
ctx.lineWidth = h || 4;
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.restore();
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Drawing error:', e);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
artworksData.forEach(art => {
|
||||
const canvas = document.getElementById('art-' + art.id);
|
||||
if (canvas) {
|
||||
drawArt(canvas, art.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
66
rodchenko/app/templates/login.html
Executable file
66
rodchenko/app/templates/login.html
Executable file
@@ -0,0 +1,66 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-center">
|
||||
<div style="text-align: center; margin-bottom: 40px;">
|
||||
<h1 style="font-size: 48px; margin-bottom: 10px;">ВХОД</h1>
|
||||
<div class="decorative-line" style="width: 100px; margin: 0 auto;"></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">◆ Авторизация</div>
|
||||
<div class="card-body">
|
||||
<form method="POST">
|
||||
<div class="form-group">
|
||||
<label for="username" class="form-label">Имя пользователя</label>
|
||||
<input type="text" class="form-control" id="username" name="username"
|
||||
placeholder="Введите логин" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password" class="form-label">Пароль</label>
|
||||
<input type="password" class="form-control" id="password" name="password"
|
||||
placeholder="Введите пароль" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" style="width: 100%;">Войти</button>
|
||||
</form>
|
||||
|
||||
<div class="decorative-line mt-3"></div>
|
||||
|
||||
<div style="text-align: center;">
|
||||
<p class="text-muted">Нет аккаунта?</p>
|
||||
<a href="{{ url_for('register') }}" class="btn btn-outline">Зарегистрироваться</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Декоративные фигуры для страницы входа */
|
||||
.layout-center {
|
||||
position: relative;
|
||||
padding-top: 60px;
|
||||
}
|
||||
|
||||
.layout-center::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -100px;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background: var(--red);
|
||||
transform: rotate(15deg);
|
||||
}
|
||||
|
||||
.layout-center::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -50px;
|
||||
right: -80px;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
border: 8px solid var(--black);
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
136
rodchenko/app/templates/profile.html
Executable file
136
rodchenko/app/templates/profile.html
Executable file
@@ -0,0 +1,136 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card mb-3" style="background: var(--black); color: var(--cream);">
|
||||
<div class="card-body" style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px;">
|
||||
<div>
|
||||
<p style="font-size: 12px; letter-spacing: 2px; text-transform: uppercase; opacity: 0.7; margin-bottom: 5px;">Профиль</p>
|
||||
<h2 style="font-family: 'Playfair Display', serif; font-size: 36px; color: var(--cream); margin: 0;">
|
||||
{{ user.username }}
|
||||
</h2>
|
||||
</div>
|
||||
<div style="display: flex; gap: 40px; align-items: center;">
|
||||
<div style="text-align: center;">
|
||||
<p style="font-size: 12px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.7;">ID</p>
|
||||
<p style="font-size: 24px; font-weight: 700; color: var(--yellow);">#{{ user.id }}</p>
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<p style="font-size: 12px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.7;">Баланс</p>
|
||||
<p style="font-size: 24px; font-weight: 700; color: var(--yellow);">{{ user.balance }} ₽</p>
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<p style="font-size: 12px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.7;">Работ</p>
|
||||
<p style="font-size: 24px; font-weight: 700; color: var(--yellow);">{{ artworks|length }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="section-title">Коллекция</h3>
|
||||
|
||||
{% if artworks %}
|
||||
<div class="grid grid-3">
|
||||
{% for art in artworks %}
|
||||
<div class="card">
|
||||
<div class="card-header" style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<span>#{{ art.id }}</span>
|
||||
{% if art.is_private %}
|
||||
<span style="background: var(--red); color: white; padding: 2px 8px; font-size: 10px;">ПРИВАТНАЯ</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ art.title }}</h5>
|
||||
<div class="art-preview mb-2" style="height: 160px;">
|
||||
<canvas id="profile-art-{{ art.id }}" width="350" height="160"></canvas>
|
||||
</div>
|
||||
{% if art.signature %}
|
||||
<div class="artwork-signature mb-2" style="padding: 8px; background: #f0f0f0; border-left: 3px solid var(--red); font-style: italic; font-size: 13px;">
|
||||
{{ art.signature }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="text-price mb-1">
|
||||
{{ art.price }} <span>₽</span>
|
||||
</div>
|
||||
<p class="text-muted mb-2">{{ art.created_at[:16] if art.created_at else 'Недавно' }}</p>
|
||||
<a href="{{ url_for('artwork_settings', artwork_id=art.id) }}" class="btn btn-outline btn-small">Настройки</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="info-block">
|
||||
<p>У вас пока нет работ. <a href="{{ url_for('index') }}" style="color: var(--yellow);">Создайте первую!</a></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
const profileArtworksData = {{ artworks|tojson }};
|
||||
|
||||
function drawArt(canvas, artData) {
|
||||
try {
|
||||
const ctx = canvas.getContext('2d');
|
||||
const shapes = JSON.parse(artData);
|
||||
|
||||
ctx.fillStyle = '#F5F0E6';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
const scale = canvas.width / 100;
|
||||
|
||||
shapes.forEach(shape => {
|
||||
ctx.save();
|
||||
ctx.fillStyle = shape.color;
|
||||
ctx.strokeStyle = shape.color;
|
||||
ctx.lineWidth = 3;
|
||||
|
||||
const x = shape.x * scale;
|
||||
const y = shape.y * scale;
|
||||
const w = shape.width * scale;
|
||||
const h = shape.height * scale;
|
||||
const angle = (shape.angle || 0) * Math.PI / 180;
|
||||
|
||||
const cx = x + w / 2;
|
||||
const cy = y + h / 2;
|
||||
|
||||
if (shape.type === 'rectangle' || shape.type === 'rotated_rect') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.fillRect(-w/2, -h/2, w, h);
|
||||
} else if (shape.type === 'circle') {
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, Math.min(w, h) / 2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
} else if (shape.type === 'triangle') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, -h/2);
|
||||
ctx.lineTo(w/2, h/2);
|
||||
ctx.lineTo(-w/2, h/2);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
} else if (shape.type === 'line') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-w/2, 0);
|
||||
ctx.lineTo(w/2, 0);
|
||||
ctx.lineWidth = h || 4;
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.restore();
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Error:', e);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
profileArtworksData.forEach(art => {
|
||||
const canvas = document.getElementById('profile-art-' + art.id);
|
||||
if (canvas) {
|
||||
drawArt(canvas, art.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
73
rodchenko/app/templates/register.html
Executable file
73
rodchenko/app/templates/register.html
Executable file
@@ -0,0 +1,73 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-center">
|
||||
<div style="text-align: center; margin-bottom: 40px;">
|
||||
<h1 style="font-size: 42px; margin-bottom: 10px;">РЕГИСТРАЦИЯ</h1>
|
||||
<div class="decorative-line" style="width: 100px; margin: 0 auto;"></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">◼ Новый художник</div>
|
||||
<div class="card-body">
|
||||
<div class="info-block mb-3">
|
||||
<p style="font-size: 14px;">
|
||||
Присоединяйтесь к миру супрематизма!<br>
|
||||
Начальный баланс: <strong>1000 ₽</strong>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form method="POST">
|
||||
<div class="form-group">
|
||||
<label for="username" class="form-label">Имя пользователя</label>
|
||||
<input type="text" class="form-control" id="username" name="username"
|
||||
placeholder="Придумайте логин" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password" class="form-label">Пароль</label>
|
||||
<input type="password" class="form-control" id="password" name="password"
|
||||
placeholder="Придумайте пароль" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success" style="width: 100%;">Создать аккаунт</button>
|
||||
</form>
|
||||
|
||||
<div class="decorative-line mt-3"></div>
|
||||
|
||||
<div style="text-align: center;">
|
||||
<p class="text-muted">Уже зарегистрированы?</p>
|
||||
<a href="{{ url_for('login') }}" class="btn btn-outline">Войти</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.layout-center {
|
||||
position: relative;
|
||||
padding-top: 60px;
|
||||
}
|
||||
|
||||
.layout-center::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -30px;
|
||||
right: -100px;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background: var(--yellow);
|
||||
transform: rotate(-10deg);
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.layout-center::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -30px;
|
||||
left: -60px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background: var(--black);
|
||||
z-index: -1;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
121
rodchenko/app/templates/search.html
Executable file
121
rodchenko/app/templates/search.html
Executable file
@@ -0,0 +1,121 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h2 class="section-title">Поиск</h2>
|
||||
|
||||
<form action="{{ url_for('search') }}" method="GET" class="mb-3" style="width: 100%;">
|
||||
<div style="display: flex; gap: 20px; width: 100%;">
|
||||
<input type="text" name="q" value="{{ query }}"
|
||||
placeholder="Поиск по названию или данным..."
|
||||
style="flex-grow: 1; width: calc(100% - 160px); padding: 15px 20px; font-size: 16px; border: 2px solid #1A1A1A; font-family: 'Oswald', sans-serif; background: #F5F0E6;">
|
||||
<button class="btn btn-primary" type="submit" style="padding: 15px 40px; flex-shrink: 0;">Найти</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% if results %}
|
||||
<div class="info-block mb-3">
|
||||
<p>Найдено работ: <strong>{{ results|length }}</strong> по запросу «{{ query }}»</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-3">
|
||||
{% for art in results %}
|
||||
<div class="card">
|
||||
<div class="card-header">#{{ art.id }}</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ art.title }}</h5>
|
||||
<div class="art-preview mb-2" style="height: 160px;">
|
||||
<canvas id="search-art-{{ art.id }}" width="350" height="160"></canvas>
|
||||
</div>
|
||||
<div class="text-price mb-2">
|
||||
{{ art.price }} <span>₽</span>
|
||||
</div>
|
||||
{% if art.owner_id != session.user_id %}
|
||||
<a href="{{ url_for('buy_artwork', artwork_id=art.id) }}" class="btn btn-primary">Купить</a>
|
||||
{% else %}
|
||||
<span class="badge badge-success">Ваша работа</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% elif query %}
|
||||
<div class="info-block">
|
||||
<p>По запросу «<strong>{{ query }}</strong>» ничего не найдено.</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="info-block">
|
||||
<p>Введите поисковый запрос для поиска работ.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
const searchResultsData = {{ results|tojson }};
|
||||
|
||||
function drawArt(canvas, artData) {
|
||||
try {
|
||||
const ctx = canvas.getContext('2d');
|
||||
const shapes = JSON.parse(artData);
|
||||
|
||||
ctx.fillStyle = '#F5F0E6';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
const scale = canvas.width / 100;
|
||||
|
||||
shapes.forEach(shape => {
|
||||
ctx.save();
|
||||
ctx.fillStyle = shape.color;
|
||||
ctx.strokeStyle = shape.color;
|
||||
ctx.lineWidth = 3;
|
||||
|
||||
const x = shape.x * scale;
|
||||
const y = shape.y * scale;
|
||||
const w = shape.width * scale;
|
||||
const h = shape.height * scale;
|
||||
const angle = (shape.angle || 0) * Math.PI / 180;
|
||||
|
||||
const cx = x + w / 2;
|
||||
const cy = y + h / 2;
|
||||
|
||||
if (shape.type === 'rectangle' || shape.type === 'rotated_rect') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.fillRect(-w/2, -h/2, w, h);
|
||||
} else if (shape.type === 'circle') {
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, Math.min(w, h) / 2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
} else if (shape.type === 'triangle') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, -h/2);
|
||||
ctx.lineTo(w/2, h/2);
|
||||
ctx.lineTo(-w/2, h/2);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
} else if (shape.type === 'line') {
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(angle);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-w/2, 0);
|
||||
ctx.lineTo(w/2, 0);
|
||||
ctx.lineWidth = h || 4;
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.restore();
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Error:', e);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
searchResultsData.forEach(art => {
|
||||
const canvas = document.getElementById('search-art-' + art.id);
|
||||
if (canvas && art.data) {
|
||||
drawArt(canvas, art.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user