added logo

This commit is contained in:
2025-01-21 20:59:05 +01:00
committed by Flo Greistorfer
parent 122117f125
commit ec32c24af3
6 changed files with 37 additions and 14 deletions

3
.gitignore vendored
View File

@@ -167,4 +167,5 @@ test/**/index.html
test/**/.sizelist.json test/**/.sizelist.json
test/manifest.json test/manifest.json
themes/previews themes/previews
logs logs
.lock

View File

@@ -1 +1 @@
2.4.3 2.4.5

View File

@@ -5,6 +5,7 @@ import sys
import shutil import shutil
import fnmatch import fnmatch
import urllib.parse import urllib.parse
import urllib.request
from multiprocessing import Pool, freeze_support from multiprocessing import Pool, freeze_support
from pathlib import Path from pathlib import Path
@@ -200,6 +201,18 @@ def main() -> None:
try: try:
Path(lock_file).touch() Path(lock_file).touch()
logger.info("starting builder", extra={"version": VERSION}) 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("<?xml"):
logo = re.sub(r"<\?xml.+\?>", "", logo).strip()
if logo.startswith("<!--"):
logo = re.sub(r"<!--.+-->", "", logo).strip()
logo = logo.replace("\n", " ")
logo = ' '.join(logo.split())
if args.reread_metadata: if args.reread_metadata:
logger.warning("reread metadata flag is set to true, all image metadata will be reread") logger.warning("reread metadata flag is set to true, all image metadata will be reread")
if args.regenerate_thumbnails: if args.regenerate_thumbnails:
@@ -219,7 +232,7 @@ def main() -> None:
if args.non_interactive_mode: if args.non_interactive_mode:
logger.info("generating HTML files") logger.info("generating HTML files")
print("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: with Pool(os.cpu_count()) as pool:
logger.info("generating thumbnails") logger.info("generating thumbnails")
print("Generating thumbnails...") print("Generating thumbnails...")
@@ -232,7 +245,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, VERSION) thumbnails = list_folder(total, args.root_directory, args.site_title, args, raw, VERSION, logo)
with Pool(os.cpu_count()) as pool: with Pool(os.cpu_count()) as pool:
logger.info("generating thumbnails") logger.info("generating thumbnails")

View File

@@ -175,6 +175,14 @@ figure {
cursor: pointer; cursor: pointer;
} }
.attribution svg {
height: calc(6.75pt + 12px);
width: fit-content;
position: relative;
bottom: -8px;
right: 0px;
}
#totop { #totop {
display: none; display: none;
position: fixed; position: fixed;

View File

@@ -181,7 +181,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], 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. 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: for item in items:
if item not in EXCLUDES and not item.startswith("."): if item not in EXCLUDES and not item.startswith("."):
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, version) process_subfolder(item, folder, baseurl, subfolders, _args, raw, version, logo)
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:
@@ -232,7 +232,7 @@ def generate_html(folder: str, title: str, _args: Args, raw: list[str], version:
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, version) create_html_file(folder, title, foldername, images, subfolders, _args, version, logo)
else: else:
if os.path.exists(os.path.join(folder, "index.html")): if os.path.exists(os.path.join(folder, "index.html")):
logger.info("removing existing index.html", extra={"folder": folder}) 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) 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. 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}) 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, 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: 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) 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. 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, info=_info,
webmanifest=_args.generate_webmanifest, webmanifest=_args.generate_webmanifest,
version=version, version=version,
logo=logo,
) )
with open(html_file, "w", encoding="utf-8") as f: 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) 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. 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: 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, version) generate_html(folder, title, _args, raw, version, logo)
return thumbnails return thumbnails

View File

@@ -104,14 +104,14 @@
</a> </a>
{%- endif %} {%- endif %}
<span class="attribution">Made with <a href="https://github.com/greflm13/StaticGalleryBuilder" target="_blank" rel="noopener noreferrer">StaticGalleryBuilder {{ version }}</a> by <a <span class="attribution">Made with <a href="https://github.com/greflm13/StaticGalleryBuilder" target="_blank" rel="noopener noreferrer">StaticGalleryBuilder {{ version }}</a> by <a
href="https://github.com/greflm13" target="_blank" rel="noopener noreferrer">Flo Greistorfer</a>.</span> href="https://github.com/greflm13" target="_blank" rel="noopener noreferrer">{{ logo }}</a>.</span>
<button onclick="topFunction()" id="totop" title="Back to Top">Back to Top</button> <button onclick="topFunction()" id="totop" title="Back to Top">Back to Top</button>
</div> </div>
{%- endif %} {%- endif %}
{%- else %} {%- else %}
<div class="footer"> <div class="footer">
<span class="attribution">Made with <a href="https://github.com/greflm13/StaticGalleryBuilder" target="_blank" rel="noopener noreferrer">StaticGalleryBuilder {{ version }}</a> by <a <span class="attribution">Made with <a href="https://github.com/greflm13/StaticGalleryBuilder" target="_blank" rel="noopener noreferrer">StaticGalleryBuilder {{ version }}</a> by <a
href="https://github.com/greflm13" target="_blank" rel="noopener noreferrer">Flo Greistorfer</a>.</span> href="https://github.com/greflm13" target="_blank" rel="noopener noreferrer">{{ logo }}</a>.</span>
<button onclick="topFunction()" id="totop" title="Back to Top">Back to Top</button> <button onclick="topFunction()" id="totop" title="Back to Top">Back to Top</button>
</div> </div>
{%- endif %} {%- endif %}