Compare commits

..

8 Commits

Author SHA1 Message Date
ed
0c786b0766 v0.10.17 2021-05-12 23:39:54 +02:00
ed
68c7528911 yes good 2021-05-12 23:26:30 +02:00
ed
26e18ae800 disallow uploading logues 2021-05-12 23:22:43 +02:00
ed
c30dc0b546 write-only QoL mostly 2021-05-12 23:06:13 +02:00
ed
f94aa46a11 open write-only folders from tree 2021-05-12 21:50:32 +02:00
ed
403261a293 support pyinstaller 2021-05-12 21:21:07 +02:00
ed
c7d9cbb11f show logues in write-only folders 2021-05-12 21:20:59 +02:00
ed
57e1c53cbb mention volume flags in the cfg-file example 2021-05-02 09:48:19 +02:00
14 changed files with 113 additions and 40 deletions

View File

@@ -136,11 +136,13 @@ summary: it works! you can use it! (but technically not even close to beta)
## hotkeys
the browser has the following hotkeys
* `0..9` jump to 10%..90%
* `U/O` skip 10sec back/forward
* `J/L` prev/next song
* `I/K` prev/next folder
* `P` parent folder
* when playing audio:
* `0..9` jump to 10%..90%
* `U/O` skip 10sec back/forward
* `J/L` prev/next song
* `J` also starts playing the folder
## tree-mode
@@ -203,6 +205,8 @@ and then theres the tabs below it,
* plus up to 3 entries each from `[done]` and `[que]` for context
* `[que]` is all the files that are still queued
protip: you can avoid scaring away users by hiding some of the UI with hacks like [docs/minimal-up2k.html](docs/minimal-up2k.html)
### file-search
![copyparty-fsearch-fs8](https://user-images.githubusercontent.com/241032/116008320-36919780-a614-11eb-803f-04162326a700.png)
@@ -399,7 +403,7 @@ these are standalone programs and will never be imported / evaluated by copypart
# sfx
currently there are two self-contained binaries:
currently there are two self-contained "binaries":
* [copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.py) -- pure python, works everywhere
* [copyparty-sfx.sh](https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.sh) -- smaller, but only for linux and macos

View File

@@ -24,6 +24,9 @@ MACOS = platform.system() == "Darwin"
class EnvParams(object):
def __init__(self):
self.mod = os.path.dirname(os.path.realpath(__file__))
if self.mod.endswith("__init__"):
self.mod = os.path.dirname(self.mod)
if sys.platform == "win32":
self.cfg = os.path.normpath(os.environ["APPDATA"] + "/copyparty")
elif sys.platform == "darwin":

View File

@@ -1,8 +1,8 @@
# coding: utf-8
VERSION = (0, 10, 16)
VERSION = (0, 10, 17)
CODENAME = "zip it"
BUILD_DT = (2021, 5, 2)
BUILD_DT = (2021, 5, 12)
S_VERSION = ".".join(map(str, VERSION))
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)

View File

@@ -141,7 +141,12 @@ class VFS(object):
real.sort()
if not rem:
for name, vn2 in sorted(self.nodes.items()):
if uname in vn2.uread or "*" in vn2.uread:
if (
uname in vn2.uread
or "*" in vn2.uread
or uname in vn2.uwrite
or "*" in vn2.uwrite
):
virt_vis[name] = vn2
# no vfs nodes in the list of real inodes

View File

