From 3376385a17f6b82e5ba5f11aa52b5663abaa461f Mon Sep 17 00:00:00 2001 From: Flo Greistorfer Date: Tue, 9 Jul 2024 15:20:01 +0200 Subject: [PATCH] fixed img size (in newer browsers fuck you if you use outdated software, i use arch btw) --- builder.py | 25 +++++++++++++++++++------ files/global.css | 4 +++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/builder.py b/builder.py index e6c9f21..42046dc 100755 --- a/builder.py +++ b/builder.py @@ -135,7 +135,9 @@ def webmanifest(_args: Args) -> None: files = os.listdir(os.path.join(STATIC_FILES_DIR, "icons")) if svgsupport and any(file.endswith(".svg") for file in files): svg = [file for file in files if file.endswith(".svg")][0] - icons.append({"src": f"{_args.web_root_url}.static/icons/{svg}", "type": "image/svg+xml", "sizes": "512x512", "purpose": "maskable"}) + icons.append( + {"src": f"{_args.web_root_url}.static/icons/{svg}", "type": "image/svg+xml", "sizes": "512x512", "purpose": "maskable"} + ) icons.append({"src": f"{_args.web_root_url}.static/icons/{svg}", "type": "image/svg+xml", "sizes": "512x512", "purpose": "any"}) for size in ICON_SIZES: tmpimg = BytesIO() @@ -172,7 +174,9 @@ def webmanifest(_args: Args) -> None: continue with Image.open(os.path.join(STATIC_FILES_DIR, "icons", icon)) as iconfile: iconsize = f"{iconfile.size[0]}x{iconfile.size[1]}" - icons.append({"src": f"{_args.web_root_url}.static/icons/{icon}", "sizes": iconsize, "type": "image/png", "purpose": "maskable"}) + icons.append( + {"src": f"{_args.web_root_url}.static/icons/{icon}", "sizes": iconsize, "type": "image/png", "purpose": "maskable"} + ) icons.append({"src": f"{_args.web_root_url}.static/icons/{icon}", "sizes": iconsize, "type": "image/png", "purpose": "any"}) if len(icons) == 0: print("No icons found in the static/icons folder!") @@ -180,8 +184,12 @@ def webmanifest(_args: Args) -> None: with open(os.path.join(_args.root_directory, ".static", "theme.css")) as f: content = f.read() - background_color = content.replace("body{", "body {").split("body {")[1].split("}")[0].split("background-color:")[1].split(";")[0].strip() - theme_color = content.replace(".navbar{", "navbar {").split(".navbar {")[1].split("}")[0].split("background-color:")[1].split(";")[0].strip() + background_color = ( + content.replace("body{", "body {").split("body {")[1].split("}")[0].split("background-color:")[1].split(";")[0].strip() + ) + theme_color = ( + content.replace(".navbar{", "navbar {").split(".navbar {")[1].split("}")[0].split("background-color:")[1].split(";")[0].strip() + ) with open(os.path.join(_args.root_directory, ".static", "manifest.json"), "w", encoding="utf-8") as f: manifest = env.get_template("manifest.json.j2") content = manifest.render( @@ -305,7 +313,8 @@ def list_folder(folder: str, title: str) -> None: if not args.non_interactive_mode: pbardict[folder].update(1) pbar.update(0) - pbardict[folder].close() + if not args.non_interactive_mode: + pbardict[folder].close() sizelistfile.seek(0) sizelistfile.write(json.dumps(sizelist, indent=4)) sizelistfile.truncate() @@ -316,7 +325,11 @@ def list_folder(folder: str, title: str) -> None: with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f: _info: List[str] = None header = os.path.basename(folder) or title - parent = None if not foldername else f"{args.web_root_url}{urllib.parse.quote(foldername.removesuffix(folder.split('/')[-1] + '/'))}" + parent = ( + None + if not foldername + else f"{args.web_root_url}{urllib.parse.quote(foldername.removesuffix(folder.split('/')[-1] + '/'))}" + ) license_info: cclicense.License = ( { "project": args.site_title, diff --git a/files/global.css b/files/global.css index b79122a..e82e61e 100644 --- a/files/global.css +++ b/files/global.css @@ -149,6 +149,8 @@ figure { margin-top: 20px; vertical-align: middle; width: 100%; + aspect-ratio: 1 / 1; + object-fit: contain; } /* Responsive layout - makes a four column-layout instead of eight columns */ @@ -215,4 +217,4 @@ figure { .navbar { font-size: smaller; } -} \ No newline at end of file +}