mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 11:47:27 -03: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
3 changed files with 20 additions and 28 deletions
|
@ -27,6 +27,15 @@ from .web import Web
|
||||||
from .onion import *
|
from .onion import *
|
||||||
from .onionshare import OnionShare
|
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):
|
def main(cwd=None):
|
||||||
"""
|
"""
|
||||||
The main() function implements all of the logic that the command-line version of
|
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.set_stealth(stealth)
|
||||||
app.choose_port()
|
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
|
# Delay the startup if a startup timer was set
|
||||||
if autostart_timer > 0:
|
if autostart_timer > 0:
|
||||||
# Can't set a schedule that is later than the auto-stop timer
|
# Can't set a schedule that is later than the auto-stop timer
|
||||||
|
@ -142,6 +145,7 @@ def main(cwd=None):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
app.start_onion_service(False, True)
|
app.start_onion_service(False, True)
|
||||||
|
url = build_url(common, app, web)
|
||||||
schedule = datetime.now() + timedelta(seconds=autostart_timer)
|
schedule = datetime.now() + timedelta(seconds=autostart_timer)
|
||||||
if mode == 'receive':
|
if mode == 'receive':
|
||||||
print("Files sent to you appear in this folder: {}".format(common.settings.get('data_dir')))
|
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.set('password', web.password)
|
||||||
common.settings.save()
|
common.settings.save()
|
||||||
|
|
||||||
|
# Build the URL
|
||||||
|
url = build_url(common, app, web)
|
||||||
|
|
||||||
print('')
|
print('')
|
||||||
if autostart_timer > 0:
|
if autostart_timer > 0:
|
||||||
print("Server started")
|
print("Server started")
|
||||||
|
|
|
@ -64,24 +64,13 @@ class ShareModeWeb(object):
|
||||||
else:
|
else:
|
||||||
self.filesize = self.download_filesize
|
self.filesize = self.download_filesize
|
||||||
|
|
||||||
if self.web.password:
|
r = make_response(render_template(
|
||||||
r = make_response(render_template(
|
'send.html',
|
||||||
'send.html',
|
file_info=self.file_info,
|
||||||
password=self.web.password,
|
filename=os.path.basename(self.download_filename),
|
||||||
file_info=self.file_info,
|
filesize=self.filesize,
|
||||||
filename=os.path.basename(self.download_filename),
|
filesize_human=self.common.human_readable_filesize(self.download_filesize),
|
||||||
filesize=self.filesize,
|
is_zipped=self.is_zipped))
|
||||||
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))
|
|
||||||
return self.web.add_security_headers(r)
|
return self.web.add_security_headers(r)
|
||||||
|
|
||||||
@self.web.app.route("/download")
|
@self.web.app.route("/download")
|
||||||
|
|
|
@ -15,11 +15,7 @@
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<ul>
|
<ul>
|
||||||
<li>Total size: <strong>{{ filesize_human }}</strong> {% if is_zipped %} (compressed){% endif %}</li>
|
<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>
|
<li><a class="button" href='/download'>Download Files</a></li>
|
||||||
{% endif %}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<img class="logo" src="/static/img/logo.png" title="OnionShare">
|
<img class="logo" src="/static/img/logo.png" title="OnionShare">
|
||||||
|
|
Loading…
Reference in a new issue