From 18c865feafd2c892fb034766135f06600520654f Mon Sep 17 00:00:00 2001 From: deltaaa00 Date: Mon, 16 Nov 2026 09:52:01 +0200 Subject: [PATCH 1/6] chore: add Apache 2.0 headers to source and configuration files --- .coveragerc | 14 ++++++++++++++ .dockerignore | 14 ++++++++++++++ .github/CODEOWNERS | 14 ++++++++++++++ .github/workflows/deploy.yml | 14 ++++++++++++++ .github/workflows/python-tests.yml | 14 ++++++++++++++ .gitignore | 14 ++++++++++++++ Dockerfile.web | 14 ++++++++++++++ Dockerfile.ytserver | 14 ++++++++++++++ automap_rs/Cargo.toml | 14 ++++++++++++++ automap_rs/pyproject.toml | 14 ++++++++++++++ automap_rs/src/lib.rs | 14 ++++++++++++++ benchmarks/bench_video_render.py | 14 ++++++++++++++ docker-compose.yml | 14 ++++++++++++++ example.env | 14 ++++++++++++++ extra_stickers.py | 14 ++++++++++++++ map/__init__.py | 13 +++++++++++++ map/functions.py | 14 ++++++++++++++ optimization.md | 16 ++++++++++++++++ overview.md | 16 ++++++++++++++++ pyproject.toml | 14 ++++++++++++++ readme.md | 16 ++++++++++++++++ render_progress.py | 14 ++++++++++++++ requirements-test.txt | 14 ++++++++++++++ requirements.txt | 14 ++++++++++++++ resources/maps/border_procesing.py | 14 ++++++++++++++ resources/othr/white_pixels_cleaning.py | 14 ++++++++++++++ server_runtime.py | 14 ++++++++++++++ static/studio-storage.js | 14 ++++++++++++++ sticker_themes.py | 14 ++++++++++++++ templates/index.html | 16 ++++++++++++++++ templates/login.html | 16 ++++++++++++++++ templates/video.html | 16 ++++++++++++++++ tests/README.md | 16 ++++++++++++++++ tests/browser/test_cookie_file_upload.py | 14 ++++++++++++++ tests/browser/test_map_palettes.py | 14 ++++++++++++++ tests/browser/test_music_file_upload.py | 14 ++++++++++++++ tests/browser/test_video_studio.py | 14 ++++++++++++++ tests/browser/test_web_security.py | 14 ++++++++++++++ tests/conftest.py | 14 ++++++++++++++ tests/test_ai_and_filling.py | 14 ++++++++++++++ tests/test_asset_tools.py | 14 ++++++++++++++ tests/test_audio_upload.py | 14 ++++++++++++++ tests/test_auto_map.py | 14 ++++++++++++++ tests/test_batch_csv.py | 14 ++++++++++++++ tests/test_cli.py | 14 ++++++++++++++ tests/test_deepseek.py | 14 ++++++++++++++ tests/test_dependencies.py | 14 ++++++++++++++ tests/test_functions.py | 14 ++++++++++++++ tests/test_logging.py | 14 ++++++++++++++ tests/test_map_styling.py | 14 ++++++++++++++ tests/test_music_upload_proxy.py | 14 ++++++++++++++ tests/test_numeric_extrema.py | 14 ++++++++++++++ tests/test_render_progress.py | 14 ++++++++++++++ tests/test_server_runtime.py | 14 ++++++++++++++ tests/test_video_render.py | 14 ++++++++++++++ tests/test_web.py | 14 ++++++++++++++ tests/test_web_ai_cache.py | 14 ++++++++++++++ tests/test_web_auth.py | 14 ++++++++++++++ tests/test_web_auth_security.py | 14 ++++++++++++++ tests/test_web_input_validation.py | 14 ++++++++++++++ tests/test_worker.py | 14 ++++++++++++++ tests/test_worker_audit.py | 14 ++++++++++++++ tests/test_world_countries.py | 14 ++++++++++++++ tools/bench_map.py | 14 ++++++++++++++ video_render.py | 14 ++++++++++++++ video_stickers.py | 14 ++++++++++++++ video_text.py | 14 ++++++++++++++ web_ai_cache.py | 14 ++++++++++++++ web_auth.py | 14 ++++++++++++++ yt-dlp_serv.py | 14 ++++++++++++++ 70 files changed, 993 insertions(+) diff --git a/.coveragerc b/.coveragerc index c233674..15cd0eb 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + [run] branch = True source = . diff --git a/.dockerignore b/.dockerignore index b8879b5..ab54a02 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + .DS_Store .env .env.* diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4355eea..3206ee9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,16 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Automatically request the maintainer's review for all changes. * @deltaaa00 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 89cfe7c..152b4b2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Deploy to Server on: diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 5b4d6f1..0249bf7 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Run Pytest on: diff --git a/.gitignore b/.gitignore index e373311..0a082a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + .DS_Store .AppleDouble .LSOverride diff --git a/Dockerfile.web b/Dockerfile.web index 4cd803d..fa03736 100644 --- a/Dockerfile.web +++ b/Dockerfile.web @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FROM python:3.12-slim WORKDIR /app diff --git a/Dockerfile.ytserver b/Dockerfile.ytserver index e625127..b54ab7c 100644 --- a/Dockerfile.ytserver +++ b/Dockerfile.ytserver @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FROM rust:1.83-slim AS rust-builder WORKDIR /build RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/* \ diff --git a/automap_rs/Cargo.toml b/automap_rs/Cargo.toml index 93cf872..ca3e748 100644 --- a/automap_rs/Cargo.toml +++ b/automap_rs/Cargo.toml @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + [package] name = "automap_rs" version = "0.1.0" diff --git a/automap_rs/pyproject.toml b/automap_rs/pyproject.toml index 652fc55..67c3b8c 100644 --- a/automap_rs/pyproject.toml +++ b/automap_rs/pyproject.toml @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + [build-system] requires = ["maturin>=1.7,<2.0"] build-backend = "maturin" diff --git a/automap_rs/src/lib.rs b/automap_rs/src/lib.rs index 700fef5..a0ee964 100644 --- a/automap_rs/src/lib.rs +++ b/automap_rs/src/lib.rs @@ -1,3 +1,17 @@ +// Copyright 2025-2026 deltaaa00 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + use pyo3::prelude::*; use std::io::{Read, Write}; use std::process::{Command, Stdio}; diff --git a/benchmarks/bench_video_render.py b/benchmarks/bench_video_render.py index b5bf5d6..f41206d 100644 --- a/benchmarks/bench_video_render.py +++ b/benchmarks/bench_video_render.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Render benchmark for the video worker. Usage: python benchmarks/bench_video_render.py [--seconds 3] [--module yt-dlp_serv.py] diff --git a/docker-compose.yml b/docker-compose.yml index 7718c25..fa2ddde 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + services: web: restart: unless-stopped diff --git a/example.env b/example.env index f550408..d40e20e 100644 --- a/example.env +++ b/example.env @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + GEMINI_API_KEY=your_google_ai_studio_key DEEPSEEK_API_KEY=your_deepseek_api_key SERVER=TRUE diff --git a/extra_stickers.py b/extra_stickers.py index ca141b1..39d5479 100644 --- a/extra_stickers.py +++ b/extra_stickers.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Offline vector artwork for the extended sticker library.""" diff --git a/map/__init__.py b/map/__init__.py index e69de29..e0a5433 100644 --- a/map/__init__.py +++ b/map/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/map/functions.py b/map/functions.py index 01d61bc..d99d5d3 100644 --- a/map/functions.py +++ b/map/functions.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import csv import io import json diff --git a/optimization.md b/optimization.md index 1197812..d3d739e 100644 --- a/optimization.md +++ b/optimization.md @@ -1,3 +1,19 @@ + + # Performance optimization review This review covers the map generation engine (`map/auto_map.py` and diff --git a/overview.md b/overview.md index b5c5ccb..9bd2601 100644 --- a/overview.md +++ b/overview.md @@ -1,3 +1,19 @@ + + # Project overview for AI agents AutoMap generates labelled, coloured maps from natural-language prompts using diff --git a/pyproject.toml b/pyproject.toml index b519aeb..457aac7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" diff --git a/readme.md b/readme.md index 3e710df..850b529 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,19 @@ + + # AutoMap ![AutoMap](resources/demo/banner.png) diff --git a/render_progress.py b/render_progress.py index f230c42..9e989de 100644 --- a/render_progress.py +++ b/render_progress.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Thread-safe per-render progress for the single-process media worker.""" from functools import wraps from threading import Lock diff --git a/requirements-test.txt b/requirements-test.txt index 8c52804..941c7de 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Install the application plus the tools needed to run its test suite. -r requirements.txt pytest>=9.0.0 diff --git a/requirements.txt b/requirements.txt index e81ca4b..db259f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Runtime dependencies for the CLI, web app, and media worker. pillow>=9.2.0,<12.0.0 click>=8.0.0 diff --git a/resources/maps/border_procesing.py b/resources/maps/border_procesing.py index b9732db..405e7a0 100644 --- a/resources/maps/border_procesing.py +++ b/resources/maps/border_procesing.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #This file makes blured borders diff --git a/resources/othr/white_pixels_cleaning.py b/resources/othr/white_pixels_cleaning.py index d268a5b..3965ab2 100644 --- a/resources/othr/white_pixels_cleaning.py +++ b/resources/othr/white_pixels_cleaning.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from PIL import Image _OPAQUE_ALPHA_LUT: list[int] = [255 if a == 255 else 0 for a in range(256)] diff --git a/server_runtime.py b/server_runtime.py index 7d86d7d..d6632fb 100644 --- a/server_runtime.py +++ b/server_runtime.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Shared development and production launch settings for the web services.""" import os diff --git a/static/studio-storage.js b/static/studio-storage.js index c500bd9..41355f0 100644 --- a/static/studio-storage.js +++ b/static/studio-storage.js @@ -1,3 +1,17 @@ +// Copyright 2025-2026 deltaaa00 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + /* Shared browser storage for generated maps and selected video materials. */ window.StudioStorage = (() => { let connection; diff --git a/sticker_themes.py b/sticker_themes.py index 325b9d6..10ef006 100644 --- a/sticker_themes.py +++ b/sticker_themes.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """English-only sticker catalog and keyword dictionary for automatic video sticker selection.""" # Valid sticker identifiers accepted by the API; 'none' and 'auto' are control modes. diff --git a/templates/index.html b/templates/index.html index 910e5a5..65e866b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,4 +1,20 @@ + + diff --git a/templates/login.html b/templates/login.html index 4180abe..c155791 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,4 +1,20 @@ + + diff --git a/templates/video.html b/templates/video.html index 1248d59..a4b5466 100644 --- a/templates/video.html +++ b/templates/video.html @@ -1,4 +1,20 @@ + + diff --git a/tests/README.md b/tests/README.md index 45c652c..13930c8 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,3 +1,19 @@ + + # Tests Use Python 3.12, matching CI. From the project root: diff --git a/tests/browser/test_cookie_file_upload.py b/tests/browser/test_cookie_file_upload.py index 5aa243e..002cea0 100644 --- a/tests/browser/test_cookie_file_upload.py +++ b/tests/browser/test_cookie_file_upload.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Cookies remain parseable across file import, browser storage and both APIs.""" from http.cookiejar import MozillaCookieJar from pathlib import Path diff --git a/tests/browser/test_map_palettes.py b/tests/browser/test_map_palettes.py index c1d5a37..f2b999a 100644 --- a/tests/browser/test_map_palettes.py +++ b/tests/browser/test_map_palettes.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Exercise palette selection and request ordering in the actual map UI.""" import base64 import io diff --git a/tests/browser/test_music_file_upload.py b/tests/browser/test_music_file_upload.py index c18c345..e772484 100644 --- a/tests/browser/test_music_file_upload.py +++ b/tests/browser/test_music_file_upload.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Browser coverage for uploaded music; keep a unique pytest module name.""" import base64 diff --git a/tests/browser/test_video_studio.py b/tests/browser/test_video_studio.py index 930ddeb..268c79f 100644 --- a/tests/browser/test_video_studio.py +++ b/tests/browser/test_video_studio.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Offline browser interaction tests; CDN styling is deliberately stubbed. Python API and real title rasterization run in-process. These are behavior diff --git a/tests/browser/test_web_security.py b/tests/browser/test_web_security.py index 6ec4102..b916bc0 100644 --- a/tests/browser/test_web_security.py +++ b/tests/browser/test_web_security.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Untrusted model responses and UI text must remain literal browser text.""" import pytest diff --git a/tests/conftest.py b/tests/conftest.py index d2bc2f9..bceac21 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Shared isolation: tests never use real credentials or external services.""" import importlib.util import io diff --git a/tests/test_ai_and_filling.py b/tests/test_ai_and_filling.py index 7f7ea63..6608e89 100644 --- a/tests/test_ai_and_filling.py +++ b/tests/test_ai_and_filling.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import json from pathlib import Path from types import SimpleNamespace diff --git a/tests/test_asset_tools.py b/tests/test_asset_tools.py index 9d8a024..83f7995 100644 --- a/tests/test_asset_tools.py +++ b/tests/test_asset_tools.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Verify image preparation tools on temporary inputs, never repository assets.""" import runpy from pathlib import Path diff --git a/tests/test_audio_upload.py b/tests/test_audio_upload.py index 61da23d..2182bcb 100644 --- a/tests/test_audio_upload.py +++ b/tests/test_audio_upload.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Real audio uploads and browser-restored sources without external downloads.""" import base64 import io diff --git a/tests/test_auto_map.py b/tests/test_auto_map.py index cc3fdae..7222522 100644 --- a/tests/test_auto_map.py +++ b/tests/test_auto_map.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import importlib import io from pathlib import Path diff --git a/tests/test_batch_csv.py b/tests/test_batch_csv.py index 0a25a78..a8e6772 100644 --- a/tests/test_batch_csv.py +++ b/tests/test_batch_csv.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import io import base64 import zipfile diff --git a/tests/test_cli.py b/tests/test_cli.py index 23d776b..ed4a78a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import importlib import io import re diff --git a/tests/test_deepseek.py b/tests/test_deepseek.py index d92f08d..ca397d4 100644 --- a/tests/test_deepseek.py +++ b/tests/test_deepseek.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """DeepSeek transport and credential isolation; no real API keys or requests.""" import io from unittest.mock import Mock diff --git a/tests/test_dependencies.py b/tests/test_dependencies.py index 7463cef..40ec035 100644 --- a/tests/test_dependencies.py +++ b/tests/test_dependencies.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Keep Docker/requirements and package installations on the same dependencies.""" from importlib import metadata from pathlib import Path diff --git a/tests/test_functions.py b/tests/test_functions.py index 22a7055..35835b1 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Regression fixture for the original saved AI response.""" import json import pytest diff --git a/tests/test_logging.py b/tests/test_logging.py index 8741ad2..832d759 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import io import pytest diff --git a/tests/test_map_styling.py b/tests/test_map_styling.py index d298704..39cacc9 100644 --- a/tests/test_map_styling.py +++ b/tests/test_map_styling.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Color configuration and AI-value analysis without external services.""" import importlib diff --git a/tests/test_music_upload_proxy.py b/tests/test_music_upload_proxy.py index 93b94d5..c1fc85b 100644 --- a/tests/test_music_upload_proxy.py +++ b/tests/test_music_upload_proxy.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from unittest.mock import Mock import pytest diff --git a/tests/test_numeric_extrema.py b/tests/test_numeric_extrema.py index 30f1536..e8a2d00 100644 --- a/tests/test_numeric_extrema.py +++ b/tests/test_numeric_extrema.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import pytest from map.auto_map import _numeric_extrema diff --git a/tests/test_render_progress.py b/tests/test_render_progress.py index 91fe0a8..e29ef13 100644 --- a/tests/test_render_progress.py +++ b/tests/test_render_progress.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Progress is isolated per request and follows actual MoviePy callbacks.""" from unittest.mock import Mock from uuid import uuid4 diff --git a/tests/test_server_runtime.py b/tests/test_server_runtime.py index 756bf35..36e4e0e 100644 --- a/tests/test_server_runtime.py +++ b/tests/test_server_runtime.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """The server switch chooses a production WSGI server without opening sockets.""" import sys diff --git a/tests/test_video_render.py b/tests/test_video_render.py index 5088d27..ec47176 100644 --- a/tests/test_video_render.py +++ b/tests/test_video_render.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import base64 import io from urllib.parse import parse_qs, urlsplit diff --git a/tests/test_web.py b/tests/test_web.py index 4b103f5..8f523a2 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import base64 import io from unittest.mock import Mock diff --git a/tests/test_web_ai_cache.py b/tests/test_web_ai_cache.py index ccba0b3..915a4f2 100644 --- a/tests/test_web_ai_cache.py +++ b/tests/test_web_ai_cache.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import io import json from unittest.mock import Mock diff --git a/tests/test_web_auth.py b/tests/test_web_auth.py index 20dbc18..c067ce7 100644 --- a/tests/test_web_auth.py +++ b/tests/test_web_auth.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Check the login boundary using a real Flask session cookie.""" from pathlib import Path diff --git a/tests/test_web_auth_security.py b/tests/test_web_auth_security.py index 1d30336..48387aa 100644 --- a/tests/test_web_auth_security.py +++ b/tests/test_web_auth_security.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Malformed untrusted login/logout input must not raise server errors.""" from test_web_auth import auth_app diff --git a/tests/test_web_input_validation.py b/tests/test_web_input_validation.py index 7b4e573..3ad01b4 100644 --- a/tests/test_web_input_validation.py +++ b/tests/test_web_input_validation.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Malformed client requests and interrupted downloads stay controlled.""" from unittest.mock import Mock diff --git a/tests/test_worker.py b/tests/test_worker.py index dbcb137..dda2b92 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import base64 import os from pathlib import Path diff --git a/tests/test_worker_audit.py b/tests/test_worker_audit.py index 6ef708d..fe85619 100644 --- a/tests/test_worker_audit.py +++ b/tests/test_worker_audit.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Regressions found while checking long-lived server deployments.""" import base64 from pathlib import Path diff --git a/tests/test_world_countries.py b/tests/test_world_countries.py index 57fd113..1d3b062 100644 --- a/tests/test_world_countries.py +++ b/tests/test_world_countries.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Tests for the ``world_countries`` map type across renderer, CLI, CSV, and web API.""" import importlib import io diff --git a/tools/bench_map.py b/tools/bench_map.py index 91c88fe..64685e5 100644 --- a/tools/bench_map.py +++ b/tools/bench_map.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Benchmark (and optionally compare) map generation with a fixed fake AI response. Usage: diff --git a/video_render.py b/video_render.py index edf5abc..2e1cce5 100644 --- a/video_render.py +++ b/video_render.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import subprocess diff --git a/video_stickers.py b/video_stickers.py index 092e232..1061170 100644 --- a/video_stickers.py +++ b/video_stickers.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import io import os import re diff --git a/video_text.py b/video_text.py index b1ed267..98514d3 100644 --- a/video_text.py +++ b/video_text.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import re diff --git a/web_ai_cache.py b/web_ai_cache.py index bfe0d97..6ac9806 100644 --- a/web_ai_cache.py +++ b/web_ai_cache.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """In-memory cache of AI map data so visual-only changes skip the AI request. Entries are keyed by a SHA-256 digest of the request-affecting inputs diff --git a/web_auth.py b/web_auth.py index 5cefd79..c5d6b97 100644 --- a/web_auth.py +++ b/web_auth.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Password gate and persistent browser sessions for the web interface.""" import hashlib import hmac diff --git a/yt-dlp_serv.py b/yt-dlp_serv.py index d6a868f..4495807 100644 --- a/yt-dlp_serv.py +++ b/yt-dlp_serv.py @@ -1,3 +1,17 @@ +# Copyright 2025-2026 deltaaa00 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import base64 import io import os From fd4d7215d84e2ae43e66a0e2bca48bb546d46cdf Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 16 Nov 2026 09:34:18 +0000 Subject: [PATCH 2/6] Reduce mobile compositing and defer topic preview updates --- templates/index.html | 42 +++++++++++++++++++++++-- tests/frontend/topic-preview.test.cjs | 44 +++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 tests/frontend/topic-preview.test.cjs diff --git a/templates/index.html b/templates/index.html index 65e866b..47e024f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -179,6 +179,18 @@ border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 0.5rem; } + /* Avoid large composited blur layers while scrolling or opening a touch keyboard. */ + @media (max-width: 1023px), (pointer: coarse) { + #ambientBackdrop { display: none; } + .cyber-card, [class*="backdrop-blur"] { + backdrop-filter: none !important; + -webkit-backdrop-filter: none !important; + } + header { position: relative !important; } + } + @media (prefers-reduced-motion: reduce) { + .aurora-blob-1, .aurora-blob-2, .aurora-blob-3 { animation: none; } + } /* Phone layouts keep controls reachable without shrinking form text. */ @media (max-width: 639px) { header > div { height: auto !important; min-height: 64px; flex-wrap: wrap; gap: 10px !important; padding-block: 12px; } @@ -226,7 +238,7 @@ - @@ -586,7 +602,6 @@