@@ -741,7 +741,9 @@ class HttpCli(object):
if p_file and not nullwrite:
fdir = os.path.join(vfs.realpath, rem)
fname = sanitize_fn(p_file)
fname = sanitize_fn(
p_file, bad=[".prologue.html", ".epilogue.html"]
)
if not os.path.isdir(fsenc(fdir)):
raise Pebkac(404, "that folder does not exist")
@@ -1360,6 +1362,21 @@ class HttpCli(object):
if "b" in self.uparam:
tpl = "browser2"
logues = ["", ""]
for n, fn in enumerate([".prologue.html", ".epilogue.html"]):
fn = os.path.join(abspath, fn)
if os.path.exists(fsenc(fn)):
with open(fsenc(fn), "rb") as f:
logues[n] = f.read().decode("utf-8")
ls_ret = {
"dirs": [],
"files": [],
"taglist": [],
"srvinf": srv_info,
"perms": perms,
"logues": logues,
}
j2a = {
"vdir": quotep(self.vpath),
"vpnodes": vpnodes,
@@ -1373,13 +1390,15 @@ class HttpCli(object):
"have_zip": (not self.args.no_zip),
"have_b_u": (self.writable and self.uparam.get("b") == "u"),
"url_suf": url_suf,
"logues": ["", ""],
"logues": logues,
"title": html_escape(self.vpath, crlf=True),
"srv_info": srv_info,
}
if not self.readable:
if is_ls:
raise Pebkac(403)
ret = json.dumps(ls_ret)
self.reply(ret.encode("utf-8", "replace"), mime="application/json")
return True
if not os.path.isdir(fsenc(abspath)):
raise Pebkac(404)
@@ -1526,24 +1545,12 @@ class HttpCli(object):
for f in dirs:
f["tags"] = {}
logues = ["", ""]
for n, fn in enumerate([".prologue.html", ".epilogue.html"]):
fn = os.path.join(abspath, fn)
if os.path.exists(fsenc(fn)):
with open(fsenc(fn), "rb") as f:
logues[n] = f.read().decode("utf-8")
if is_ls:
[x.pop(k) for k in ["name", "dt"] for y in [dirs, files] for x in y]
ret = {
"dirs": dirs,
"files": files,
"srvinf": srv_info,
"perms": perms,
"logues": logues,
"taglist": taglist,
}
ret = json.dumps(ret)
ls_ret["dirs"] = dirs
ls_ret["files"] = files
ls_ret["taglist"] = taglist
ret = json.dumps(ls_ret)
self.reply(ret.encode("utf-8", "replace"), mime="application/json")
return True

View File

@@ -87,7 +87,7 @@ def gen_hdr(h_pos, fn, sz, lastmod, utf8, crc32, pre_crc):
ret += struct.pack("<LL", vsz, vsz)
# windows support (the "?" replace below too)
fn = sanitize_fn(fn, "/")
fn = sanitize_fn(fn, ok="/")
bfn = fn.encode("utf-8" if utf8 else "cp437", "replace").replace(b"?", b"_")
z64_len = len(z64v) * 8 + 4 if z64v else 0

View File

@@ -891,7 +891,7 @@ class Up2k(object):
if cj["ptop"] not in self.registry:
raise Pebkac(410, "location unavailable")
cj["name"] = sanitize_fn(cj["name"])
cj["name"] = sanitize_fn(cj["name"], bad=[".prologue.html", ".epilogue.html"])
cj["poke"] = time.time()
wark = self._get_wark(cj)
now = time.time()

View File

@@ -576,7 +576,7 @@ def undot(path):
return "/".join(ret)
def sanitize_fn(fn, ok=""):
def sanitize_fn(fn, ok="", bad=[]):
if "/" not in ok:
fn = fn.replace("\\", "/").split("/")[-1]
@@ -595,12 +595,12 @@ def sanitize_fn(fn, ok=""):
for bad, good in [x for x in remap if x[0] not in ok]:
fn = fn.replace(bad, good)
bad = ["con", "prn", "aux", "nul"]
bad.extend(["con", "prn", "aux", "nul"])
for n in range(1, 10):
bad += "com{0} lpt{0}".format(n).split(" ")
if fn.lower() in bad:
fn = "_" + fn
if fn.lower() in bad:
fn = "_" + fn
return fn.strip()

View File

