From 752f1506e3d631ff407a922182d5c0cc93b7620c Mon Sep 17 00:00:00 2001 From: erjemin Date: Sun, 23 Aug 2026 23:24:47 +0300 Subject: [PATCH] =?UTF-8?q?mod:=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84?= =?UTF-8?q?=D0=B5=D0=B9=D1=81=20(10)=20=D0=BF=D1=80=D0=B5=D0=B2=D1=8C?= =?UTF-8?q?=D1=8E=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BA=D0=B8.=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=20"=D1=81=D0=BA=D0=B0=D1=80?= =?UTF-8?q?=D0=BC=D0=BB=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=93?= =?UTF-8?q?=D0=B8=D0=BF=D0=BE=D0=BD=D0=BE=D0=B6=D0=B0=D0=B1=D0=B5"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hypn0/hypn0_site/services/halftone.py | 2 +- hypn0/hypn0_site/tests.py | 3 ++ hypn0/templates/index.html | 43 ++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/hypn0/hypn0_site/services/halftone.py b/hypn0/hypn0_site/services/halftone.py index b091c25..d613391 100644 --- a/hypn0/hypn0_site/services/halftone.py +++ b/hypn0/hypn0_site/services/halftone.py @@ -86,7 +86,7 @@ def generate_shape_def(shape: str, radius: int, shape_id: str) -> str: def generate_halftone_svg( image: Union[Image.Image, BinaryIO, bytes, str], *, - cols: int = 80, + cols: int = 35, max_radius: int = 8, shape: str = "circle", color: str = "#a855ff", diff --git a/hypn0/hypn0_site/tests.py b/hypn0/hypn0_site/tests.py index cf9a1b3..7420506 100644 --- a/hypn0/hypn0_site/tests.py +++ b/hypn0/hypn0_site/tests.py @@ -120,6 +120,9 @@ class HalftoneViewTests(TestCase): self.assertContains(response, 'id="preview"') self.assertContains(response, 'name="csrfmiddlewaretoken"') self.assertContains(response, 'X-CSRFToken') + self.assertContains(response, "handleFileChange") + self.assertContains(response, "imagePreviewUrl") + self.assertContains(response, "Гипножаба облизывается на:") # Проверяем, что csrf_token не пустой в hx-headers content = response.content.decode("utf-8") self.assertNotIn('hx-headers=\'{"X-CSRFToken": ""}\'', content) diff --git a/hypn0/templates/index.html b/hypn0/templates/index.html index 77ef8c1..268e18d 100644 --- a/hypn0/templates/index.html +++ b/hypn0/templates/index.html @@ -22,9 +22,29 @@ isLoading: false, /* Идет ли процесс генерации SVG (индикация, блокировка) */ hasChanges: true, /* Флаг наличия правок в форме для активности кнопки */ hasImage: false, /* Флаг загрузки пользовательского файла */ + fileName: '', /* Имя выбранного файла */ + imagePreviewUrl: null, /* Превью загруженного файла (Blob URL) */ timer: null, /* Ссылка на таймер удержания анимации размышления */ copied: false, /* Флаг успешного копирования в буфер */ + /* Обработка выбора файла (превью + имя) */ + handleFileChange(event) { + const files = event.target.files; + if (files && files.length > 0) { + const file = files[0]; + this.hasImage = true; + this.fileName = file.name; + if (this.imagePreviewUrl) URL.revokeObjectURL(this.imagePreviewUrl); + this.imagePreviewUrl = URL.createObjectURL(file); + } else { + this.hasImage = false; + this.fileName = ''; + if (this.imagePreviewUrl) URL.revokeObjectURL(this.imagePreviewUrl); + this.imagePreviewUrl = null; + } + this.hasChanges = true; + }, + /* Метод запуска состояния размышления (8 секунд) */ startThinking() { this.isLoading = true; @@ -91,15 +111,30 @@
- + :class="hasImage ? 'border-emerald-500 bg-emerald-50/20 dark:bg-emerald-950/20' : 'border-stone-300 dark:border-zinc-700'" + class="border-2 border-dashed group-hover:border-emerald-500 rounded-xl p-6 flex flex-col items-center justify-center text-center transition-all"> + + +
Покорми Гипнoжабу,
притащи сюда img или кликни
- +
+ + +
+ Превью +
+

Гипножаба облизывается на:

+

+

кликни или притащи другой файл, чтобы скормить

+
+
+