diff --git a/.gitignore b/.gitignore
index 70ac818..6e9a005 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
pathlist.txt
thumbs/*
GenThumb.log
+index.html
diff --git a/GenTemplate.py b/GenTemplate.py
new file mode 100755
index 0000000..0204a88
--- /dev/null
+++ b/GenTemplate.py
@@ -0,0 +1,158 @@
+#!/usr/bin/env python3
+# GenThumb.py - Part of the simple s3 gallery
+# Usage: ./GenThumb.py
+
+from pathlib import Path
+
+baseuri = "https://s3.wasabisys.com/c0de-photography/"
+thumb_path = "./thumbs"
+
+template = """
+
+
+ Simple S3 Gallery
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+"""
+
+thumblist = list(Path(thumb_path).rglob("*.[jJ][pP][gG]"))
+
+with open('pathlist.txt', 'r') as pathlist:
+ with open('index.html', 'w') as index:
+ pathlist = "%s" % pathlist.read()
+ pathlist = pathlist.splitlines()
+ thumbrow = ""
+ for image in thumblist:
+ indices = [i for i, s in enumerate(pathlist) if image.name in s]
+ if len(indices) > 0:
+ imagename = "%s" % image
+ the_template = template2
+ the_template = the_template.replace("{{FULLLINK}}", pathlist[indices[0]])
+ the_template = the_template.replace("{{TITLE}}", imagename.strip("thumbs/"))
+ thumbrow += the_template.replace("{{THUMBNAIL}}", "%s" % image)
+ index.write(template.replace("{{THUMBROW}}", thumbrow))
+
diff --git a/GenThumb.py b/GenThumb.py
index d6f0b7f..6df8bfb 100755
--- a/GenThumb.py
+++ b/GenThumb.py
@@ -23,10 +23,7 @@ logging.info("Getting Paths (Can take time on large directories)")
filelist = list(Path(s3_path + browse_path).rglob("*.[jJ][pP][gG]"))
thumblist = list(Path(thumb_path).rglob("*.[jJ][pP][gG]"))
-def gen_thumb(image):
- imagepath = "%s" % image.parent
- imagepath = imagepath.strip(s3_path)
- pathlist.write(baseuri + imagepath + '/' + image.name)
+def gen_thumb(image, imagepath):
Path(thumb_path + '/' + imagepath).mkdir(mode=0o755, parents=True, exist_ok=True) # Generate the path if it doesn't already exist
thumbname = "%s/%s/%s" % (thumb_path, imagepath, image.name)
@@ -44,9 +41,12 @@ def gen_thumb(image):
with open('pathlist.txt', 'w') as pathlist:
for image in filelist:
+ imagepath = "%s" % image.parent
+ imagepath = imagepath.strip(s3_path)
+ pathlist.write(baseuri + imagepath + '/' + image.name + '\n')
try:
# WARNING: Each file found will become a thread! Be sure your computer can handle the load
- _thread.start_new_thread(gen_thumb, (image,))
+ _thread.start_new_thread(gen_thumb, (image, imagepath,))
time.sleep(0.15)
except:
logging.error("unable to start thread")