This commit is contained in:
SG
2025-06-17 18:13:47 +03:00
parent 0ea2fbeda6
commit 00f1c1a9ae
4 changed files with 12 additions and 6 deletions

View File

@@ -26,17 +26,16 @@ else:
if Path(f"themes/{config.theme}/templates").exists():
# Use the templates from the initialized site instance and the installed theme
jinja_env_dir = f"themes/{config.theme}/templates"
print("USING LOCALLY INITIALIZED THEMES")
logger.debug(f"Using locally initialized templates from {jinja_env_dir}")
else:
# Use default templates from the default theme shipped with the app
# i.e. PyInstaller-packed single executable
print("USING DEFAULT THEMES")
logger.debug("Using shipped default temlpates.")
jinja_env_dir = f"{base_dir}/themes/default/templates"
env = Environment(loader=FileSystemLoader(f"{jinja_env_dir}"))
env.globals['header_image'] = f"{base_dir}/themes/{config.theme}/static/images/header.jpg"
index_template = env.get_template("index.html")
content_item_template = env.get_template("content_item.html")
print(env.loader.searchpath)
class ContentItem:
def render_content(self, categories, target_file = False):
@@ -120,7 +119,11 @@ class Site:
self.categories = defaultdict(list)
def init_site(self):
if os.path.isdir('.') and os.listdir('.'):
logger.error("Current directory is not empty.")
sys.exit(1)
logger.info("Initializing new site")
config.create_default_config()
# Create directories
for subdir in [self.content_dir]:
os.makedirs(subdir, exist_ok=True)