Remove old webapp files

This commit is contained in:
Lazlo Westerhof 2014-08-14 16:41:07 +02:00
parent 141707785f
commit 5b8f3f777b
7 changed files with 0 additions and 558 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -1,60 +0,0 @@
function human_readable_filesize(bytes, si) {
var thresh = si ? 1000 : 1024;
if(bytes < thresh) return bytes + ' B';
var units = si ? ['kB','MB','GB','TB','PB','EB','ZB','YB'] : ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];
var u = -1;
do {
bytes /= thresh;
++u;
} while(bytes >= thresh);
return bytes.toFixed(1)+' '+units[u];
};
function htmlspecialchars(string, quote_style, charset, double_encode) {
var optTemp = 0,
i = 0,
noquotes = false;
if (typeof quote_style === 'undefined' || quote_style === null) {
quote_style = 2;
}
string = string.toString();
if (double_encode !== false) {
// Put this first to avoid double-encoding
string = string.replace(/&/g, '&amp;');
}
string = string.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
var OPTS = {
'ENT_NOQUOTES': 0,
'ENT_HTML_QUOTE_SINGLE': 1,
'ENT_HTML_QUOTE_DOUBLE': 2,
'ENT_COMPAT': 2,
'ENT_QUOTES': 3,
'ENT_IGNORE': 4
};
if (quote_style === 0) {
noquotes = true;
}
if (typeof quote_style !== 'number') {
// Allow for a single string or an array of string flags
quote_style = [].concat(quote_style);
for (i = 0; i < quote_style.length; i++) {
// Resolve string input to bitwise e.g. 'ENT_IGNORE' becomes 4
if (OPTS[quote_style[i]] === 0) {
noquotes = true;
} else if (OPTS[quote_style[i]]) {
optTemp = optTemp | OPTS[quote_style[i]];
}
}
quote_style = optTemp;
}
if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
string = string.replace(/'/g, '&#039;');
}
if (!noquotes) {
string = string.replace(/"/g, '&quot;');
}
return string;
}

File diff suppressed because one or more lines are too long

View File

@ -1,128 +0,0 @@
$(function(){
var onionshare = {}
function update($msg) {
var $line = $('<li>').append($msg);
$('#log').prepend($line);
}
function copy_to_clipboard() {
$.ajax({
url: '/copy_url',
success: function(data, textStatus, jqXHR){
update(onionshare.strings['copied_url']);
}
});
}
$('#copy-button').click(copy_to_clipboard);
var REQUEST_LOAD = 0;
var REQUEST_DOWNLOAD = 1;
var REQUEST_PROGRESS = 2;
var REQUEST_OTHER = 3;
function check_for_requests() {
$.ajax({
url: '/heartbeat',
success: function(data, textStatus, jqXHR){
if(data != '') {
var events = JSON.parse(data);
for(var i=0; i<events.length; i++) {
var r = events[i];
if(r.type == REQUEST_LOAD) {
update($('<span>').addClass('weblog').html(onionshare.strings['download_page_loaded']));
} else if(r.type == REQUEST_DOWNLOAD) {
var $download = $('<span>')
.attr('id', 'download-'+r.data.id)
.addClass('weblog').html(onionshare.strings['download_started'])
.append($('<span>').addClass('progress'));
update($download);
} else if(r.type == REQUEST_PROGRESS) {
// is the download complete?
if(r.data.bytes == onionshare.filesize) {
$('#download-'+r.data.id).html(onionshare.strings['download_finished']);
// close on finish?
if($('#close-on-finish').is(':checked')) {
function close_countdown(i) {
$('#close-countdown').html(onionshare.strings['close_countdown'].replace('{0}', i));
if(i == 0) {
// close program
$.ajax({ url: '/close' });
} else {
// continue countdown
setTimeout(function(){ close_countdown(i-1) }, 1000);
}
}
update($('<span>').attr('id', 'close-countdown'));
close_countdown(3);
}
}
// still in progress
else {
var percent = Math.floor((r.data.bytes / onionshare.filesize) * 100);
$('#download-'+r.data.id+' .progress').html(' '+human_readable_filesize(r.data.bytes)+', '+percent+'%');
}
} else {
if(r.path != '/favicon.ico')
update($('<span>').addClass('weblog-error').html(onionshare.strings['other_page_loaded']+': '+htmlspecialchars(r.path)));
}
}
}
setTimeout(check_for_requests, 1000);
}
});
}
$('#close-on-finish').change(function(){
if($('#close-on-finish').is(':checked')) {
$.ajax({ url: '/stay_open_false' });
} else {
$.ajax({ url: '/stay_open_true' });
}
});
// initialize
$.ajax({
url: '/init_info',
success: function(data, textStatus, jqXHR){
onionshare = JSON.parse(data);
$('#basename').html(onionshare.basename);
$('#filesize .label').html(onionshare.strings['filesize']+':');
$('#filehash .label').html(onionshare.strings['sha1_checksum']+':');
$('#close-on-finish-wrapper label').html(onionshare.strings['close_on_finish']);
$('#loading .calculating').html(onionshare.strings['calculating_sha1']);
$('#copy-button').html(onionshare.strings['copy_url']);
if(onionshare.stay_open) {
$('#close-on-finish').removeAttr('checked');
}
// after getting the initial info, start the onionshare server
$.ajax({
url: '/start_onionshare',
success: function(data, textStatus, jqXHR){
var data_obj = JSON.parse(data);
onionshare.filehash = data_obj.filehash;
onionshare.filesize = data_obj.filesize;
onionshare.url = data_obj.url;
$('#loading').remove();
$('#filesize .value').html(human_readable_filesize(onionshare.filesize));
$('#filehash .value').html(onionshare.filehash);
$('#filesize').show(500);
$('#filehash').show(500);
update('<span>'+onionshare.strings['give_this_url']+'</span><br/><strong>'+onionshare.url+'</strong>');
copy_to_clipboard();
$('#copy-button').show();
setTimeout(check_for_requests, 1000);
}
});
}
});
});

View File

@ -1,173 +0,0 @@
body {
color: #000000;
font-family: arial;
margin: 0;
padding: 0;
background-color: #f0f0f0;
min-width: 550px;
min-height: 300px;
overflow: hidden;
}
#wrapper {
}
#header {
height: 80px;
padding: 10px;
background-color: #ffffff;
}
#header #logo {
float: left;
width: 80px;
height: 80px;
margin-right: 10px;
}
#header #header-content {
float: left;
width: 440px;
height: 80px;
}
#header #header-content #basename {
font-family: sans-serif;
font-size: 22px;
font-weight: bold;
color: #000000;
white-space: nowrap;
overflow: hidden;
}
#header #header-content #filesize,
#header #header-content #filehash {
margin-top: 3px;
word-break: break-all;
text-align: left;
color: #666666;
display: none;
}
#header #header-content .label {
font-size: 14px;
}
#header #header-content .value {
font-weight: bold;
font-size: 14px;
}
ul#log {
margin: 0;
padding: 0;
list-style: none;
height: 258px;
overflow: auto;
word-wrap: break-word;
font-family: arial;
font-size: 14px;
border-top: 1px solid #000000;
width: 100%;
}
ul#log li {
margin: 0 10px;
padding: 10px;
border-bottom: 1px solid #cccccc;
}
ul#log .weblog {
color: #009900;
font-weight: bold;
}
ul#log .weblog .progress {
color: #0000cc;
}
ul#log .weblog-error {
color: #ff0000;
font-weight: bold;
}
ul#log li#loading {
text-align: center;
padding: 60px 30px;
border-bottom: 0;
}
ul#log li#loading .calculating {
color: #666666;
font-style: italic;
font-size: 12px;
}
ul#log #close-countdown {
font-weight: bold;
font-style: italic;
}
#footer {
position: fixed;
bottom: 0;
height: 20px;
background-color: #ffffff;
padding: 10px 0;
width: 100%;
border-top: 1px solid #000000;
}
#footer #close-on-finish-wrapper {
float: left;
margin-left: 5px;
}
#footer #close-on-finish-wrapper input {
cursor: pointer;
vertical-align: middle;
}
#footer #close-on-finish-wrapper label {
cursor: pointer;
font-size: 12px;
vertical-align: middle;
}
#footer #copy-button-wrapper {
float: right;
margin-right: 5px;
margin-top: -3px;
}
#footer #copy-button {
display: none;
}
.button {
-moz-box-shadow:inset 0px 1px 0px 0px #d197fe;
-webkit-box-shadow:inset 0px 1px 0px 0px #d197fe;
box-shadow:inset 0px 1px 0px 0px #d197fe;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #a53df6), color-stop(1, #7c16cb) );
background:-moz-linear-gradient( center top, #a53df6 5%, #7c16cb 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#a53df6', endColorstr='#7c16cb');
background-color:#a53df6;
-webkit-border-top-left-radius:0px;
-moz-border-radius-topleft:0px;
border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-moz-border-radius-topright:0px;
border-top-right-radius:0px;
-webkit-border-bottom-right-radius:0px;
-moz-border-radius-bottomright:0px;
border-bottom-right-radius:0px;
-webkit-border-bottom-left-radius:0px;
-moz-border-radius-bottomleft:0px;
border-bottom-left-radius:0px;
text-indent:0;
border:1px solid #9c33ed;
display:inline-block;
color:#ffffff;
font-family:Arial;
font-size:13px;
font-weight:bold;
font-style:normal;
text-decoration:none;
text-align:center;
text-shadow:1px 1px 0px #7d15cd;
}
.button:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #7c16cb), color-stop(1, #a53df6) );
background:-moz-linear-gradient( center top, #7c16cb 5%, #a53df6 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#7c16cb', endColorstr='#a53df6');
background-color:#7c16cb;
}
.clear {
clear: both;
}

View File

@ -1,46 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="static/style.css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<img id="logo" src="static/logo.png" />
<div id="header-content">
<div id="basename"></div>
<div id="filehash">
<span class="label"></span>
<span class="value"></span>
</div>
<div id="filesize">
<span class="label"></span>
<span class="value"></span>
</div>
</div>
</div>
<ul id="log">
<li id="loading">
<img src="static/loader.gif" />
<p class="calculating"></p>
</li>
</ul>
<div id="footer">
<div id="close-on-finish-wrapper">
<input type="checkbox" id="close-on-finish" name="close-on-finish" checked />
<label for="close-on-finish"></span>
</div>
<div id="copy-button-wrapper">
<button class="button" id="copy-button">Copy URL</button>
</div>
<div class="clear"></div>
</div>
</ul>
<script src="static/jquery-1.11.1.min.js"></script>
<script src="static/helpers.js"></script>
<script src="static/onionshare.js"></script>
</body>
</html>

View File

@ -1,147 +0,0 @@
from flask import Flask, render_template, make_response
from functools import wraps
import threading, json, os, time, platform, sys
onionshare = None
onionshare_port = None
filename = None
onion_host = None
qtapp = None
clipboard = None
stay_open = None
url = None
app = Flask(__name__, template_folder='./templates')
def debug_mode():
import logging
global app
if platform.system() == 'Windows':
temp_dir = os.environ['Temp'].replace('\\', '/')
else:
temp_dir = '/tmp/'
log_handler = logging.FileHandler('{0}/onionshare_gui.log'.format(temp_dir))
log_handler.setLevel(logging.WARNING)
app.logger.addHandler(log_handler)
def add_response_headers(headers={}):
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
resp = make_response(f(*args, **kwargs))
h = resp.headers
for header, value in headers.items():
h[header] = value
return resp
return decorated_function
return decorator
def csp(f):
@wraps(f)
# disable inline js, external js
@add_response_headers({'Content-Security-Policy': "default-src 'self'; connect-src 'self'"})
# ugh, webkit embedded in Qt4 is stupid old
# TODO: remove webkit, build GUI with normal Qt widgets
@add_response_headers({'X-WebKit-CSP': "default-src 'self'; connect-src 'self'"})
def decorated_function(*args, **kwargs):
return f(*args, **kwargs)
return decorated_function
@app.route("/")
@csp
def index():
return render_template('index.html')
@app.route("/init_info")
@csp
def init_info():
global onionshare, filename, stay_open
basename = os.path.basename(filename)
return json.dumps({
'strings': onionshare.strings,
'basename': basename,
'stay_open': stay_open
})
@app.route("/start_onionshare")
@csp
def start_onionshare():
global onionshare, onionshare_port, filename, onion_host, url
url = 'http://{0}/{1}'.format(onion_host, onionshare.slug)
filehash, filesize = onionshare.file_crunching(filename)
onionshare.set_file_info(filename, filehash, filesize)
# start onionshare service in new thread
t = threading.Thread(target=onionshare.app.run, kwargs={'port': onionshare_port})
t.daemon = True
t.start()
return json.dumps({
'filehash': filehash,
'filesize': filesize,
'url': url
})
@app.route("/copy_url")
@csp
def copy_url():
if platform.system() == 'Windows':
# Qt's QClipboard isn't working in Windows
# https://github.com/micahflee/onionshare/issues/46
import ctypes
GMEM_DDESHARE = 0x2000
ctypes.windll.user32.OpenClipboard(None)
ctypes.windll.user32.EmptyClipboard()
hcd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(url))+1)
pch_data = ctypes.windll.kernel32.GlobalLock(hcd)
ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pch_data), bytes(url))
ctypes.windll.kernel32.GlobalUnlock(hcd)
ctypes.windll.user32.SetClipboardData(1, hcd)
ctypes.windll.user32.CloseClipboard()
else:
global clipboard
clipboard.setText(url)
return ''
@app.route("/stay_open_true")
@csp
def stay_open_true():
global onionshare
onionshare.set_stay_open(True)
@app.route("/stay_open_false")
@csp
def stay_open_false():
global onionshare
onionshare.set_stay_open(False)
@app.route("/heartbeat")
@csp
def check_for_requests():
global onionshare
events = []
done = False
while not done:
try:
r = onionshare.q.get(False)
events.append(r)
except onionshare.Queue.Empty:
done = True
return json.dumps(events)
@app.route("/close")
@csp
def close():
global qtapp
time.sleep(1)
qtapp.closeAllWindows()
return ''