Sort images before displaying list.

os.listdir returns a file list in inode order, not alphabtical.
master
q3k 2013-03-31 13:31:08 +02:00
parent a1e660fc12
commit c01410344c
1 changed files with 2 additions and 2 deletions

View File

@ -73,9 +73,9 @@ def send_thumb(tgt):
@app.route('/')
@app.route('/<path:tgt>')
def view(tgt=''):
try:
try:
path = abspath(safe_join(base, tgt))
names = map(lambda s: s.decode(app.config['CHARSET']), os.listdir(path))
names = map(lambda s: s.decode(app.config['CHARSET']), sorted(os.listdir(path)))
dirs = filter(lambda f: isdir(safe_join(path,f)), names)
pics = filter(is_image, names)
return render_template('main.html', dirs=dirs, pics=pics, path=tgt,