Spaces:
Running
Running
burtenshaw
commited on
Commit
·
badfb4c
1
Parent(s):
903f1b2
use environment variable for template path
Browse files- app/app.py +10 -6
app/app.py
CHANGED
|
@@ -50,6 +50,7 @@ PRESENTATION_PROMPT = os.getenv(
|
|
| 50 |
CACHE_DIR = ".cache" # For TTS caching
|
| 51 |
URL_CACHE_DIR = ".url_cache"
|
| 52 |
URL_CACHE_FILE = os.path.join(URL_CACHE_DIR, "presentations_cache")
|
|
|
|
| 53 |
|
| 54 |
# Initialize clients (do this once if possible, or manage carefully in functions)
|
| 55 |
try:
|
|
@@ -251,8 +252,9 @@ def generate_pdf_from_markdown(markdown_file_path, output_pdf_path):
|
|
| 251 |
|
| 252 |
|
| 253 |
# --- Helper Function to Read CSS ---
|
| 254 |
-
def load_css(
|
| 255 |
-
"""Loads CSS content from
|
|
|
|
| 256 |
try:
|
| 257 |
with open(css_path, "r", encoding="utf-8") as f:
|
| 258 |
return f.read()
|
|
@@ -296,8 +298,10 @@ def step1_fetch_and_generate_presentation(url, progress=gr.Progress(track_tqdm=T
|
|
| 296 |
)
|
| 297 |
|
| 298 |
# --- Copy Template Directory for Cached Item ---
|
| 299 |
-
template_src_dir =
|
| 300 |
-
template_dest_dir = os.path.join(
|
|
|
|
|
|
|
| 301 |
if os.path.isdir(template_src_dir):
|
| 302 |
try:
|
| 303 |
shutil.copytree(template_src_dir, template_dest_dir)
|
|
@@ -387,8 +391,8 @@ def step1_fetch_and_generate_presentation(url, progress=gr.Progress(track_tqdm=T
|
|
| 387 |
logger.info(f"Presentation markdown saved to temp file: {md_path}")
|
| 388 |
|
| 389 |
# --- Copy Template Directory for New Item ---
|
| 390 |
-
template_src_dir =
|
| 391 |
-
template_dest_dir = os.path.join(temp_dir,
|
| 392 |
if os.path.isdir(template_src_dir):
|
| 393 |
try:
|
| 394 |
shutil.copytree(template_src_dir, template_dest_dir)
|
|
|
|
| 50 |
CACHE_DIR = ".cache" # For TTS caching
|
| 51 |
URL_CACHE_DIR = ".url_cache"
|
| 52 |
URL_CACHE_FILE = os.path.join(URL_CACHE_DIR, "presentations_cache")
|
| 53 |
+
TEMPLATE_DIR = os.getenv("TEMPLATE_DIR", "app/template")
|
| 54 |
|
| 55 |
# Initialize clients (do this once if possible, or manage carefully in functions)
|
| 56 |
try:
|
|
|
|
| 252 |
|
| 253 |
|
| 254 |
# --- Helper Function to Read CSS ---
|
| 255 |
+
def load_css(css_filename="style.scss"):
|
| 256 |
+
"""Loads CSS content from the template directory."""
|
| 257 |
+
css_path = os.path.join(TEMPLATE_DIR, css_filename)
|
| 258 |
try:
|
| 259 |
with open(css_path, "r", encoding="utf-8") as f:
|
| 260 |
return f.read()
|
|
|
|
| 298 |
)
|
| 299 |
|
| 300 |
# --- Copy Template Directory for Cached Item ---
|
| 301 |
+
template_src_dir = TEMPLATE_DIR
|
| 302 |
+
template_dest_dir = os.path.join(
|
| 303 |
+
temp_dir, os.path.basename(TEMPLATE_DIR)
|
| 304 |
+
)
|
| 305 |
if os.path.isdir(template_src_dir):
|
| 306 |
try:
|
| 307 |
shutil.copytree(template_src_dir, template_dest_dir)
|
|
|
|
| 391 |
logger.info(f"Presentation markdown saved to temp file: {md_path}")
|
| 392 |
|
| 393 |
# --- Copy Template Directory for New Item ---
|
| 394 |
+
template_src_dir = TEMPLATE_DIR
|
| 395 |
+
template_dest_dir = os.path.join(temp_dir, os.path.basename(TEMPLATE_DIR))
|
| 396 |
if os.path.isdir(template_src_dir):
|
| 397 |
try:
|
| 398 |
shutil.copytree(template_src_dir, template_dest_dir)
|