fix md perm reqs + dyn up2k modeset

This commit is contained in:
ed 2021-05-13 17:22:31 +02:00
parent e7982a04fe
commit c061461d01
4 changed files with 27 additions and 21 deletions

View file

@ -120,6 +120,8 @@ class HttpCli(object):
else:
uparam[k.lower()] = False
self.ouparam = {k: v for k, v in uparam.items()}
cookies = self.headers.get("cookie") or {}
if cookies:
cookies = [x.split("=", 1) for x in cookies.split(";") if "=" in x]
@ -273,7 +275,7 @@ class HttpCli(object):
return self.tx_tree()
# conditional redirect to single volumes
if self.vpath == "" and not self.uparam:
if self.vpath == "" and not self.ouparam:
nread = len(self.rvol)
nwrite = len(self.wvol)
if nread + nwrite == 1 or (self.rvol == self.wvol and nread == 1):
@ -282,8 +284,9 @@ class HttpCli(object):
else:
vpath = self.wvol[0]
self.redirect(vpath, flavor="redirecting to", use302=True)
return True
if self.vpath != vpath:
self.redirect(vpath, flavor="redirecting to", use302=True)
return True
self.readable, self.writable = self.conn.auth.vfs.can_access(
self.vpath, self.uname

View file

@ -21,7 +21,7 @@
{%- endif %}
<a href="#" data-perm="write" data-dest="bup" data-desc="bup: basic uploader, even supports netscape 4.0">🎈</a>
<a href="#" data-perm="write" data-dest="mkdir" data-desc="mkdir: create a new directory">📂</a>
<a href="#" data-perm="write" data-dest="new_md" data-desc="new-md: create a new markdown document">📝</a>
<a href="#" data-perm="read write" data-dest="new_md" data-desc="new-md: create a new markdown document">📝</a>
<a href="#" data-perm="write" data-dest="msg" data-desc="msg: send a message to the server log">📟</a>
<a href="#" data-dest="cfg" data-desc="configuration options">⚙️</a>
<div id="opdesc"></div>

View file

@ -1307,21 +1307,20 @@ function apply_perms(perms) {
perms = perms || [];
var o = QSA('#ops>a[data-perm]');
for (var a = 0; a < o.length; a++)
o[a].style.display = 'none';
for (var a = 0; a < perms.length; a++) {
o = QSA('#ops>a[data-perm="' + perms[a] + '"]');
for (var b = 0; b < o.length; b++)
o[b].style.display = 'inline';
for (var a = 0; a < o.length; a++) {
var display = 'inline';
var needed = o[a].getAttribute('data-perm').split(' ');
for (var b = 0; b < needed.length; b++) {
if (!has(perms, needed[b])) {
display = 'none';
}
}
o[a].style.display = display;
}
var act = QS('#ops>a.act');
if (act) {
var areq = act.getAttribute('data-perm');
if (areq && !has(perms, areq))
goto();
}
if (act && act.style.display === 'none')
goto();
document.body.setAttribute('perms', perms.join(' '));

View file

@ -1309,15 +1309,19 @@ function up2k_init(have_crypto) {
}
function set_fsearch(new_state) {
var perms = document.body.getAttribute('perms'),
read_only = false;
var perms = (document.body.getAttribute('perms') + '').split(' '),
fixed = false;
if (!ebi('fsearch')) {
new_state = false;
}
else if (perms && perms.indexOf('write') === -1) {
else if (!has(perms, 'write')) {
new_state = true;
read_only = true;
fixed = true;
}
else if (!has(perms, 'read')) {
new_state = false;
fixed = true;
}
if (new_state !== undefined) {
@ -1326,7 +1330,7 @@ function up2k_init(have_crypto) {
}
try {
QS('label[for="fsearch"]').style.opacity = read_only ? '0' : '1';
QS('label[for="fsearch"]').style.display = QS('#fsearch').style.display = fixed ? 'none' : '';
}
catch (ex) { }