mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
fixed img size (in newer browsers fuck you if you use outdated software, i use arch btw)
This commit is contained in:
25
builder.py
25
builder.py
@@ -135,7 +135,9 @@ def webmanifest(_args: Args) -> None:
|
|||||||
files = os.listdir(os.path.join(STATIC_FILES_DIR, "icons"))
|
files = os.listdir(os.path.join(STATIC_FILES_DIR, "icons"))
|
||||||
if svgsupport and any(file.endswith(".svg") for file in files):
|
if svgsupport and any(file.endswith(".svg") for file in files):
|
||||||
svg = [file for file in files if file.endswith(".svg")][0]
|
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"})
|
icons.append({"src": f"{_args.web_root_url}.static/icons/{svg}", "type": "image/svg+xml", "sizes": "512x512", "purpose": "any"})
|
||||||
for size in ICON_SIZES:
|
for size in ICON_SIZES:
|
||||||
tmpimg = BytesIO()
|
tmpimg = BytesIO()
|
||||||
@@ -172,7 +174,9 @@ def webmanifest(_args: Args) -> None:
|
|||||||
continue
|
continue
|
||||||
with Image.open(os.path.join(STATIC_FILES_DIR, "icons", icon)) as iconfile:
|
with Image.open(os.path.join(STATIC_FILES_DIR, "icons", icon)) as iconfile:
|
||||||
iconsize = f"{iconfile.size[0]}x{iconfile.size[1]}"
|
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"})
|
icons.append({"src": f"{_args.web_root_url}.static/icons/{icon}", "sizes": iconsize, "type": "image/png", "purpose": "any"})
|
||||||
if len(icons) == 0:
|
if len(icons) == 0:
|
||||||
print("No icons found in the static/icons folder!")
|
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:
|
with open(os.path.join(_args.root_directory, ".static", "theme.css")) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
background_color = content.replace("body{", "body {").split("body {")[1].split("}")[0].split("background-color:")[1].split(";")[0].strip()
|
background_color = (
|
||||||
theme_color = content.replace(".navbar{", "navbar {").split(".navbar {")[1].split("}")[0].split("background-color:")[1].split(";")[0].strip()
|
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:
|
with open(os.path.join(_args.root_directory, ".static", "manifest.json"), "w", encoding="utf-8") as f:
|
||||||
manifest = env.get_template("manifest.json.j2")
|
manifest = env.get_template("manifest.json.j2")
|
||||||
content = manifest.render(
|
content = manifest.render(
|
||||||
@@ -305,7 +313,8 @@ def list_folder(folder: str, title: str) -> None:
|
|||||||
if not args.non_interactive_mode:
|
if not args.non_interactive_mode:
|
||||||
pbardict[folder].update(1)
|
pbardict[folder].update(1)
|
||||||
pbar.update(0)
|
pbar.update(0)
|
||||||
pbardict[folder].close()
|
if not args.non_interactive_mode:
|
||||||
|
pbardict[folder].close()
|
||||||
sizelistfile.seek(0)
|
sizelistfile.seek(0)
|
||||||
sizelistfile.write(json.dumps(sizelist, indent=4))
|
sizelistfile.write(json.dumps(sizelist, indent=4))
|
||||||
sizelistfile.truncate()
|
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:
|
with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f:
|
||||||
_info: List[str] = None
|
_info: List[str] = None
|
||||||
header = os.path.basename(folder) or title
|
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 = (
|
license_info: cclicense.License = (
|
||||||
{
|
{
|
||||||
"project": args.site_title,
|
"project": args.site_title,
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ figure {
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
aspect-ratio: 1 / 1;
|
||||||
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive layout - makes a four column-layout instead of eight columns */
|
/* Responsive layout - makes a four column-layout instead of eight columns */
|
||||||
|
|||||||
Reference in New Issue
Block a user