Separated the modern theme script into it's own file.
This commit is contained in:
@@ -36,6 +36,12 @@ def load_template(template_file: str) -> str:
|
||||
return template_path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def load_script(script_file: str) -> str:
|
||||
"""Load the JS script from the specified file."""
|
||||
script_path = SCRIPT_DIR / script_file
|
||||
return script_path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def load_asset_as_base64(path: Path, mime_type: str) -> str:
|
||||
"""Load a file and return it as a base64 data URL."""
|
||||
if path.exists():
|
||||
@@ -117,10 +123,14 @@ def generate_report(db_path: str, output_path: str, top_n: int, assets_dir: str,
|
||||
theme_css = get_theme_css(style)
|
||||
theme_config = get_theme_config(style)
|
||||
|
||||
# Inject javascript
|
||||
javascript = load_script('templates/script.js')
|
||||
javascript = javascript.replace("__ALL_GAMES__", json.dumps(all_games))
|
||||
javascript = javascript.replace("__TOP_N__", str(top_n))
|
||||
javascript = javascript.replace("__THEME_CONFIG__", theme_config)
|
||||
|
||||
html = html.replace("__THEME_CSS__", theme_css)
|
||||
html = html.replace("__THEME_CONFIG__", theme_config)
|
||||
html = html.replace("__ALL_GAMES__", json.dumps(all_games))
|
||||
html = html.replace("__TOP_N__", str(top_n))
|
||||
html = html.replace("__SCRIPT__", javascript)
|
||||
html = html.replace("__TOTAL_LIBRARY__", str(total_library))
|
||||
html = html.replace("__BACKGROUND_IMAGE__", background_image)
|
||||
html = html.replace("__BACKGROUND_IMAGE_CUSTOM__", background_image_custom)
|
||||
|
||||
Reference in New Issue
Block a user