diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 0a3bc2d2..0b895eae 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -2281,6 +2281,9 @@ class HttpCli(object): j2a["doc"] = doc + if not self.conn.hsrv.prism: + j2a["no_prism"] = True + for d in dirs: d["name"] += "/" @@ -2289,7 +2292,7 @@ class HttpCli(object): j2a["files"] = dirs + files j2a["logues"] = logues j2a["taglist"] = taglist - j2a["txt_ext"] = self.args.textfiles.replace(',', ' ') + j2a["txt_ext"] = self.args.textfiles.replace(",", " ") if "mth" in vn.flags: j2a["def_hcols"] = vn.flags["mth"].split(",") diff --git a/copyparty/httpsrv.py b/copyparty/httpsrv.py index 4150e55e..1cc7bee7 100644 --- a/copyparty/httpsrv.py +++ b/copyparty/httpsrv.py @@ -76,6 +76,7 @@ class HttpSrv(object): x: env.get_template(x + ".html") for x in ["splash", "browser", "browser2", "msg", "md", "mde"] } + self.prism = os.path.exists(os.path.join(E.mod, "web", "deps", "prism.js.gz")) cert_path = os.path.join(E.cfg, "cert.pem") if bos.path.exists(cert_path): diff --git a/copyparty/web/browser.html b/copyparty/web/browser.html index 4b27f836..3bd37568 100644 --- a/copyparty/web/browser.html +++ b/copyparty/web/browser.html @@ -142,6 +142,7 @@ have_unpost = {{ have_unpost|tojson }}, have_zip = {{ have_zip|tojson }}, txt_ext = "{{ txt_ext }}", + {% if no_prism %}no_prism = 1,{% endif %} readme = {{ readme|tojson }}; document.documentElement.setAttribute("class", localStorage.lightmode == 1 ? "light" : "dark"); diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 7c5f38ab..bdc78026 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -2336,6 +2336,9 @@ var showfile = (function () { em = [r.sname(window.location.search), window.location.hash, em.textContent]; r.setstyle = function () { + if (window['no_prism']) + return; + qsr('#prism_css'); var el = mknod('link'); el.rel = 'stylesheet'; @@ -2438,11 +2441,13 @@ var showfile = (function () { else { el.textContent = txt; el.innerHTML = '' + el.innerHTML + ''; - el.setAttribute('class', 'prism linkable-line-numbers line-numbers language-' + lang); - if (!defer) - fun(el.firstChild); - else - import_js('/.cpr/deps/prism.js', function () { fun(); }); + if (!window['no_prism']) { + el.setAttribute('class', 'prism linkable-line-numbers line-numbers language-' + lang); + if (!defer) + fun(el.firstChild); + else + import_js('/.cpr/deps/prism.js', function () { fun(); }); + } } wr.appendChild(el); diff --git a/scripts/copyparty-repack.sh b/scripts/copyparty-repack.sh index 08049c86..47a91019 100755 --- a/scripts/copyparty-repack.sh +++ b/scripts/copyparty-repack.sh @@ -29,7 +29,8 @@ set -e # 259288 copyparty-extras/sfx-lite/copyparty-sfx.sh # 270004 copyparty-extras/sfx-lite/copyparty-sfx.py # 293159 copyparty-extras/sfx-lite/copyparty-sfx-gz.py -# `- also removed the codemirror markdown editor, +# `- also removed the codemirror markdown editor +# and the text-viewer syntax hilighting, # only essential features remaining # # 646297 copyparty-extras/copyparty-1.0.14.tar.gz @@ -141,8 +142,8 @@ repack() { repack sfx-full "re gz no-sh" repack sfx-ent "re no-dd no-ogv" repack sfx-ent "re no-dd no-ogv gz no-sh" -repack sfx-lite "re no-dd no-ogv no-cm" -repack sfx-lite "re no-dd no-ogv no-cm gz no-sh" +repack sfx-lite "re no-dd no-ogv no-cm no-hl" +repack sfx-lite "re no-dd no-ogv no-cm no-hl gz no-sh" # move fuse and up2k clients into copyparty-extras/, diff --git a/scripts/make-sfx.sh b/scripts/make-sfx.sh index 6d66bb0e..ed12f5ed 100755 --- a/scripts/make-sfx.sh +++ b/scripts/make-sfx.sh @@ -22,6 +22,8 @@ help() { exec cat <<'EOF' # `no-cm` saves ~92k by removing easymde/codemirror # (the fancy markdown editor) # +# `no-hl` saves ~41k by removing syntax hilighting in the text viewer +# # `no-fnt` saves ~9k by removing the source-code-pro font # (browsers will try to use 'Consolas' instead) # @@ -75,6 +77,7 @@ while [ ! -z "$1" ]; do gz) use_gz=1 ; ;; no-ogv) no_ogv=1 ; ;; no-fnt) no_fnt=1 ; ;; + no-hl) no_hl=1 ; ;; no-dd) no_dd=1 ; ;; no-cm) no_cm=1 ; ;; no-sh) do_sh= ; ;; @@ -226,6 +229,9 @@ rm have tmv "$f" } +[ $no_hl ] && + rm -rf copyparty/web/deps/prism* + [ $no_fnt ] && { rm -f copyparty/web/deps/scp.woff2 f=copyparty/web/ui.css diff --git a/scripts/sfx.ls b/scripts/sfx.ls index a65f5686..f7c75787 100644 --- a/scripts/sfx.ls +++ b/scripts/sfx.ls @@ -57,6 +57,9 @@ copyparty/web/deps/ogv-demuxer-ogg-wasm.js, copyparty/web/deps/ogv-demuxer-ogg-wasm.wasm, copyparty/web/deps/ogv-worker-audio.js, copyparty/web/deps/ogv.js, +copyparty/web/deps/prism.js, +copyparty/web/deps/prism.css, +copyparty/web/deps/prismd.css, copyparty/web/deps/scp.woff2, copyparty/web/deps/sha512.ac.js, copyparty/web/deps/sha512.hw.js,