mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-11 23:39:31 -05:00
starting to build onionshare functionality into GUI
This commit is contained in:
parent
3deab0dc40
commit
9d7689f578
@ -76,6 +76,7 @@ def load_strings(default="en"):
|
|||||||
lang = lc[:2]
|
lang = lc[:2]
|
||||||
if lang in translated:
|
if lang in translated:
|
||||||
strings = translated[lang]
|
strings = translated[lang]
|
||||||
|
return strings
|
||||||
|
|
||||||
def file_crunching(filename):
|
def file_crunching(filename):
|
||||||
# calculate filehash, file size
|
# calculate filehash, file size
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<div id="give-this-url">Give this URL to the person you're sending the file to:</div>
|
<div id="give-this-url">Give this URL to the person you're sending the file to:</div>
|
||||||
<div id="url"></div>
|
<div id="url"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="output">...</div>
|
<div id="output"></div>
|
||||||
|
|
||||||
<script src="jquery-1.11.1.min.js"></script>
|
<script src="jquery-1.11.1.min.js"></script>
|
||||||
<script src="onionshare.js"></script>
|
<script src="onionshare.js"></script>
|
||||||
|
@ -3,11 +3,16 @@ function send(msg) {
|
|||||||
document.title = msg;
|
document.title = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_basename(basename) {
|
function init(basename, strings) {
|
||||||
$('#basename').html(basename);
|
$('#basename').html(basename);
|
||||||
}
|
|
||||||
|
|
||||||
function set_strings(strings) {
|
|
||||||
strings = JSON.parse(strings)
|
|
||||||
$('#give-this-url').html(strings['give_this_url'])
|
$('#give-this-url').html(strings['give_this_url'])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_url(url) {
|
||||||
|
$('#url').html(url);
|
||||||
|
$('#url-wrapper').slideDown(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
function update(msg) {
|
||||||
|
$('#output').append($('<p></p>').html(msg))
|
||||||
|
}
|
||||||
|
@ -2,7 +2,8 @@ body {
|
|||||||
background-color: #222222;
|
background-color: #222222;
|
||||||
color: #aaffaa;
|
color: #aaffaa;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
width: 400px;
|
width: 600px;
|
||||||
|
height: 500px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
@ -33,10 +34,12 @@ h1 .skull {
|
|||||||
}
|
}
|
||||||
#url {
|
#url {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
font-size: 30px;
|
font-size: 25px;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
}
|
}
|
||||||
#output {
|
#output {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
word-wrap: break-word;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,19 +14,32 @@ def main():
|
|||||||
if not filename:
|
if not filename:
|
||||||
return
|
return
|
||||||
|
|
||||||
# initialize onionshare
|
|
||||||
onionshare.load_strings()
|
|
||||||
|
|
||||||
# open the window, launching webkit browser
|
# open the window, launching webkit browser
|
||||||
webgui.start_gtk_thread()
|
webgui.start_gtk_thread()
|
||||||
browser, web_recv, web_send = webgui.sync_gtk_msg(webgui.launch_window)(
|
browser, web_recv, web_send = webgui.sync_gtk_msg(webgui.launch_window)(
|
||||||
title="OnionShare | {0}".format(basename),
|
title="OnionShare | {0}".format(basename),
|
||||||
quit_function=Global.set_quit)
|
quit_function=Global.set_quit)
|
||||||
|
|
||||||
# send the browser initial data
|
# wait for window to render
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
web_send("set_basename('{0}')".format(basename))
|
|
||||||
web_send("set_strings('{0}')".format(json.dumps(onionshare.strings)))
|
# initialize onionshare
|
||||||
|
strings = onionshare.load_strings()
|
||||||
|
web_send("init('{0}', {1});".format(basename, json.dumps(strings)))
|
||||||
|
|
||||||
|
web_send("update('{0}')".format(strings['calculating_sha1']))
|
||||||
|
filehash, filesize = onionshare.file_crunching(filename)
|
||||||
|
port = onionshare.choose_port()
|
||||||
|
|
||||||
|
web_send("update('{0}')".format(strings['connecting_ctrlport'].format(port)))
|
||||||
|
onion_host = onionshare.start_hidden_service(port)
|
||||||
|
|
||||||
|
# punch a hole in the firewall
|
||||||
|
onionshare.tails_open_port(port)
|
||||||
|
|
||||||
|
url = 'http://{0}/{1}'.format(onion_host, onionshare.slug)
|
||||||
|
web_send("update('{0}')".format('Secret URL is {0}'.format(url)))
|
||||||
|
web_send("set_url('{0}')".format(url));
|
||||||
|
|
||||||
# main loop
|
# main loop
|
||||||
last_second = time.time()
|
last_second = time.time()
|
||||||
|
Loading…
Reference in New Issue
Block a user