Några fixar för enklare publicering

This commit is contained in:
2017-03-22 20:16:45 +01:00
parent f93b9659a1
commit 65b283168b
4 changed files with 13 additions and 4 deletions

View File

@@ -46,7 +46,7 @@ def thumbnails(category, num=0):
catdir = pages + '/' + category
thumbdir = catdir + '/thumbnails'
if not os.path.isfile('%s/%d.jpg' % (thumbdir, num)):
images = sorted([x for x in next(os.walk(catdir))[2] if x.endswith('.jpg')])
images = sorted([x for x in next(os.walk(catdir))[2] if x.endswith('.jpg')], key=lambda x: x.lower())
if not os.path.exists(thumbdir):
os.makedirs(thumbdir)
imgin = '%s/%s' % (catdir, images[num])
@@ -59,7 +59,7 @@ def slides(category, num=0):
catdir = pages + '/' + category
thumbdir = catdir + '/slides'
if not os.path.isfile('%s/%d.jpg' % (thumbdir, num)):
images = sorted([x for x in next(os.walk(catdir))[2] if x.endswith('.jpg')])
images = sorted([x for x in next(os.walk(catdir))[2] if x.endswith('.jpg')], key=lambda x: x.lower())
imgin = '%s/%s' % (catdir, images[num])
imgout = '%s/%d.jpg' % (thumbdir, num)
if not os.path.exists(thumbdir):
@@ -71,7 +71,7 @@ def slides(category, num=0):
@app.route('/<category>/<int:num>.jpg')
def cat_photo(category, num):
directory = pages + '/' + category
images = sorted([x for x in next(os.walk(directory))[2] if x.endswith('.jpg')])
images = sorted([x for x in next(os.walk(directory))[2] if x.endswith('.jpg')], key=lambda x: x.lower())
try:
return send_from_directory(directory, images[num]);
except IndexError: