diff --git a/src/main.py b/src/main.py index f930767..101eeb0 100644 --- a/src/main.py +++ b/src/main.py @@ -9,6 +9,11 @@ from bulk_album import BulkAlbum import argparse import config +from jinja2 import Environment, FileSystemLoader + +env = Environment(loader=FileSystemLoader('src/templates')) +home_template = env.get_template('home.jinja') + def argument_parsing(): parser = argparse.ArgumentParser() parser.add_argument("site_path", help="the folder of your site MUST BE ALWAYS BEFORT PARAMETERS", type=str) @@ -93,7 +98,6 @@ def gen_bulk(bulk_path: Path): create_albums(albums) - def regen(bulk_path: Path, is_thumb: bool, is_small: bool): for page in scan_pages(bulk_path.get_dirs()): for picture in page.get_pictures(): @@ -102,14 +106,22 @@ def regen(bulk_path: Path, is_thumb: bool, is_small: bool): if is_small: picture.gen_small() +def gen_home(site_path: Path) -> None: + home_path = Path(site_path, "index.html") + + with open(home_path.get_absolute_path(), "w") as f: + f.write(home_template.render()) + def main(): args = argument_parsing() - bulk_path: Path = Path(args.site_path, "bulk/") + site_path: Path = Path(args.site_path) + bulk_path: Path = Path(site_path, "bulk/") if args.regen is not None: regen(bulk_path, 't' in args.regen, 's' in args.regen) gen_bulk(bulk_path) + gen_home(site_path) if __name__ == "__main__": diff --git a/src/templates/home.jinja b/src/templates/home.jinja new file mode 100644 index 0000000..971ac41 --- /dev/null +++ b/src/templates/home.jinja @@ -0,0 +1,7 @@ + + +
+ +