Skip to content

Commit

Permalink
add nsort option/volflag
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Nov 19, 2024
1 parent 9c8507a commit 8f7ffcf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions copyparty/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])")
Expand Down
1 change: 1 addition & 0 deletions copyparty/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions copyparty/httpcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5505,6 +5505,7 @@ def tx_browser(self) -> bool:
"acct": self.uname,
"idx": e2d,
"itag": e2t,
"dnsort": "nsort" in vf,
"dsort": vf["sort"],
"dcrop": vf["crop"],
"dth3x": vf["th3x"],
Expand Down Expand Up @@ -5533,6 +5534,7 @@ def tx_browser(self) -> bool:
"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"],
Expand Down
7 changes: 5 additions & 2 deletions copyparty/web/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8f7ffcf

Please sign in to comment.