add: use photodown to gen page

This commit is contained in:
2025-07-08 16:32:19 +02:00
parent 1563b3618a
commit cf9cd77bcf
4 changed files with 26 additions and 16 deletions

View File

@ -1,5 +1,3 @@
import sys
import os
from progress.bar import Bar
from path import Path
@ -7,6 +5,7 @@ from picture import Picture
from bulk_page import BulkPage
from bulk_category import BulkCategory
from page import Page
from photodown import Photodown
import argparse
import config
@ -80,12 +79,18 @@ def create_categories(categories: list[BulkCategory]) -> None:
category.create()
bar.next()
def gen_bulk(bulk_path: Path):
def gen_bulk(bulk_path: Path, markdown: Photodown):
category_path: Path = Path(bulk_path, "categories")
pages: list[BulkPage] = scan_bulk_pages(bulk_path.get_dirs())
categories: list[BulkCategory] = scan_categories(pages, category_path)
bulk: list[Picture] = []
for page in pages:
for picture in page.get_pictures():
bulk.append(picture)
markdown.add_bulk(bulk)
if config.CREATE_GENERAL_CATEGORY:
for category in categories:
if (category.name == "general"):
@ -99,13 +104,13 @@ def gen_bulk(bulk_path: Path):
category_path.create()
create_categories(categories)
def scan_pages(site_path: Path):
def scan_pages(site_path: Path, markdown: Photodown):
for path in [f for f in site_path.get_files() if f.get_name().endswith(config.PAGE_EXT)]:
page: Page = Page(path)
page: Page = Page(path, markdown)
page.create()
def gen_pages(site_path: Path):
scan_pages(site_path)
def gen_pages(site_path: Path, markdown: Photodown):
scan_pages(site_path, markdown)
def regen(bulk_path: Path, is_thumb: bool, is_small: bool):
pages: list[BulkPage] = scan_bulk_pages(bulk_path.get_dirs())
@ -132,8 +137,9 @@ def main():
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_pages(site_path)
markdown = Photodown()
gen_bulk(bulk_path, markdown)
gen_pages(site_path, markdown)
gen_home(site_path)