diff --git a/copyparty/__main__.py b/copyparty/__main__.py index ee690f7f..5be262f7 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -969,6 +969,7 @@ def add_ui(ap, retry): ap2.add_argument("--lang", metavar="LANG", type=u, default="eng", help="language") ap2.add_argument("--theme", metavar="NUM", type=int, default=0, help="default theme to use") ap2.add_argument("--themes", metavar="NUM", type=int, default=8, help="number of themes installed") + ap2.add_argument("--unlist", metavar="REGEX", type=u, default="", help="don't show files matching REGEX in file list. Purely cosmetic! Does not affect API calls, just the browser. Example: [\033[32m\.(js|css)$\033[0m] (volflag=unlist)") ap2.add_argument("--favico", metavar="TXT", type=u, default="c 000 none" if retry else "πŸŽ‰ 000 none", help="\033[33mfavicon-text\033[0m [ \033[33mforeground\033[0m [ \033[33mbackground\033[0m ] ], set blank to disable") ap2.add_argument("--mpmc", metavar="URL", type=u, default="", help="change the mediaplayer-toggle mouse cursor; URL to a folder with {2..5}.png inside (or disable with [\033[32m.\033[0m])") ap2.add_argument("--js-browser", metavar="L", type=u, help="URL to additional JS to include") diff --git a/copyparty/cfg.py b/copyparty/cfg.py index 407e6cb0..494cdb88 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -41,7 +41,7 @@ def vf_bmap() -> dict[str, str]: def vf_vmap() -> dict[str, str]: """argv-to-volflag: simple values""" ret = {} - for k in ("lg_sbf", "md_sbf"): + for k in ("lg_sbf", "md_sbf", "unlist"): ret[k] = k return ret @@ -135,6 +135,7 @@ flagcats = { }, "client and ux": { "grid": "show grid/thumbnails by default", + "unlist": "dont list files matching REGEX", "html_head=TXT": "includes TXT in the ", "robots": "allows indexing by search engines (default)", "norobots": "kindly asks search engines to leave", diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 4ebce3bf..a72d79e4 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -3459,6 +3459,7 @@ class HttpCli(object): break vf = vn.flags + unlist = vf.get("unlist", "") ls_ret = { "dirs": [], "files": [], @@ -3469,6 +3470,7 @@ class HttpCli(object): "itag": e2t, "lifetime": vn.flags.get("lifetime") or 0, "frand": bool(vn.flags.get("rand")), + "unlist": unlist, "perms": perms, "logues": logues, "readme": readme, @@ -3501,6 +3503,7 @@ class HttpCli(object): "title": html_escape(self.vpath, crlf=True) or "πŸ’ΎπŸŽ‰", "srv_info": srv_infot, "dgrid": "grid" in vf, + "unlist": unlist, "dtheme": self.args.theme, "themes": self.args.themes, "turbolvl": self.args.turbo, @@ -3730,7 +3733,12 @@ class HttpCli(object): dirs.sort(key=itemgetter("name")) if is_js: - j2a["ls0"] = {"dirs": dirs, "files": files, "taglist": taglist} + j2a["ls0"] = { + "dirs": dirs, + "files": files, + "taglist": taglist, + "unlist": unlist, + } j2a["files"] = [] else: j2a["files"] = dirs + files diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index ca0d687c..aedd9113 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -5726,6 +5726,12 @@ var treectl = (function () { seen = {}; r.lsc = res; + if (res.unlist) { + var ptn = new RegExp(res.unlist); + for (var a = nodes.length - 1; a >= 0; a--) + if (ptn.exec(nodes[a].href.split('?')[0])) + nodes.splice(a, 1); + } nodes = sortfiles(nodes); window.removeEventListener('scroll', r.tscroll); r.trunc = nodes.length > r.nvis && location.hash.length < 2; diff --git a/tests/util.py b/tests/util.py index 5303a2df..bcbf34a6 100644 --- a/tests/util.py +++ b/tests/util.py @@ -113,7 +113,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 = "doctitle favico html_head lg_sbf log_fk md_sbf mth textfiles R RS SR" + ex = "doctitle favico html_head lg_sbf log_fk md_sbf mth textfiles unlist R RS SR" ka.update(**{k: "" for k in ex.split()}) ex = "xad xar xau xbd xbr xbu xiu xm"