mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-13 00:09:38 -05:00
running async startup work in a separate thread, and design tweaks
This commit is contained in:
parent
23f9a577fe
commit
906eeccb54
@ -4,7 +4,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
|
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1><span id="basename">...</span></h1>
|
<h1><span id="basename"></span></h1>
|
||||||
<div id="output"></div>
|
<div id="output"></div>
|
||||||
<button class="button" id="copy-button">Copy URL</button>
|
<button class="button" id="copy-button">Copy URL</button>
|
||||||
|
|
||||||
|
BIN
onionshare_gui/html/loader.gif
Normal file
BIN
onionshare_gui/html/loader.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
@ -4,7 +4,7 @@ function send(msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init(basename, strings) {
|
function init(basename, strings) {
|
||||||
$('#basename').html(basename);
|
$('#basename').html(basename).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function url_is_set() {
|
function url_is_set() {
|
||||||
@ -16,7 +16,8 @@ function url_is_set() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update(msg) {
|
function update(msg) {
|
||||||
$('#output').append($('<p></p>').html(msg))
|
var $line = $('<p></p>').append(msg);
|
||||||
|
$('#output').append($line);
|
||||||
|
|
||||||
// scroll to bottom
|
// scroll to bottom
|
||||||
$('#output').scrollTop($('#output').height());
|
$('#output').scrollTop($('#output').height());
|
||||||
|
@ -2,7 +2,7 @@ body {
|
|||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
font-family: arial;
|
font-family: arial;
|
||||||
width: 650px;
|
width: 550px;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -28,6 +28,7 @@ p {
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
height: 260px;
|
height: 260px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
@ -75,3 +76,11 @@ p {
|
|||||||
right: 20px;
|
right: 20px;
|
||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loader {
|
||||||
|
width: 21px;
|
||||||
|
height: 20px;
|
||||||
|
background-image: url('loader.gif');
|
||||||
|
background-position: top left;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
@ -61,6 +61,7 @@ def main():
|
|||||||
except onionshare.NoTor as e:
|
except onionshare.NoTor as e:
|
||||||
alert(e.args[0], gtk.MESSAGE_ERROR)
|
alert(e.args[0], gtk.MESSAGE_ERROR)
|
||||||
return
|
return
|
||||||
|
onionshare.tails_open_port(port)
|
||||||
|
|
||||||
# select file to share
|
# select file to share
|
||||||
filename, basename = select_file(strings)
|
filename, basename = select_file(strings)
|
||||||
@ -80,14 +81,11 @@ def main():
|
|||||||
clipboard.set_text(url)
|
clipboard.set_text(url)
|
||||||
web_send("update('{0}')".format('Copied secret URL to clipboard.'))
|
web_send("update('{0}')".format('Copied secret URL to clipboard.'))
|
||||||
|
|
||||||
# startup
|
# the async nature of things requires startup to be split into multiple functions
|
||||||
def startup():
|
def startup_async():
|
||||||
global url
|
global url
|
||||||
web_send("init('{0}', {1});".format(basename, json.dumps(strings)))
|
|
||||||
web_send("update('{0}')".format(strings['calculating_sha1']))
|
|
||||||
filehash, filesize = onionshare.file_crunching(filename)
|
filehash, filesize = onionshare.file_crunching(filename)
|
||||||
onionshare.set_file_info(filename, filehash, filesize)
|
onionshare.set_file_info(filename, filehash, filesize)
|
||||||
onionshare.tails_open_port(port)
|
|
||||||
url = 'http://{0}/{1}'.format(onion_host, onionshare.slug)
|
url = 'http://{0}/{1}'.format(onion_host, onionshare.slug)
|
||||||
web_send("update('{0}')".format(strings['give_this_url'].replace('\'', '\\\'')))
|
web_send("update('{0}')".format(strings['give_this_url'].replace('\'', '\\\'')))
|
||||||
web_send("update('<strong>{0}</strong>')".format(url))
|
web_send("update('<strong>{0}</strong>')".format(url))
|
||||||
@ -96,11 +94,17 @@ def main():
|
|||||||
# clipboard needs a bit of time before copying url
|
# clipboard needs a bit of time before copying url
|
||||||
gobject.timeout_add(500, set_clipboard)
|
gobject.timeout_add(500, set_clipboard)
|
||||||
|
|
||||||
# start the web server
|
def startup_sync():
|
||||||
web_thread = thread.start_new_thread(onionshare.app.run, (), {"port": port})
|
web_send("init('{0}', {1});".format(basename, json.dumps(strings)))
|
||||||
|
web_send("update('{0}')".format(strings['calculating_sha1']))
|
||||||
|
|
||||||
# webview needs a bit of time before receiving data
|
# run other startup in the background
|
||||||
gobject.timeout_add(100, startup)
|
thread_crunch = thread.start_new_thread(startup_async, ())
|
||||||
|
|
||||||
|
# start the web server
|
||||||
|
thread_web = thread.start_new_thread(onionshare.app.run, (), {"port": port})
|
||||||
|
|
||||||
|
gobject.timeout_add(100, startup_sync)
|
||||||
|
|
||||||
# main loop
|
# main loop
|
||||||
last_second = time.time()
|
last_second = time.time()
|
||||||
|
Loading…
Reference in New Issue
Block a user