mirror of
https://github.com/onionshare/onionshare.git
synced 2025-07-28 09:04:26 -04:00
commit
957d3e9c6d
6 changed files with 50 additions and 4 deletions
|
@ -90,9 +90,15 @@ class SendBaseModeWeb:
|
||||||
'status_code': 200
|
'status_code': 200
|
||||||
})
|
})
|
||||||
|
|
||||||
|
breadcrumbs = [('☗', '/')]
|
||||||
|
parts = path.split('/')[:-1]
|
||||||
|
for i in range(len(parts)):
|
||||||
|
breadcrumbs.append(('{}'.format(parts[i]), '/{}/'.format('/'.join(parts[0:i+1]))))
|
||||||
|
breadcrumbs_leaf = breadcrumbs.pop()[0]
|
||||||
|
|
||||||
# If filesystem_path is None, this is the root directory listing
|
# If filesystem_path is None, this is the root directory listing
|
||||||
files, dirs = self.build_directory_listing(filenames, filesystem_path)
|
files, dirs = self.build_directory_listing(filenames, filesystem_path)
|
||||||
r = self.directory_listing_template(path, files, dirs)
|
r = self.directory_listing_template(path, files, dirs, breadcrumbs, breadcrumbs_leaf)
|
||||||
return self.web.add_security_headers(r)
|
return self.web.add_security_headers(r)
|
||||||
|
|
||||||
def build_directory_listing(self, filenames, filesystem_path):
|
def build_directory_listing(self, filenames, filesystem_path):
|
||||||
|
|
|
@ -168,12 +168,14 @@ class ShareModeWeb(SendBaseModeWeb):
|
||||||
r.headers.set('Content-Type', content_type)
|
r.headers.set('Content-Type', content_type)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def directory_listing_template(self, path, files, dirs):
|
def directory_listing_template(self, path, files, dirs, breadcrumbs, breadcrumbs_leaf):
|
||||||
return make_response(render_template(
|
return make_response(render_template(
|
||||||
'send.html',
|
'send.html',
|
||||||
file_info=self.file_info,
|
file_info=self.file_info,
|
||||||
files=files,
|
files=files,
|
||||||
dirs=dirs,
|
dirs=dirs,
|
||||||
|
breadcrumbs=breadcrumbs,
|
||||||
|
breadcrumbs_leaf=breadcrumbs_leaf,
|
||||||
filename=os.path.basename(self.download_filename),
|
filename=os.path.basename(self.download_filename),
|
||||||
filesize=self.filesize,
|
filesize=self.filesize,
|
||||||
filesize_human=self.common.human_readable_filesize(self.download_filesize),
|
filesize_human=self.common.human_readable_filesize(self.download_filesize),
|
||||||
|
|
|
@ -30,11 +30,13 @@ class WebsiteModeWeb(SendBaseModeWeb):
|
||||||
"""
|
"""
|
||||||
return self.render_logic(path)
|
return self.render_logic(path)
|
||||||
|
|
||||||
def directory_listing_template(self, path, files, dirs):
|
def directory_listing_template(self, path, files, dirs, breadcrumbs, breadcrumbs_leaf):
|
||||||
return make_response(render_template('listing.html',
|
return make_response(render_template('listing.html',
|
||||||
path=path,
|
path=path,
|
||||||
files=files,
|
files=files,
|
||||||
dirs=dirs,
|
dirs=dirs,
|
||||||
|
breadcrumbs=breadcrumbs,
|
||||||
|
breadcrumbs_leaf=breadcrumbs_leaf,
|
||||||
static_url_path=self.web.static_url_path))
|
static_url_path=self.web.static_url_path))
|
||||||
|
|
||||||
def set_file_info_custom(self, filenames, processed_size_callback):
|
def set_file_info_custom(self, filenames, processed_size_callback):
|
||||||
|
@ -51,7 +53,7 @@ class WebsiteModeWeb(SendBaseModeWeb):
|
||||||
index_path = os.path.join(path, 'index.html')
|
index_path = os.path.join(path, 'index.html')
|
||||||
if index_path in self.files:
|
if index_path in self.files:
|
||||||
# Render it
|
# Render it
|
||||||
return self.stream_individual_file(filesystem_path)
|
return self.stream_individual_file(self.files[index_path])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Otherwise, render directory listing
|
# Otherwise, render directory listing
|
||||||
|
|
|
@ -74,6 +74,30 @@ a.button:visited {
|
||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.breadcrumbs {
|
||||||
|
display: block;
|
||||||
|
list-style: none;
|
||||||
|
margin: 10px 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.breadcrumbs li {
|
||||||
|
display: inline-block;
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 5px;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.breadcrumbs li span.sep {
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.breadcrumbs li a:link, ul.breadcrumbs li a:visited {
|
||||||
|
color: #666666;
|
||||||
|
border-bottom: 1px solid #666666;
|
||||||
|
}
|
||||||
|
|
||||||
table.file-list {
|
table.file-list {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
|
@ -12,6 +12,12 @@
|
||||||
<h1>OnionShare</h1>
|
<h1>OnionShare</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
{% if breadcrumbs %}
|
||||||
|
<ul class="breadcrumbs">
|
||||||
|
{% for breadcrumb in breadcrumbs %}<li><a href="{{ breadcrumb[1] }}">{{ breadcrumb[0] }}</a> <span class="sep">‣</span></li>{% endfor %}<li>{{ breadcrumbs_leaf }}</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<table class="file-list" id="file-list">
|
<table class="file-list" id="file-list">
|
||||||
<tr>
|
<tr>
|
||||||
<th id="filename-header">Filename</th>
|
<th id="filename-header">Filename</th>
|
||||||
|
|
|
@ -22,6 +22,12 @@
|
||||||
<h1>OnionShare</h1>
|
<h1>OnionShare</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
{% if breadcrumbs %}
|
||||||
|
<ul class="breadcrumbs">
|
||||||
|
{% for breadcrumb in breadcrumbs %}<li><a href="{{ breadcrumb[1] }}">{{ breadcrumb[0] }}</a> <span class="sep">‣</span></li>{% endfor %}<li>{{ breadcrumbs_leaf }}</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<table class="file-list" id="file-list">
|
<table class="file-list" id="file-list">
|
||||||
<tr>
|
<tr>
|
||||||
<th id="filename-header">Filename</th>
|
<th id="filename-header">Filename</th>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue