From 9068c3aacfbc74b16f1cee3d3744d12f629455b5 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Oct 2026 11:46:00 +0000 Subject: [PATCH 1/2] Make Pasteup an installable package with a `pasteup` command The code moves from image_grid_app/app, a top-level package named `app`, to src/pasteup, and the tests to the repository root. Installing used to mean cloning, `cd image_grid_app` and running uvicorn on a module path; a package called `app` would also collide with anything else of that name once installed. - pyproject.toml replaces requirements.txt, requirements-dev.txt and ruff.toml: the same pinned dependencies, a `dev` extra for the test tools, and the ruff and pytest settings. Built with hatchling, which ships the templates and static files inside the package. - `pasteup` (also `python -m pasteup`) serves the app on 127.0.0.1:8000, with --host, --port, --reload and --version. Listening anywhere else prints a warning pointing at SECURITY.md. - Tests import the installed package; the UI string tests read the template and script through importlib.resources, so they now also prove both ship. - CI does a regular, not editable, install before testing, so a file left out of the built package fails the build. No behaviour changes beyond how it is installed and started. The visible "Image Grid App" naming is renamed in the next commit. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01E6aBDEnU4vqKQ4F9cnJMrL --- .github/workflows/tests.yml | 11 ++-- .gitignore | 3 + image_grid_app/app/services/__init__.py | 0 image_grid_app/requirements-dev.txt | 5 -- image_grid_app/requirements.txt | 11 ---- image_grid_app/ruff.toml | 7 --- pyproject.toml | 62 +++++++++++++++++++ src/pasteup/__init__.py | 3 + src/pasteup/__main__.py | 4 ++ src/pasteup/cli.py | 34 ++++++++++ {image_grid_app/app => src/pasteup}/main.py | 4 +- .../app => src/pasteup/models}/__init__.py | 0 .../app => src/pasteup}/models/schemas.py | 2 +- .../models => src/pasteup/routes}/__init__.py | 0 .../app => src/pasteup}/routes/jobs.py | 12 ++-- .../app => src/pasteup}/routes/ui.py | 2 +- .../pasteup/services}/__init__.py | 0 .../pasteup}/services/cover_collage.py | 0 .../app => src/pasteup}/services/exporter.py | 0 .../pasteup}/services/folder_scanner.py | 0 .../pasteup}/services/grid_composer.py | 0 .../pasteup}/services/image_batcher.py | 0 .../pasteup}/services/video_exporter.py | 0 .../app => src/pasteup}/static/css/styles.css | 0 .../app => src/pasteup}/static/js/app.js | 0 .../app => src/pasteup}/templates/index.html | 0 {image_grid_app/tests => tests}/conftest.py | 6 -- .../test_batch_cover_collage_api.py | 4 +- tests/test_cli.py | 42 +++++++++++++ .../tests => tests}/test_cover_collage.py | 2 +- .../tests => tests}/test_cover_collage_api.py | 6 +- .../test_generate_all_folders.py | 4 +- ...est_generate_single_folder_video_status.py | 6 +- .../tests => tests}/test_grid_composer.py | 2 +- .../tests => tests}/test_image_batcher.py | 2 +- .../test_page_dpi_and_geometry.py | 2 +- ...est_partial_page_and_generation_options.py | 4 +- .../tests => tests}/test_request_safety.py | 8 +-- .../tests => tests}/test_scan_folder_api.py | 4 +- .../test_scan_selected_batch_folders.py | 4 +- .../test_transparent_png_handling.py | 2 +- .../tests => tests}/test_ui_defaults.py | 9 ++- .../test_ui_generation_modes.py | 9 +-- .../tests => tests}/test_video_exporter.py | 10 +-- 44 files changed, 205 insertions(+), 81 deletions(-) delete mode 100644 image_grid_app/app/services/__init__.py delete mode 100644 image_grid_app/requirements-dev.txt delete mode 100644 image_grid_app/requirements.txt delete mode 100644 image_grid_app/ruff.toml create mode 100644 pyproject.toml create mode 100644 src/pasteup/__init__.py create mode 100644 src/pasteup/__main__.py create mode 100644 src/pasteup/cli.py rename {image_grid_app/app => src/pasteup}/main.py (91%) rename {image_grid_app/app => src/pasteup/models}/__init__.py (100%) rename {image_grid_app/app => src/pasteup}/models/schemas.py (99%) rename {image_grid_app/app/models => src/pasteup/routes}/__init__.py (100%) rename {image_grid_app/app => src/pasteup}/routes/jobs.py (98%) rename {image_grid_app/app => src/pasteup}/routes/ui.py (94%) rename {image_grid_app/app/routes => src/pasteup/services}/__init__.py (100%) rename {image_grid_app/app => src/pasteup}/services/cover_collage.py (100%) rename {image_grid_app/app => src/pasteup}/services/exporter.py (100%) rename {image_grid_app/app => src/pasteup}/services/folder_scanner.py (100%) rename {image_grid_app/app => src/pasteup}/services/grid_composer.py (100%) rename {image_grid_app/app => src/pasteup}/services/image_batcher.py (100%) rename {image_grid_app/app => src/pasteup}/services/video_exporter.py (100%) rename {image_grid_app/app => src/pasteup}/static/css/styles.css (100%) rename {image_grid_app/app => src/pasteup}/static/js/app.js (100%) rename {image_grid_app/app => src/pasteup}/templates/index.html (100%) rename {image_grid_app/tests => tests}/conftest.py (60%) rename {image_grid_app/tests => tests}/test_batch_cover_collage_api.py (97%) create mode 100644 tests/test_cli.py rename {image_grid_app/tests => tests}/test_cover_collage.py (99%) rename {image_grid_app/tests => tests}/test_cover_collage_api.py (97%) rename {image_grid_app/tests => tests}/test_generate_all_folders.py (98%) rename {image_grid_app/tests => tests}/test_generate_single_folder_video_status.py (92%) rename {image_grid_app/tests => tests}/test_grid_composer.py (93%) rename {image_grid_app/tests => tests}/test_image_batcher.py (87%) rename {image_grid_app/tests => tests}/test_page_dpi_and_geometry.py (96%) rename {image_grid_app/tests => tests}/test_partial_page_and_generation_options.py (98%) rename {image_grid_app/tests => tests}/test_request_safety.py (95%) rename {image_grid_app/tests => tests}/test_scan_folder_api.py (98%) rename {image_grid_app/tests => tests}/test_scan_selected_batch_folders.py (96%) rename {image_grid_app/tests => tests}/test_transparent_png_handling.py (97%) rename {image_grid_app/tests => tests}/test_ui_defaults.py (73%) rename {image_grid_app/tests => tests}/test_ui_generation_modes.py (94%) rename {image_grid_app/tests => tests}/test_video_exporter.py (94%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b791a01..16307ab 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,9 +20,6 @@ jobs: matrix: # 3.11 is the floor: mullion and the app's StrEnum use need it. python-version: ["3.11", "3.13"] - defaults: - run: - working-directory: image_grid_app steps: - uses: actions/checkout@v5 @@ -30,14 +27,16 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: pip - cache-dependency-path: image_grid_app/requirements*.txt + cache-dependency-path: pyproject.toml # The preview-video tests encode real files; without ffmpeg they skip. - name: Install ffmpeg run: sudo apt-get update && sudo apt-get install --yes --no-install-recommends ffmpeg - - name: Install dependencies - run: pip install -r requirements-dev.txt + # A regular (not editable) install, so the tests run against the built + # package and fail if a template or static file is left out of it. + - name: Install + run: pip install ".[dev]" # Lint first: a slip fails in seconds rather than after the suite. - name: Lint diff --git a/.gitignore b/.gitignore index 98dbeb4..309336f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ __pycache__/ *.py[cod] .venv/ +build/ +dist/ +*.egg-info/ diff --git a/image_grid_app/app/services/__init__.py b/image_grid_app/app/services/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/image_grid_app/requirements-dev.txt b/image_grid_app/requirements-dev.txt deleted file mode 100644 index 61a6696..0000000 --- a/image_grid_app/requirements-dev.txt +++ /dev/null @@ -1,5 +0,0 @@ --r requirements.txt -pytest~=9.1 -# starlette.testclient uses httpx2; plain httpx is deprecated there. -httpx2~=2.13 -ruff==0.17.1 diff --git a/image_grid_app/requirements.txt b/image_grid_app/requirements.txt deleted file mode 100644 index fc80953..0000000 --- a/image_grid_app/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Compatible-release pins: bug-fix releases flow in, while anything that may -# change behaviour (a new minor of a 0.x package, a new major elsewhere) is a -# deliberate bump. An unpinned FastAPI/Starlette has already broken this app -# once (37b6da7). -fastapi~=0.143.2 -uvicorn~=0.54.0 -jinja2~=3.1 -pillow~=12.3 -pydantic~=2.14 -# mullion is pre-1.0, so pin the minor rather than taking any 0.x (#137). -mullion~=0.2.1 diff --git a/image_grid_app/ruff.toml b/image_grid_app/ruff.toml deleted file mode 100644 index 6fa1158..0000000 --- a/image_grid_app/ruff.toml +++ /dev/null @@ -1,7 +0,0 @@ -# Pyflakes plus pycodestyle's error classes: real bugs such as undefined names -# and unused imports, without a formatting pass over existing code. Widening the -# rule set, or adding `ruff format --check`, is a separate decision (#138). -target-version = "py311" - -[lint] -select = ["E4", "E7", "E9", "F"] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..349d462 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,62 @@ +[build-system] +requires = ["hatchling>=1.27"] +build-backend = "hatchling.build" + +[project] +name = "pasteup" +dynamic = ["version"] +description = "Turn a folder of clip art into listing images: preview sheets, cover collages and preview videos." +readme = "README.md" +license = "Apache-2.0" +license-files = ["LICENSE"] +requires-python = ">=3.11" +# Compatible-release pins: bug-fix releases flow in, while anything that may +# change behaviour (a new minor of a 0.x package, a new major elsewhere) is a +# deliberate bump. mullion is pre-1.0, so its minor is pinned too. +dependencies = [ + "fastapi~=0.143.2", + "uvicorn~=0.54.0", + "jinja2~=3.1", + "pillow~=12.3", + "pydantic~=2.14", + "mullion~=0.2.1", +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Framework :: FastAPI", + "Intended Audience :: End Users/Desktop", + "Programming Language :: Python :: 3", + "Topic :: Multimedia :: Graphics", +] + +[project.optional-dependencies] +dev = [ + "pytest~=9.1", + # starlette.testclient uses httpx2; plain httpx is deprecated there. + "httpx2~=2.13", + "ruff==0.17.1", +] + +[project.scripts] +pasteup = "pasteup.cli:main" + +[project.urls] +Source = "https://github.com/ftymoshchuk/pasteup" + +[tool.hatch.version] +path = "src/pasteup/__init__.py" + +[tool.hatch.build.targets.wheel] +packages = ["src/pasteup"] + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.ruff] +target-version = "py311" + +[tool.ruff.lint] +# Pyflakes plus pycodestyle's error classes: real bugs such as undefined names +# and unused imports, without a formatting pass over existing code. Widening the +# rule set, or adding `ruff format --check`, is a separate decision. +select = ["E4", "E7", "E9", "F"] diff --git a/src/pasteup/__init__.py b/src/pasteup/__init__.py new file mode 100644 index 0000000..3aac1eb --- /dev/null +++ b/src/pasteup/__init__.py @@ -0,0 +1,3 @@ +"""Pasteup: turn a folder of clip art into listing images.""" + +__version__ = "0.1.0" diff --git a/src/pasteup/__main__.py b/src/pasteup/__main__.py new file mode 100644 index 0000000..3f3c61a --- /dev/null +++ b/src/pasteup/__main__.py @@ -0,0 +1,4 @@ +from pasteup.cli import main + +if __name__ == "__main__": + main() diff --git a/src/pasteup/cli.py b/src/pasteup/cli.py new file mode 100644 index 0000000..0a01d99 --- /dev/null +++ b/src/pasteup/cli.py @@ -0,0 +1,34 @@ +"""The `pasteup` command: serve the app locally.""" + +from __future__ import annotations + +import argparse +import sys + +from pasteup import __version__ + +LOCAL_HOSTS = ("127.0.0.1", "localhost", "::1") + + +def main(argv: list[str] | None = None) -> None: + parser = argparse.ArgumentParser( + prog="pasteup", + description="Turn a folder of clip art into listing images. Serves the app in your browser.", + ) + parser.add_argument("--host", default="127.0.0.1", help="address to listen on (default: 127.0.0.1)") + parser.add_argument("--port", type=int, default=8000, help="port to listen on (default: 8000)") + parser.add_argument("--reload", action="store_true", help="restart on code changes, for development") + parser.add_argument("--version", action="version", version=f"pasteup {__version__}") + args = parser.parse_args(argv) + + if args.host not in LOCAL_HOSTS: + print( + f"Warning: listening on {args.host} lets other machines reach an app that reads and " + "writes your files, with no login. See SECURITY.md before doing this.", + file=sys.stderr, + ) + + # Imported here so `pasteup --help` and `--version` stay instant. + import uvicorn + + uvicorn.run("pasteup.main:app", host=args.host, port=args.port, reload=args.reload) diff --git a/image_grid_app/app/main.py b/src/pasteup/main.py similarity index 91% rename from image_grid_app/app/main.py rename to src/pasteup/main.py index 1183607..b7c7401 100644 --- a/image_grid_app/app/main.py +++ b/src/pasteup/main.py @@ -5,8 +5,8 @@ from fastapi.middleware.trustedhost import TrustedHostMiddleware from fastapi.staticfiles import StaticFiles -from app.routes.jobs import router as jobs_router -from app.routes.ui import router as ui_router +from pasteup.routes.jobs import router as jobs_router +from pasteup.routes.ui import router as ui_router APP_DIR = Path(__file__).resolve().parent diff --git a/image_grid_app/app/__init__.py b/src/pasteup/models/__init__.py similarity index 100% rename from image_grid_app/app/__init__.py rename to src/pasteup/models/__init__.py diff --git a/image_grid_app/app/models/schemas.py b/src/pasteup/models/schemas.py similarity index 99% rename from image_grid_app/app/models/schemas.py rename to src/pasteup/models/schemas.py index 6ea546b..f2e7224 100644 --- a/image_grid_app/app/models/schemas.py +++ b/src/pasteup/models/schemas.py @@ -2,7 +2,7 @@ from typing import Literal from mullion import DEFAULT_TOLERANCE, BackgroundCleanMode -from app.services.cover_collage import CoverCollageFittingMode, CoverCollageTemplate +from pasteup.services.cover_collage import CoverCollageFittingMode, CoverCollageTemplate from mullion import DEFAULT_DPI from pydantic import AliasChoices, BaseModel, Field, field_validator diff --git a/image_grid_app/app/models/__init__.py b/src/pasteup/routes/__init__.py similarity index 100% rename from image_grid_app/app/models/__init__.py rename to src/pasteup/routes/__init__.py diff --git a/image_grid_app/app/routes/jobs.py b/src/pasteup/routes/jobs.py similarity index 98% rename from image_grid_app/app/routes/jobs.py rename to src/pasteup/routes/jobs.py index ab4edc1..bc96068 100644 --- a/image_grid_app/app/routes/jobs.py +++ b/src/pasteup/routes/jobs.py @@ -7,7 +7,7 @@ from fastapi import APIRouter, HTTPException from fastapi.responses import JSONResponse -from app.models.schemas import ( +from pasteup.models.schemas import ( BatchBundleResult, BatchCoverCollageGenerationRequest, BatchCoverCollageGenerationResponse, @@ -24,22 +24,22 @@ SelectedBatchFolderValidationRequest, SelectedBatchFolderValidationResponse, ) -from app.services.cover_collage import compose_cover_collage +from pasteup.services.cover_collage import compose_cover_collage from mullion import DEFAULT_TOLERANCE, BackgroundCleanMode -from app.services.exporter import export_pages +from pasteup.services.exporter import export_pages from mullion import ( DEFAULT_DPI, PageGeometry, resolve_page_geometry, ) -from app.services.folder_scanner import ( +from pasteup.services.folder_scanner import ( is_generated_output_folder, list_supported_image_paths, resolve_folder_path, scan_folder, ) -from app.services.grid_composer import compose_image_grids -from app.services.video_exporter import build_preview_video +from pasteup.services.grid_composer import compose_image_grids +from pasteup.services.video_exporter import build_preview_video router = APIRouter(prefix="/jobs", tags=["jobs"]) diff --git a/image_grid_app/app/routes/ui.py b/src/pasteup/routes/ui.py similarity index 94% rename from image_grid_app/app/routes/ui.py rename to src/pasteup/routes/ui.py index 5f6f798..b078807 100644 --- a/image_grid_app/app/routes/ui.py +++ b/src/pasteup/routes/ui.py @@ -4,7 +4,7 @@ from fastapi import APIRouter, Request from fastapi.templating import Jinja2Templates -from app.services.cover_collage import COVER_COLLAGE_TEMPLATE_OPTIONS +from pasteup.services.cover_collage import COVER_COLLAGE_TEMPLATE_OPTIONS from mullion import DEFAULT_DPI # Prefills the input-folder field so a regular workflow does not need retyping on diff --git a/image_grid_app/app/routes/__init__.py b/src/pasteup/services/__init__.py similarity index 100% rename from image_grid_app/app/routes/__init__.py rename to src/pasteup/services/__init__.py diff --git a/image_grid_app/app/services/cover_collage.py b/src/pasteup/services/cover_collage.py similarity index 100% rename from image_grid_app/app/services/cover_collage.py rename to src/pasteup/services/cover_collage.py diff --git a/image_grid_app/app/services/exporter.py b/src/pasteup/services/exporter.py similarity index 100% rename from image_grid_app/app/services/exporter.py rename to src/pasteup/services/exporter.py diff --git a/image_grid_app/app/services/folder_scanner.py b/src/pasteup/services/folder_scanner.py similarity index 100% rename from image_grid_app/app/services/folder_scanner.py rename to src/pasteup/services/folder_scanner.py diff --git a/image_grid_app/app/services/grid_composer.py b/src/pasteup/services/grid_composer.py similarity index 100% rename from image_grid_app/app/services/grid_composer.py rename to src/pasteup/services/grid_composer.py diff --git a/image_grid_app/app/services/image_batcher.py b/src/pasteup/services/image_batcher.py similarity index 100% rename from image_grid_app/app/services/image_batcher.py rename to src/pasteup/services/image_batcher.py diff --git a/image_grid_app/app/services/video_exporter.py b/src/pasteup/services/video_exporter.py similarity index 100% rename from image_grid_app/app/services/video_exporter.py rename to src/pasteup/services/video_exporter.py diff --git a/image_grid_app/app/static/css/styles.css b/src/pasteup/static/css/styles.css similarity index 100% rename from image_grid_app/app/static/css/styles.css rename to src/pasteup/static/css/styles.css diff --git a/image_grid_app/app/static/js/app.js b/src/pasteup/static/js/app.js similarity index 100% rename from image_grid_app/app/static/js/app.js rename to src/pasteup/static/js/app.js diff --git a/image_grid_app/app/templates/index.html b/src/pasteup/templates/index.html similarity index 100% rename from image_grid_app/app/templates/index.html rename to src/pasteup/templates/index.html diff --git a/image_grid_app/tests/conftest.py b/tests/conftest.py similarity index 60% rename from image_grid_app/tests/conftest.py rename to tests/conftest.py index 0f37c5c..126ccd8 100644 --- a/image_grid_app/tests/conftest.py +++ b/tests/conftest.py @@ -1,10 +1,4 @@ import os -import sys -from pathlib import Path - -ROOT = Path(__file__).resolve().parents[1] -if str(ROOT) not in sys.path: - sys.path.insert(0, str(ROOT)) # TestClient addresses every request to "testserver", which the app's Host check # refuses by default. Set before any test module imports the app. diff --git a/image_grid_app/tests/test_batch_cover_collage_api.py b/tests/test_batch_cover_collage_api.py similarity index 97% rename from image_grid_app/tests/test_batch_cover_collage_api.py rename to tests/test_batch_cover_collage_api.py index 3a1de2c..28f06af 100644 --- a/image_grid_app/tests/test_batch_cover_collage_api.py +++ b/tests/test_batch_cover_collage_api.py @@ -4,8 +4,8 @@ from PIL import Image from fastapi import HTTPException -from app.models.schemas import BatchCoverCollageGenerationRequest -from app.routes.jobs import generate_cover_collage_batch_job +from pasteup.models.schemas import BatchCoverCollageGenerationRequest +from pasteup.routes.jobs import generate_cover_collage_batch_job def _create_image(path: Path, color: tuple[int, int, int]) -> None: diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..4428432 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import pytest + +from pasteup import __version__, cli + + +def test_version_flag_prints_the_package_version(capsys) -> None: + with pytest.raises(SystemExit) as exit_info: + cli.main(["--version"]) + + assert exit_info.value.code == 0 + assert capsys.readouterr().out.strip() == f"pasteup {__version__}" + + +def test_serves_the_app_on_this_machine_by_default(monkeypatch) -> None: + calls = [] + monkeypatch.setattr("uvicorn.run", lambda app, **kwargs: calls.append((app, kwargs))) + + cli.main([]) + + assert calls == [("pasteup.main:app", {"host": "127.0.0.1", "port": 8000, "reload": False})] + + +def test_warns_when_listening_beyond_this_machine(monkeypatch, capsys) -> None: + monkeypatch.setattr("uvicorn.run", lambda app, **kwargs: None) + + cli.main(["--host", "0.0.0.0", "--port", "9000"]) + + assert "See SECURITY.md" in capsys.readouterr().err + + +def test_python_dash_m_runs_the_same_command() -> None: + result = subprocess.run( + [sys.executable, "-m", "pasteup", "--version"], + check=True, + capture_output=True, + text=True, + ) + + assert result.stdout.strip() == f"pasteup {__version__}" diff --git a/image_grid_app/tests/test_cover_collage.py b/tests/test_cover_collage.py similarity index 99% rename from image_grid_app/tests/test_cover_collage.py rename to tests/test_cover_collage.py index fc460a2..fdc3580 100644 --- a/image_grid_app/tests/test_cover_collage.py +++ b/tests/test_cover_collage.py @@ -4,7 +4,7 @@ import pytest from PIL import Image -from app.services.cover_collage import ( +from pasteup.services.cover_collage import ( COVER_COLLAGE_TEMPLATE_OPTIONS, CoverCollageFittingMode, CoverCollageTemplate, diff --git a/image_grid_app/tests/test_cover_collage_api.py b/tests/test_cover_collage_api.py similarity index 97% rename from image_grid_app/tests/test_cover_collage_api.py rename to tests/test_cover_collage_api.py index ec1f143..fc3146d 100644 --- a/image_grid_app/tests/test_cover_collage_api.py +++ b/tests/test_cover_collage_api.py @@ -5,9 +5,9 @@ from fastapi import HTTPException from pydantic import ValidationError -from app.models.schemas import CoverCollageGenerationRequest -from app.routes import jobs -from app.routes.jobs import generate_cover_collage_job +from pasteup.models.schemas import CoverCollageGenerationRequest +from pasteup.routes import jobs +from pasteup.routes.jobs import generate_cover_collage_job def _create_image(path: Path, color: tuple[int, int, int]) -> None: diff --git a/image_grid_app/tests/test_generate_all_folders.py b/tests/test_generate_all_folders.py similarity index 98% rename from image_grid_app/tests/test_generate_all_folders.py rename to tests/test_generate_all_folders.py index d675fb9..80fde14 100644 --- a/image_grid_app/tests/test_generate_all_folders.py +++ b/tests/test_generate_all_folders.py @@ -2,8 +2,8 @@ from PIL import Image -from app.models.schemas import BatchGenerationRequest, GenerationRequest -from app.routes.jobs import generate_all_folders_job +from pasteup.models.schemas import BatchGenerationRequest, GenerationRequest +from pasteup.routes.jobs import generate_all_folders_job def _create_image(path: Path) -> None: diff --git a/image_grid_app/tests/test_generate_single_folder_video_status.py b/tests/test_generate_single_folder_video_status.py similarity index 92% rename from image_grid_app/tests/test_generate_single_folder_video_status.py rename to tests/test_generate_single_folder_video_status.py index 1979705..fc76d32 100644 --- a/image_grid_app/tests/test_generate_single_folder_video_status.py +++ b/tests/test_generate_single_folder_video_status.py @@ -2,7 +2,7 @@ from PIL import Image -from app.routes import jobs +from pasteup.routes import jobs def _create_image(path: Path) -> None: @@ -21,7 +21,7 @@ def test_generate_single_folder_reports_video_output_path_when_created( _create_image(input_dir / f"img_{index:03}.png") expected_video_path = str((output_dir / "preview.mp4").resolve()) - monkeypatch.setattr("app.routes.jobs.build_preview_video", lambda **_: expected_video_path) + monkeypatch.setattr("pasteup.routes.jobs.build_preview_video", lambda **_: expected_video_path) result = jobs._generate_for_single_folder( folder_path=str(input_dir), @@ -54,7 +54,7 @@ def test_generate_single_folder_reports_video_failure_with_expected_path( _create_image(input_dir / f"img_{index:03}.png") monkeypatch.setattr( - "app.routes.jobs.build_preview_video", + "pasteup.routes.jobs.build_preview_video", lambda **_: (_ for _ in ()).throw(RuntimeError("ffmpeg unavailable")), ) diff --git a/image_grid_app/tests/test_grid_composer.py b/tests/test_grid_composer.py similarity index 93% rename from image_grid_app/tests/test_grid_composer.py rename to tests/test_grid_composer.py index 521ab39..1b1b8f0 100644 --- a/image_grid_app/tests/test_grid_composer.py +++ b/tests/test_grid_composer.py @@ -2,7 +2,7 @@ from PIL import Image -from app.services.grid_composer import compose_image_grids +from pasteup.services.grid_composer import compose_image_grids def _create_image(path: Path) -> None: diff --git a/image_grid_app/tests/test_image_batcher.py b/tests/test_image_batcher.py similarity index 87% rename from image_grid_app/tests/test_image_batcher.py rename to tests/test_image_batcher.py index b5823c7..be2113b 100644 --- a/image_grid_app/tests/test_image_batcher.py +++ b/tests/test_image_batcher.py @@ -1,4 +1,4 @@ -from app.services.image_batcher import build_image_batches, estimate_page_count +from pasteup.services.image_batcher import build_image_batches, estimate_page_count def test_build_image_batches_returns_only_full_12_image_pages() -> None: diff --git a/image_grid_app/tests/test_page_dpi_and_geometry.py b/tests/test_page_dpi_and_geometry.py similarity index 96% rename from image_grid_app/tests/test_page_dpi_and_geometry.py rename to tests/test_page_dpi_and_geometry.py index b49522c..122e567 100644 --- a/image_grid_app/tests/test_page_dpi_and_geometry.py +++ b/tests/test_page_dpi_and_geometry.py @@ -10,7 +10,7 @@ import pytest from PIL import Image -from app.services.exporter import export_pages +from pasteup.services.exporter import export_pages def _round_dpi(image: Image.Image) -> tuple[int, int]: diff --git a/image_grid_app/tests/test_partial_page_and_generation_options.py b/tests/test_partial_page_and_generation_options.py similarity index 98% rename from image_grid_app/tests/test_partial_page_and_generation_options.py rename to tests/test_partial_page_and_generation_options.py index b733b56..62b7607 100644 --- a/image_grid_app/tests/test_partial_page_and_generation_options.py +++ b/tests/test_partial_page_and_generation_options.py @@ -11,8 +11,8 @@ from fastapi.testclient import TestClient from PIL import Image -from app.main import app -from app.services.grid_composer import CELLS_PER_PAGE, compose_image_grids +from pasteup.main import app +from pasteup.services.grid_composer import CELLS_PER_PAGE, compose_image_grids client = TestClient(app) diff --git a/image_grid_app/tests/test_request_safety.py b/tests/test_request_safety.py similarity index 95% rename from image_grid_app/tests/test_request_safety.py rename to tests/test_request_safety.py index 89b506c..0c4065a 100644 --- a/image_grid_app/tests/test_request_safety.py +++ b/tests/test_request_safety.py @@ -12,10 +12,10 @@ from PIL import Image from pydantic import ValidationError -from app.main import app -from app.models.schemas import GenerationRequest -from app.routes.jobs import MAX_PAGE_MEGAPIXELS, _OutputOptions -from app.services.video_exporter import build_preview_video +from pasteup.main import app +from pasteup.models.schemas import GenerationRequest +from pasteup.routes.jobs import MAX_PAGE_MEGAPIXELS, _OutputOptions +from pasteup.services.video_exporter import build_preview_video client = TestClient(app) diff --git a/image_grid_app/tests/test_scan_folder_api.py b/tests/test_scan_folder_api.py similarity index 98% rename from image_grid_app/tests/test_scan_folder_api.py rename to tests/test_scan_folder_api.py index 3318ede..61e45d9 100644 --- a/image_grid_app/tests/test_scan_folder_api.py +++ b/tests/test_scan_folder_api.py @@ -1,7 +1,7 @@ from pathlib import Path -from app.models.schemas import ScanRequest -from app.routes.jobs import scan_folder_job +from pasteup.models.schemas import ScanRequest +from pasteup.routes.jobs import scan_folder_job def test_scan_folder_valid_directory_under_12_images_returns_zero_estimated_pages(tmp_path: Path) -> None: diff --git a/image_grid_app/tests/test_scan_selected_batch_folders.py b/tests/test_scan_selected_batch_folders.py similarity index 96% rename from image_grid_app/tests/test_scan_selected_batch_folders.py rename to tests/test_scan_selected_batch_folders.py index e407b73..b281e9c 100644 --- a/image_grid_app/tests/test_scan_selected_batch_folders.py +++ b/tests/test_scan_selected_batch_folders.py @@ -4,8 +4,8 @@ import pytest from fastapi import HTTPException -from app.models.schemas import SelectedBatchFolderValidationRequest -from app.routes.jobs import scan_selected_batch_folders_job +from pasteup.models.schemas import SelectedBatchFolderValidationRequest +from pasteup.routes.jobs import scan_selected_batch_folders_job def _create_image(path: Path) -> None: diff --git a/image_grid_app/tests/test_transparent_png_handling.py b/tests/test_transparent_png_handling.py similarity index 97% rename from image_grid_app/tests/test_transparent_png_handling.py rename to tests/test_transparent_png_handling.py index 34a6071..27af1b2 100644 --- a/image_grid_app/tests/test_transparent_png_handling.py +++ b/tests/test_transparent_png_handling.py @@ -15,7 +15,7 @@ import pytest from PIL import Image, ImageChops -from app.services.grid_composer import compose_image_grids +from pasteup.services.grid_composer import compose_image_grids def _cutout_rgba(size: int = 80) -> Image.Image: diff --git a/image_grid_app/tests/test_ui_defaults.py b/tests/test_ui_defaults.py similarity index 73% rename from image_grid_app/tests/test_ui_defaults.py rename to tests/test_ui_defaults.py index d6f4d48..fc67d0c 100644 --- a/image_grid_app/tests/test_ui_defaults.py +++ b/tests/test_ui_defaults.py @@ -1,7 +1,7 @@ from fastapi.testclient import TestClient -from app.main import app -from app.routes.ui import INPUT_FOLDER_ENV_VAR +from pasteup.main import app +from pasteup.routes.ui import INPUT_FOLDER_ENV_VAR client = TestClient(app) @@ -27,3 +27,8 @@ def test_index_prefills_the_input_folder_from_the_environment(monkeypatch) -> No response = client.get("/") assert 'value="~/clip-art/bundle-01"' in _input_folder_tag(response.text) + + +def test_static_assets_are_served_from_the_installed_package() -> None: + assert client.get("/static/js/app.js").status_code == 200 + assert client.get("/static/css/styles.css").status_code == 200 diff --git a/image_grid_app/tests/test_ui_generation_modes.py b/tests/test_ui_generation_modes.py similarity index 94% rename from image_grid_app/tests/test_ui_generation_modes.py rename to tests/test_ui_generation_modes.py index d96b973..55c8a83 100644 --- a/image_grid_app/tests/test_ui_generation_modes.py +++ b/tests/test_ui_generation_modes.py @@ -1,9 +1,10 @@ import re -from pathlib import Path +from importlib.resources import files -ROOT = Path(__file__).resolve().parents[1] -INDEX_TEMPLATE = ROOT / "app" / "templates" / "index.html" -APP_JS = ROOT / "app" / "static" / "js" / "app.js" +# Read from the installed package, so these also prove the assets ship in it. +PACKAGE = files("pasteup") +INDEX_TEMPLATE = PACKAGE / "templates" / "index.html" +APP_JS = PACKAGE / "static" / "js" / "app.js" def _squash_whitespace(value: str) -> str: diff --git a/image_grid_app/tests/test_video_exporter.py b/tests/test_video_exporter.py similarity index 94% rename from image_grid_app/tests/test_video_exporter.py rename to tests/test_video_exporter.py index f1a098f..84422bd 100644 --- a/image_grid_app/tests/test_video_exporter.py +++ b/tests/test_video_exporter.py @@ -6,8 +6,8 @@ import pytest from PIL import Image -from app.services import video_exporter -from app.services.video_exporter import ( +from pasteup.services import video_exporter +from pasteup.services.video_exporter import ( FRAME_RATE, MAX_TRANSITION_SECONDS, MAX_VIDEO_SIDE, @@ -79,14 +79,14 @@ def test_build_preview_video_sorts_paths_before_encoding( _create_image(page_1, "red") _create_image(page_2, "blue") - monkeypatch.setattr("app.services.video_exporter.shutil.which", lambda _: "/usr/bin/ffmpeg") + monkeypatch.setattr("pasteup.services.video_exporter.shutil.which", lambda _: "/usr/bin/ffmpeg") captured: dict[str, list[str]] = {} def _fake_run(command: list[str], check: bool, capture_output: bool, text: bool) -> None: captured["command"] = command - monkeypatch.setattr("app.services.video_exporter.subprocess.run", _fake_run) + monkeypatch.setattr("pasteup.services.video_exporter.subprocess.run", _fake_run) output = build_preview_video( [str(page_2), str(page_1)], @@ -178,7 +178,7 @@ def test_encoding_failure_reports_ffmpegs_own_error(tmp_path: Path, monkeypatch: def test_an_unreadable_page_is_reported_not_raised_raw(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setattr("app.services.video_exporter.shutil.which", lambda _: "/usr/bin/ffmpeg") + monkeypatch.setattr("pasteup.services.video_exporter.shutil.which", lambda _: "/usr/bin/ffmpeg") broken_page = tmp_path / "page_001.png" broken_page.write_bytes(b"not a png") From a342ce169efd929b7b8b887516cb9aa20efb2b5e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Oct 2026 11:48:28 +0000 Subject: [PATCH 2/2] Call it Pasteup everywhere The visible name, settings and docs still said Image Grid App. - The page title, heading and window label read Pasteup, and the API docs show Pasteup with the package version. - Environment variables become PASTEUP_INPUT_FOLDER and PASTEUP_ALLOWED_HOSTS. The old IMAGE_GRID_* names are not read any more; nothing outside this project used them. - The theme preference is stored under `pasteup-theme`, so a theme chosen in the old app is asked for once more. - The README now opens with what Pasteup does, then how to install it and start it with `pasteup`, and how to develop on it. The separate app README is folded in: its project layout and its notes on how mullion loads images were the only parts not already covered. SECURITY.md shows the `pasteup` command. Function names such as compose_image_grids describe what the code does, not the project, and stay as they are. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01E6aBDEnU4vqKQ4F9cnJMrL --- README.md | 102 +++++++++++++++++++------------ SECURITY.md | 12 ++-- image_grid_app/README.md | 84 ------------------------- src/pasteup/main.py | 5 +- src/pasteup/routes/ui.py | 2 +- src/pasteup/static/js/app.js | 2 +- src/pasteup/templates/index.html | 8 +-- tests/conftest.py | 2 +- tests/test_ui_defaults.py | 7 +++ 9 files changed, 86 insertions(+), 138 deletions(-) delete mode 100644 image_grid_app/README.md diff --git a/README.md b/README.md index f893840..366fa07 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,69 @@ -# mar_place - -## MVP Overview -`mar_place` contains **Image Grid App**, a FastAPI + vanilla JS tool that: -- scans an input folder for supported images, -- estimates page count, -- composes a fixed **4x3 image grid** (12 images) per page, -- exports generated pages as PNG or JPG at a chosen DPI, -- optionally cleans a near-white background off each image before placing it, -- lets the UI toggle between single-folder and batch-folder generation modes. - -Project root: -- `image_grid_app/` — runnable application. - ---- - -## Installation and Run Commands - -Requires Python 3.11 or newer. The optional preview video also needs +# Pasteup + +Turn a folder of clip art into listing images: preview sheets, a cover collage +and a short preview video, ready for Etsy and other marketplaces. Pasteup runs +on your own computer and works in your browser. + +The name comes from *paste-up*, how clip art was used before desktop +publishing: cut out by hand and pasted onto a layout board. + +## What it does +- **Preview sheets:** 4x3 grids of your images on a white page, as PNG or JPG + at a chosen DPI. +- **Cover collage:** a single page in one of three layouts, for a listing's + main image. +- **Preview video:** an MP4 slideshow of the sheets, exactly as long as you ask + (Etsy's listing videos run 5 to 15 s). +- **Clean-up:** transparent PNGs land on white instead of black, phone photos + are turned upright, and near-white backgrounds can be removed. +- **Batch mode:** process every bundle folder under a parent folder in one go. + +## Install +Requires Python 3.11 or newer. The preview video also needs [ffmpeg](https://ffmpeg.org/) on `PATH`. -### 1) Install dependencies ```bash -cd image_grid_app +git clone https://github.com/ftymoshchuk/pasteup.git +cd pasteup python -m venv .venv source .venv/bin/activate -pip install -r requirements.txt +pip install . ``` -### 2) Run the app +## Run ```bash -cd image_grid_app -uvicorn app.main:app --reload +pasteup ``` +Then open `http://127.0.0.1:8000/` (API docs: `http://127.0.0.1:8000/docs`). +`pasteup --help` lists the options, and `python -m pasteup` works too. -### 3) Open in browser -- UI: `http://127.0.0.1:8000/` -- API docs (Swagger): `http://127.0.0.1:8000/docs` - -The app reads and writes files at the paths you give it and has no login, so +Pasteup reads and writes files at the paths you give it and has no login, so keep it on `127.0.0.1` (the default). See [SECURITY.md](SECURITY.md). ### Optional environment variables -- `IMAGE_GRID_INPUT_FOLDER`: prefills the input-folder field, e.g. - `IMAGE_GRID_INPUT_FOLDER=~/Pictures/clip-art uvicorn app.main:app`. -- `IMAGE_GRID_ALLOWED_HOSTS`: comma-separated host names to accept besides +- `PASTEUP_INPUT_FOLDER`: prefills the input-folder field, e.g. + `PASTEUP_INPUT_FOLDER=~/Pictures/clip-art pasteup`. +- `PASTEUP_ALLOWED_HOSTS`: comma-separated host names to accept besides `localhost`, `127.0.0.1` and `[::1]`. Only for serving the app under another name on purpose. -### Development +## Development ```bash -cd image_grid_app -pip install -r requirements-dev.txt +pip install -e ".[dev]" ruff check . pytest ``` -CI runs the same on Python 3.11 and 3.13, with ffmpeg installed so the -preview-video tests encode real files. +CI runs the same on Python 3.11 and 3.13, against a regular install of the +package and with ffmpeg present, so the preview-video tests encode real files. + +Project layout: +- `src/pasteup/main.py`: the FastAPI app +- `src/pasteup/routes/`: the page and the `/api/jobs` endpoints +- `src/pasteup/services/`: scanning, page composition, collages, export, video +- `src/pasteup/models/`: request and response schemas +- `src/pasteup/templates/` and `src/pasteup/static/`: the UI +- `src/pasteup/cli.py`: the `pasteup` command +- `tests/` --- @@ -74,7 +82,7 @@ Notes: ## Default Setting Values Default UI values: -- input folder: empty (set `IMAGE_GRID_INPUT_FOLDER` to prefill it) +- input folder: empty (set `PASTEUP_INPUT_FOLDER` to prefill it) - `page_width`: `3000` - `page_height`: `3000` - `gap`: `30` @@ -361,6 +369,22 @@ Fixes: --- +## How images are loaded +Opening, background cleaning and page geometry live in +[mullion](https://github.com/sigrix-io/mullion), a small library Pasteup +depends on (`mullion~=0.2.1`, from PyPI). + +`mullion.open_path()` is the one place a source image is opened. It composites +transparency onto white (a bare `convert("RGB")` drops the alpha and leaves the +black underneath showing) and applies EXIF orientation, so a phone photo is not +placed sideways. `mullion.clean_background()` is the border-seeded cleaner +described above, and `mullion.resolve_page_geometry()` turns `page_unit` and +`dpi` into the pixel size the exporter stamps. mullion's own suite tests these +directly; Pasteup's tests check the same claims through its composer and +exporter, so a bad mullion upgrade still fails here. + +--- + ## License Apache License 2.0, see [LICENSE](LICENSE). Security reports: see [SECURITY.md](SECURITY.md). diff --git a/SECURITY.md b/SECURITY.md index f5c0f14..f01b121 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,14 +1,14 @@ # Security -## Image Grid App is a local tool +## Pasteup is a local tool -The app reads and writes files at whatever paths it is given — that is its job. +Pasteup reads and writes files at whatever paths it is given — that is its job. It has no accounts and no authentication, so run it only on your own machine, -bound to `127.0.0.1` (uvicorn's default): +bound to `127.0.0.1` (the default): ```bash -uvicorn app.main:app # fine: only this machine can reach it -uvicorn app.main:app --host 0.0.0.0 # don't: anyone on your network can read and write your files +pasteup # fine: only this machine can reach it +pasteup --host 0.0.0.0 # don't: anyone on your network can read and write your files ``` Two guards back that up: @@ -16,7 +16,7 @@ Two guards back that up: - **Host check.** Requests are only answered when addressed to `localhost` or `127.0.0.1`. That stops a web page that points its own domain at your machine (DNS rebinding) from driving the app through your browser. If you deliberately - serve the app under another name, list it in `IMAGE_GRID_ALLOWED_HOSTS` + serve the app under another name, list it in `PASTEUP_ALLOWED_HOSTS` (comma-separated). - **Bounded requests.** Output files stay inside the output folder you chose, and page size and video length are capped, so a single request cannot overwrite diff --git a/image_grid_app/README.md b/image_grid_app/README.md deleted file mode 100644 index 416a928..0000000 --- a/image_grid_app/README.md +++ /dev/null @@ -1,84 +0,0 @@ -# Image Grid App - -Base structure for a FastAPI project that scans folders, batches images, composes image grids, and exports results. - -## Structure - -- `app/main.py`: FastAPI app setup -- `app/routes/`: UI and API routes -- `app/services/`: domain service modules -- `app/models/`: shared schemas -- `app/templates/`: Jinja templates -- `app/static/`: CSS and JavaScript assets - -## Run locally - -```bash -pip install -r requirements.txt -uvicorn app.main:app --reload -``` - -For development, `pip install -r requirements-dev.txt`, then `ruff check .` and -`pytest`. - -## UI generation modes - -The home page now has a mode selector next to the generation controls. The selector drives a single client-side source of truth for generation requests: - -- **Single folder** - - Labels: `Input folder` + `Output folder` - - Endpoint: `POST /api/jobs/generate` -- **Batch folders** - - Labels: `Parent folder` + `Created output folder` - - Validation endpoint: `POST /api/jobs/scan-selected-batch-folders` - - Generation endpoint: `POST /api/jobs/generate-all-folders` - -`Cover collage` remains a separate single-folder action and still calls `POST /api/jobs/generate-cover-collage`. It is not part of the mode toggle. - -## Output quality - -Every page-producing endpoint accepts the same print and cleanup options: - -| Field | Default | Does | -| --- | --- | --- | -| `page_unit` | `px` | Read `page_width`/`page_height` as `px`, `in` or `mm` | -| `dpi` | `300` | Converts physical units, and is stamped into the exported file | -| `background_clean_mode` | `off` | `flatten` or `transparent` to clean a near-white background | -| `background_tolerance` | `240` | Lowest channel value counted as background | -| `background_feather` | `1` | Mask softening, in pixels, to kill halos | -| `include_partial_page` | `false` | Grid endpoints only: render a partly-filled final page | - -Background cleaning flood-fills inward from the image border, so only a -background *connected to the edge* is touched — a white highlight enclosed by -the subject is never reached. An image whose border is not near-white is -reported as having no background and returned unchanged. - -## Image loading and background cleaning - -Both live in **[mullion](https://github.com/sigrix-io/mullion)**, a small -library this app depends on rather than a module it owns. It is installed from -PyPI, pinned to its minor version (`mullion~=0.2.1`). - -`mullion.open_path()` is the one place a source image is opened. It composites -transparency onto white — a bare `convert("RGB")` drops the alpha and leaves the -black underneath showing — and applies EXIF orientation, so a phone photo is not -placed sideways. `mullion.clean_background()` is the cleaner described above, -and `mullion.resolve_page_geometry()` is what turns `page_unit` and `dpi` into -the pixel dimensions the exporter stamps. The grid composer and the cover -collage both go through all three. - -It was extracted because the same three problems arrive in every application -that accepts user images, and an app that solves them in six places gets six -different answers. Nothing about the behaviour here changed in the move. -mullion's own suite tests these functions directly; this app's tests check the -same claims through its composer and exporter, so a bad mullion upgrade still -fails here. - -## Export behavior - -- Exports carry DPI metadata, so the page reports a real physical size instead of - falling back to 72 DPI. -- Output directories are created automatically when they do not exist. -- Pages are saved with sequential names: `page_001.png`, `page_002.png`, etc. (or `.jpg` for JPG export). -- Export is conflict-safe: existing `page_###` files are **not** overwritten; new exports continue at the next available index. -- Export responses can return saved paths as relative paths (default) or absolute paths. diff --git a/src/pasteup/main.py b/src/pasteup/main.py index b7c7401..500052f 100644 --- a/src/pasteup/main.py +++ b/src/pasteup/main.py @@ -5,6 +5,7 @@ from fastapi.middleware.trustedhost import TrustedHostMiddleware from fastapi.staticfiles import StaticFiles +from pasteup import __version__ from pasteup.routes.jobs import router as jobs_router from pasteup.routes.ui import router as ui_router @@ -15,7 +16,7 @@ # domain has been re-pointed at 127.0.0.1 (DNS rebinding) from driving the app # through the user's browser. Extra names, comma-separated, are for serving the # app deliberately under another host. -ALLOWED_HOSTS_ENV_VAR = "IMAGE_GRID_ALLOWED_HOSTS" +ALLOWED_HOSTS_ENV_VAR = "PASTEUP_ALLOWED_HOSTS" DEFAULT_ALLOWED_HOSTS = ("localhost", "127.0.0.1", "[::1]") @@ -24,7 +25,7 @@ def allowed_hosts() -> list[str]: return [*DEFAULT_ALLOWED_HOSTS, *(host.strip() for host in extra_hosts if host.strip())] -app = FastAPI(title="Image Grid App") +app = FastAPI(title="Pasteup", version=__version__) app.add_middleware(TrustedHostMiddleware, allowed_hosts=allowed_hosts()) app.mount("/static", StaticFiles(directory=APP_DIR / "static"), name="static") diff --git a/src/pasteup/routes/ui.py b/src/pasteup/routes/ui.py index b078807..93365d2 100644 --- a/src/pasteup/routes/ui.py +++ b/src/pasteup/routes/ui.py @@ -10,7 +10,7 @@ # Prefills the input-folder field so a regular workflow does not need retyping on # every launch. It is read from the environment rather than written here because # any real value is somebody's home directory. -INPUT_FOLDER_ENV_VAR = "IMAGE_GRID_INPUT_FOLDER" +INPUT_FOLDER_ENV_VAR = "PASTEUP_INPUT_FOLDER" router = APIRouter() templates = Jinja2Templates(directory=Path(__file__).resolve().parents[1] / "templates") diff --git a/src/pasteup/static/js/app.js b/src/pasteup/static/js/app.js index 041c030..33e5cae 100644 --- a/src/pasteup/static/js/app.js +++ b/src/pasteup/static/js/app.js @@ -1,4 +1,4 @@ -const THEME_STORAGE_KEY = "image-grid-theme"; +const THEME_STORAGE_KEY = "pasteup-theme"; const GENERATION_MODES = { single: { inputLabel: "Input folder", diff --git a/src/pasteup/templates/index.html b/src/pasteup/templates/index.html index 142e3c6..48e2c75 100644 --- a/src/pasteup/templates/index.html +++ b/src/pasteup/templates/index.html @@ -3,19 +3,19 @@ - Image Grid App + Pasteup
-
+
-

image-grid-app :: operator console

+

pasteup :: operator console

@@ -24,7 +24,7 @@ diff --git a/tests/conftest.py b/tests/conftest.py index 126ccd8..353b36f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,4 +2,4 @@ # TestClient addresses every request to "testserver", which the app's Host check # refuses by default. Set before any test module imports the app. -os.environ.setdefault("IMAGE_GRID_ALLOWED_HOSTS", "testserver") +os.environ.setdefault("PASTEUP_ALLOWED_HOSTS", "testserver") diff --git a/tests/test_ui_defaults.py b/tests/test_ui_defaults.py index fc67d0c..ca401b0 100644 --- a/tests/test_ui_defaults.py +++ b/tests/test_ui_defaults.py @@ -32,3 +32,10 @@ def test_index_prefills_the_input_folder_from_the_environment(monkeypatch) -> No def test_static_assets_are_served_from_the_installed_package() -> None: assert client.get("/static/js/app.js").status_code == 200 assert client.get("/static/css/styles.css").status_code == 200 + + +def test_index_is_titled_pasteup() -> None: + html = client.get("/").text + + assert "Pasteup" in html + assert "

Pasteup

" in html