"""Shared web UI resources for EPUB search.""" from __future__ import annotations from pathlib import Path from fastapi.templating import Jinja2Templates PACKAGE_DIR = Path(__file__).resolve().parent TEMPLATE_DIR = PACKAGE_DIR / "templates" STATIC_DIR = PACKAGE_DIR / "static" def static_version(filename: str) -> int: """Return a cache-busting token for a static file based on its modification time.""" try: return int((STATIC_DIR / filename).stat().st_mtime) except OSError: return 0 templates = Jinja2Templates(directory=TEMPLATE_DIR) templates.env.globals["static_version"] = static_version