gallery: Sort by screenshots modification time
parent
04b7e0cb9b
commit
15719c20b5
|
@ -33,7 +33,8 @@ def get_images(path, extensions=None):
|
||||||
try:
|
try:
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
if os.path.splitext(f)[1] in extensions:
|
if os.path.splitext(f)[1] in extensions:
|
||||||
yield f
|
st = os.stat(os.path.join(path, f))
|
||||||
|
yield (st.st_mtime, f)
|
||||||
except OSError:
|
except OSError:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
||||||
|
@ -42,7 +43,8 @@ class GalleryController(milla.controllers.HTTPVerbController):
|
||||||
|
|
||||||
def GET(self, request):
|
def GET(self, request):
|
||||||
response = request.ResponseClass()
|
response = request.ResponseClass()
|
||||||
|
images = get_images(request.config['gallery.screenshot_dir'])
|
||||||
response.text = render(request, 'gallery.html.j2', {
|
response.text = render(request, 'gallery.html.j2', {
|
||||||
'images': get_images(request.config['gallery.screenshot_dir']),
|
'images': (i for m, i in sorted(images)),
|
||||||
})
|
})
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row small-up-1 medium-up-2 large-up-4">
|
<div class="row small-up-1 medium-up-2 large-up-4">
|
||||||
{% for image in images %}
|
{% for image in images|reverse %}
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<a href="{{ static('screenshots/' + image) }}">
|
<a href="{{ static('screenshots/' + image) }}">
|
||||||
<img class="thumbnail" src="{{ url('/thumbnails/' + image) }}"
|
<img class="thumbnail" src="{{ url('/thumbnails/' + image) }}"
|
||||||
|
|
Loading…
Reference in New Issue