Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cf6924dca | ||
|
|
5fd81e9f90 | ||
|
|
52bf6f892b | ||
|
|
f3cce232a4 | ||
|
|
53d3c8b28e |
25
README.md
25
README.md
@@ -27,6 +27,7 @@ turn your phone or raspi into a portable file server with resumable uploads/down
|
|||||||
* [metadata from audio files](#metadata-from-audio-files)
|
* [metadata from audio files](#metadata-from-audio-files)
|
||||||
* [file parser plugins](#file-parser-plugins)
|
* [file parser plugins](#file-parser-plugins)
|
||||||
* [complete examples](#complete-examples)
|
* [complete examples](#complete-examples)
|
||||||
|
* [browser support](#browser-support)
|
||||||
* [client examples](#client-examples)
|
* [client examples](#client-examples)
|
||||||
* [dependencies](#dependencies)
|
* [dependencies](#dependencies)
|
||||||
* [optional gpl stuff](#optional-gpl-stuff)
|
* [optional gpl stuff](#optional-gpl-stuff)
|
||||||
@@ -196,6 +197,29 @@ copyparty can invoke external programs to collect additional metadata for files
|
|||||||
`python copyparty-sfx.py -v /mnt/nas/music:/music:r -e2dsa -e2ts -mtp .bpm=f,audio-bpm.py -mtp key=f,audio-key.py`
|
`python copyparty-sfx.py -v /mnt/nas/music:/music:r -e2dsa -e2ts -mtp .bpm=f,audio-bpm.py -mtp key=f,audio-key.py`
|
||||||
|
|
||||||
|
|
||||||
|
# browser support
|
||||||
|
|
||||||
|
| feature | ie6 | ie9 | ie10 | ie11 | ff 52+ | chr 49+ |
|
||||||
|
| --------------- | --- | --- | ---- | ---- | ------ | ------- |
|
||||||
|
| browse files | yep | yep | yep | yep | yep | yep |
|
||||||
|
| basic uploader | yep | yep | yep | yep | yep | yep |
|
||||||
|
| make directory | yep | yep | yep | yep | yep | yep |
|
||||||
|
| send message | yep | yep | yep | yep | yep | yep |
|
||||||
|
| set sort order | - | yep | yep | yep | yep | yep |
|
||||||
|
| zip selection | - | yep | yep | yep | yep | yep |
|
||||||
|
| directory tree | - | - | `*1` | yep | yep | yep |
|
||||||
|
| up2k | - | - | yep | yep | yep | yep |
|
||||||
|
| icons work | - | - | yep | yep | yep | yep |
|
||||||
|
| markdown editor | - | - | yep | yep | yep | yep |
|
||||||
|
| markdown viewer | - | - | yep | yep | yep | yep |
|
||||||
|
| play mp3/mp4 | - | yep | yep | yep | yep | yep |
|
||||||
|
| play ogg/opus | - | - | - | - | yep | yep |
|
||||||
|
|
||||||
|
* internet explorer 6 to 8 (and netscape 4.0) behave the same
|
||||||
|
* firefox 52 and chrome 49 are the last winxp versions
|
||||||
|
* `*1` only public folders (login session is dropped) and no history / back-button
|
||||||
|
|
||||||
|
|
||||||
# client examples
|
# client examples
|
||||||
|
|
||||||
* javascript: dump some state into a file (two separate examples)
|
* javascript: dump some state into a file (two separate examples)
|
||||||
@@ -306,7 +330,6 @@ roughly sorted by priority
|
|||||||
* reduce up2k roundtrips
|
* reduce up2k roundtrips
|
||||||
* start from a chunk index and just go
|
* start from a chunk index and just go
|
||||||
* terminate client on bad data
|
* terminate client on bad data
|
||||||
* drop onto folders
|
|
||||||
* `os.copy_file_range` for up2k cloning
|
* `os.copy_file_range` for up2k cloning
|
||||||
* up2k partials ui
|
* up2k partials ui
|
||||||
* support pillow-simd
|
* support pillow-simd
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
VERSION = (0, 10, 5)
|
VERSION = (0, 10, 6)
|
||||||
CODENAME = "zip it"
|
CODENAME = "zip it"
|
||||||
BUILD_DT = (2021, 3, 31)
|
BUILD_DT = (2021, 4, 2)
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -168,8 +168,13 @@ class VFS(object):
|
|||||||
for vpath, apath, files, rd, vd in self.walk("", vrem, uname, dots, scandir):
|
for vpath, apath, files, rd, vd in self.walk("", vrem, uname, dots, scandir):
|
||||||
if flt:
|
if flt:
|
||||||
files = [x for x in files if x[0] in flt]
|
files = [x for x in files if x[0] in flt]
|
||||||
rd = [x for x in rd if x[0] in flt]
|
|
||||||
vd = {x: y for x, y in vd.items() if x in flt}
|
rm = [x for x in rd if x[0] not in flt]
|
||||||
|
[rd.remove(x) for x in rm]
|
||||||
|
|
||||||
|
rm = [x for x in vd.keys() if x not in flt]
|
||||||
|
[vd.pop(x) for x in rm]
|
||||||
|
|
||||||
flt = None
|
flt = None
|
||||||
|
|
||||||
# print(repr([vpath, apath, [x[0] for x in files]]))
|
# print(repr([vpath, apath, [x[0] for x in files]]))
|
||||||
|
|||||||
@@ -321,8 +321,19 @@ class HttpCli(object):
|
|||||||
elif "print" in opt:
|
elif "print" in opt:
|
||||||
reader, _ = self.get_body_reader()
|
reader, _ = self.get_body_reader()
|
||||||
for buf in reader:
|
for buf in reader:
|
||||||
buf = buf.decode("utf-8", "replace")
|
orig = buf.decode("utf-8", "replace")
|
||||||
self.log("urlform @ {}\n {}\n".format(self.vpath, buf))
|
m = "urlform_raw {} @ {}\n {}\n"
|
||||||
|
self.log(m.format(len(orig), self.vpath, orig))
|
||||||
|
try:
|
||||||
|
plain = unquote(buf.replace(b"+", b" "))
|
||||||
|
plain = plain.decode("utf-8", "replace")
|
||||||
|
if buf.startswith(b"msg="):
|
||||||
|
plain = plain[4:]
|
||||||
|
|
||||||
|
m = "urlform_dec {} @ {}\n {}\n"
|
||||||
|
self.log(m.format(len(plain), self.vpath, plain))
|
||||||
|
except Exception as ex:
|
||||||
|
self.log(repr(ex))
|
||||||
|
|
||||||
if "get" in opt:
|
if "get" in opt:
|
||||||
return self.handle_get()
|
return self.handle_get()
|
||||||
|
|||||||
@@ -622,7 +622,8 @@ input[type="checkbox"]:checked+label {
|
|||||||
#files td.min a {
|
#files td.min a {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#files tr.play td {
|
#files tr.play td,
|
||||||
|
#files tr.play div a {
|
||||||
background: #fc4;
|
background: #fc4;
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
color: #400;
|
color: #400;
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ function play(tid, call_depth) {
|
|||||||
setclass(oid, 'play act');
|
setclass(oid, 'play act');
|
||||||
var trs = ebi('files').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
|
var trs = ebi('files').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
|
||||||
for (var a = 0, aa = trs.length; a < aa; a++) {
|
for (var a = 0, aa = trs.length; a < aa; a++) {
|
||||||
trs[a].className = trs[a].className.replace(/ *play */, "");
|
clmod(trs[a], 'play');
|
||||||
}
|
}
|
||||||
ebi(oid).parentElement.parentElement.className += ' play';
|
ebi(oid).parentElement.parentElement.className += ' play';
|
||||||
|
|
||||||
@@ -649,10 +649,10 @@ function tree_up() {
|
|||||||
|
|
||||||
|
|
||||||
document.onkeydown = function (e) {
|
document.onkeydown = function (e) {
|
||||||
if (document.activeElement != document.body && document.activeElement.nodeName.toLowerCase() != 'a')
|
if (!document.activeElement || document.activeElement != document.body && document.activeElement.nodeName.toLowerCase() != 'a')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var k = e.code, pos = -1;
|
var k = (e.code + ''), pos = -1;
|
||||||
if (k.indexOf('Digit') === 0)
|
if (k.indexOf('Digit') === 0)
|
||||||
pos = parseInt(k.slice(-1)) * 0.1;
|
pos = parseInt(k.slice(-1)) * 0.1;
|
||||||
|
|
||||||
@@ -772,6 +772,7 @@ document.onkeydown = function (e) {
|
|||||||
// ebi('srch_q').textContent = JSON.stringify(params, null, 4);
|
// ebi('srch_q').textContent = JSON.stringify(params, null, 4);
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', '/?srch', true);
|
xhr.open('POST', '/?srch', true);
|
||||||
|
xhr.setRequestHeader('Content-Type', 'text/plain');
|
||||||
xhr.onreadystatechange = xhr_search_results;
|
xhr.onreadystatechange = xhr_search_results;
|
||||||
xhr.ts = new Date().getTime();
|
xhr.ts = new Date().getTime();
|
||||||
xhr.send(JSON.stringify(params));
|
xhr.send(JSON.stringify(params));
|
||||||
@@ -869,6 +870,7 @@ document.onkeydown = function (e) {
|
|||||||
oldcfg = [];
|
oldcfg = [];
|
||||||
ebi('files').innerHTML = orig_html;
|
ebi('files').innerHTML = orig_html;
|
||||||
orig_html = null;
|
orig_html = null;
|
||||||
|
msel.render();
|
||||||
reload_browser();
|
reload_browser();
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
@@ -997,8 +999,6 @@ var treectl = (function () {
|
|||||||
var o = links[a].parentNode;
|
var o = links[a].parentNode;
|
||||||
if (!o.getElementsByTagName('li').length)
|
if (!o.getElementsByTagName('li').length)
|
||||||
o.innerHTML = html;
|
o.innerHTML = html;
|
||||||
//else
|
|
||||||
// links[a].previousSibling.textContent = '-';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1282,7 +1282,7 @@ function find_file_col(txt) {
|
|||||||
|
|
||||||
function mk_files_header(taglist) {
|
function mk_files_header(taglist) {
|
||||||
var html = [
|
var html = [
|
||||||
'<thead>',
|
'<thead><tr>',
|
||||||
'<th name="lead"><span>c</span></th>',
|
'<th name="lead"><span>c</span></th>',
|
||||||
'<th name="href"><span>File Name</span></th>',
|
'<th name="href"><span>File Name</span></th>',
|
||||||
'<th name="sz" sort="int"><span>Size</span></th>'
|
'<th name="sz" sort="int"><span>Size</span></th>'
|
||||||
@@ -1301,7 +1301,7 @@ function mk_files_header(taglist) {
|
|||||||
html = html.concat([
|
html = html.concat([
|
||||||
'<th name="ext"><span>T</span></th>',
|
'<th name="ext"><span>T</span></th>',
|
||||||
'<th name="ts"><span>Date</span></th>',
|
'<th name="ts"><span>Date</span></th>',
|
||||||
'</thead>',
|
'</tr></thead>',
|
||||||
]);
|
]);
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
@@ -1335,13 +1335,13 @@ var filecols = (function () {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var name = span[0].textContent,
|
var name = span[0].textContent,
|
||||||
cls = '';
|
cls = false;
|
||||||
|
|
||||||
if (has(hidden, name)) {
|
if (has(hidden, name)) {
|
||||||
ohidden.push(a);
|
ohidden.push(a);
|
||||||
cls = ' min';
|
cls = true;
|
||||||
}
|
}
|
||||||
ths[a].className = ths[a].className.replace(/ *min */, " ") + cls;
|
clmod(ths[a], 'min', cls)
|
||||||
}
|
}
|
||||||
for (var a = 0; a < ncols; a++) {
|
for (var a = 0; a < ncols; a++) {
|
||||||
var cls = has(ohidden, a) ? 'min' : '';
|
var cls = has(ohidden, a) ? 'min' : '';
|
||||||
@@ -1512,12 +1512,12 @@ var mukey = (function () {
|
|||||||
|
|
||||||
function addcrc() {
|
function addcrc() {
|
||||||
var links = document.querySelectorAll(
|
var links = document.querySelectorAll(
|
||||||
'#files>tbody>tr>td:nth-child(2)>' + (
|
'#files>tbody>tr>td:first-child+td>' + (
|
||||||
ebi('unsearch') ? 'div>a:last-child' : 'a'));
|
ebi('unsearch') ? 'div>a:last-child' : 'a'));
|
||||||
|
|
||||||
for (var a = 0, aa = links.length; a < aa; a++)
|
for (var a = 0, aa = links.length; a < aa; a++)
|
||||||
if (!links[a].getAttribute('id'))
|
if (!links[a].getAttribute('id'))
|
||||||
links[a].setAttribute('id', 'f-' + crc32(links[a].textContent));
|
links[a].setAttribute('id', 'f-' + crc32(links[a].textContent || links[a].innerText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1620,27 +1620,26 @@ var msel = (function () {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
function selui() {
|
function selui() {
|
||||||
var fun = getsel().length ? "add" : "remove";
|
clmod(ebi('wtoggle'), 'sel', getsel().length);
|
||||||
ebi('wtoggle').classList[fun]('sel');
|
|
||||||
}
|
}
|
||||||
function seltgl(e) {
|
function seltgl(e) {
|
||||||
ev(e);
|
ev(e);
|
||||||
var tr = this.parentNode;
|
var tr = this.parentNode;
|
||||||
tr.classList.toggle('sel');
|
clmod(tr, 'sel', 't');
|
||||||
selui();
|
selui();
|
||||||
}
|
}
|
||||||
function evsel(e, fun) {
|
function evsel(e, fun) {
|
||||||
ev(e);
|
ev(e);
|
||||||
var trs = document.querySelectorAll('#files tbody tr');
|
var trs = document.querySelectorAll('#files tbody tr');
|
||||||
for (var a = 0, aa = trs.length; a < aa; a++)
|
for (var a = 0, aa = trs.length; a < aa; a++)
|
||||||
trs[a].classList[fun]('sel');
|
clmod(trs[a], 'sel', fun);
|
||||||
selui();
|
selui();
|
||||||
}
|
}
|
||||||
ebi('selall').onclick = function (e) {
|
ebi('selall').onclick = function (e) {
|
||||||
evsel(e, "add");
|
evsel(e, "add");
|
||||||
};
|
};
|
||||||
ebi('selinv').onclick = function (e) {
|
ebi('selinv').onclick = function (e) {
|
||||||
evsel(e, "toggle");
|
evsel(e, "t");
|
||||||
};
|
};
|
||||||
ebi('selzip').onclick = function (e) {
|
ebi('selzip').onclick = function (e) {
|
||||||
ev(e);
|
ev(e);
|
||||||
|
|||||||
@@ -979,7 +979,9 @@ function up2k_init(have_crypto) {
|
|||||||
xhr.setRequestHeader("X-Up2k-Hash", t.hash[npart]);
|
xhr.setRequestHeader("X-Up2k-Hash", t.hash[npart]);
|
||||||
xhr.setRequestHeader("X-Up2k-Wark", t.wark);
|
xhr.setRequestHeader("X-Up2k-Wark", t.wark);
|
||||||
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
|
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
|
||||||
xhr.overrideMimeType('Content-Type', 'application/octet-stream');
|
if (xhr.overrideMimeType)
|
||||||
|
xhr.overrideMimeType('Content-Type', 'application/octet-stream');
|
||||||
|
|
||||||
xhr.responseType = 'text';
|
xhr.responseType = 'text';
|
||||||
xhr.send(e.target.result);
|
xhr.send(e.target.result);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="op_msg" class="opview opbox">
|
<div id="op_msg" class="opview opbox act">
|
||||||
<form method="post" enctype="application/x-www-form-urlencoded" accept-charset="utf-8">
|
<form method="post" enctype="application/x-www-form-urlencoded" accept-charset="utf-8">
|
||||||
<input type="text" name="msg" size="30">
|
<input type="text" name="msg" size="30">
|
||||||
<input type="submit" value="send msg">
|
<input type="submit" value="send msg">
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
if (!window['console'])
|
||||||
|
window['console'] = {
|
||||||
|
"log": function (msg) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// error handler for mobile devices
|
// error handler for mobile devices
|
||||||
function hcroak(msg) {
|
function hcroak(msg) {
|
||||||
document.body.innerHTML = msg;
|
document.body.innerHTML = msg;
|
||||||
@@ -113,6 +119,15 @@ function crc32(str) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function clmod(obj, cls, add) {
|
||||||
|
var re = new RegExp('\\s*\\b' + cls + '\\s*\\b', 'g');
|
||||||
|
if (add == 't')
|
||||||
|
add = !re.test(obj.className);
|
||||||
|
|
||||||
|
obj.className = obj.className.replace(re, ' ') + (add ? ' ' + cls : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sortfiles(nodes) {
|
function sortfiles(nodes) {
|
||||||
var sopts = jread('fsort', [["lead", -1, ""], ["href", 1, ""]]);
|
var sopts = jread('fsort', [["lead", -1, ""], ["href", 1, ""]]);
|
||||||
|
|
||||||
@@ -149,7 +164,7 @@ function sortfiles(nodes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var onodes = nodes.map((x) => x);
|
var onodes = nodes.map(function (x) { return x; });
|
||||||
nodes.sort(function (n1, n2) {
|
nodes.sort(function (n1, n2) {
|
||||||
var v1 = n1._sv,
|
var v1 = n1._sv,
|
||||||
v2 = n2._sv;
|
v2 = n2._sv;
|
||||||
@@ -280,16 +295,16 @@ function opclick(e) {
|
|||||||
function goto(dest) {
|
function goto(dest) {
|
||||||
var obj = document.querySelectorAll('.opview.act');
|
var obj = document.querySelectorAll('.opview.act');
|
||||||
for (var a = obj.length - 1; a >= 0; a--)
|
for (var a = obj.length - 1; a >= 0; a--)
|
||||||
obj[a].classList.remove('act');
|
clmod(obj[a], 'act');
|
||||||
|
|
||||||
obj = document.querySelectorAll('#ops>a');
|
obj = document.querySelectorAll('#ops>a');
|
||||||
for (var a = obj.length - 1; a >= 0; a--)
|
for (var a = obj.length - 1; a >= 0; a--)
|
||||||
obj[a].classList.remove('act');
|
clmod(obj[a], 'act');
|
||||||
|
|
||||||
if (dest) {
|
if (dest) {
|
||||||
var ui = ebi('op_' + dest);
|
var ui = ebi('op_' + dest);
|
||||||
ui.classList.add('act');
|
clmod(ui, 'act', true);
|
||||||
document.querySelector('#ops>a[data-dest=' + dest + ']').classList.add('act');
|
document.querySelector('#ops>a[data-dest=' + dest + ']').className += " act";
|
||||||
|
|
||||||
var fn = window['goto_' + dest];
|
var fn = window['goto_' + dest];
|
||||||
if (fn)
|
if (fn)
|
||||||
@@ -476,8 +491,7 @@ function bcfg_upd_ui(name, val) {
|
|||||||
if (o.getAttribute('type') == 'checkbox')
|
if (o.getAttribute('type') == 'checkbox')
|
||||||
o.checked = val;
|
o.checked = val;
|
||||||
else if (o) {
|
else if (o) {
|
||||||
var fun = val ? 'add' : 'remove';
|
clmod(o, 'on', val);
|
||||||
o.classList[fun]('on');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user