From 025a5374131873c1c326ccc17a479e9423dca947 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 2 Jun 2023 18:41:21 +0000 Subject: [PATCH] add option to show thumbs by default; closes #31 --- README.md | 1 + copyparty/__main__.py | 1 + copyparty/cfg.py | 2 ++ copyparty/httpcli.py | 1 + copyparty/web/browser.html | 1 + copyparty/web/browser.js | 2 +- 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 08a5cfea..41fcde00 100644 --- a/README.md +++ b/README.md @@ -471,6 +471,7 @@ click the `🌲` or pressing the `B` hotkey to toggle between breadcrumbs path ( ## thumbnails press `g` or `η”°` to toggle grid-view instead of the file listing and `t` toggles icons / thumbnails +* can be made default globally with `--grid` or per-volume with volflag `grid` ![copyparty-thumbs-fs8](https://user-images.githubusercontent.com/241032/129636211-abd20fa2-a953-4366-9423-1c88ebb96ba9.png) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 625764ca..2efb037e 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -963,6 +963,7 @@ def add_db_metadata(ap): def add_ui(ap, retry): ap2 = ap.add_argument_group('ui options') + ap2.add_argument("--grid", action="store_true", help="show grid/thumbnails by default (volflag=grid)") 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") diff --git a/copyparty/cfg.py b/copyparty/cfg.py index bf128544..407e6cb0 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -24,6 +24,7 @@ def vf_bmap() -> dict[str, str]: "e2v", "e2vu", "e2vp", + "grid", "hardlink", "magic", "no_sb_md", @@ -133,6 +134,7 @@ flagcats = { "xm=CMD": "execute CMD on message", }, "client and ux": { + "grid": "show grid/thumbnails by default", "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 fcce03b8..4ebce3bf 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -3500,6 +3500,7 @@ class HttpCli(object): "readme": readme, "title": html_escape(self.vpath, crlf=True) or "πŸ’ΎπŸŽ‰", "srv_info": srv_infot, + "dgrid": "grid" in vf, "dtheme": self.args.theme, "themes": self.args.themes, "turbolvl": self.args.turbo, diff --git a/copyparty/web/browser.html b/copyparty/web/browser.html index 0485b2c3..df23c557 100644 --- a/copyparty/web/browser.html +++ b/copyparty/web/browser.html @@ -138,6 +138,7 @@ TS = "{{ ts }}", acct = "{{ acct }}", perms = {{ perms }}, + dgrid = {{ dgrid|tojson }}, themes = {{ themes }}, dtheme = "{{ dtheme }}", srvinf = "{{ srv_info }}", diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index ddb1340a..ca0d687c 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -4526,7 +4526,7 @@ var thegrid = (function () { bcfg_bind(r, 'thumbs', 'thumbs', true, r.setdirty); bcfg_bind(r, 'sel', 'gridsel', false, r.loadsel); - bcfg_bind(r, 'en', 'griden', false, function (v) { + bcfg_bind(r, 'en', 'griden', dgrid, function (v) { v ? loadgrid() : r.setvis(true); pbar.onresize(); vbar.onresize();