Global Size Modifier - -gsm, --global-size-modifier
Extra Display Options - -eop, --extra-option
-
- +
+
@@ -643,7 +661,6 @@

- --model
@@ -686,7 +703,6 @@

- --font

@@ -907,14 +923,18 @@

Cartograp
1. AI Geospatial Query - Active + Running
- 2. Region Flood-Fill & Palette + 2. Painting Regions & Labels Pending
- 3. Relief & Typography Composite + 3. Adding Relief, Borders & Overlays + Pending +
+
+ 4. Encoding Final PNG Pending
@@ -1573,8 +1593,7 @@

const mapRadio = document.querySelector(`input[name="map_type"][value="${mapType}"]`); if (mapRadio) mapRadio.checked = true; - const eopRadio = document.querySelector(`input[name="extra_option"][value="${extraOption}"]`); - if (eopRadio) eopRadio.checked = true; + setSelectedExtraOption(extraOption); updateCommandPreview(); showToast(`Preset loaded: "${promptText}"`, 'info'); @@ -1698,11 +1717,12 @@

function restoreBatchResultParameters(item) { changeAiProvider(item.provider || modelProvider(item.model), item.model); - for (const name of ['mode', 'map_type', 'extra_option']) { + for (const name of ['mode', 'map_type']) { const input = Array.from(document.getElementsByName(name)) .find(input => input.value === item[name]); if (input) input.checked = true; } + if (item.extra_option !== undefined) setSelectedExtraOption(item.extra_option); document.getElementById('topicInput').value = item.prompt || ''; if (item.gsm !== undefined) syncGsm(item.gsm); for (const [field, id] of [['model', 'modelSelect'], ['font', 'fontSelect']]) { @@ -2059,11 +2079,28 @@

return { filling_txt, filling_num }; } + function getSelectedExtraOption() { + const parts = []; + if (document.getElementById('showMostLeastToggle')?.checked) parts.push('show_most_least'); + if (document.getElementById('shortFormToggle')?.checked) parts.push('short_form'); + return parts.length ? parts.join(',') : 'none'; + } + + function setSelectedExtraOption(value) { + const raw = String(value || 'none').toLowerCase(); + const showMostLeast = raw.includes('show_most_least') || raw === 'both'; + const shortForm = raw.includes('short_form') || raw === 'both'; + const mlEl = document.getElementById('showMostLeastToggle'); + const sfEl = document.getElementById('shortFormToggle'); + if (mlEl) mlEl.checked = showMostLeast; + if (sfEl) sfEl.checked = shortForm; + } + function getFormState() { const mode = document.querySelector('input[name="mode"]:checked')?.value || 'text'; const mapType = document.querySelector('input[name="map_type"]:checked')?.value || 'default'; const gsm = parseInt(document.getElementById('gsmNumber').value, 10) || 15; - const extraOption = document.querySelector('input[name="extra_option"]:checked')?.value || 'none'; + const extraOption = getSelectedExtraOption(); const model = document.getElementById('modelSelect').value; const font = document.getElementById('fontSelect').value; const topic = document.getElementById('topicInput').value.trim(); @@ -2081,6 +2118,7 @@

map_type: mapType, gsm, extra_option: extraOption, + show_legend: !!document.getElementById('showLegendToggle')?.checked, model, font, topic, @@ -2150,6 +2188,7 @@

// Match cli.py's signature: `cli.py make "" -m ... -mp ... -gsm ... -eop ... --model ... --font ...` const escapedTopic = (state.topic || '').replace(/"/g, '\\"'); let cmd = `python cli.py make "${escapedTopic}" -m ${state.mode} -mp ${state.map_type} -gsm ${state.gsm} -eop ${state.extra_option} --model ${state.model} --font "${state.font}" --temperature ${state.temperature}`; + if (state.show_legend) cmd += ' --legend'; document.getElementById('cliCommandDisplay').textContent = cmd; updateActiveBadges(state); @@ -2160,10 +2199,11 @@

function updateCompatibilityHint(state) { const hint = document.getElementById('extraOptionHint'); if (!hint) return; - if (state.extra_option === 'show_most_least' && state.mode === 'text') { + const hasMostLeast = String(state.extra_option || '').includes('show_most_least'); + if (hasMostLeast && state.mode === 'text') { hint.textContent = 'Note: show_most_least is designed for numeric mode (-m number).'; hint.className = 'text-[11px] text-amber-400/90 mt-1.5 block'; - } else if (state.extra_option === 'show_most_least' && state.map_type === 'world') { + } else if (hasMostLeast && state.map_type === 'world') { hint.textContent = 'Note: show_most_least overlay is supported on default, flag, and world_countries maps.'; hint.className = 'text-[11px] text-amber-400/90 mt-1.5 block'; } else { @@ -2192,6 +2232,7 @@

{ label: `map: ${state.map_type}`, color: 'bg-purple-500/20 text-purple-300 border-purple-500/30' }, { label: `gsm: ${state.gsm}`, color: 'bg-emerald-500/20 text-emerald-300 border-emerald-500/30' }, { label: `eop: ${state.extra_option}`, color: 'bg-amber-500/20 text-amber-300 border-amber-500/30' }, + ...(state.show_legend ? [{ label: 'legend', color: 'bg-cyan-500/20 text-cyan-300 border-cyan-500/30' }] : []), { label: state.model, color: 'bg-sky-500/20 text-sky-300 border-sky-500/30' }, { label: state.font, color: 'bg-slate-900/90 text-slate-300 border-slate-700' } ]; @@ -2268,34 +2309,93 @@

} } + let loadingProgressPollInterval = null; + let lastRenderedLoadingStage = 0; + + function renderLoadingStages(activeStage, labelText) { + const stepText = document.getElementById('loadingStepText'); + if (stepText && labelText) stepText.textContent = labelText; + if (activeStage === lastRenderedLoadingStage) return; + lastRenderedLoadingStage = activeStage; + + const stageNames = [ + '1. AI Geospatial Query', + '2. Painting Regions & Labels', + '3. Adding Relief, Borders & Overlays', + '4. Encoding Final PNG' + ]; + + for (let i = 1; i <= 4; i++) { + const el = document.getElementById(`loadStage${i}`); + if (!el) continue; + const title = stageNames[i - 1]; + const nextState = i < activeStage ? 'done' : (i === activeStage ? 'running' : 'pending'); + if (el.dataset.state === nextState) continue; + el.dataset.state = nextState; + if (nextState === 'done') { + el.className = 'flex items-center justify-between text-emerald-400'; + el.innerHTML = ` ${title}Done`; + } else if (nextState === 'running') { + el.className = 'flex items-center justify-between text-indigo-300'; + el.innerHTML = ` ${title}Running`; + } else { + el.className = 'flex items-center justify-between text-slate-500'; + el.innerHTML = ` ${title}Pending`; + } + } + } + // --- Multi-Stage Loading Animation Helper --- - function startLoadingStages() { + function startLoadingStages(progressId = '') { const stepText = document.getElementById('loadingStepText'); const timerEl = document.getElementById('loadingElapsedTimer'); - const s1 = document.getElementById('loadStage1'); - const s2 = document.getElementById('loadStage2'); - const s3 = document.getElementById('loadStage3'); - const startTime = performance.now(); clearInterval(loadingTimerInterval); - stepText.textContent = 'Waiting for the AI response and map rendering...'; - if (s1 && s2 && s3) { - s1.className = 'flex items-center justify-between text-indigo-300'; - s1.innerHTML = ' AI query & map renderingRunning'; - s2.className = 'hidden'; - s3.className = 'hidden'; + clearInterval(loadingProgressPollInterval); + lastRenderedLoadingStage = 0; + for (let i = 1; i <= 4; i++) { + const el = document.getElementById(`loadStage${i}`); + if (el) delete el.dataset.state; } + + renderLoadingStages(1, 'Querying AI model...'); + loadingTimerInterval = setInterval(() => { const elapsed = (performance.now() - startTime) / 1000; if (timerEl) timerEl.textContent = `${elapsed.toFixed(1)}s`; - if (elapsed >= 15) { - stepText.textContent = 'Still waiting for the server. The selected AI model may be busy.'; + if (elapsed >= 15 && stepText && stepText.textContent === 'Querying AI model...') { + stepText.textContent = 'Still waiting for the AI model response...'; } }, 150); + + if (progressId) { + let polling = false; + loadingProgressPollInterval = setInterval(async () => { + if (polling) return; + polling = true; + try { + const resp = await fetch(`/api/generate_progress/${encodeURIComponent(progressId)}`, { cache: 'no-store' }); + if (resp.ok) { + const prog = await resp.json(); + if (prog && typeof prog.stage === 'number') { + renderLoadingStages(prog.stage, prog.label); + } + if (prog && (prog.status === 'done' || prog.status === 'error')) { + clearInterval(loadingProgressPollInterval); + } + } + } catch { + // Ignore transient polling errors while map is generating. + } finally { + polling = false; + } + }, 250); + } } function stopLoadingStages() { clearInterval(loadingTimerInterval); + clearInterval(loadingProgressPollInterval); } // --- Handle Map Generation (Form Submit) --- @@ -2317,12 +2417,16 @@

return; } + const progressId = (window.crypto && typeof crypto.randomUUID === 'function') + ? crypto.randomUUID() + : `map_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`; + document.getElementById('generationError').classList.add('hidden'); overlay.classList.remove('hidden'); btn.disabled = true; btn.classList.add('opacity-70'); metaBadge.textContent = "Synthesizing..."; - startLoadingStages(); + startLoadingStages(progressId); logToConsole(`$ ${cmd}`, 'cmd'); @@ -2330,7 +2434,7 @@

const response = await fetch('/api/generate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(state) + body: JSON.stringify({ ...state, progress_id: progressId }) }); // The backend may return JSON on error; guard against non-JSON bodies. @@ -3139,8 +3243,9 @@

const mapRadio = document.querySelector(`input[name="map_type"][value="${s.map_type}"]`); if (mapRadio) mapRadio.checked = true; syncGsm(s.gsm); - const eopRadio = document.querySelector(`input[name="extra_option"][value="${s.extra_option}"]`); - if (eopRadio) eopRadio.checked = true; + setSelectedExtraOption(s.extra_option); + const legendToggle = document.getElementById('showLegendToggle'); + if (legendToggle) legendToggle.checked = !!s.show_legend; document.getElementById('modelSelect').value = s.model; document.getElementById('fontSelect').value = s.font; document.getElementById('topicInput').value = s.topic || ''; @@ -3201,7 +3306,9 @@

document.querySelector('input[name="mode"][value="text"]').checked = true; document.querySelector('input[name="map_type"][value="default"]').checked = true; syncGsm(15); - document.querySelector('input[name="extra_option"][value="none"]').checked = true; + setSelectedExtraOption('none'); + const legendToggle = document.getElementById('showLegendToggle'); + if (legendToggle) legendToggle.checked = false; changeAiProvider('gemini', fallbackModels.find(model => modelProvider(model) === 'gemini')); document.getElementById('fontSelect').selectedIndex = 0; document.getElementById('topicInput').value = ''; From 9bbc13a9e477331c8d69d4311b936192af3360b9 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 16 Nov 2026 18:25:26 +0000 Subject: [PATCH 6/6] Fix combined map options, legend CLI support, and precision across cached renders --- cli.py | 9 ++++--- main.py | 11 ++++---- map/auto_map.py | 5 ++-- readme.md | 5 ++-- tests/test_auto_map.py | 52 ++++++++++++++++++++++++++++++++++++++ tests/test_cli.py | 8 ++++++ tests/test_web.py | 33 +++++++++++++++++++++++- tests/test_web_ai_cache.py | 26 ++++++++++++++++++- 8 files changed, 134 insertions(+), 15 deletions(-) diff --git a/cli.py b/cli.py index 73ba708..0b0da7b 100644 --- a/cli.py +++ b/cli.py @@ -76,10 +76,10 @@ def main(): help="Global font size modifier (default 15).") @click.option("-eop", "--extra-option", "optional_feature", - type=click.Choice(["none", "show_most_least", "short_form"], case_sensitive=False), + type=click.Choice(["none", "show_most_least", "short_form", "show_most_least,short_form", "short_form,show_most_least"], case_sensitive=False), default="none", show_default=True, - help="One extra option: none (default), show_most_least or short_form.") + help="Extra options: none, show_most_least, short_form, or both separated by a comma.") @click.option("--model", type=click.Choice(AVAILABLE_MODELS, case_sensitive=False), default=AVAILABLE_MODELS[0], @@ -106,7 +106,8 @@ def main(): help="API key for the selected model provider (overrides its environment key).") @click.option("--temperature", type=click.FloatRange(0, 2), default=None, help="AI sampling randomness, from 0 to 2. Omit to use the model default.") -def make(prompt, mode, map_type, size_mod, optional_feature, model, font_name, show_result, verbose, api_key, temperature): +@click.option("--legend", "show_legend", is_flag=True, help="Draw a color legend on the map.") +def make(prompt, mode, map_type, size_mod, optional_feature, model, font_name, show_result, verbose, api_key, temperature, show_legend): """Generate a map from PROMPT and save it as result.png. Example: @@ -119,6 +120,8 @@ def make(prompt, mode, map_type, size_mod, optional_feature, model, font_name, s from map.auto_map import auto_map ai_options = {} + if show_legend: + ai_options["show_legend"] = True if temperature is not None: from map.functions import validate_temperature try: diff --git a/main.py b/main.py index c5c1aed..1205907 100644 --- a/main.py +++ b/main.py @@ -297,17 +297,16 @@ def _auto_map_with_ai_cache(*, refresh: bool, provider: str, api_key, **kwargs): if cached is None and not refresh and short_form: raw_cached = ai_cache.get(ai_cache.make_key(scope, short_form=False, **base_fields)) if raw_cached and any(_parse_short_number(v) is not None for v in raw_cached.values()): - cached = {k: _format_short_number(v) for k, v in raw_cached.items()} + cached = raw_cached if cached is not None: kwargs['ai_answer_override'] = cached buffer = auto_map(api_key=api_key, **kwargs) if buffer is not None: meta = getattr(buffer, 'map_meta', None) - answer = meta.get('ai_answer') if isinstance(meta, dict) else None + answer = meta.get('raw_ai_answer', meta.get('ai_answer')) if isinstance(meta, dict) else None if isinstance(answer, dict): if short_form: - answer = {k: _format_short_number(v) for k, v in answer.items()} - meta['ai_answer'] = answer + meta['ai_answer'] = {k: _format_short_number(v) for k, v in answer.items()} if not refresh: ai_cache.put(cache_key, answer) return buffer, cached is not None @@ -699,7 +698,7 @@ def generate(): render_meta = getattr(buffer, "map_meta", None) ai_vals = render_meta.get("ai_answer") if isinstance(render_meta, dict) else None if isinstance(ai_vals, dict) and ai_vals: - resp_payload["map_values"] = ai_vals + resp_payload["map_values"] = render_meta.get("raw_ai_answer", ai_vals) resp_payload["analysis"] = _build_analysis_from_ai( ai_vals, mode=str(data.get("mode") or "auto"), @@ -995,7 +994,7 @@ def generate_batch(): render_meta = getattr(buffer, "map_meta", None) ai_vals = render_meta.get("ai_answer") if isinstance(render_meta, dict) else None if isinstance(ai_vals, dict) and ai_vals: - item_payload["map_values"] = ai_vals + item_payload["map_values"] = render_meta.get("raw_ai_answer", ai_vals) item_payload["analysis"] = _build_analysis_from_ai( ai_vals, mode=item_mode, diff --git a/map/auto_map.py b/map/auto_map.py index 4601383..39222fd 100644 --- a/map/auto_map.py +++ b/map/auto_map.py @@ -804,7 +804,7 @@ def auto_map(prompt: str, mode: str, map_type: str, size_mod: int, mode -- "text" or "number" map_type -- "default", "flag", "world" or "world_countries" size_mod -- global font size modifier (default 15) - optional_feature -- None, "show_most_least" or "short_form" + optional_feature -- None, "show_most_least", "short_form", or comma-separated flags model -- Gemini model id font_name -- font file name from resources/fonts show_result -- open the result in the OS image viewer (GUI only) @@ -988,7 +988,7 @@ def _report(stage: int, label: str) -> None: filling_txt_ci.setdefault(short_k, v) most_least = None - extrema = _numeric_extrema(ai_answer) if has_most_least else None + extrema = _numeric_extrema(raw_ai_answer) if has_most_least else None if has_most_least and extrema is None: log.warning("No numeric values available; skipping most / least overlay") if extrema is not None: @@ -1209,6 +1209,7 @@ def _report(stage: int, label: str) -> None: render_meta = { "ai_answer": dict(ai_answer), + "raw_ai_answer": raw_ai_answer, "mode": mode, "resolved_theme": resolved_theme, "filling_txt": {str(k): list(v) for k, v in effective_txt.items()}, diff --git a/readme.md b/readme.md index 850b529..2effc8e 100644 --- a/readme.md +++ b/readme.md @@ -213,7 +213,8 @@ python cli.py make "GDP per capita by country" -m number -eop show_most_least -- | `-m`, `--mode` | `text`, `number` | `text` | | `-mp`, `--map-type` | `default`, `flag`, `world` | `default` | | `-gsm`, `--global-size-modifier` | Integer font-size adjustment | `15` | -| `-eop`, `--extra-option` | `none`, `show_most_least`, `short_form` | `none` | +| `-eop`, `--extra-option` | `none`, `show_most_least`, `short_form`, `show_most_least,short_form` (either order) | `none` | +| `--legend` | Draw a color legend | off | | `--model` | Supported model ID; see command help | `gemini-3.8-flash` | | `--font` | Bundled `.ttf` or `.otf` filename | `Bips.ttf` | | `--key` | Key for the selected model's provider | Provider environment/file key | @@ -221,7 +222,7 @@ python cli.py make "GDP per capita by country" -m number -eop show_most_least -- | `--show` / `--no-show` | Open the generated image; `make` only | `--no-show` | | `-v`, `--verbose` | Detailed progress output | Off | -`show_most_least` is supported in **numeric mode on Europe maps** (`default` or `flag`). `short_form` asks the model for shortened values such as `1k` or `2M` and is supported in **text mode**. These are mutually exclusive extra options. +`show_most_least` is supported in **numeric mode** on `default`, `flag`, and `world_countries` maps. `short_form` displays shortened values such as `1k` or `2M` in either mode. Combine them with `-eop show_most_least,short_form`; extrema use the original values before display rounding. Add `--legend` to show the color key. ### Batch generation diff --git a/tests/test_auto_map.py b/tests/test_auto_map.py index 7222522..fce880b 100644 --- a/tests/test_auto_map.py +++ b/tests/test_auto_map.py @@ -442,3 +442,55 @@ def test_global_label_shift_moves_all_labels_but_not_country_fill_seeds(scene, m assert [call.args[0] for call in draw.call_args_list] == [(x + offset, y) for x, y in baseline] assert [call.kwargs['xy'] for call in fill.call_args_list] == seeds assert output.map_meta['label_style']['offset_x'] == offset + + +@pytest.mark.parametrize('feature', ['show_most_least,short_form', 'short_form,show_most_least', 'both', ['short_form', 'show_most_least']]) +def test_combined_features_compare_unrounded_values(scene, monkeypatch, feature): + scene[0].return_value = {'one': 1001, 'two': 1049} + text = Mock() + monkeypatch.setattr(ImageDraw.ImageDraw, 'text', text) + result = render(mode='number', optional_feature=feature) + labels = [call.args[1] for call in text.call_args_list] + assert 'Most: Two\nLeast: One' in labels + assert result.map_meta['raw_ai_answer'] == {'one': 1001, 'two': 1049} + assert result.map_meta['ai_answer'] == {'one': '1k', 'two': '1k'} + + +@pytest.mark.parametrize('mode', ['text', 'number']) +def test_legend_and_progress_are_rendered(scene, monkeypatch, mode): + scene[0].return_value = {'one': 5, 'two': 15} if mode == 'number' else {'one': 'Yes', 'two': 'No'} + overlay = Mock(wraps=renderer._draw_legend_overlay) + monkeypatch.setattr(renderer, '_draw_legend_overlay', overlay) + progress = Mock() + result = render(mode=mode, show_legend=True, progress_callback=progress) + assert result.getvalue().startswith(b'\x89PNG') + assert overlay.call_args.args[1] + assert [call.args[0] for call in progress.call_args_list] == [1, 2, 3, 4] + + +@pytest.mark.parametrize('value,expected', [(0, '0'), (1.25, '1.25'), (10000, '10k'), (12500, '12.5k'), (1000000, '1M'), (1500000000, '1.5B'), (-15000, '-15k')]) +def test_legend_formats_bounds(value, expected): + assert renderer._format_legend_bound(value) == expected + + +@pytest.mark.parametrize('lo,hi,expected', [(-1e12, 1e12, 'All'), (-1e12, 20, '< 20'), (20, 1e12, '20+'), (10, 20, '10 - 20')]) +def test_legend_formats_ranges(lo, hi, expected): + assert renderer._format_legend_range(lo, hi) == expected + + +@pytest.mark.parametrize('map_type', ['default', 'world', 'world_countries']) +@pytest.mark.parametrize('has_ml', [False, True]) +def test_legend_draws_visible_swatches(map_type, has_ml): + font_path = renderer.FONTS_DIR / 'Bips.ttf' + font = lambda size: renderer.ImageFont.truetype(str(font_path), size) + layer = renderer._draw_legend_overlay((2000, 3000), [((255, 0, 0, 255), 'Yes'), ((0, 0, 255, 255), 'No')], font, (255,255,255,255), (0,0,0,255), 5, map_type, has_ml) + assert layer.getbbox() is not None + assert layer.mode == 'RGBA' + + +def test_legend_empty_long_and_overflow_entries(): + font = lambda size: renderer.ImageFont.truetype(str(renderer.FONTS_DIR / 'Bips.ttf'), size) + args = (font, (255,255,255,255), (0,0,0,255), 0, 'world', False) + assert renderer._draw_legend_overlay((100,100), [], *args) is None + layer = renderer._draw_legend_overlay((100,100), [((255,0,0,255), 'Long category ' * 20)] * 100, *args) + assert layer.size == (100,100) diff --git a/tests/test_cli.py b/tests/test_cli.py index ed4a78a..0c4a53f 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -143,3 +143,11 @@ def test_deepseek_cli_key_does_not_replace_gemini_key(generate, monkeypatch): assert os.environ['GEMINI_API_KEY'] == 'keep-gemini' assert os.environ['DEEPSEEK_API_KEY'] == 'deepseek-cli-key' assert generate.call_args.kwargs['model'] == 'deepseek-flash' + + +@pytest.mark.parametrize('feature', ['show_most_least,short_form', 'short_form,show_most_least']) +def test_make_accepts_web_legend_and_combined_options(generate, feature): + result = CliRunner().invoke(cli.main, ['make', 'GDP', '-m', 'number', '-eop', feature, '--legend']) + assert result.exit_code == 0, result.output + assert generate.call_args.kwargs['optional_feature'] == feature + assert generate.call_args.kwargs['show_legend'] is True diff --git a/tests/test_web.py b/tests/test_web.py index 8f523a2..9b45e6f 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -47,7 +47,7 @@ def test_generate_forwards_options_and_encodes_png(web, monkeypatch, generation_ assert base64.b64decode(response.json['image_url'].split(',')[1]) == b'png-data' generate.assert_called_once_with(prompt='Population', mode='number', map_type='default', size_mod=22, optional_feature='show_most_least', model='mock-model', - font_name='DIN Condensed.ttf', show_result=False, io_res=True, api_key='form-key') + font_name='DIN Condensed.ttf', show_result=False, io_res=True, api_key='form-key', show_legend=False) assert 'form-key' not in response.json['command'] @@ -481,3 +481,34 @@ def test_model_discovery_excludes_non_text_models_and_keeps_new_versions(web, mo assert result.status_code == 200 assert set(result.json['models']) == {'gemini-4-hydrogen', 'gemini-3.8-flash', 'gemma-4-31b-it'} assert client.call_args.kwargs['http_options'].timeout == 15000 + + +def test_map_progress_tracks_stages_and_expires_old_entries(web, monkeypatch, generation_request): + def generate(**kwargs): + kwargs['progress_callback'](2, 'Painting') + assert web._MAP_PROGRESS['render-id']['stage'] == 2 + buf = io.BytesIO(b'png') + buf.map_meta = {'ai_answer': {'a': '1k'}, 'raw_ai_answer': {'a': 1049}} + return buf + monkeypatch.setattr(web, 'auto_map', generate) + web._MAP_PROGRESS['old'] = {'updated_at': 0} + web._set_map_progress('', 1, 'ignored') + client = web.app.test_client() + response = client.post('/api/generate', json={**generation_request, 'progress_id': 'render-id', 'show_legend': True}) + assert response.status_code == 200 + assert response.json['map_values'] == {'a': 1049} + assert '--legend' in response.json['command'] + assert 'old' not in web._MAP_PROGRESS + progress = client.get('/api/generate_progress/render-id') + assert progress.json['status'] == 'done' and progress.json['stage'] == 4 + assert progress.headers['Cache-Control'] == 'no-store' + assert client.get('/api/generate_progress/unknown').json['stage'] == 1 + + +@pytest.mark.parametrize('error,status', [(KeyError('x'), 400), (RuntimeError('failed'), 500), (None, 500)]) +def test_map_progress_records_generation_failure(web, monkeypatch, generation_request, error, status): + monkeypatch.setattr(web, 'auto_map', Mock(side_effect=error, return_value=None)) + client = web.app.test_client() + response = client.post('/api/generate', json={**generation_request, 'progress_id': 'failed'}) + assert response.status_code == status + assert client.get('/api/generate_progress/failed').json['status'] == 'error' diff --git a/tests/test_web_ai_cache.py b/tests/test_web_ai_cache.py index 915a4f2..9d7c9c2 100644 --- a/tests/test_web_ai_cache.py +++ b/tests/test_web_ai_cache.py @@ -112,7 +112,7 @@ def render(**kwargs): assert first['map_values'] == {'ukraine': 38_000_000, 'germany': 84_500_000} assert second['ai_cached'] is True assert second['map_values'] == {'ukraine': '38M', 'germany': '84.5M'} - assert calls[1]['ai_answer_override'] == {'ukraine': '38M', 'germany': '84.5M'} + assert calls[1]['ai_answer_override'] == {'ukraine': 38_000_000, 'germany': 84_500_000} def test_render_video_accepts_binary_multipart(monkeypatch): @@ -131,3 +131,27 @@ def test_render_video_accepts_binary_multipart(monkeypatch): assert sent['map_file'] == 'data:image/png;base64,iVBORw==' assert sent['background_video'].startswith('data:video/mp4;base64,') assert sent['video_title'] == 'T' and sent['duration'] == 8 + + +def test_combined_features_keep_precision_across_cached_requests_and_repaint(monkeypatch): + calls = [] + raw = {'france': 1001, 'germany': 1049} + + def render(**kwargs): + calls.append(kwargs) + values = kwargs.get('ai_answer_override', raw) + buf = _buffer({k: web._format_short_number(v) for k, v in values.items()}) + buf.map_meta['raw_ai_answer'] = dict(values) + return buf + + monkeypatch.setattr(web, 'auto_map', render) + client = web.app.test_client() + body = _body(mode='number', extra_option='show_most_least,short_form') + for _ in range(2): + response = client.post('/api/generate', json=body) + assert response.status_code == 200 + assert response.json['map_values'] == raw + assert calls[1]['ai_answer_override'] == raw + response = client.post('/api/restyle_map', json={**body, 'map_values': response.json['map_values']}) + assert response.status_code == 200 + assert calls[2]['ai_answer_override'] == raw