From 961a273764fc6afadd2bd3765a7bbae7b9961832 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 10 Apr 2026 19:37:00 +0000 Subject: [PATCH] autogrid global-option --- copyparty/__main__.py | 1 + copyparty/authsrv.py | 1 + copyparty/web/browser.js | 6 +++--- tests/util.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 43fc9916..286e358f 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1868,6 +1868,7 @@ def add_ui(ap, retry: int): ap2.add_argument("--gsel", action="store_true", help="select files in grid by ctrl-click (volflag=gsel)") ap2.add_argument("--localtime", action="store_true", help="default to local timezone instead of UTC") ap2.add_argument("--ui-filesz", metavar="FMT", type=u, default="1", help="default filesize format; one of these: 0, 1, 2, 2c, 3, 3c, 4, 4c, 5, 5c, fuzzy (see UI)") + ap2.add_argument("--gauto", metavar="PERCENT", type=int, default=0, help="switch to gridview if more than \033[33mPERCENT\033[0m of files are pics/vids; 0=disabled") ap2.add_argument("--rcm", metavar="TXT", default="yy", help="rightclick-menu; two yes/no options: 1st y/n is enable-custom-menu, 2nd y/n is enable-double") ap2.add_argument("--lang", metavar="LANG", type=u, default="eng", help="language, for example \033[32meng\033[0m / \033[32mnor\033[0m / ...") ap2.add_argument("--glang", action="store_true", help="guess the browser's default language, otherwise fall back to \033[33m--lang\033[0m") diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index af25c7e9..40d5944e 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -3258,6 +3258,7 @@ class AuthSrv(object): "idxh": int(self.args.ih), "dutc": not self.args.localtime, "dfszf": self.args.ui_filesz.strip("-"), + "dgauto": self.args.gauto, "themes": self.args.themes, "turbolvl": self.args.turbo, "nosubtle": self.args.nosubtle, diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index b525dc29..1efb295e 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -2,7 +2,7 @@ var J_BRW = 1; -if (window.rw_edit === undefined) +if (window.dgauto === undefined) alert('FATAL ERROR: receiving stale data from the server; this may be due to a broken reverse-proxy (stuck cache). Try restarting copyparty and press CTRL-SHIFT-R in the browser'); var XHR = XMLHttpRequest; @@ -6015,13 +6015,13 @@ var thegrid = (function () { pbar.onresize(); vbar.onresize(); }); - bcfg_bind(r, 'gaen', 'gauto', false, function(v) { + bcfg_bind(r, 'gaen', 'gauto', !!dgauto, function(v) { if (r.en && sread("griden") != 1) { r.en = false; r.setvis(true); } }); - ebi('ga_thresh').value = r.gathr = icfg_get('ga_thresh', 70); + ebi('ga_thresh').value = r.gathr = icfg_get('ga_thresh', dgauto || 70); ebi('ga_thresh').oninput = function (e) { var n = parseInt(this.value); swrite('ga_thresh', r.gathr = (isNum(n) ? n : 0) || 70); diff --git a/tests/util.py b/tests/util.py index 802417c5..16701876 100644 --- a/tests/util.py +++ b/tests/util.py @@ -161,7 +161,7 @@ class Cfg(Namespace): ex = "ac_convt au_vol dl_list du_iwho mtab_age reg_cap s_thead s_tbody tail_tmax tail_who th_convt th_qv th_qvx ups_who ver_iwho zip_who" ka.update(**{k: 9 for k in ex.split()}) - ex = "ctl_re db_act forget_ip idp_cookie idp_store k304 loris no304 nosubtle qr_pin qr_wait re_maxage rproxy rsp_jtr rsp_slp s_wr_slp snap_wri theme themes turbo u2ow zipmaxn zipmaxs" + ex = "ctl_re db_act forget_ip gauto idp_cookie idp_store k304 loris no304 nosubtle qr_pin qr_wait re_maxage rproxy rsp_jtr rsp_slp s_wr_slp snap_wri theme themes turbo u2ow zipmaxn zipmaxs" ka.update(**{k: 0 for k in ex.split()}) ex = "ah_alg bname chdir chmod_f chpw_db db_xattr doctitle df epilogues exit favico fika ipa ipar html_head html_head_d html_head_s idp_login idp_logout lg_sba lg_sbf log_date log_fk md_sba md_sbf name og_desc og_site og_th og_title og_title_a og_title_v og_title_i opds_exts preadmes prologues readmes shr shr1 shr_site site smsg tcolor textfiles th_pregen txt_eol ufavico ufavico_h unlist up_site vc_url vname xff_src zipmaxt R RS SR"