wip: implement page
This commit is contained in:
16
src/main.py
16
src/main.py
@ -6,6 +6,8 @@ from path import Path
|
||||
from picture import Picture
|
||||
from bulk_page import BulkPage
|
||||
from bulk_category import BulkCategory
|
||||
from page import Page
|
||||
|
||||
import argparse
|
||||
import config
|
||||
|
||||
@ -21,7 +23,7 @@ def argument_parsing():
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
def scan_pages(folders: list[Path]) -> list[BulkPage]:
|
||||
def scan_bulk_pages(folders: list[Path]) -> list[BulkPage]:
|
||||
pages: list[BulkPage] = []
|
||||
prev: BulkPage = None
|
||||
with Bar("Scanning Pages...", max=len(folders)) as bar:
|
||||
@ -81,7 +83,7 @@ def create_categories(categories: list[BulkCategory]) -> None:
|
||||
def gen_bulk(bulk_path: Path):
|
||||
category_path: Path = Path(bulk_path, "categories")
|
||||
|
||||
pages: list[BulkPage] = scan_pages(bulk_path.get_dirs())
|
||||
pages: list[BulkPage] = scan_bulk_pages(bulk_path.get_dirs())
|
||||
categories: list[BulkCategory] = scan_categories(pages, category_path)
|
||||
|
||||
if config.CREATE_GENERAL_CATEGORY:
|
||||
@ -97,9 +99,16 @@ def gen_bulk(bulk_path: Path):
|
||||
category_path.create()
|
||||
create_categories(categories)
|
||||
|
||||
def scan_pages(site_path: Path):
|
||||
for path in [f for f in site_path.get_files() if f.get_name().endswith(config.PAGE_EXT)]:
|
||||
page: Page = Page(path)
|
||||
page.create()
|
||||
|
||||
def gen_pages(site_path: Path):
|
||||
scan_pages(site_path)
|
||||
|
||||
def regen(bulk_path: Path, is_thumb: bool, is_small: bool):
|
||||
pages: list[BulkPage] = scan_pages(bulk_path.get_dirs())
|
||||
pages: list[BulkPage] = scan_bulk_pages(bulk_path.get_dirs())
|
||||
with Bar("Regenerating assets...", max=len(pages)) as bar:
|
||||
for page in pages:
|
||||
for picture in page.get_pictures():
|
||||
@ -124,6 +133,7 @@ def main():
|
||||
if args.regen is not None:
|
||||
regen(bulk_path, 't' in args.regen, 's' in args.regen)
|
||||
gen_bulk(bulk_path)
|
||||
gen_pages(site_path)
|
||||
gen_home(site_path)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user