This commit is contained in:
SG
2025-06-17 16:22:47 +03:00
parent 4ea54eaa91
commit 326e5c5edd
7 changed files with 77 additions and 51 deletions

View File

@@ -1,14 +1,41 @@
import os
import os, yaml
# Main config section
#class Config:
# MAIN_PAGE_TITLE = "microgen library"
# APP_NAME = "hydrogen"
# APP_DESCRIPTION = "Simplistic static site generator"
# APP_SRC_URL = f"https://git.exocortex.ru/Exocortex/{APP_NAME}"
# OUTPUT_DIR = 'public'
# TEMPLATES_DIR = 'templates'
# CONTENT_DIR = 'content'
# STATIC_DIR = 'static'
# HEADER_IMAGE = 'static/header.jpg'
# THEME = "default"
class Config:
MAIN_PAGE_TITLE = "microgen library"
APP_NAME = "hydrogen"
APP_DESCRIPTION = "Simplistic static site generator"
APP_SRC_URL = f"https://git.exocortex.ru/Exocortex/{APP_NAME}"
OUTPUT_DIR = 'public'
TEMPLATES_DIR = 'templates'
CONTENT_DIR = 'content'
STATIC_DIR = 'static'
HEADER_IMAGE = 'static/header.jpg'
THEME = "default"
def __init__(self, config_path="config.yml"):
self.app_name = "microgen"
self.app_description = "Simplistic static site generator"
self.app_src_url = f"https://git.exocortex.ru/Exocortex/{self.app_name}"
self.content_dir = 'content'
self.templates_dir = 'templates'
self.static_dir = 'static'
self.output_dir = 'public'
self.header_image = 'static/header.jpg'
self.site_name = "microgen library"
self.theme = "default"
if os.path.isfile (config_path):
with open(config_path, "r") as f:
config = yaml.safe_load(f)
if config:
self.update_from_dict(config)
def update_from_dict(self, config_dict):
for key, value in config_dict.items():
setattr(self, key, value)
def __repr__(self):
return f"{self.__dict__}"
config = Config()