mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-06 09:57:57 +00:00
Ensure that [Parent Directory] link ends up at the top of directory listings
Locale-aware sorting ignores the initial [, and sorts it at P. Instead, sort before we add the parent link, and just insert it at the beginning.
This commit is contained in:
@ -51,10 +51,11 @@ def ftpbrowser(request, subpath):
|
|||||||
directories = [{'link': k, 'url': k} for k,v in node.items() if v['t'] == 'd']
|
directories = [{'link': k, 'url': k} for k,v in node.items() if v['t'] == 'd']
|
||||||
# Add all symlinks (only directoreis supported)
|
# Add all symlinks (only directoreis supported)
|
||||||
directories.extend([{'link': k, 'url': v['d']} for k,v in node.items() if v['t'] == 'l'])
|
directories.extend([{'link': k, 'url': v['d']} for k,v in node.items() if v['t'] == 'l'])
|
||||||
|
directories.sort()
|
||||||
|
|
||||||
# Add a link to the parent directory
|
# Add a link to the parent directory
|
||||||
if subpath:
|
if subpath:
|
||||||
directories.append({'link':'[Parent Directory]', 'url':'..'})
|
directories.insert(0, {'link':'[Parent Directory]', 'url':'..'})
|
||||||
|
|
||||||
# Fetch files
|
# Fetch files
|
||||||
files = [{'name': k, 'mtime': v['t'], 'size': v['s']} for k,v in node.items() if v['t'] == 'f']
|
files = [{'name': k, 'mtime': v['t'], 'size': v['s']} for k,v in node.items() if v['t'] == 'f']
|
||||||
@ -81,7 +82,7 @@ def ftpbrowser(request, subpath):
|
|||||||
|
|
||||||
return render_to_response('downloads/ftpbrowser.html', {
|
return render_to_response('downloads/ftpbrowser.html', {
|
||||||
'basepath': subpath.rstrip('/'),
|
'basepath': subpath.rstrip('/'),
|
||||||
'directories': sorted(directories),
|
'directories': directories,
|
||||||
'files': sorted(files),
|
'files': sorted(files),
|
||||||
'breadcrumbs': breadcrumbs,
|
'breadcrumbs': breadcrumbs,
|
||||||
'readme': file_readme,
|
'readme': file_readme,
|
||||||
@ -96,7 +97,6 @@ def _get_numeric_ip(request):
|
|||||||
return int(p[0])*16777216 + int(p[1])*65536 + int(p[2])*256 + int(p[3])
|
return int(p[0])*16777216 + int(p[1])*65536 + int(p[2])*256 + int(p[3])
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@nocache
|
@nocache
|
||||||
def mirrorselect(request, path):
|
def mirrorselect(request, path):
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user