mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-26 07:49:48 -05:00
Fix building the URL in CLI mode, and removing the slug from the download button in share mode
This commit is contained in:
parent
7d89f80f20
commit
97b5984aff
@ -27,6 +27,15 @@ from .web import Web
|
||||
from .onion import *
|
||||
from .onionshare import OnionShare
|
||||
|
||||
|
||||
def build_url(common, app, web):
|
||||
# Build the URL
|
||||
if common.settings.get('public_mode'):
|
||||
return 'http://{0:s}'.format(app.onion_host)
|
||||
else:
|
||||
return 'http://onionshare:{0:s}@{1:s}'.format(web.password, app.onion_host)
|
||||
|
||||
|
||||
def main(cwd=None):
|
||||
"""
|
||||
The main() function implements all of the logic that the command-line version of
|
||||
@ -128,12 +137,6 @@ def main(cwd=None):
|
||||
app.set_stealth(stealth)
|
||||
app.choose_port()
|
||||
|
||||
# Build the URL
|
||||
if common.settings.get('public_mode'):
|
||||
url = 'http://{0:s}'.format(app.onion_host)
|
||||
else:
|
||||
url = 'http://onionshare:{0:s}@{1:s}'.format(web.password, app.onion_host)
|
||||
|
||||
# Delay the startup if a startup timer was set
|
||||
if autostart_timer > 0:
|
||||
# Can't set a schedule that is later than the auto-stop timer
|
||||
@ -142,6 +145,7 @@ def main(cwd=None):
|
||||
sys.exit()
|
||||
|
||||
app.start_onion_service(False, True)
|
||||
url = build_url(common, app, web)
|
||||
schedule = datetime.now() + timedelta(seconds=autostart_timer)
|
||||
if mode == 'receive':
|
||||
print("Files sent to you appear in this folder: {}".format(common.settings.get('data_dir')))
|
||||
@ -218,6 +222,9 @@ def main(cwd=None):
|
||||
common.settings.set('password', web.password)
|
||||
common.settings.save()
|
||||
|
||||
# Build the URL
|
||||
url = build_url(common, app, web)
|
||||
|
||||
print('')
|
||||
if autostart_timer > 0:
|
||||
print("Server started")
|
||||
|
@ -64,24 +64,13 @@ class ShareModeWeb(object):
|
||||
else:
|
||||
self.filesize = self.download_filesize
|
||||
|
||||
if self.web.password:
|
||||
r = make_response(render_template(
|
||||
'send.html',
|
||||
password=self.web.password,
|
||||
file_info=self.file_info,
|
||||
filename=os.path.basename(self.download_filename),
|
||||
filesize=self.filesize,
|
||||
filesize_human=self.common.human_readable_filesize(self.download_filesize),
|
||||
is_zipped=self.is_zipped))
|
||||
else:
|
||||
# If download is allowed to continue, serve download page
|
||||
r = make_response(render_template(
|
||||
'send.html',
|
||||
file_info=self.file_info,
|
||||
filename=os.path.basename(self.download_filename),
|
||||
filesize=self.filesize,
|
||||
filesize_human=self.common.human_readable_filesize(self.download_filesize),
|
||||
is_zipped=self.is_zipped))
|
||||
r = make_response(render_template(
|
||||
'send.html',
|
||||
file_info=self.file_info,
|
||||
filename=os.path.basename(self.download_filename),
|
||||
filesize=self.filesize,
|
||||
filesize_human=self.common.human_readable_filesize(self.download_filesize),
|
||||
is_zipped=self.is_zipped))
|
||||
return self.web.add_security_headers(r)
|
||||
|
||||
@self.web.app.route("/download")
|
||||
|
@ -15,11 +15,7 @@
|
||||
<div class="right">
|
||||
<ul>
|
||||
<li>Total size: <strong>{{ filesize_human }}</strong> {% if is_zipped %} (compressed){% endif %}</li>
|
||||
{% if slug %}
|
||||
<li><a class="button" href='/{{ slug }}/download'>Download Files</a></li>
|
||||
{% else %}
|
||||
<li><a class="button" href='/download'>Download Files</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
<img class="logo" src="/static/img/logo.png" title="OnionShare">
|
||||
|
Loading…
Reference in New Issue
Block a user