From ec32c24af3ce16c52c52285dd6db8d0cadbd61d7 Mon Sep 17 00:00:00 2001 From: Flo Greistorfer Date: Tue, 21 Jan 2025 20:59:05 +0100 Subject: [PATCH] added logo --- .gitignore | 3 ++- .version | 2 +- builder.py | 17 +++++++++++++++-- files/global.css | 8 ++++++++ modules/generate_html.py | 17 +++++++++-------- templates/index.html.j2 | 4 ++-- 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 14e8f5c..cd0a4fb 100644 --- a/.gitignore +++ b/.gitignore @@ -167,4 +167,5 @@ test/**/index.html test/**/.sizelist.json test/manifest.json themes/previews -logs \ No newline at end of file +logs +.lock \ No newline at end of file diff --git a/.version b/.version index 6550da6..26f8b8b 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.4.3 \ No newline at end of file +2.4.5 \ No newline at end of file diff --git a/builder.py b/builder.py index cb6d13f..3b15d8b 100755 --- a/builder.py +++ b/builder.py @@ -5,6 +5,7 @@ import sys import shutil import fnmatch import urllib.parse +import urllib.request from multiprocessing import Pool, freeze_support from pathlib import Path @@ -200,6 +201,18 @@ def main() -> None: try: Path(lock_file).touch() logger.info("starting builder", extra={"version": VERSION}) + + req = urllib.request.Request("https://files.sorogon.eu/logo.svg") + with urllib.request.urlopen(req) as res: + logo = res.read().decode() + + if logo.startswith("", "", logo).strip() + if logo.startswith("", "", logo).strip() + logo = logo.replace("\n", " ") + logo = ' '.join(logo.split()) + if args.reread_metadata: logger.warning("reread metadata flag is set to true, all image metadata will be reread") if args.regenerate_thumbnails: @@ -219,7 +232,7 @@ def main() -> None: if args.non_interactive_mode: logger.info("generating HTML files") print("Generating HTML files...") - thumbnails = list_folder(0, args.root_directory, args.site_title, args, raw, VERSION) + thumbnails = list_folder(0, args.root_directory, args.site_title, args, raw, VERSION, logo) with Pool(os.cpu_count()) as pool: logger.info("generating thumbnails") print("Generating thumbnails...") @@ -232,7 +245,7 @@ def main() -> None: pbardict["traversingbar"].update(0) pbardict["traversingbar"].close() - thumbnails = list_folder(total, args.root_directory, args.site_title, args, raw, VERSION) + thumbnails = list_folder(total, args.root_directory, args.site_title, args, raw, VERSION, logo) with Pool(os.cpu_count()) as pool: logger.info("generating thumbnails") diff --git a/files/global.css b/files/global.css index c9e9d5e..bffe98f 100644 --- a/files/global.css +++ b/files/global.css @@ -175,6 +175,14 @@ figure { cursor: pointer; } +.attribution svg { + height: calc(6.75pt + 12px); + width: fit-content; + position: relative; + bottom: -8px; + right: 0px; +} + #totop { display: none; position: fixed; diff --git a/modules/generate_html.py b/modules/generate_html.py index d575449..25f3de9 100644 --- a/modules/generate_html.py +++ b/modules/generate_html.py @@ -181,7 +181,7 @@ def process_image(item: str, folder: str, _args: Args, baseurl: str, sizelist: d return image -def generate_html(folder: str, title: str, _args: Args, raw: list[str], version: str) -> None: +def generate_html(folder: str, title: str, _args: Args, raw: list[str], version: str, logo) -> None: """ Generates HTML content for a folder of images. @@ -215,7 +215,7 @@ def generate_html(folder: str, title: str, _args: Args, raw: list[str], version: for item in items: if item not in EXCLUDES and not item.startswith("."): if os.path.isdir(os.path.join(folder, item)): - process_subfolder(item, folder, baseurl, subfolders, _args, raw, version) + process_subfolder(item, folder, baseurl, subfolders, _args, raw, version, logo) else: contains_files = True if os.path.splitext(item)[1].lower() in _args.file_extensions: @@ -232,7 +232,7 @@ def generate_html(folder: str, title: str, _args: Args, raw: list[str], version: update_sizelist(sizelist, folder) if should_generate_html(images, contains_files, _args): - create_html_file(folder, title, foldername, images, subfolders, _args, version) + create_html_file(folder, title, foldername, images, subfolders, _args, version, logo) else: if os.path.exists(os.path.join(folder, "index.html")): logger.info("removing existing index.html", extra={"folder": folder}) @@ -256,7 +256,7 @@ def create_thumbnail_folder(foldername: str, root_directory: str) -> None: os.mkdir(thumbnails_path) -def process_subfolder(item: str, folder: str, baseurl: str, subfolders: list[dict[str, str]], _args: Args, raw: list[str], version: str) -> None: +def process_subfolder(item: str, folder: str, baseurl: str, subfolders: list[dict[str, str]], _args: Args, raw: list[str], version: str, logo: str) -> None: """ Processes a subfolder. @@ -272,7 +272,7 @@ def process_subfolder(item: str, folder: str, baseurl: str, subfolders: list[dic subfolders.append({"url": subfolder_url, "name": item}) if item not 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, version) + generate_html(os.path.join(folder, item), os.path.join(folder, item).removeprefix(_args.root_directory), _args, raw, version, logo) def process_info_file(folder: str, item: str) -> None: @@ -302,7 +302,7 @@ def should_generate_html(images: list[dict[str, Any]], contains_files, _args: Ar return images or (_args.use_fancy_folders and not contains_files) or (_args.use_fancy_folders and _args.ignore_other_files) -def create_html_file(folder: str, title: str, foldername: str, images: list[dict[str, Any]], subfolders: list[dict[str, str]], _args: Args, version: str) -> None: +def create_html_file(folder: str, title: str, foldername: str, images: list[dict[str, Any]], subfolders: list[dict[str, str]], _args: Args, version: str, logo: str) -> None: """ Creates the HTML file using the template. @@ -353,6 +353,7 @@ def create_html_file(folder: str, title: str, foldername: str, images: list[dict info=_info, webmanifest=_args.generate_webmanifest, version=version, + logo=logo, ) with open(html_file, "w", encoding="utf-8") as f: @@ -360,7 +361,7 @@ def create_html_file(folder: str, title: str, foldername: str, images: list[dict f.write(content) -def list_folder(total: int, folder: str, title: str, _args: Args, raw: list[str], version: str) -> list[tuple[str, str]]: +def list_folder(total: int, folder: str, title: str, _args: Args, raw: list[str], version: str, logo: str) -> list[tuple[str, str]]: """ lists and processes a folder, generating HTML files. @@ -376,5 +377,5 @@ def list_folder(total: int, folder: str, title: str, _args: Args, raw: list[str] """ if not _args.non_interactive_mode: pbardict["htmlbar"] = tqdm(total=total, desc="Generating HTML files", unit="folders", ascii=True, dynamic_ncols=True) - generate_html(folder, title, _args, raw, version) + generate_html(folder, title, _args, raw, version, logo) return thumbnails diff --git a/templates/index.html.j2 b/templates/index.html.j2 index 8223dc3..ea537ad 100644 --- a/templates/index.html.j2 +++ b/templates/index.html.j2 @@ -104,14 +104,14 @@ {%- endif %} Made with StaticGalleryBuilder {{ version }} by Flo Greistorfer. + href="https://github.com/greflm13" target="_blank" rel="noopener noreferrer">{{ logo }}. {%- endif %} {%- else %} {%- endif %}