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 @@
Гипножаба облизывается на:
+ +кликни или притащи другой файл, чтобы скормить
+