sfx-customizer:

* better translation stripping
* add support in bruteforcer
* add examples

and fix login-banner usage example
This commit is contained in:
ed 2024-08-28 05:53:26 +00:00
parent cdd2da0208
commit 03b13e8a1c
5 changed files with 42 additions and 12 deletions

View file

@ -1,8 +1,8 @@
(function() { (function() {
// usage: copy this to '.banner.js' in your webroot, // usage: copy this to '.banner.js' in your webroot,
// and run copyparty with the following argument: // and run copyparty with the following arguments:
// --body-foot '<script src="/.banner.js"></script>' // --js-browser /.banner.js --js-other /.banner.js

View file

@ -1618,7 +1618,12 @@ var LANGS = ["eng", "nor", "chi"];
if (window.langmod) if (window.langmod)
langmod(); langmod();
var L = Ls[sread("cpp_lang", LANGS) || lang] || Ls.eng || Ls.nor || Ls.chi; for (var a = LANGS.length; a > 0;)
if (!Ls[LANGS[--a]])
LANGS.splice(a, 1);
var L = Ls[sread("cpp_lang", LANGS) || lang] ||
Ls.eng || Ls.nor || Ls.chi;
for (var a = 0; a < LANGS.length; a++) { for (var a = 0; a < LANGS.length; a++) {
for (var b = a + 1; b < LANGS.length; b++) { for (var b = a + 1; b < LANGS.length; b++) {

View file

@ -81,12 +81,11 @@ var Ls = {
} }
}; };
var LANGS = ["eng", "nor", "chi"];
if (window.langmod) if (window.langmod)
langmod(); langmod();
var d = Ls[sread("cpp_lang", LANGS) || lang] || Ls.eng || Ls.nor || Ls.chi; var d = Ls[sread("cpp_lang", Object.keys(Ls)) || lang] ||
Ls.eng || Ls.nor || Ls.chi;
for (var k in (d || {})) { for (var k in (d || {})) {
var f = k.slice(-1), var f = k.slice(-1),

View file

@ -3,6 +3,7 @@ set -e
echo echo
berr() { p=$(head -c 72 </dev/zero | tr '\0' =); printf '\n%s\n\n' $p; cat; printf '\n%s\n\n' $p; } berr() { p=$(head -c 72 </dev/zero | tr '\0' =); printf '\n%s\n\n' $p; cat; printf '\n%s\n\n' $p; }
aerr() { printf '%s\n' "$*" | berr; }
help() { exec cat <<'EOF' help() { exec cat <<'EOF'
@ -28,9 +29,11 @@ help() { exec cat <<'EOF'
# #
# `no-tfp` saves ~10k by removing the tftp server, disabling --tftp # `no-tfp` saves ~10k by removing the tftp server, disabling --tftp
# #
# `no-zm` saves ~7k by removing the zeroconf mDNS server
#
# `no-smb` saves ~3.5k by removing the smb / cifs server # `no-smb` saves ~3.5k by removing the smb / cifs server
# #
# `no-zm` saves ~k by removing the zeroconf mDNS server # `no-pf` saves ~2.8k by removing the option to download partyfuse
# #
# _____________________________________________________________________ # _____________________________________________________________________
# web features: # web features:
@ -52,10 +55,15 @@ help() { exec cat <<'EOF'
# #
# `ign-wd` allows building an sfx without webdeps # `ign-wd` allows building an sfx without webdeps
# #
# --------------------------------------------------------------------- # _____________________________________________________________________
#
# if you are on windows, you can use msys2: # if you are on windows, you can use msys2:
# PATH=/c/Users/$USER/AppData/Local/Programs/Python/Python310:"$PATH" ./make-sfx.sh fast # PATH=/c/Users/$USER/AppData/Local/Programs/Python/Python310:"$PATH" ./make-sfx.sh fast
#
# _____________________________________________________________________
# some usage examples:
# ./scripts/make-sfx.sh lang eng no-cm no-hl no-dd no-fnt no-smb no-pf
# ./scripts/rls.sh sfx lang eng no-cm no-hl no-dd no-fnt no-smb no-pf
# (reduces v1.14.2 from 700k to 495k)
EOF EOF
} }
@ -112,6 +120,7 @@ while [ ! -z "$1" ]; do
no-tfp) no_tfp=1 ; ;; no-tfp) no_tfp=1 ; ;;
no-smb) no_smb=1 ; ;; no-smb) no_smb=1 ; ;;
no-zm) no_zm=1 ; ;; no-zm) no_zm=1 ; ;;
no-pf) no_pf=1 ; ;;
no-fnt) no_fnt=1 ; ;; no-fnt) no_fnt=1 ; ;;
no-hl) no_hl=1 ; ;; no-hl) no_hl=1 ; ;;
no-dd) no_dd=1 ; ;; no-dd) no_dd=1 ; ;;
@ -119,7 +128,6 @@ while [ ! -z "$1" ]; do
dl-wd) dl_wd=1 ; ;; dl-wd) dl_wd=1 ; ;;
ign-wd) ign_wd=1 ; ;; ign-wd) ign_wd=1 ; ;;
fast) zopf= ; ;; fast) zopf= ; ;;
ultra) ultra=1 ; ;;
lang) shift;langs="$1"; ;; lang) shift;langs="$1"; ;;
*) help ; ;; *) help ; ;;
esac esac
@ -428,6 +436,9 @@ rm -f ftp/pyftpdlib/{__main__,prefork}.py
[ $no_zm ] && [ $no_zm ] &&
rm -rf copyparty/mdns.py copyparty/stolen/dnslib rm -rf copyparty/mdns.py copyparty/stolen/dnslib
[ $no_pf ] &&
rm -rf copyparty/web/a/partyfuse.py
[ $no_cm ] && { [ $no_cm ] && {
rm -rf copyparty/web/mde.* copyparty/web/deps/easymde* rm -rf copyparty/web/mde.* copyparty/web/deps/easymde*
echo h > copyparty/web/mde.html echo h > copyparty/web/mde.html
@ -451,11 +462,16 @@ rm -f ftp/pyftpdlib/{__main__,prefork}.py
ised 's/(cursor: ?)url\([^)]+\), ?(pointer)/\1\2/; s/[0-9]+% \{cursor:[^}]+\}//; s/animation: ?cursor[^};]+//' $f ised 's/(cursor: ?)url\([^)]+\), ?(pointer)/\1\2/; s/[0-9]+% \{cursor:[^}]+\}//; s/animation: ?cursor[^};]+//' $f
} }
[ $langs ] && [ $langs ] && {
echo $langs | grep -q eng || {
langs="eng|$langs"
aerr "ERROR: removing english is not supported; will do this instead: $langs"
}
for f in copyparty/web/{browser.js,splash.js}; do for f in copyparty/web/{browser.js,splash.js}; do
gzip -d "$f.gz" || true gzip -d "$f.gz" || true
iawk '/^\}/{l=0} !l; /^var Ls =/{l=1;next} o; /^\t["}]/{o=0} /^\t"'"$langs"'"/{o=1;print}' $f iawk '/^\}/{l=0} !l; /^var Ls =/{l=1;next} !l{next} o; /^\t["}]/{o=0} /^\t"'"$langs"'"/{o=1;print}' $f
done done
}
[ ! $repack ] && { [ ! $repack ] && {
# uncomment # uncomment

View file

@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
set -e set -e
# if specified, keep the following sfx flags last: gz gzz fast
parallel=1 parallel=1
[ -e make-sfx.sh ] || cd scripts [ -e make-sfx.sh ] || cd scripts
@ -35,6 +37,14 @@ f=../dist/copyparty-sfx
$f$s.py --version >/dev/null $f$s.py --version >/dev/null
while [ "$1" ]; do
case "$1" in
gz*) break;;
fast) break;;
esac
shift
done
[ $parallel -gt 1 ] && { [ $parallel -gt 1 ] && {
printf '\033[%s' s 2r H "0;1;37;44mbruteforcing sfx size -- press enter to terminate" K u "7m $* " K $'27m\n' printf '\033[%s' s 2r H "0;1;37;44mbruteforcing sfx size -- press enter to terminate" K u "7m $* " K $'27m\n'
trap "rm -f .sfx-run; printf '\033[%s' s r u" INT TERM EXIT trap "rm -f .sfx-run; printf '\033[%s' s r u" INT TERM EXIT