mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 02:59:27 +00:00
whoopsie
This commit is contained in:
@@ -192,7 +192,7 @@ def main() -> None:
|
|||||||
|
|
||||||
if args.non_interactive_mode:
|
if args.non_interactive_mode:
|
||||||
print("Generating HTML files...")
|
print("Generating HTML files...")
|
||||||
thumbnails = list_folder(0, args.root_directory, args.site_title, args, raw)
|
thumbnails = list_folder(0, args.root_directory, args.site_title, args, raw, VERSION)
|
||||||
with Pool(os.cpu_count()) as pool:
|
with Pool(os.cpu_count()) as pool:
|
||||||
print("Generating thumbnails...")
|
print("Generating thumbnails...")
|
||||||
pool.map(generate_thumbnail, thumbnails)
|
pool.map(generate_thumbnail, thumbnails)
|
||||||
@@ -203,7 +203,7 @@ def main() -> None:
|
|||||||
pbardict["traversingbar"].update(0)
|
pbardict["traversingbar"].update(0)
|
||||||
pbardict["traversingbar"].close()
|
pbardict["traversingbar"].close()
|
||||||
|
|
||||||
thumbnails = list_folder(total, args.root_directory, args.site_title, args, raw)
|
thumbnails = list_folder(total, args.root_directory, args.site_title, args, raw, VERSION)
|
||||||
|
|
||||||
with Pool(os.cpu_count()) as pool:
|
with Pool(os.cpu_count()) as pool:
|
||||||
for _ in tqdm(
|
for _ in tqdm(
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from jinja2 import Environment, FileSystemLoader
|
|||||||
|
|
||||||
import modules.cclicense as cclicense
|
import modules.cclicense as cclicense
|
||||||
from modules.argumentparser import Args
|
from modules.argumentparser import Args
|
||||||
from builder import VERSION
|
|
||||||
|
|
||||||
# Constants for file paths and exclusions
|
# Constants for file paths and exclusions
|
||||||
FAVICON_PATH = ".static/favicon.ico"
|
FAVICON_PATH = ".static/favicon.ico"
|
||||||
@@ -130,7 +129,7 @@ def process_image(item: str, folder: str, _args: Args, baseurl: str, sizelist: D
|
|||||||
return image
|
return image
|
||||||
|
|
||||||
|
|
||||||
def generate_html(folder: str, title: str, _args: Args, raw: List[str]) -> None:
|
def generate_html(folder: str, title: str, _args: Args, raw: List[str], version: str) -> None:
|
||||||
"""
|
"""
|
||||||
Generates HTML content for a folder of images.
|
Generates HTML content for a folder of images.
|
||||||
|
|
||||||
@@ -158,7 +157,7 @@ def generate_html(folder: str, title: str, _args: Args, raw: List[str]) -> None:
|
|||||||
for item in items:
|
for item in items:
|
||||||
if item not in EXCLUDES:
|
if item not in EXCLUDES:
|
||||||
if os.path.isdir(os.path.join(folder, item)):
|
if os.path.isdir(os.path.join(folder, item)):
|
||||||
process_subfolder(item, folder, baseurl, subfolders, _args, raw)
|
process_subfolder(item, folder, baseurl, subfolders, _args, raw, version)
|
||||||
else:
|
else:
|
||||||
contains_files = True
|
contains_files = True
|
||||||
if os.path.splitext(item)[1].lower() in _args.file_extensions:
|
if os.path.splitext(item)[1].lower() in _args.file_extensions:
|
||||||
@@ -175,7 +174,7 @@ def generate_html(folder: str, title: str, _args: Args, raw: List[str]) -> None:
|
|||||||
update_sizelist(sizelist, folder)
|
update_sizelist(sizelist, folder)
|
||||||
|
|
||||||
if should_generate_html(images, contains_files, _args):
|
if should_generate_html(images, contains_files, _args):
|
||||||
create_html_file(folder, title, foldername, images, subfolders, _args)
|
create_html_file(folder, title, foldername, images, subfolders, _args, version)
|
||||||
else:
|
else:
|
||||||
if os.path.exists(os.path.join(folder, "index.html")):
|
if os.path.exists(os.path.join(folder, "index.html")):
|
||||||
os.remove(os.path.join(folder, "index.html"))
|
os.remove(os.path.join(folder, "index.html"))
|
||||||
@@ -197,7 +196,9 @@ def create_thumbnail_folder(foldername: str, root_directory: str) -> None:
|
|||||||
os.mkdir(thumbnails_path)
|
os.mkdir(thumbnails_path)
|
||||||
|
|
||||||
|
|
||||||
def process_subfolder(item: str, folder: str, baseurl: str, subfolders: List[Dict[str, str]], _args: Args, raw: List[str]) -> None:
|
def process_subfolder(
|
||||||
|
item: str, folder: str, baseurl: str, subfolders: List[Dict[str, str]], _args: Args, raw: List[str], version: str
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Processes a subfolder.
|
Processes a subfolder.
|
||||||
|
|
||||||
@@ -217,7 +218,7 @@ def process_subfolder(item: str, folder: str, baseurl: str, subfolders: List[Dic
|
|||||||
subfolders.append({"url": subfolder_url, "name": item})
|
subfolders.append({"url": subfolder_url, "name": item})
|
||||||
if item not in _args.exclude_folders:
|
if item not in _args.exclude_folders:
|
||||||
if not any(fnmatch.fnmatchcase(os.path.join(folder, item), exclude) for exclude in _args.exclude_folders):
|
if not any(fnmatch.fnmatchcase(os.path.join(folder, item), exclude) for exclude in _args.exclude_folders):
|
||||||
generate_html(os.path.join(folder, item), os.path.join(folder, item).removeprefix(_args.root_directory), _args, raw)
|
generate_html(os.path.join(folder, item), os.path.join(folder, item).removeprefix(_args.root_directory), _args, raw, version)
|
||||||
|
|
||||||
|
|
||||||
def process_info_file(folder: str, item: str) -> None:
|
def process_info_file(folder: str, item: str) -> None:
|
||||||
@@ -247,7 +248,7 @@ def should_generate_html(images: List[Dict[str, Any]], contains_files, _args: Ar
|
|||||||
|
|
||||||
|
|
||||||
def create_html_file(
|
def create_html_file(
|
||||||
folder: str, title: str, foldername: str, images: List[Dict[str, Any]], subfolders: List[Dict[str, str]], _args: Args
|
folder: str, title: str, foldername: str, images: List[Dict[str, Any]], subfolders: List[Dict[str, str]], _args: Args, version: str
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Creates the HTML file using the template.
|
Creates the HTML file using the template.
|
||||||
@@ -296,14 +297,14 @@ def create_html_file(
|
|||||||
info=_info,
|
info=_info,
|
||||||
allimages=images,
|
allimages=images,
|
||||||
webmanifest=_args.generate_webmanifest,
|
webmanifest=_args.generate_webmanifest,
|
||||||
version=VERSION,
|
version=version,
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f:
|
with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
|
|
||||||
def list_folder(total: int, folder: str, title: str, _args: Args, raw: List[str]) -> List[Tuple[str, str]]:
|
def list_folder(total: int, folder: str, title: str, _args: Args, raw: List[str], version: str) -> List[Tuple[str, str]]:
|
||||||
"""
|
"""
|
||||||
Lists and processes a folder, generating HTML files.
|
Lists and processes a folder, generating HTML files.
|
||||||
|
|
||||||
@@ -319,5 +320,5 @@ def list_folder(total: int, folder: str, title: str, _args: Args, raw: List[str]
|
|||||||
"""
|
"""
|
||||||
if not _args.non_interactive_mode:
|
if not _args.non_interactive_mode:
|
||||||
pbardict["htmlbar"] = tqdm(total=total, desc="Generating HTML files", unit="folders", ascii=True, dynamic_ncols=True)
|
pbardict["htmlbar"] = tqdm(total=total, desc="Generating HTML files", unit="folders", ascii=True, dynamic_ncols=True)
|
||||||
generate_html(folder, title, _args, raw)
|
generate_html(folder, title, _args, raw, version)
|
||||||
return thumbnails
|
return thumbnails
|
||||||
|
|||||||
Reference in New Issue
Block a user