From e73cab566ca6f40c213c9a42d34d8f6af8515589 Mon Sep 17 00:00:00 2001 From: stuppie Date: Thu, 17 Sep 2026 10:05:48 -0600 Subject: render_base_html to server base html with js file templated --- jb/settings.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'jb/settings.py') diff --git a/jb/settings.py b/jb/settings.py index 1bf65bc..779bd85 100644 --- a/jb/settings.py +++ b/jb/settings.py @@ -2,7 +2,6 @@ import json from functools import lru_cache from os.path import abspath from os.path import dirname as pdirname -from os.path import join as pjoin from pathlib import Path from generalresearch.config import GRLBaseSettings, is_debug @@ -16,7 +15,6 @@ from pydantic_settings import SettingsConfigDict BASE_DIR = pdirname(pdirname(abspath(__file__))) BASE_HTML_PATH = Path(BASE_DIR) / "templates" / "base.html" -BASE_HTML = BASE_HTML_PATH.read_text() MANIFEST_PATH = Path(BASE_DIR) / "jb-ui" / "dist/.vite/manifest.json" @@ -25,8 +23,16 @@ def load_manifest(): return json.load(f) -class Settings(GRLBaseSettings): +def render_base_html() -> str: + manifest = load_manifest() + return ( + BASE_HTML_PATH.read_text() + .replace("{{ css_file }}", manifest["style.css"]["file"]) + .replace("{{ js_file }}", manifest["src/main.tsx"]["file"]) + ) + +class Settings(GRLBaseSettings): model_config = SettingsConfigDict( env_file=(".env.test", ".env.testing", ".env.staging", ".env.prod"), env_file_encoding="utf-8", -- cgit v1.2.3