mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
impl write-only volumes + support py3.8
This commit is contained in:
parent
85454e409a
commit
ded987d9b5
|
@ -1,7 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
VERSION = (0, 2, 0)
|
VERSION = (0, 2, 1)
|
||||||
BUILD_DT = (2019, 7, 8)
|
BUILD_DT = (2020, 1, 19)
|
||||||
|
|
||||||
S_VERSION = ".".join(map(str, VERSION))
|
S_VERSION = ".".join(map(str, VERSION))
|
||||||
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)
|
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)
|
||||||
|
|
|
@ -9,13 +9,15 @@ import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import calendar
|
import calendar
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import cgi
|
|
||||||
|
|
||||||
from .__init__ import E, PY2
|
from .__init__ import E, PY2
|
||||||
from .util import * # noqa # pylint: disable=unused-wildcard-import
|
from .util import * # noqa # pylint: disable=unused-wildcard-import
|
||||||
|
|
||||||
if not PY2:
|
if not PY2:
|
||||||
unicode = str
|
unicode = str
|
||||||
|
from html import escape as html_escape
|
||||||
|
else:
|
||||||
|
from cgi import escape as html_escape
|
||||||
|
|
||||||
|
|
||||||
class HttpCli(object):
|
class HttpCli(object):
|
||||||
|
@ -192,10 +194,7 @@ class HttpCli(object):
|
||||||
self.vpath = None
|
self.vpath = None
|
||||||
return self.tx_mounts()
|
return self.tx_mounts()
|
||||||
|
|
||||||
if self.readable:
|
|
||||||
return self.tx_browser()
|
return self.tx_browser()
|
||||||
else:
|
|
||||||
return self.tx_upper()
|
|
||||||
|
|
||||||
def handle_post(self):
|
def handle_post(self):
|
||||||
self.log("POST " + self.req)
|
self.log("POST " + self.req)
|
||||||
|
@ -445,7 +444,7 @@ class HttpCli(object):
|
||||||
|
|
||||||
html = self.conn.tpl_msg.render(
|
html = self.conn.tpl_msg.render(
|
||||||
h2='<a href="/{}">return to /{}</a>'.format(
|
h2='<a href="/{}">return to /{}</a>'.format(
|
||||||
quotep(self.vpath), cgi.escape(self.vpath, quote=True)
|
quotep(self.vpath), html_escape(self.vpath, quote=False)
|
||||||
),
|
),
|
||||||
pre=msg,
|
pre=msg,
|
||||||
)
|
)
|
||||||
|
@ -609,12 +608,6 @@ class HttpCli(object):
|
||||||
self.reply(html.encode("utf-8"))
|
self.reply(html.encode("utf-8"))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def tx_upper(self):
|
|
||||||
# return html for basic uploader;
|
|
||||||
# js rewrites to up2k unless uparam['b']
|
|
||||||
self.loud_reply("TODO jupper {}".format(self.vpath))
|
|
||||||
return True
|
|
||||||
|
|
||||||
def tx_browser(self):
|
def tx_browser(self):
|
||||||
vpath = ""
|
vpath = ""
|
||||||
vpnodes = [["", "/"]]
|
vpnodes = [["", "/"]]
|
||||||
|
@ -625,9 +618,9 @@ class HttpCli(object):
|
||||||
else:
|
else:
|
||||||
vpath += "/" + node
|
vpath += "/" + node
|
||||||
|
|
||||||
vpnodes.append([quotep(vpath) + "/", cgi.escape(node)])
|
vpnodes.append([quotep(vpath) + "/", html_escape(node, quote=False)])
|
||||||
|
|
||||||
vn, rem = self.auth.vfs.get(self.vpath, self.uname, True, False)
|
vn, rem = self.auth.vfs.get(self.vpath, self.uname, self.readable, self.writable)
|
||||||
abspath = vn.canonical(rem)
|
abspath = vn.canonical(rem)
|
||||||
|
|
||||||
if not os.path.exists(fsenc(abspath)):
|
if not os.path.exists(fsenc(abspath)):
|
||||||
|
@ -665,7 +658,7 @@ class HttpCli(object):
|
||||||
dt = datetime.utcfromtimestamp(inf.st_mtime)
|
dt = datetime.utcfromtimestamp(inf.st_mtime)
|
||||||
dt = dt.strftime("%Y-%m-%d %H:%M:%S")
|
dt = dt.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
item = [margin, quotep(href), cgi.escape(fn, quote=True), sz, dt]
|
item = [margin, quotep(href), html_escape(fn, quote=False), sz, dt]
|
||||||
if is_dir:
|
if is_dir:
|
||||||
dirs.append(item)
|
dirs.append(item)
|
||||||
else:
|
else:
|
||||||
|
@ -687,6 +680,7 @@ class HttpCli(object):
|
||||||
vpnodes=vpnodes,
|
vpnodes=vpnodes,
|
||||||
files=dirs,
|
files=dirs,
|
||||||
can_upload=self.writable,
|
can_upload=self.writable,
|
||||||
|
can_read=self.readable,
|
||||||
ts=ts,
|
ts=ts,
|
||||||
prologue=logues[0],
|
prologue=logues[0],
|
||||||
epilogue=logues[1],
|
epilogue=logues[1],
|
||||||
|
|
|
@ -36,11 +36,12 @@ body {
|
||||||
padding: .35em .5em .2em .5em;
|
padding: .35em .5em .2em .5em;
|
||||||
border-radius: 0 .3em .3em 0;
|
border-radius: 0 .3em .3em 0;
|
||||||
box-shadow: .1em .1em .4em #222;
|
box-shadow: .1em .1em .4em #222;
|
||||||
margin: 1em 0;
|
margin: 2em 0 1em 0;
|
||||||
font-size: 1.4em;
|
font-size: 1.4em;
|
||||||
}
|
}
|
||||||
#files {
|
#files {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
#files tbody a {
|
#files tbody a {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
|
@ -13,16 +13,17 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{%- if can_upload %}
|
|
||||||
{%- include 'upload.html' %}
|
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
<h1 id="path">
|
<h1 id="path">
|
||||||
{%- for n in vpnodes %}
|
{%- for n in vpnodes %}
|
||||||
<a href="/{{ n[0] }}">{{ n[1] }}</a>
|
<a href="/{{ n[0] }}">{{ n[1] }}</a>
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
|
{%- if can_upload %}
|
||||||
|
{%- include 'upload.html' %}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if can_read %}
|
||||||
{%- if prologue %}
|
{%- if prologue %}
|
||||||
<div id="pro" class="logue">{{ prologue }}</div>
|
<div id="pro" class="logue">{{ prologue }}</div>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
{%- if epilogue %}
|
{%- if epilogue %}
|
||||||
<div id="epi" class="logue">{{ epilogue }}</div>
|
<div id="epi" class="logue">{{ epilogue }}</div>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
<h2><a href="?h">control-panel</a></h2>
|
<h2><a href="?h">control-panel</a></h2>
|
||||||
|
|
||||||
|
@ -60,7 +62,11 @@
|
||||||
<canvas id="barbuf"></canvas>
|
<canvas id="barbuf"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{%- if can_read %}
|
||||||
<script src="/.cpr/browser.js{{ ts }}"></script>
|
<script src="/.cpr/browser.js{{ ts }}"></script>
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{%- if can_upload %}
|
{%- if can_upload %}
|
||||||
<script src="/.cpr/up2k.js{{ ts }}"></script>
|
<script src="/.cpr/up2k.js{{ ts }}"></script>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
|
@ -105,8 +105,10 @@ function up2k_init(have_crypto) {
|
||||||
shame = 'your browser is impressively ancient';
|
shame = 'your browser is impressively ancient';
|
||||||
|
|
||||||
// upload ui hidden by default, clicking the header shows it
|
// upload ui hidden by default, clicking the header shows it
|
||||||
o('u2tgl').onclick = function (e) {
|
function toggle_upload_visible(ev) {
|
||||||
e.preventDefault();
|
if (ev)
|
||||||
|
ev.preventDefault();
|
||||||
|
|
||||||
o('u2tgl').style.display = 'none';
|
o('u2tgl').style.display = 'none';
|
||||||
o('u2body').style.display = 'block';
|
o('u2body').style.display = 'block';
|
||||||
|
|
||||||
|
@ -120,6 +122,11 @@ function up2k_init(have_crypto) {
|
||||||
o('u2foot').innerHTML = 'seems like ' + shame + ' so do that if you want more performance';
|
o('u2foot').innerHTML = 'seems like ' + shame + ' so do that if you want more performance';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
o('u2tgl').onclick = toggle_upload_visible;
|
||||||
|
|
||||||
|
// show uploader if the user only has write-access
|
||||||
|
if (!o('files'))
|
||||||
|
toggle_upload_visible();
|
||||||
|
|
||||||
// shows or clears an error message in the basic uploader ui
|
// shows or clears an error message in the basic uploader ui
|
||||||
function setmsg(msg) {
|
function setmsg(msg) {
|
||||||
|
@ -601,8 +608,7 @@ function up2k_init(have_crypto) {
|
||||||
}
|
}
|
||||||
|
|
||||||
t.t2 = new Date().getTime();
|
t.t2 = new Date().getTime();
|
||||||
if (t.n == 0) {
|
if (t.n == 0 && window.location.hash == '#dbg') {
|
||||||
// TODO remove
|
|
||||||
var spd = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.);
|
var spd = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.);
|
||||||
alert('{0} ms, {1} MB/s\n'.format(t.t2 - t.t1, spd.toFixed(3)) + t.hash.join('\n'));
|
alert('{0} ms, {1} MB/s\n'.format(t.t2 - t.t1, spd.toFixed(3)) + t.hash.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#bup {
|
#bup {
|
||||||
padding: .5em .5em .5em .3em;
|
padding: .5em .5em .5em .3em;
|
||||||
|
margin: 1em 0 2em 0;
|
||||||
background: #2d2d2d;
|
background: #2d2d2d;
|
||||||
border-radius: 0 0 1em 0;
|
border-radius: 0 1em 1em 0;
|
||||||
border: 1px solid #3a3a3a;
|
border: 1px solid #3a3a3a;
|
||||||
border-width: 0 .3em .3em 0;
|
border-width: 0 .3em .3em 0;
|
||||||
box-shadow: 0 0 1em #222 inset;
|
box-shadow: 0 0 1em #222 inset;
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
}
|
}
|
||||||
#up2k {
|
#up2k {
|
||||||
display: none;
|
display: none;
|
||||||
padding: 1.5em 1em 0 1em;
|
padding: 0 1em;
|
||||||
}
|
}
|
||||||
#u2form {
|
#u2form {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -31,6 +32,8 @@
|
||||||
#u2tgl {
|
#u2tgl {
|
||||||
color: #fc5;
|
color: #fc5;
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
|
margin: .5em 0 1em 0;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
#u2body {
|
#u2body {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
Loading…
Reference in a new issue