From 4a843a66245ea185505cbc9436ef7eff8f39ad23 Mon Sep 17 00:00:00 2001
From: ed
Date: Sat, 4 Dec 2021 02:46:00 +0100
Subject: [PATCH] unflicker navpane + add client state escape hatch
---
copyparty/httpcli.py | 25 ++++++++++++++++++-------
copyparty/web/browser.js | 1 +
copyparty/web/splash.css | 5 +++--
copyparty/web/splash.html | 6 ++++--
4 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py
index f1fe34ba..354e048a 100644
--- a/copyparty/httpcli.py
+++ b/copyparty/httpcli.py
@@ -60,6 +60,7 @@ class HttpCli(object):
self.bufsz = 1024 * 32
self.hint = None
self.trailing_slash = True
+ self.out_headerlist = []
self.out_headers = {
"Access-Control-Allow-Origin": "*",
"Cache-Control": "no-store; max-age=0",
@@ -226,7 +227,7 @@ class HttpCli(object):
self.gvol = self.asrv.vfs.aget[self.uname]
if pwd and "pw" in self.ouparam and pwd != cookies.get("cppwd"):
- self.out_headers["Set-Cookie"] = self.get_pwd_cookie(pwd)[0]
+ self.out_headerlist.append(("Set-Cookie", self.get_pwd_cookie(pwd)[0]))
self.ua = self.headers.get("user-agent", "")
self.is_rclone = self.ua.startswith("rclone/")
@@ -310,7 +311,7 @@ class HttpCli(object):
self.out_headers["Content-Type"] = mime
- for k, v in self.out_headers.items():
+ for k, v in list(self.out_headers.items()) + self.out_headerlist:
response.append("{}: {}".format(k, v))
try:
@@ -442,6 +443,9 @@ class HttpCli(object):
if "am_js" in self.uparam:
return self.set_am_js()
+ if "reset" in self.uparam:
+ return self.set_cfg_reset()
+
if "h" in self.uparam:
return self.tx_mounts()
@@ -1720,14 +1724,21 @@ class HttpCli(object):
def set_k304(self):
ck = gencookie("k304", self.uparam["k304"], 60 * 60 * 24 * 365)
- self.out_headers["Set-Cookie"] = ck
+ self.out_headerlist.append(("Set-Cookie", ck))
self.redirect("", "?h#cc")
def set_am_js(self):
- ck = gencookie("js", "y", 60 * 60 * 24 * 365)
- self.out_headers["Set-Cookie"] = ck
+ v = "n" if self.uparam["am_js"] == "n" else "y"
+ ck = gencookie("js", v, 60 * 60 * 24 * 365)
+ self.out_headerlist.append(("Set-Cookie", ck))
self.reply(b"promoted\n")
+ def set_cfg_reset(self):
+ for k in ("k304", "js", "cppwd"):
+ self.out_headerlist.append(("Set-Cookie", gencookie(k, "x", None)))
+
+ self.redirect("", "?h#cc")
+
def tx_404(self, is_403=False):
if self.args.vague_403:
m = '404 not found ┐( ´ -`)┌
or maybe you don\'t have access -- try logging in or go home
' @@ -2121,6 +2132,7 @@ class HttpCli(object): "vdir": quotep(self.vpath), "vpnodes": vpnodes, "files": [], + "ls0": None, "acct": self.uname, "perms": json.dumps(perms), "taglist": [], @@ -2344,11 +2356,10 @@ class HttpCli(object): dirs.sort(key=itemgetter("name")) - if self.cookies.get("js"): + if self.cookies.get("js") == "y": j2a["ls0"] = {"dirs": dirs, "files": files, "taglist": taglist} j2a["files"] = [] else: - j2a["ls0"] = None j2a["files"] = dirs + files j2a["logues"] = logues diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 5fd4be45..64496dc1 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -3613,6 +3613,7 @@ var treectl = (function () { if (!QS(q)) break; } + nq = Math.max(nq, get_evpath().split('/').length - 2); var iw = (treesz + Math.max(0, nq)), w = iw + 'em', w2 = (iw + 2) + 'em'; diff --git a/copyparty/web/splash.css b/copyparty/web/splash.css index 429eb542..e838ee15 100644 --- a/copyparty/web/splash.css +++ b/copyparty/web/splash.css @@ -81,9 +81,10 @@ table { text-align: right; } blockquote { - margin: 0 0 0 .6em; - padding: .7em 1em; + margin: 0 0 1.6em .6em; + padding: .7em 1em 0 1em; border-left: .3em solid rgba(128,128,128,0.5); + border-radius: 0 0 0 .25em; } diff --git a/copyparty/web/splash.html b/copyparty/web/splash.html index 820ea03c..8cc04d15 100644 --- a/copyparty/web/splash.html +++ b/copyparty/web/splash.html @@ -75,11 +75,13 @@enabling this will disconnect your client on every HTTP 304, which can prevent some buggy browsers/proxies from getting stuck (suddenly not being able to load pages), but it will also make things slower in general