From 4f8cf2fc87f9c2740425c8f8150ce7a87062225d Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 20 Feb 2021 17:39:08 +0100 Subject: [PATCH] qol --- copyparty/httpcli.py | 2 +- copyparty/up2k.py | 10 +++++----- copyparty/web/browser.css | 8 ++++++-- copyparty/web/browser.js | 23 +++++++++++++++++------ copyparty/web/up2k.js | 21 +++++++++++---------- copyparty/web/upload.css | 8 ++++---- copyparty/web/upload.html | 8 ++++---- copyparty/web/util.js | 3 +++ 8 files changed, 51 insertions(+), 32 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index e7bb0877..740119f9 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -311,7 +311,7 @@ class HttpCli(object): reader, _ = self.get_body_reader() for buf in reader: buf = buf.decode("utf-8", "replace") - self.log("urlform:\n {}\n".format(buf)) + self.log("urlform @ {}\n {}\n".format(self.vpath, buf)) if "get" in opt: return self.handle_get() diff --git a/copyparty/up2k.py b/copyparty/up2k.py index ed9ddc5a..d54708df 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -412,11 +412,11 @@ class Up2k(object): if job["need"]: self.log("unfinished:\n {0}\n {1}".format(src, dst)) err = "partial upload exists at a different location; please resume uploading here instead:\n" - err += vsrc + " " + err += "/" + vsrc + " " raise Pebkac(400, err) elif "nodupe" in job["flag"]: self.log("dupe-reject:\n {0}\n {1}".format(src, dst)) - err = "upload rejected, file already exists:\n " + vsrc + " " + err = "upload rejected, file already exists:\n/" + vsrc + " " raise Pebkac(400, err) else: # symlink to the client-provided name, @@ -644,14 +644,14 @@ class Up2k(object): while not self.lastmod_q.empty(): ready.append(self.lastmod_q.get()) - # self.log("lmod", "got {}".format(len(ready))) + # self.log("lmod: got {}".format(len(ready))) time.sleep(5) for path, times in ready: - self.log("lmod", "setting times {} on {}".format(times, path)) + self.log("lmod: setting times {} on {}".format(times, path)) try: os.utime(fsenc(path), times) except: - self.log("lmod", "failed to utime ({}, {})".format(path, times)) + self.log("lmod: failed to utime ({}, {})".format(path, times)) def _snapshot(self): persist_interval = 30 # persist unfinished uploads index every 30 sec diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index baedfa50..36506a5c 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -154,10 +154,12 @@ a, #srv_info span { color: #fff; } -a.play { +#files tbody a.play { color: #e70; + padding: .2em; + margin: -.2em; } -a.play.act { +#files tbody a.play.act { color: #af0; } #blocked { @@ -423,6 +425,8 @@ input[type="checkbox"]:checked+label { #detree { padding: .3em .5em; font-size: 1.5em; + display: inline-block; + width: 100%; } #treefiles #files tbody { border-radius: 0 .7em 0 .7em; diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 03e45953..0e44218d 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -928,7 +928,7 @@ function autoplay_blocked() { })(); -function reload_browser() { +function reload_browser(not_mp) { makeSortable(ebi('files')); var parts = get_vpath().split('/'); @@ -945,10 +945,21 @@ function reload_browser() { ebi('path').appendChild(o); } - if (mp && mp.au) { - mp.au.pause(); - mp.au = null; + var oo = document.querySelectorAll('#files>tbody>tr>td:nth-child(3)'); + for (var a = 0, aa = oo.length; a < aa; a++) { + var sz = oo[a].textContent.replace(/ /g, ""), + hsz = sz.replace(/\B(?=(\d{3})+(?!\d))/g, " "); + + oo[a].textContent = hsz; + } + + if (!not_mp) { + if (mp && mp.au) { + mp.au.pause(); + mp.au = null; + } + widget.close(); + mp = init_mp(); } - widget.close(); - mp = init_mp(); } +reload_browser(true); diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 37da44cd..74ecf38f 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -151,10 +151,6 @@ function up2k_init(have_crypto) { ebi('u2notbtn').innerHTML = ''; } - var post_url = ebi('op_bup').getElementsByTagName('form')[0].getAttribute('action'); - if (post_url && post_url.charAt(post_url.length - 1) !== '/') - post_url += '/'; - var shame = 'your browser disables sha512 unless you use https' var is_https = (window.location + '').indexOf('https:') === 0; if (is_https) @@ -371,6 +367,7 @@ function up2k_init(have_crypto) { "name": fobj.name, "size": fobj.size, "lmod": lmod / 1000, + "purl": get_vpath(), "hash": [] }; @@ -385,7 +382,7 @@ function up2k_init(have_crypto) { var tr = document.createElement('tr'); tr.innerHTML = 'hashing'.format(st.files.length); - tr.getElementsByTagName('td')[0].textContent = entry.name; + tr.getElementsByTagName('td')[0].innerHTML = linksplit(esc(entry.purl + entry.name)).join(' '); ebi('u2tab').appendChild(tr); st.files.push(entry); @@ -758,8 +755,7 @@ function up2k_init(have_crypto) { else { smsg = 'found'; var hit = response[0], - links = linksplit(hit.rp), - msg = links.join(''), + msg = linksplit(hit.rp).join(''), tr = new Date(hit.ts * 1000).toISOString().replace("T", " ").slice(0, -5), tu = new Date(t.lmod * 1000).toISOString().replace("T", " ").slice(0, -5), diff = parseInt(t.lmod) - parseInt(hit.ts), @@ -779,7 +775,7 @@ function up2k_init(have_crypto) { if (response.name !== t.name) { // file exists; server renamed us t.name = response.name; - ebi('f{0}n'.format(t.n)).textContent = t.name; + ebi('f{0}n'.format(t.n)).innerHTML = linksplit(esc(t.purl + t.name)).join(' '); } t.postlist = []; @@ -832,6 +828,11 @@ function up2k_init(have_crypto) { var ofs = err.lastIndexOf(' : '); if (ofs > 0) err = err.slice(0, ofs); + + ofs = err.indexOf('\n/'); + if (ofs !== -1) { + err = err.slice(0, ofs + 1) + linksplit(err.slice(ofs + 2, -1)).join(' '); + } } if (err != "") { ebi('f{0}t'.format(t.n)).innerHTML = "ERROR"; @@ -858,7 +859,7 @@ function up2k_init(have_crypto) { if (fsearch) req.srch = 1; - xhr.open('POST', post_url + 'handshake.php', true); + xhr.open('POST', t.purl + 'handshake.php', true); xhr.responseType = 'text'; xhr.send(JSON.stringify(req)); } @@ -916,7 +917,7 @@ function up2k_init(have_crypto) { (xhr.responseText && xhr.responseText) || "no further information")); }; - xhr.open('POST', post_url + 'chunkpit.php', true); + xhr.open('POST', t.purl + 'chunkpit.php', true); //xhr.setRequestHeader("X-Up2k-Hash", t.hash[npart].substr(1) + "x"); xhr.setRequestHeader("X-Up2k-Hash", t.hash[npart]); xhr.setRequestHeader("X-Up2k-Wark", t.wark); diff --git a/copyparty/web/upload.css b/copyparty/web/upload.css index 426eff31..784e37cd 100644 --- a/copyparty/web/upload.css +++ b/copyparty/web/upload.css @@ -35,14 +35,14 @@ text-align: center; font-size: 1.5em; margin: .5em auto; - padding: .6em 0; + padding: 1.2em 0; width: 16em; cursor: pointer; box-shadow: .4em .4em 0 #111; } #u2conf #u2btn { - margin: -1em 0; - padding: .7em 0; + margin: -1.5em 0; + padding: 1.5em 0; width: 100%; } #u2notbtn { @@ -206,7 +206,7 @@ bottom: 0; background: #0a0; } -.prog>a>span { +#u2tab a>span { font-weight: bold; font-style: italic; color: #fff; diff --git a/copyparty/web/upload.html b/copyparty/web/upload.html index ab167a82..aa9d9bb4 100644 --- a/copyparty/web/upload.html +++ b/copyparty/web/upload.html @@ -1,7 +1,7 @@
-
+
@@ -9,7 +9,7 @@
- + @@ -17,7 +17,7 @@
- + @@ -25,7 +25,7 @@
- + diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 41b31348..a52a198d 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -174,6 +174,9 @@ function goto(dest) { function linksplit(rp) { var ret = []; var apath = '/'; + if (rp && rp.charAt(0) == '/') + rp = rp.slice(1); + while (rp) { var link = rp; var ofs = rp.indexOf('/');