summaryrefslogtreecommitdiff
path: root/pgweb/util/misc.py
diff options
context:
space:
mode:
authorMagnus Hagander2017-10-13 13:56:25 +0000
committerMagnus Hagander2017-10-13 13:56:25 +0000
commitc06ece5dd8f5582e28aeaef32ca614b9f31c5d66 (patch)
treeef75f441882bf8e5b66357c572768c6e574496ba /pgweb/util/misc.py
parent022dd26283393048189a1fc46cde2c825be90072 (diff)
Attempt to fix version sorting in ftp browser
There was already an ugly hack to handle this, so make it a bit uglier with even more hardcoded assumptions. Seems to be working for the site as it is now, but may definitely need further ugly hacks in the future.
Diffstat (limited to 'pgweb/util/misc.py')
-rw-r--r--pgweb/util/misc.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pgweb/util/misc.py b/pgweb/util/misc.py
index 4b3e0728..3f436c85 100644
--- a/pgweb/util/misc.py
+++ b/pgweb/util/misc.py
@@ -40,14 +40,25 @@ def varnish_purge(url):
def version_sort(l):
"""
map a directory name to a format that will show up sensibly in an ascii sort
+ We specifically detect entries that look like versions. Weird things may happen
+ if there is a mix of versions and non-versions in the same directory, but we
+ generally don't have that.
"""
mkey = l['link']
- m = re.match('v([0-9]+)\.([0-9]+)\.([0-9]+)$',l['url'])
+ m = re.match('v?([0-9]+)\.([0-9]+)\.([0-9]+)$',l['url'])
if m:
mkey = m.group(1) + '%02d' % int(m.group(2)) + '%02d' % int(m.group(3));
- m = re.match('v([0-9]+)\.([0-9]+)$',l['url'])
+ m = re.match('v?([0-9]+)\.([0-9]+)$',l['url'])
if m:
mkey = m.group(1) + '%02d' % int(m.group(2));
+ # SOOO ugly. But if it's v10 and up, just prefix it to get it higher
+ if int(m.group(1)) >= 10:
+ mkey = 'a' + mkey
+ m = re.match('v?([0-9]+)$', l['url'])
+ if m:
+ # This can only happen on 10+, so...
+ mkey = 'a' + m.group(1) + '0'
+
return mkey
def generate_random_token():