mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
if no images default apache
This commit is contained in:
@@ -151,49 +151,50 @@ def listfolder(folder: str, title: str):
|
|||||||
if not os.path.exists(os.path.join(args.root, ".previews", folder.removeprefix(args.root))):
|
if not os.path.exists(os.path.join(args.root, ".previews", folder.removeprefix(args.root))):
|
||||||
os.mkdir(os.path.join(args.root, ".previews", folder.removeprefix(args.root)))
|
os.mkdir(os.path.join(args.root, ".previews", folder.removeprefix(args.root)))
|
||||||
|
|
||||||
with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f:
|
temp_obj = Template(HTMLHEADER)
|
||||||
temp_obj = Template(HTMLHEADER)
|
for item in items:
|
||||||
f.write(temp_obj.substitute(title=title))
|
if item != "Galleries" and item != ".previews":
|
||||||
for item in items:
|
if os.path.isdir(os.path.join(folder, item)):
|
||||||
if item != "Galleries" and item != ".previews":
|
subfolders.extend([f'<figure><a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(item)}"><img src="{args.foldericon}" alt="Folder icon"/></a><figcaption><a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(item)}">{item}</a></figcaption></figure>'])
|
||||||
if os.path.isdir(os.path.join(folder, item)):
|
listfolder(os.path.join(folder, item), item)
|
||||||
subfolders.extend([f'<figure><a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(item)}"><img src="{args.foldericon}" alt="Folder icon"/></a><figcaption><a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(item)}">{item}</a></figcaption></figure>'])
|
else:
|
||||||
listfolder(os.path.join(folder, item), item)
|
if os.path.splitext(item)[1].lower() in imgext:
|
||||||
else:
|
image = f'<figure><a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(item)}"><img src="{args.webroot}.previews/{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(item)}" alt="{item}"/></a><figcaption class="caption">{item}'
|
||||||
if os.path.splitext(item)[1].lower() in imgext:
|
if not os.path.exists(os.path.join(args.root, ".previews", folder.removeprefix(args.root), item)):
|
||||||
image = f'<figure><a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(item)}"><img src="{args.webroot}.previews/{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(item)}" alt="{item}"/></a><figcaption class="caption">{item}'
|
thumbnails.append((folder, item))
|
||||||
if not os.path.exists(os.path.join(args.root, ".previews", folder.removeprefix(args.root), item)):
|
for raw in rawext:
|
||||||
thumbnails.append((folder, item))
|
if os.path.exists(os.path.join(folder, os.path.splitext(item)[0] + raw)):
|
||||||
for raw in rawext:
|
if raw == ".tif" or raw == ".tiff":
|
||||||
if os.path.exists(os.path.join(folder, os.path.splitext(item)[0] + raw)):
|
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw}">TIFF</a>'
|
||||||
if raw == ".tif" or raw == ".tiff":
|
else:
|
||||||
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw}">TIFF</a>'
|
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw}">RAW</a>'
|
||||||
else:
|
elif os.path.exists(os.path.join(folder, os.path.splitext(item)[0] + raw.upper())):
|
||||||
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw}">RAW</a>'
|
if raw == ".tif" or raw == ".tiff":
|
||||||
elif os.path.exists(os.path.join(folder, os.path.splitext(item)[0] + raw.upper())):
|
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw}">TIFF</a>'
|
||||||
if raw == ".tif" or raw == ".tiff":
|
else:
|
||||||
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw}">TIFF</a>'
|
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw}">RAW</a>'
|
||||||
else:
|
image += "</figcaption></figure>"
|
||||||
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw}">RAW</a>'
|
images.extend([image])
|
||||||
image += "</figcaption></figure>"
|
if len(images) > 0:
|
||||||
images.extend([image])
|
with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f:
|
||||||
f.write(' <div class="header">\n')
|
f.write(temp_obj.substitute(title=title))
|
||||||
f.write(f" <h1>{title}</h1>\n")
|
f.write(' <div class="header">\n')
|
||||||
f.write(' <div class="folders">\n')
|
f.write(f" <h1>{title}</h1>\n")
|
||||||
for subfolder in subfolders:
|
f.write(' <div class="folders">\n')
|
||||||
f.write(subfolder)
|
for subfolder in subfolders:
|
||||||
f.write("\n")
|
f.write(subfolder)
|
||||||
f.write(" </div>\n")
|
f.write("\n")
|
||||||
f.write(" </div>\n")
|
|
||||||
f.write(' <div class="row">\n')
|
|
||||||
for chunk in np.array_split(images, 8):
|
|
||||||
f.write(' <div class="column">\n')
|
|
||||||
for image in chunk:
|
|
||||||
f.write(f" {image}\n")
|
|
||||||
f.write(" </div>\n")
|
f.write(" </div>\n")
|
||||||
f.write(" </div>\n")
|
f.write(" </div>\n")
|
||||||
f.write(" </body>\n</html>")
|
f.write(' <div class="row">\n')
|
||||||
f.close()
|
for chunk in np.array_split(images, 8):
|
||||||
|
f.write(' <div class="column">\n')
|
||||||
|
for image in chunk:
|
||||||
|
f.write(f" {image}\n")
|
||||||
|
f.write(" </div>\n")
|
||||||
|
f.write(" </div>\n")
|
||||||
|
f.write(" </body>\n</html>")
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user