Added sorting of album posts

This commit is contained in:
Kevin F 2021-10-03 22:26:25 +00:00
parent 28d2d77c19
commit 3c34c366b1
3 changed files with 13 additions and 3 deletions

View File

@ -14,7 +14,7 @@
<ul> <ul>
<li><input type="checkbox" checked> Image proxying</li> <li><input type="checkbox" checked> Image proxying</li>
<li><input type="checkbox" checked> Gallery/album proxying</li> <li><input type="checkbox" checked> Gallery/album proxying</li>
<li><input type="checkbox"> Proper order of gallery posts</li> <li><input type="checkbox" checked> Proper order of gallery posts</li>
<li><input type="checkbox"> Image description and author info</li> <li><input type="checkbox"> Image description and author info</li>
<li><input type="checkbox"> Tor/SOCKS support for block circumvention</li> <li><input type="checkbox"> Tor/SOCKS support for block circumvention</li>
<li><input type="checkbox"> GIFs/videos (For now use youtube-dl)</li> <li><input type="checkbox"> GIFs/videos (For now use youtube-dl)</li>

View File

@ -2,7 +2,7 @@ from gevent import monkey
from gevent import sleep from gevent import sleep
monkey.patch_all() monkey.patch_all()
from threading import Thread from threading import Thread
from os import remove, mkdir, path from os import remove, mkdir, path, stat
from shutil import rmtree from shutil import rmtree
from glob import glob from glob import glob
@ -16,6 +16,9 @@ from .get import get
from .config import IMAGE_CACHE, SINGLE_IMAGE_DELETE_AFTER_SECS, ALBUM_DELETE_AFTER_SECS, template_dir from .config import IMAGE_CACHE, SINGLE_IMAGE_DELETE_AFTER_SECS, ALBUM_DELETE_AFTER_SECS, template_dir
def get_timestamp_of_file(file):
return stat(file).st_ctime
def album(id): def album(id):
req_id = str(uuid4()) req_id = str(uuid4())
req = IMAGE_CACHE req = IMAGE_CACHE
@ -23,8 +26,15 @@ def album(id):
get("/a/" + id, req) get("/a/" + id, req)
imgs = glob(req + "*") imgs = glob(req + "*")
# sort image order (file creation time)
imgs = sorted(imgs, key=get_timestamp_of_file)
for c, img in enumerate(imgs): for c, img in enumerate(imgs):
imgs[c] = img.replace(IMAGE_CACHE, '/') imgs[c] = img.replace(IMAGE_CACHE, '/')
with open(f'{template_dir}gallery.html', 'r') as img_view: with open(f'{template_dir}gallery.html', 'r') as img_view:
tpl = SimpleTemplate(img_view) tpl = SimpleTemplate(img_view)
return tpl.render(imgs=imgs) return tpl.render(imgs=imgs)

View File

@ -25,7 +25,7 @@
<ul> <ul>
<li><input type="checkbox" checked> Image proxying</li> <li><input type="checkbox" checked> Image proxying</li>
<li><input type="checkbox" checked> Gallery/album proxying</li> <li><input type="checkbox" checked> Gallery/album proxying</li>
<li><input type="checkbox"> Proper order of gallery posts</li> <li><input type="checkbox" checked> Proper order of gallery posts</li>
<li><input type="checkbox"> Image description and author info</li> <li><input type="checkbox"> Image description and author info</li>
<li><input type="checkbox"> Tor/SOCKS support for block circumvention</li> <li><input type="checkbox"> Tor/SOCKS support for block circumvention</li>
<li><input type="checkbox"> GIFs/videos (For now use youtube-dl)</li> <li><input type="checkbox"> GIFs/videos (For now use youtube-dl)</li>