modularizing

This commit is contained in:
David Todd 2019-04-09 02:37:57 -05:00
parent 7daea2b93a
commit e4c83f67c4
3 changed files with 11 additions and 10 deletions

4
.gitignore vendored
View File

@ -1,4 +1,4 @@
pathlist.txt
pathlist*.txt
thumbs/*
GenThumb.log
index.html
index*.html

View File

@ -6,6 +6,7 @@ from pathlib import Path
baseuri = "https://s3.wasabisys.com/c0de-photography/"
thumb_path = "./thumbs"
pathlist_file = "pathlist_EOS 30D:10.03.2015 - Jay Cooke:.txt" # Index file created by GenThumb.py
template = """
<html>
@ -80,7 +81,7 @@ template = """
<div class="container d-flex justify-content-between">
<a href="#" class="navbar-brand d-flex align-items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" class="mr-2" viewBox="0 0 24 24" focusable="false"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
<strong>Album</strong>
<strong>Simple S3 Gallery</strong>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -117,7 +118,7 @@ template = """
<footer class="text-muted">
<div class="container">
<p class="float-right"><a href="#">Back to top</a></p>
<p>Simple S3 Gallery &copy; 2019 <a href="https://c0defox.es">David Todd</a></p>
<p>Simple S3 Gallery &copy; 2019 <a href="https://c0defox.es">David Todd</a> - All photos are &copy; <a href="https://dtodd.us">David Todd</a></p>
</div>
</footer>
@ -125,7 +126,7 @@ template = """
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html
</html>
"""
template2 = """
@ -141,8 +142,8 @@ template2 = """
thumblist = list(Path(thumb_path).rglob("*.[jJ][pP][gG]"))
with open('pathlist.txt', 'r') as pathlist:
with open('index.html', 'w') as index:
with open(pathlist_file, 'r') as pathlist:
with open('index_%s.html' % pathlist_file.strip("pathlist_").strip(".txt"), 'w') as index:
pathlist = "%s" % pathlist.read()
pathlist = pathlist.splitlines()
thumbrow = ""

View File

@ -15,7 +15,7 @@ logging.info("---------------")
baseuri = "https://s3.wasabisys.com/c0de-photography/"
s3_path = "/mnt/photos/"
browse_path = "EOS M100/"
browse_path = "EOS 30D/MFF 2016"
thumb_path = "./thumbs"
thumbsize = (250, 250)
@ -35,14 +35,14 @@ def gen_thumb(image, imagepath):
img = Image.open(image)
img.thumbnail(thumbsize)
img.save(thumbname)
img.close(image) # So we're not wasting memory when the threads wait to get closed
logging.info("Saved Thumbnail as %s" % thumbname)
with open('pathlist.txt', 'w') as pathlist:
with open('pathlist_%s.txt' % browse_path.replace('/', ':'), 'w') as pathlist:
for image in filelist:
imagepath = "%s" % image.parent
imagepath = imagepath.strip(s3_path)
# The pathlist file is used by GenTemplate.py to generate a specific gallery for a specific directory and its children
pathlist.write(baseuri + imagepath + '/' + image.name + '\n')
try:
# WARNING: Each file found will become a thread! Be sure your computer can handle the load