Fix for dynamic js map embed in blog output

This commit is contained in:
Marty Oehme 2024-07-07 22:29:59 +02:00
parent f508be0740
commit bff3cb22fa
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
4 changed files with 2678 additions and 19 deletions

View file

@ -1,18 +1,36 @@
#!/usr/bin/env python3
# Simply move the map.png file to the blog output dir
# since it won't do so automatically for pillow creations.
# A HACK TO PUT THE LEAFLET JS INTO THE CORRECT PUBLIC BLOG DIR
# will have to be changed when the hardcoded public dir path changes
import shutil
import os
import shutil
import sys
from pathlib import Path
if not os.getenv("QUARTO_PROJECT_RENDER_ALL"):
sys.exit(0)
relative_pub_dir = Path(
"../../../../public/blog/2024-07-02-nuclear-explosions-analysis/"
)
q_output_dir = os.getenv("QUARTO_PROJECT_OUTPUT_DIR")
if not q_output_dir:
print(f"ERROR: output dir: {q_output_dir} DOES NOT EXIST.")
sys.exit(1)
src = "map.png"
dest = Path(q_output_dir).joinpath(relative_pub_dir)
shutil.copy(src, q_output_dir)
# Correct relative WORKING DIR DOES NOT EXIST
if not dest.is_dir():
print(f"ERROR: map.html destination path: {dest} DOES NOT EXIST.")
sys.exit(1)
src = "map.html"
shutil.copy(src, dest)
print("sucessfully moved map.html to ")