diff --git a/pagerite/app.py b/pagerite/app.py index 11e5599..4880e14 100644 --- a/pagerite/app.py +++ b/pagerite/app.py @@ -30,18 +30,28 @@ walking the tree (``resolve``), moves are slot detach/attach import asyncio import logging +from collections.abc import AsyncGenerator from contextlib import asynccontextmanager +from pathlib import Path from fastapi import FastAPI, Request from fastapi.responses import Response +from fastapi_vue import Frontend from pagerite import api, files, pages, tracking from pagerite.__main__ import DEVMODE from pagerite.files import file_store -from pagerite.state import analytics_store, config, frontend, kanta -from collections.abc import AsyncGenerator +from pagerite.state import analytics_store, config, kanta + logger = logging.getLogger(__name__) +# Vue build served at the site root, no SPA catch-all (assets only). The +# build mirrors the URL space: hashed, immutable files live under +# /_assets/ (assetsDir: '_/assets'), the favicon at /favicon.ico. +frontend = Frontend( + Path(__file__).with_name("frontend-build"), spa=False, cached="/_assets/" +) + @asynccontextmanager async def lifespan(_app: FastAPI) -> AsyncGenerator: diff --git a/pagerite/state.py b/pagerite/state.py index d0d7d28..b68b9dc 100644 --- a/pagerite/state.py +++ b/pagerite/state.py @@ -3,7 +3,7 @@ Everything the route modules (files, api, tracking, pages) need that is not a route itself: environment-derived paths and tunables, the ``Data`` root with its ``Kanta`` handle (migrations in pagerite.migrations), the analytics -store, the fastapi-vue ``Frontend``, the page render cache +store, the page render cache (``_render_html``/``_cached_body``/``_html_response`` plus the ``_render_gen`` ETag generation, bumped by ``_invalidate_pages`` on every content/settings write), the translator ``dispatcher``, the slug charset @@ -22,7 +22,6 @@ from pathlib import Path import blake3 from fastapi import HTTPException, Request from fastapi.responses import Response -from fastapi_vue import Frontend from kanta import Kanta from zstandard import ZstdCompressor @@ -80,12 +79,6 @@ FAVICON_MAXSIZE = 192 data = Data() kanta = Kanta(DB_PATH, data, migrations="pagerite.migrations") -# Vue build served at the site root, no SPA catch-all (assets only). The -# build mirrors the URL space: hashed, immutable files live under -# /_assets/ (assetsDir: '_/assets'), the favicon at /favicon.ico. -BUILD_DIR = Path(__file__).with_name("frontend-build") -frontend = Frontend(BUILD_DIR, spa=False, cached="/_assets/") - # Dynamic HTML is compressed per request at level 9 (static assets are # already pre-compressed by fastapi-vue's Frontend). _zstd = ZstdCompressor(9) diff --git a/pyproject.toml b/pyproject.toml index c49cd34..215f3ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ readme = "README.md" requires-python = ">=3.14" dependencies = [ "blake3>=1.0.9", - "fastapi-vue~=1.4.0", + "fastapi-vue~=1.4.2", "fastapi[standard]>=0.141.1", "html5tagger>=2.0.0", "httpx>=0.28.1",