@@ -1326,6 +1326,7 @@ function apply_perms(perms) {
document.body.setAttribute('perms', perms.join(' '));
var have_write = has(perms, "write"),
have_read = has(perms, "read"),
tds = QSA('#u2conf td');
for (var a = 0; a < tds.length; a++) {
@@ -1336,6 +1337,11 @@ function apply_perms(perms) {
if (window['up2k'])
up2k.set_fsearch();
ebi('widget').style.display = have_read ? '' : 'none';
ebi('files').style.display = have_read ? '' : 'none';
if (!have_read)
goto('up2k');
}

View File

@@ -420,6 +420,8 @@ function up2k_init(have_crypto) {
ebi('u2notbtn').innerHTML = '';
}
var suggest_up2k = 'this is the basic uploader; <a href="#" id="u2yea">up2k</a> is better';
var shame = 'your browser <a href="https://www.chromium.org/blink/webcrypto">disables sha512</a> unless you <a href="' + (window.location + '').replace(':', 's:') + '">use https</a>',
is_https = (window.location + '').indexOf('https:') === 0;
@@ -441,34 +443,43 @@ function up2k_init(have_crypto) {
}
// show uploader if the user only has write-access
if (!ebi('files'))
var perms = (document.body.getAttribute('perms') + '').split(' ');
if (!has(perms, 'read'))
goto('up2k');
// shows or clears an error message in the basic uploader ui
function setmsg(msg) {
// shows or clears a message in the basic uploader ui
function setmsg(msg, type) {
if (msg !== undefined) {
ebi('u2err').setAttribute('class', 'err');
ebi('u2err').setAttribute('class', type);
ebi('u2err').innerHTML = msg;
}
else {
ebi('u2err').setAttribute('class', '');
ebi('u2err').innerHTML = '';
}
if (msg == suggest_up2k) {
ebi('u2yea').onclick = function (e) {
ev(e);
goto('up2k');
};
}
}
// switches to the basic uploader with msg as error message
function un2k(msg) {
setmsg(msg);
setmsg(msg, 'err');
return false;
}
// handle user intent to use the basic uploader instead
ebi('u2nope').onclick = function (e) {
ev(e);
setmsg();
setmsg(suggest_up2k, 'msg');
goto('bup');
};
setmsg(suggest_up2k, 'msg');
if (!String.prototype.format) {
String.prototype.format = function () {
var args = arguments;

View File

@@ -19,6 +19,10 @@
color: #f87;
padding: .5em;
}
#u2err.msg {
color: #999;
padding: .5em;
}
#u2btn {
color: #eee;
background: #555;

View File

@@ -36,7 +36,7 @@
<table id="u2conf">
<tr>
<td>parallel uploads</td>
<td>parallel uploads:</td>
<td rowspan="2">
<input type="checkbox" id="multitask" />
<label for="multitask" alt="continue hashing other files while uploading">🏃</label>
@@ -99,5 +99,5 @@
</table>
<p id="u2foot"></p>
<p id="u2footfoot">( if you don't need lastmod timestamps, resumable uploads or progress bars just use the <a href="#" id="u2nope">basic uploader</a>)</p>
<p id="u2footfoot">( you can use the <a href="#" id="u2nope">basic uploader</a> if you don't need lastmod timestamps, resumable uploads, or progress bars )</p>
</div>

View File

@@ -32,9 +32,13 @@ r
# and a folder where anyone can upload
# but nobody can see the contents
# and set the e2d flag to enable the uploads database
# and set the nodupe flag to reject duplicate uploads
/home/ed/inc
/dump
w
c e2d
c nodupe
# this entire config file can be replaced with these arguments:
# -u ed:123 -u k:k -v .::r:aed -v priv:priv:rk:aed -v /home/ed/Music:music:r -v /home/ed/inc:dump:w

29
docs/minimal-up2k.html Normal file
View File

@@ -0,0 +1,29 @@
<!--
save this as .epilogue.html inside a
write-only folder to declutter the UI
-->
<style>
/* make the up2k ui REALLY minimal by hiding a bunch of stuff: */
#ops, #tree, #path, /* main tabs and navigators (tree/breadcrumbs) */
#u2cleanup, #u2conf tr:first-child>td[rowspan]:not(#u2btn_cw), /* most of the config options */
#u2cards /* and the upload progress tabs */
{display:none!important} /* do it! */
/* add some margins because now it's weird */
.opview {margin-top: 2.5em}
#op_up2k {margin-top: 5em}
/* and embiggen the upload button */
#u2conf #u2btn, #u2btn {padding:1.5em 0}
</style>
<a href="#" onclick="this.parentNode.innerHTML='';">show advanced options</a>