diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 3081bcfe..9e726d49 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -940,6 +940,7 @@ def add_optouts(ap): ap2.add_argument("--no-dav", action="store_true", help="disable webdav support") ap2.add_argument("--no-del", action="store_true", help="disable delete operations") ap2.add_argument("--no-mv", action="store_true", help="disable move/rename operations") + ap2.add_argument("-nth", action="store_true", help="no title hostname; don't show --name in ") ap2.add_argument("-nih", action="store_true", help="no info hostname -- don't show in UI") ap2.add_argument("-nid", action="store_true", help="no info disk-usage -- don't show in UI") ap2.add_argument("-nb", action="store_true", help="no powered-by-copyparty branding in UI") @@ -1101,7 +1102,7 @@ def add_ui(ap, retry): ap2.add_argument("--ih", action="store_true", help="if a folder contains index.html, show that instead of the directory listing by default (can be changed in the client settings UI)") ap2.add_argument("--textfiles", metavar="CSV", type=u, default="txt,nfo,diz,cue,readme", help="file extensions to present as plaintext") ap2.add_argument("--txt-max", metavar="KiB", type=int, default=64, help="max size of embedded textfiles on ?doc= (anything bigger will be lazy-loaded by JS)") - ap2.add_argument("--doctitle", metavar="TXT", type=u, default="copyparty", help="title / service-name to show in html documents") + ap2.add_argument("--doctitle", metavar="TXT", type=u, default="copyparty @ --name", help="title / service-name to show in html documents") ap2.add_argument("--pb-url", metavar="URL", type=u, default="https://github.com/9001/copyparty", help="powered-by link; disable with -np") ap2.add_argument("--ver", action="store_true", help="show version on the control panel (incompatible by -np)") ap2.add_argument("--md-sbf", metavar="FLAGS", type=u, default="downloads forms popups scripts top-navigation-by-user-activation", help="list of capabilities to ALLOW for README.md docs (volflag=md_sbf); see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox") diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 0c324c7b..0dd4c9ee 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -211,7 +211,8 @@ class HttpCli(object): ka["ts"] = self.conn.hsrv.cachebuster() ka["lang"] = self.args.lang ka["favico"] = self.args.favico - ka["svcname"] = self.args.doctitle + ka["s_name"] = self.args.vbname + ka["s_doctitle"] = self.args.doctitle ka["html_head"] = self.html_head return tpl.render(**ka) # type: ignore @@ -2984,7 +2985,6 @@ class HttpCli(object): targs = { "r": self.args.SR if self.is_vproxied else "", "ts": self.conn.hsrv.cachebuster(), - "svcname": self.args.doctitle, "html_head": self.html_head, "edit": "edit" in self.uparam, "title": html_escape(self.vpath, crlf=True), @@ -3027,7 +3027,7 @@ class HttpCli(object): return True def tx_svcs(self) -> bool: - aname = re.sub("[^0-9a-zA-Z]+", "", self.args.name) or "a" + aname = re.sub("[^0-9a-zA-Z]+", "", self.args.vname) or "a" ep = self.host host = ep.split(":")[0] hport = ep[ep.find(":") :] if ":" in ep else "" @@ -3718,7 +3718,7 @@ class HttpCli(object): "url_suf": url_suf, "logues": logues, "readme": readme, - "title": html_escape(self.vpath, crlf=True) or "πŸ’ΎπŸŽ‰", + "title": html_escape("%s %s" % (self.args.vbname, self.vpath), crlf=True), "srv_info": srv_infot, "dgrid": "grid" in vf, "unlist": unlist, diff --git a/copyparty/ssdp.py b/copyparty/ssdp.py index 985bc293..3f60e6d5 100644 --- a/copyparty/ssdp.py +++ b/copyparty/ssdp.py @@ -81,7 +81,7 @@ class SSDPr(object): ubase = "{}://{}:{}".format(proto, sip, sport) zsl = self.args.zsl url = zsl if "://" in zsl else ubase + "/" + zsl.lstrip("/") - name = "{} @ {}".format(self.args.doctitle, self.args.name) + name = self.args.doctitle zs = zs.strip().format(c(ubase), c(url), c(name), c(self.args.zsid)) hc.reply(zs.encode("utf-8", "replace")) return False # close connectino diff --git a/copyparty/svchub.py b/copyparty/svchub.py index b6c3d8e0..28f63166 100644 --- a/copyparty/svchub.py +++ b/copyparty/svchub.py @@ -165,6 +165,14 @@ class SvcHub(object): ch = "abcdefghijklmnopqrstuvwx"[int(args.theme / 2)] args.theme = "{0}{1} {0} {1}".format(ch, bri) + if args.nih: + args.vname = "" + args.doctitle = args.doctitle.replace(" @ --name", "") + else: + args.vname = args.name + args.doctitle = args.doctitle.replace("--name", args.vname) + args.vbname = "" if args.nth else args.vname + if args.log_fk: args.log_fk = re.compile(args.log_fk) diff --git a/copyparty/web/browser.html b/copyparty/web/browser.html index df23c557..bf5df4b9 100644 --- a/copyparty/web/browser.html +++ b/copyparty/web/browser.html @@ -142,6 +142,7 @@ themes = {{ themes }}, dtheme = "{{ dtheme }}", srvinf = "{{ srv_info }}", + s_name = "{{ s_name }}", lang = "{{ lang }}", dfavico = "{{ favico }}", def_hcols = {{ def_hcols|tojson }}, diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 466cab91..cbf9e461 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -7414,8 +7414,16 @@ function goto_unpost(e) { } -function wintitle(txt) { - document.title = (txt ? txt : '') + get_vpath().slice(1, -1).split('/').pop(); +function wintitle(txt, noname) { + if (txt === undefined) + txt = ''; + + if (s_name && !noname) + txt = s_name + ' ' + txt; + + txt += get_vpath().slice(1, -1).split('/').pop(); + + document.title = txt; } diff --git a/copyparty/web/cf.html b/copyparty/web/cf.html index 05c5a7e9..4423f6ac 100644 --- a/copyparty/web/cf.html +++ b/copyparty/web/cf.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8"> - <title>{{ svcname }} + {{ s_doctitle }} diff --git a/copyparty/web/msg.html b/copyparty/web/msg.html index 17ac26be..e89d3755 100644 --- a/copyparty/web/msg.html +++ b/copyparty/web/msg.html @@ -3,7 +3,7 @@ - {{ svcname }} + {{ s_doctitle }} diff --git a/copyparty/web/splash.html b/copyparty/web/splash.html index 8810852e..67feeea2 100644 --- a/copyparty/web/splash.html +++ b/copyparty/web/splash.html @@ -3,7 +3,7 @@ - {{ svcname }} + {{ s_doctitle }} diff --git a/copyparty/web/svcs.html b/copyparty/web/svcs.html index d9350888..6b4cedcc 100644 --- a/copyparty/web/svcs.html +++ b/copyparty/web/svcs.html @@ -3,7 +3,7 @@ - {{ args.doctitle }} @ {{ args.name }} + {{ s_doctitle }} diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index f071459b..ac39eac2 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -723,7 +723,7 @@ function Donut(uc, st) { function strobe() { var txt = strobes.pop(); - wintitle(txt); + wintitle(txt, false); if (!txt) clearInterval(tstrober); } diff --git a/tests/util.py b/tests/util.py index ccfb445a..9b001ed9 100644 --- a/tests/util.py +++ b/tests/util.py @@ -114,7 +114,7 @@ class Cfg(Namespace): ex = "df loris re_maxage rproxy rsp_jtr rsp_slp s_wr_slp theme themes turbo" ka.update(**{k: 0 for k in ex.split()}) - ex = "ah_alg doctitle favico html_head lg_sbf log_fk md_sbf mth name textfiles unlist R RS SR" + ex = "ah_alg doctitle favico html_head lg_sbf log_fk md_sbf mth name textfiles unlist vname R RS SR" ka.update(**{k: "" for k in ex.split()}) ex = "on403 on404 xad xar xau xban xbd xbr xbu xiu xm"