updates
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -169,4 +169,5 @@ cython_debug/
|
||||
#.idea/
|
||||
|
||||
public
|
||||
content/*
|
||||
content/*
|
||||
config.yml
|
||||
|
||||
19
config.py
19
config.py
@@ -14,7 +14,8 @@ import os, yaml
|
||||
# THEME = "default"
|
||||
|
||||
class Config:
|
||||
def __init__(self, config_path="config.yml"):
|
||||
def __init__(self):
|
||||
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}"
|
||||
@@ -23,13 +24,15 @@ class Config:
|
||||
self.static_dir = 'static'
|
||||
self.output_dir = 'public'
|
||||
self.header_image = 'static/header.jpg'
|
||||
self.site_name = "microgen library"
|
||||
self.site_name = f"{self.app_name} library"
|
||||
self.theme = "default"
|
||||
if os.path.isfile (config_path):
|
||||
with open(config_path, "r") as f:
|
||||
if os.path.isfile (self.config_path):
|
||||
with open(self.config_path, "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
if config:
|
||||
self.update_from_dict(config)
|
||||
else:
|
||||
self.create_default_config()
|
||||
|
||||
def update_from_dict(self, config_dict):
|
||||
for key, value in config_dict.items():
|
||||
@@ -38,4 +41,12 @@ class Config:
|
||||
def __repr__(self):
|
||||
return f"{self.__dict__}"
|
||||
|
||||
def create_default_config(self):
|
||||
defaults = {
|
||||
"site_name": self.site_name,
|
||||
"theme": "default"
|
||||
}
|
||||
with open(self.config_path, mode="w", encoding="utf-8") as f:
|
||||
yaml.safe_dump(defaults, f)
|
||||
|
||||
config = Config()
|
||||
@@ -0,0 +1,2 @@
|
||||
site_name: microgen library
|
||||
theme: default
|
||||
|
||||
Reference in New Issue
Block a user