add: home page

This commit is contained in:
Starnakin 2025-05-06 23:00:11 +02:00
parent 6d1661131f
commit 26c60c5216
2 changed files with 21 additions and 2 deletions

View File

@ -9,6 +9,11 @@ from bulk_album import BulkAlbum
import argparse import argparse
import config import config
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('src/templates'))
home_template = env.get_template('home.jinja')
def argument_parsing(): def argument_parsing():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("site_path", help="the folder of your site MUST BE ALWAYS BEFORT PARAMETERS", type=str) 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) create_albums(albums)
def regen(bulk_path: Path, is_thumb: bool, is_small: bool): def regen(bulk_path: Path, is_thumb: bool, is_small: bool):
for page in scan_pages(bulk_path.get_dirs()): for page in scan_pages(bulk_path.get_dirs()):
for picture in page.get_pictures(): for picture in page.get_pictures():
@ -102,14 +106,22 @@ def regen(bulk_path: Path, is_thumb: bool, is_small: bool):
if is_small: if is_small:
picture.gen_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(): def main():
args = argument_parsing() 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: if args.regen is not None:
regen(bulk_path, 't' in args.regen, 's' in args.regen) regen(bulk_path, 't' in args.regen, 's' in args.regen)
gen_bulk(bulk_path) gen_bulk(bulk_path)
gen_home(site_path)
if __name__ == "__main__": if __name__ == "__main__":

7
src/templates/home.jinja Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<body>
<a href="/bulk/"><h1>Site WIP go to BULK</h1></a>
</body>
</html>