mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 02:59:27 +00:00
key check
This commit is contained in:
24
builder.py
24
builder.py
@@ -134,9 +134,7 @@ 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(
|
icons.append({"src": f"{_args.web_root_url}.static/icons/{svg}", "type": "image/svg+xml", "sizes": "512x512", "purpose": "maskable"})
|
||||||
{"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()
|
||||||
@@ -173,9 +171,7 @@ 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(
|
icons.append({"src": f"{_args.web_root_url}.static/icons/{icon}", "sizes": iconsize, "type": "image/png", "purpose": "maskable"})
|
||||||
{"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!")
|
||||||
@@ -183,12 +179,8 @@ 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 = (
|
background_color = content.replace("body{", "body {").split("body {")[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()
|
||||||
)
|
|
||||||
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(
|
||||||
@@ -283,7 +275,7 @@ def list_folder(folder: str, title: str) -> None:
|
|||||||
exifdata[ExifTags.TAGS[key]] = val
|
exifdata[ExifTags.TAGS[key]] = val
|
||||||
else:
|
else:
|
||||||
exifdata[key] = val
|
exifdata[key] = val
|
||||||
if exifdata != {} and (exifdata["Orientation"] == 6 or exifdata["Orientation"] == 8):
|
if "Orientation" in exifdata and (exifdata["Orientation"] == 6 or exifdata["Orientation"] == 8):
|
||||||
sizelist[item] = {"width": height, "height": width}
|
sizelist[item] = {"width": height, "height": width}
|
||||||
else:
|
else:
|
||||||
sizelist[item] = {"width": width, "height": height}
|
sizelist[item] = {"width": width, "height": height}
|
||||||
@@ -322,11 +314,7 @@ 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 = (
|
parent = None if not foldername else f"{args.web_root_url}{urllib.parse.quote(foldername.removesuffix(folder.split('/')[-1] + '/'))}"
|
||||||
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user