diff options
Diffstat (limited to 'jb/settings.py')
| -rw-r--r-- | jb/settings.py | 12 |
1 files changed, 9 insertions, 3 deletions
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", |
