mirror of
https://github.com/9001/copyparty.git
synced 2025-11-01 20:43:42 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aae8e0171e | ||
|
|
45827a2458 | ||
|
|
726030296f | ||
|
|
6659ab3881 | ||
|
|
c6a103609e | ||
|
|
c6b3f035e5 | ||
|
|
2b0a7e378e | ||
|
|
b75ce909c8 | ||
|
|
229c3f5dab | ||
|
|
ec73094506 |
@@ -198,6 +198,8 @@ it does static images with Pillow and uses FFmpeg for video files, so you may wa
|
||||
|
||||
images named `folder.jpg` and `folder.png` become the thumbnail of the folder they're in
|
||||
|
||||
in the grid/thumbnail view, if the audio player panel is open, songs will start playing when clicked
|
||||
|
||||
|
||||
## zip downloads
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# coding: utf-8
|
||||
|
||||
VERSION = (0, 11, 25)
|
||||
VERSION = (0, 11, 27)
|
||||
CODENAME = "the grid"
|
||||
BUILD_DT = (2021, 6, 25)
|
||||
|
||||
|
||||
@@ -181,6 +181,9 @@ class HttpCli(object):
|
||||
self.rvol, self.wvol, self.avol = [[], [], []]
|
||||
self.asrv.vfs.user_tree(self.uname, self.rvol, self.wvol, self.avol)
|
||||
|
||||
if pwd and "pw" in self.ouparam and pwd != cookies.get("cppwd"):
|
||||
self.out_headers["Set-Cookie"] = self.get_pwd_cookie(pwd)[0]
|
||||
|
||||
ua = self.headers.get("user-agent", "")
|
||||
self.is_rclone = ua.startswith("rclone/")
|
||||
if self.is_rclone:
|
||||
@@ -758,6 +761,12 @@ class HttpCli(object):
|
||||
pwd = self.parser.require("cppwd", 64)
|
||||
self.parser.drop()
|
||||
|
||||
ck, msg = self.get_pwd_cookie(pwd)
|
||||
html = self.j2("msg", h1=msg, h2='<a href="/">ack</a>', redir="/")
|
||||
self.reply(html.encode("utf-8"), headers={"Set-Cookie": ck})
|
||||
return True
|
||||
|
||||
def get_pwd_cookie(self, pwd):
|
||||
if pwd in self.asrv.iuser:
|
||||
msg = "login ok"
|
||||
dt = datetime.utcfromtimestamp(time.time() + 60 * 60 * 24 * 365)
|
||||
@@ -768,9 +777,7 @@ class HttpCli(object):
|
||||
exp = "Fri, 15 Aug 1997 01:00:00 GMT"
|
||||
|
||||
ck = "cppwd={}; Path=/; Expires={}; SameSite=Lax".format(pwd, exp)
|
||||
html = self.j2("msg", h1=msg, h2='<a href="/">ack</a>', redir="/")
|
||||
self.reply(html.encode("utf-8"), headers={"Set-Cookie": ck})
|
||||
return True
|
||||
return [ck, msg]
|
||||
|
||||
def handle_mkdir(self):
|
||||
new_dir = self.parser.require("name", 512)
|
||||
|
||||
@@ -243,7 +243,7 @@ var mpl = (function () {
|
||||
"pb_mode": sread('pb_mode') || 'loop-folder',
|
||||
"preload": bcfg_get('au_preload', true),
|
||||
"clip": bcfg_get('au_npclip', false),
|
||||
"os_ctl": bcfg_get('au_os_ctl', true) && have_mctl,
|
||||
"os_ctl": bcfg_get('au_os_ctl', have_mctl) && have_mctl,
|
||||
"osd_cv": bcfg_get('au_osd_cv', true),
|
||||
};
|
||||
|
||||
@@ -522,37 +522,38 @@ function get_np() {
|
||||
|
||||
// toggle player widget
|
||||
var widget = (function () {
|
||||
var ret = {},
|
||||
var r = {},
|
||||
widget = ebi('widget'),
|
||||
wtico = ebi('wtico'),
|
||||
nptxt = ebi('nptxt'),
|
||||
npirc = ebi('npirc'),
|
||||
touchmode = false,
|
||||
side_open = false,
|
||||
was_paused = true;
|
||||
|
||||
ret.open = function () {
|
||||
if (side_open)
|
||||
r.is_open = false;
|
||||
|
||||
r.open = function () {
|
||||
if (r.is_open)
|
||||
return false;
|
||||
|
||||
widget.className = 'open';
|
||||
side_open = true;
|
||||
r.is_open = true;
|
||||
return true;
|
||||
};
|
||||
ret.close = function () {
|
||||
if (!side_open)
|
||||
r.close = function () {
|
||||
if (!r.is_open)
|
||||
return false;
|
||||
|
||||
widget.className = '';
|
||||
side_open = false;
|
||||
r.is_open = false;
|
||||
return true;
|
||||
};
|
||||
ret.toggle = function (e) {
|
||||
ret.open() || ret.close();
|
||||
r.toggle = function (e) {
|
||||
r.open() || r.close();
|
||||
ev(e);
|
||||
return false;
|
||||
};
|
||||
ret.paused = function (paused) {
|
||||
r.paused = function (paused) {
|
||||
if (was_paused != paused) {
|
||||
was_paused = paused;
|
||||
ebi('bplay').innerHTML = paused ? '▶' : '⏸';
|
||||
@@ -560,7 +561,7 @@ var widget = (function () {
|
||||
};
|
||||
wtico.onclick = function (e) {
|
||||
if (!touchmode)
|
||||
ret.toggle(e);
|
||||
r.toggle(e);
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -591,7 +592,7 @@ var widget = (function () {
|
||||
document.body.removeChild(o);
|
||||
}, 500);
|
||||
};
|
||||
return ret;
|
||||
return r;
|
||||
})();
|
||||
|
||||
|
||||
@@ -857,7 +858,10 @@ function playpause(e) {
|
||||
ebi('bplay').onclick = playpause;
|
||||
ebi('bprev').onclick = prev_song;
|
||||
ebi('bnext').onclick = next_song;
|
||||
ebi('barpos').onclick = function (e) {
|
||||
|
||||
var bar = ebi('barpos');
|
||||
|
||||
bar.onclick = function (e) {
|
||||
if (!mp.au) {
|
||||
play(0, true);
|
||||
return mp.fade_in();
|
||||
@@ -868,6 +872,19 @@ function playpause(e) {
|
||||
|
||||
seek_au_mul(x * 1.0 / rect.width);
|
||||
};
|
||||
|
||||
if (!is_touch)
|
||||
bar.onwheel = function (e) {
|
||||
var dist = Math.sign(e.deltaY) * 10;
|
||||
if (Math.abs(e.deltaY) < 30 && !e.deltaMode)
|
||||
dist = e.deltaY;
|
||||
|
||||
if (!dist || !mp.au)
|
||||
return true;
|
||||
|
||||
seek_au_rel(dist);
|
||||
ev(e);
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
@@ -1186,8 +1203,11 @@ function play(tid, is_ev, seek, call_depth) {
|
||||
mp.stopfade(true);
|
||||
|
||||
var tn = tid;
|
||||
if ((tn + '').indexOf('f-') === 0)
|
||||
if ((tn + '').indexOf('f-') === 0) {
|
||||
tn = mp.order.indexOf(tn);
|
||||
if (tn < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if (tn >= mp.order.length) {
|
||||
if (mpl.pb_mode == 'loop-folder') {
|
||||
@@ -1385,8 +1405,7 @@ function autoplay_blocked(seek) {
|
||||
}
|
||||
|
||||
|
||||
// autoplay linked track
|
||||
(function () {
|
||||
function play_linked() {
|
||||
var v = location.hash;
|
||||
if (v && v.indexOf('#af-') === 0) {
|
||||
var id = v.slice(2).split('&');
|
||||
@@ -1402,7 +1421,7 @@ function autoplay_blocked(seek) {
|
||||
|
||||
return play(id[0], false, parseInt(m[1] || 0) * 60 + parseInt(m[2] || 0));
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
|
||||
var thegrid = (function () {
|
||||
@@ -1508,35 +1527,57 @@ var thegrid = (function () {
|
||||
}
|
||||
setsz();
|
||||
|
||||
function seltgl(e) {
|
||||
function gclick(e) {
|
||||
if (e && e.ctrlKey)
|
||||
return true;
|
||||
|
||||
ev(e);
|
||||
var oth = ebi(this.getAttribute('ref')),
|
||||
td = oth.parentNode.nextSibling,
|
||||
href = this.getAttribute('href'),
|
||||
aplay = ebi('a' + oth.getAttribute('id')),
|
||||
is_img = /\.(gif|jpe?g|png|webp)(\?|$)/i.test(href),
|
||||
in_tree = null,
|
||||
have_sel = QS('#files tr.sel'),
|
||||
td = oth.closest('td').nextSibling,
|
||||
tr = td.parentNode;
|
||||
|
||||
td.click();
|
||||
this.setAttribute('class', tr.getAttribute('class'));
|
||||
}
|
||||
if (/\/(\?|$)/.test(href)) {
|
||||
var ta = QSA('#treeul a.hl+ul>li>a+a'),
|
||||
txt = oth.textContent.slice(0, -1);
|
||||
|
||||
function bgopen(e) {
|
||||
for (var a = 0, aa = ta.length; a < aa; a++) {
|
||||
if (ta[a].textContent == txt) {
|
||||
in_tree = ta[a];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (r.sel) {
|
||||
td.click();
|
||||
this.setAttribute('class', tr.getAttribute('class'));
|
||||
}
|
||||
else if (widget.is_open && aplay)
|
||||
aplay.click();
|
||||
|
||||
else if (in_tree && !have_sel)
|
||||
in_tree.click();
|
||||
|
||||
else if (!is_img && have_sel)
|
||||
window.open(href, '_blank');
|
||||
|
||||
else return true;
|
||||
ev(e);
|
||||
var url = this.getAttribute('href');
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
r.loadsel = function () {
|
||||
if (r.dirty)
|
||||
return;
|
||||
|
||||
var ths = QSA('#ggrid>a'),
|
||||
have_sel = !!QS('#files tr.sel');
|
||||
var ths = QSA('#ggrid>a');
|
||||
|
||||
for (var a = 0, aa = ths.length; a < aa; a++) {
|
||||
ths[a].onclick = r.sel ? seltgl : have_sel ? bgopen : null;
|
||||
ths[a].setAttribute('class', ebi(ths[a].getAttribute('ref')).parentNode.parentNode.getAttribute('class'));
|
||||
var tr = ebi(ths[a].getAttribute('ref')).closest('tr');
|
||||
ths[a].setAttribute('class', tr.getAttribute('class'));
|
||||
}
|
||||
var uns = QS('#ggrid a[ref="unsearch"]');
|
||||
if (uns)
|
||||
@@ -1567,6 +1608,8 @@ var thegrid = (function () {
|
||||
|
||||
if (r.thumbs) {
|
||||
ihref += (ihref.indexOf('?') === -1 ? '?' : '&') + 'th=' + (have_webp ? 'w' : 'j');
|
||||
if (href == "#")
|
||||
ihref = '/.cpr/ico/⏏️';
|
||||
}
|
||||
else if (isdir) {
|
||||
ihref = '/.cpr/ico/folder';
|
||||
@@ -1594,6 +1637,11 @@ var thegrid = (function () {
|
||||
ihref + '" /><span' + ac + '>' + ao.innerHTML + '</span></a>');
|
||||
}
|
||||
ebi('ggrid').innerHTML = html.join('\n');
|
||||
|
||||
var ths = QSA('#ggrid>a');
|
||||
for (var a = 0, aa = ths.length; a < aa; a++)
|
||||
ths[a].onclick = gclick;
|
||||
|
||||
r.dirty = false;
|
||||
r.bagit();
|
||||
r.loadsel();
|
||||
@@ -2965,3 +3013,4 @@ function reload_browser(not_mp) {
|
||||
reload_browser(true);
|
||||
mukey.render();
|
||||
msel.render();
|
||||
play_linked();
|
||||
|
||||
@@ -67,6 +67,9 @@ function ev(e) {
|
||||
if (e.stopPropagation)
|
||||
e.stopPropagation();
|
||||
|
||||
if (e.stopImmediatePropagation)
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
e.returnValue = false;
|
||||
return e;
|
||||
}
|
||||
@@ -360,11 +363,11 @@ function get_vpath() {
|
||||
|
||||
|
||||
function get_pwd() {
|
||||
var pwd = ('; ' + document.cookie).split('; cppwd=');
|
||||
if (pwd.length < 2)
|
||||
return null;
|
||||
var pwd = ('; ' + document.cookie).split('; cppwd=');
|
||||
if (pwd.length < 2)
|
||||
return null;
|
||||
|
||||
return pwd[1].split(';')[0];
|
||||
return pwd[1].split(';')[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user