mirror of
https://github.com/onionshare/onionshare.git
synced 2025-07-25 23:55:36 -04:00
Fix bugs in how self.file was building the dictionary, so now browsing works
This commit is contained in:
parent
ae54ef076e
commit
5522e2a3f0
1 changed files with 12 additions and 10 deletions
|
@ -53,13 +53,10 @@ class WebsiteModeWeb(object):
|
||||||
|
|
||||||
return _check_login()
|
return _check_login()
|
||||||
|
|
||||||
@self.web.app.route('/<path:page_path>')
|
@self.web.app.route('/', defaults={'path': ''})
|
||||||
def path_public(page_path):
|
@self.web.app.route('/<path:path>')
|
||||||
return path_logic(page_path)
|
def path_public(path):
|
||||||
|
return path_logic(path)
|
||||||
@self.web.app.route("/")
|
|
||||||
def index_public():
|
|
||||||
return path_logic('')
|
|
||||||
|
|
||||||
def path_logic(path=''):
|
def path_logic(path=''):
|
||||||
"""
|
"""
|
||||||
|
@ -91,7 +88,12 @@ class WebsiteModeWeb(object):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Otherwise, render directory listing
|
# Otherwise, render directory listing
|
||||||
filenames = os.listdir(filesystem_path)
|
filenames = []
|
||||||
|
for filename in os.listdir(filesystem_path):
|
||||||
|
if os.path.isdir(os.path.join(filesystem_path, filename)):
|
||||||
|
filenames.append(filename + '/')
|
||||||
|
else:
|
||||||
|
filenames.append(filename)
|
||||||
filenames.sort()
|
filenames.sort()
|
||||||
return self.directory_listing(path, filenames, filesystem_path)
|
return self.directory_listing(path, filenames, filesystem_path)
|
||||||
|
|
||||||
|
@ -188,10 +190,10 @@ class WebsiteModeWeb(object):
|
||||||
# Normalize the root path. So if the directory name is "/home/user/Documents/some_folder",
|
# Normalize the root path. So if the directory name is "/home/user/Documents/some_folder",
|
||||||
# and it has a nested folder foobar, the root is "/home/user/Documents/some_folder/foobar".
|
# and it has a nested folder foobar, the root is "/home/user/Documents/some_folder/foobar".
|
||||||
# The normalized_root should be "some_folder/foobar"
|
# The normalized_root should be "some_folder/foobar"
|
||||||
normalized_root = os.path.join(basename, root.lstrip(filename)).rstrip('/')
|
normalized_root = os.path.join(basename, root[len(filename):].lstrip('/')).rstrip('/')
|
||||||
|
|
||||||
# Add the dir itself
|
# Add the dir itself
|
||||||
self.files[normalized_root + '/'] = filename
|
self.files[normalized_root + '/'] = root
|
||||||
|
|
||||||
# Add the files in this dir
|
# Add the files in this dir
|
||||||
for nested_filename in nested_filenames:
|
for nested_filename in nested_filenames:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue