diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 4e9f3f50..864391d9 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1457,6 +1457,7 @@ def add_ui(ap, retry): ap2.add_argument("--themes", metavar="NUM", type=int, default=8, help="number of themes installed") ap2.add_argument("--au-vol", metavar="0-100", type=int, default=50, choices=range(0, 101), help="default audio/video volume percent") ap2.add_argument("--sort", metavar="C,C,C", type=u, default="href", help="default sort order, comma-separated column IDs (see header tooltips), prefix with '-' for descending. Examples: \033[32mhref -href ext sz ts tags/Album tags/.tn\033[0m (volflag=sort)") + ap2.add_argument("--nsort", action="store_true", help="default-enable natural sort of filenames with leading numbers (volflag=nsort)") ap2.add_argument("--unlist", metavar="REGEX", type=u, default="", help="don't show files matching \033[33mREGEX\033[0m 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])") diff --git a/copyparty/cfg.py b/copyparty/cfg.py index 56d533e7..496879eb 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -42,6 +42,7 @@ def vf_bmap() -> dict[str, str]: "magic", "no_sb_md", "no_sb_lg", + "nsort", "og", "og_no_head", "og_s_title", diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index a97a0bde..3aa5bb6b 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -5505,6 +5505,7 @@ class HttpCli(object): "acct": self.uname, "idx": e2d, "itag": e2t, + "dnsort": "nsort" in vf, "dsort": vf["sort"], "dcrop": vf["crop"], "dth3x": vf["th3x"], @@ -5533,6 +5534,7 @@ class HttpCli(object): "sb_md": "" if "no_sb_md" in vf else (vf.get("md_sbf") or "y"), "dgrid": "grid" in vf, "dgsel": "gsel" in vf, + "dnsort": "nsort" in vf, "dsort": vf["sort"], "dcrop": vf["crop"], "dth3x": vf["th3x"], diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index b9aabbe7..3879af3f 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -4214,6 +4214,8 @@ function eval_hash() { function read_dsort(txt) { + dnsort = dnsort ? 1 : 0; + clmod(ebi('nsort'), 'on', (sread('nsort') || dnsort) == 1); try { var zt = (('' + txt).trim() || 'href').split(/,+/g); dsort = []; @@ -4244,7 +4246,7 @@ function sortfiles(nodes) { var sopts = jread('fsort', jcp(dsort)), dir1st = sread('dir1st') !== '0'; - var collator = sread('nsort') != 1 ? null : + var collator = !clgot(ebi('nsort'), 'on') ? null : new Intl.Collator([], {numeric: true}); try { @@ -7032,7 +7034,7 @@ var treectl = (function () { xhr.open('GET', SR + '/?setck=dots=' + (v ? 'y' : ''), true); xhr.send(); }); - bcfg_bind(r, 'nsort', 'nsort', false, resort); + bcfg_bind(r, 'nsort', 'nsort', dnsort, resort); bcfg_bind(r, 'dir1st', 'dir1st', true, resort); setwrap(bcfg_bind(r, 'wtree', 'wraptree', true, setwrap)); setwrap(bcfg_bind(r, 'parpane', 'parpane', true, onscroll)); @@ -7538,6 +7540,7 @@ var treectl = (function () { if (res.files[a].tags === undefined) res.files[a].tags = {}; + dnsort = res.dnsort; read_dsort(res.dsort); dcrop = res.dcrop; dth3x = res.dth3x;