From e7cd922d8bd41ea0c3568183b36e1b6a90fcc789 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 15 May 2022 13:20:52 +0200 Subject: [PATCH] translate splashpage and search too --- copyparty/httpcli.py | 6 +- copyparty/web/browser.js | 93 +++++++++++++++----- copyparty/web/md.html | 6 +- copyparty/web/mde.html | 2 +- copyparty/web/msg.html | 70 +++++++-------- copyparty/web/splash.css | 14 +-- copyparty/web/splash.html | 173 ++++++++++++++++++-------------------- copyparty/web/splash.js | 43 ++++++++++ scripts/make-sfx.sh | 12 +-- scripts/sfx.ls | 1 + 10 files changed, 256 insertions(+), 164 deletions(-) create mode 100644 copyparty/web/splash.js diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 1292f6ec..0c4d37de 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1829,12 +1829,12 @@ class HttpCli(object): def tx_404(self, is_403=False): rc = 404 if self.args.vague_403: - m = '

404 not found  ┐( ´ -`)┌

or maybe you don\'t have access -- try logging in or go home

' + m = '

404 not found  ┐( ´ -`)┌

or maybe you don\'t have access -- try logging in or go home

' elif is_403: - m = '

403 forbiddena  ~┻━┻

you\'ll have to log in or go home

' + m = '

403 forbiddena  ~┻━┻

you\'ll have to log in or go home

' rc = 403 else: - m = '

404 not found  ┐( ´ -`)┌

go home

' + m = '

404 not found  ┐( ´ -`)┌

go home

' html = self.j2("splash", this=self, qvpath=quotep(self.vpath), msg=m) self.reply(html.encode("utf-8"), status=rc) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index fab2c209..df1887c9 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -25,8 +25,10 @@ var Ls = { }, "goh": "control-panel", + "logout": "Logout ", + "access": " access", "ot_close": "close submenu", - "ot_search": "search for files by attributes, path / name, music tags, or any combination of those$N$N<code>foo bar</code> = must contain both «foo» and «bar»,$N<code>foo -bar</code> = must contain «foo» but not «bar»,$N<code>^yana .opus$</code> = start with «yana» and be an «opus» file$N<code>"try unite"</code> = contain exactly «try unite»", + "ot_search": "search for files by attributes, path / name, music tags, or any combination of those$N$N<code>foo bar</code> = must contain both «foo» and «bar»,$N<code>foo -bar</code> = must contain «foo» but not «bar»,$N<code>^yana .opus$</code> = start with «yana» and be an «opus» file$N<code>"try unite"</code> = contain exactly «try unite»$N$Nthe date format is iso-8601, like$N<code>2009-12-31</code> or <code>2020-09-12 23:30:00</code>", "ot_unpost": "unpost: delete your recent uploads", "ot_bup": "bup: basic uploader, even supports netscape 4.0", "ot_mkdir": "mkdir: create a new directory", @@ -37,6 +39,10 @@ var Ls = { "ot_u2i": 'up2k: upload files (if you have write-access) or toggle into the search-mode to see if they exist somewhere on the server$N$Nuploads are resumable, multithreaded, and file timestamps are preserved, but it uses more CPU than the basic uploader', "ot_u2w": 'up2k: upload files with resume support (close your browser and drop the same files in later)$N$Nmultithreaded, and file timestamps are preserved, but it uses more CPU than the basic uploader', + "ab_mkdir": "make directory", + "ab_mkdoc": "new markdown doc", + "ab_msg": "send msg to srv log", + "wt_ren": "rename selected items$NHotkey: F2", "wt_del": "delete selected items$NHotkey: ctrl-K", "wt_cut": "cut selected items <small>(then paste somewhere else)</small>$NHotkey: ctrl-X", @@ -217,6 +223,21 @@ var Ls = { "sl_hits": "showing {0} hits", "sl_moar": "load more", + "s_sz": "size", + "s_dt": "date", + "s_rd": "path", + "s_fn": "name", + "s_ta": "tags", + "s_ad": "adv.", + "s_s1": "minimum MiB", + "s_s2": "maximum MiB", + "s_d1": "min. iso8601", + "s_d2": "max. iso8601", + "s_r1": "path contains   (space-separated)", + "s_f1": "name contains   (negate with -nope)", + "s_t1": "tags contains   (^=start, end=$)", + "s_a1": "key>=1A  key<=2B  .bpm>165", + "md_eshow": "cannot show ", "xhr403": "403: Access denied\n\ntry pressing F5, maybe you got logged out", @@ -302,8 +323,10 @@ var Ls = { }, "goh": "kontrollpanel", + "logout": "Logg ut ", + "access": " tilgang", "ot_close": "lukk verktøy", - "ot_search": "søk etter filer ved å angi filnavn, mappenavn, tid, størrelse, eller metadata som sangtittel / artist / osv.$N$N<code>foo bar</code> = inneholder både «foo» og «bar»,$N<code>foo -bar</code> = inneholder «foo» men ikke «bar»,$N<code>^yana .opus$</code> = starter med «yana», filtype «opus»$N<code>"try unite"</code> = «try unite» eksakt", + "ot_search": "søk etter filer ved å angi filnavn, mappenavn, tid, størrelse, eller metadata som sangtittel / artist / osv.$N$N<code>foo bar</code> = inneholder både «foo» og «bar»,$N<code>foo -bar</code> = inneholder «foo» men ikke «bar»,$N<code>^yana .opus$</code> = starter med «yana», filtype «opus»$N<code>"try unite"</code> = «try unite» eksakt$N$Ndatoformat er iso-8601, så f.eks.$N<code>2009-12-31</code> eller <code>2020-09-12 23:30:00</code>", "ot_unpost": "unpost: slett filer som du nylig har lastet opp; «angre-knappen»", "ot_bup": "bup: tradisjonell / primitiv filopplastning,$N$Nfungerer i omtrent samtlige nettlesere", "ot_mkdir": "mkdir: lag en ny mappe", @@ -314,6 +337,10 @@ var Ls = { "ot_u2i": 'up2k: last opp filer (hvis du har skrivetilgang) eller bytt til søkemodus for å sjekke om filene finnes et-eller-annet sted på serveren$N$Nopplastninger kan gjenopptas etter avbrudd, skjer stykkevis for potensielt høyere ytelse, og ivaretar datostempling -- men bruker litt mer prosessorkraft enn den primitive opplasteren bup', "ot_u2w": 'up2k: filopplastning med støtte for å gjenoppta avbrutte opplastninger -- steng ned nettleseren og dra de samme filene inn i nettleseren igjen for å plukke opp igjen der du slapp$N$Nopplastninger skjer stykkevis for potensielt høyere ytelse, og ivaretar datostempling -- men bruker litt mer prosessorkraft enn den primitive opplasteren "bup"', + "ab_mkdir": "lag mappe", + "ab_mkdoc": "nytt dokument", + "ab_msg": "send melding", + "wt_ren": "gi nye navn til de valgte filene$NSnarvei: F2", "wt_del": "slett de valgte filene$NSnarvei: ctrl-K", "wt_cut": "klipp ut de valgte filene <small>(for å lime inn et annet sted)</small>$NSnarvei: ctrl-X", @@ -396,7 +423,7 @@ var Ls = { "ml_pmode": "spillemodus", "ml_tcode": "konvertering", "ml_tint": "tint", - "ml_eq": "audio equalizer / tonekontroll", + "ml_eq": "audio equalizer (tonejustering)", "mt_preload": "hent ned litt av neste sang i forkant,$Nslik at pausen i overgangen blir mindre\">forles", "mt_fullpre": "hent ned hele neste sang, ikke bare litt:$N✅ skru på hvis nettet ditt er ustabilt,$N❌ skru av hvis nettet ditt er tregt\">full", @@ -404,7 +431,7 @@ var Ls = { "mt_octl": "integrering med operativsystemet (fjernkontroll, info-skjerm)\">os-ctl", "mt_oseek": "tillat spoling med fjernkontroll\">spoling", "mt_oscv": "vis album-cover på infoskjermen\">bilde", - "mt_mloop": "repeter hele mappen\">🔁 repeter", + "mt_mloop": "repeter hele mappen\">🔁 gjenta", "mt_mnext": "hopp til neste mappe og fortsett\">📂 neste", "mt_cflac": "konverter flac-filer til opus\">flac", "mt_caac": "konverter aac / m4a-filer til to opus\">aac", @@ -494,6 +521,21 @@ var Ls = { "sl_hits": "viser {0} treff", "sl_moar": "hent flere", + "s_sz": "størr.", + "s_dt": "dato", + "s_rd": "sti", + "s_fn": "navn", + "s_ta": "meta", + "s_ad": "avns.", + "s_s1": "større enn ↓ MiB", + "s_s2": "mindre enn ↓ MiB", + "s_d1": "nyere enn <dato>", + "s_d2": "eldre enn", + "s_r1": "mappenavn inneholder", + "s_f1": "filnavn inneholder", + "s_t1": "sang-info inneholder", + "s_a1": "key>=1A  key<=2B  .bpm>165", + "md_eshow": "kan ikke vise ", "xhr403": "403: Tilgang nektet\n\nkanskje du ble logget ut? prøv å trykk F5", @@ -560,7 +602,7 @@ var Ls = { var L = Ls[sread("lang") || lang]; if (Ls.eng && L != Ls.eng) { for (var k in Ls.eng) - if (Ls.eng.hasOwnProperty(k) && !L[k]) + if (!L[k]) L[k] = Ls.eng[k]; } @@ -765,6 +807,9 @@ ebi('tree').innerHTML = ( ); ebi('entree').setAttribute('tt', L.tt_entree); ebi('goh').textContent = L.goh; +QS('#op_mkdir input[type="submit"]').value = L.ab_mkdir; +QS('#op_new_md input[type="submit"]').value = L.ab_mkdoc; +QS('#op_msg input[type="submit"]').value = L.ab_msg; (function () { @@ -3881,29 +3926,35 @@ document.onkeydown = function (e) { // search (function () { var sconf = [ - ["size", - ["szl", "sz_min", "minimum MiB", "14"], - ["szu", "sz_max", "maximum MiB", "14"] + [ + L.s_sz, + ["szl", "sz_min", L.s_s1, "14"], + ["szu", "sz_max", L.s_s2, "14"] ], - ["date", - ["dtl", "dt_min", "min. iso8601", "14"], - ["dtu", "dt_max", "max. iso8601", "14"] + [ + L.s_dt, + ["dtl", "dt_min", L.s_d1, "14"], + ["dtu", "dt_max", L.s_d2, "14"] ], - ["path", - ["path", "path", "path contains   (space-separated)", "30"] + [ + L.s_rd, + ["path", "path", L.s_r1, "30"] ], - ["name", - ["name", "name", "name contains   (negate with -nope)", "30"] + [ + L.s_fn, + ["name", "name", L.s_f1, "30"] ] ]; var oldcfg = []; if (QS('#srch_form.tags')) { - sconf.push(["tags", - ["tags", "tags", "tags contains   (^=start, end=$)", "30"] + sconf.push([ + L.s_ta, + ["tags", "tags", L.s_t1, "30"] ]); - sconf.push(["adv.", - ["adv", "adv", "key>=1A  key<=2B  .bpm>165", "30"] + sconf.push([ + L.s_ad, + ["adv", "adv", L.s_a1, "30"] ]); } @@ -4881,8 +4932,8 @@ function apply_perms(newperms) { } ebi('acc_info').innerHTML = '' + srvinf + - '' + (acct != '*' ? - 'Logout ' + acct + '' : 'Login'); + '' + (acct != '*' ? + '' + L.logout + acct + '' : 'Login'); var o = QSA('#ops>a[data-perm]'); for (var a = 0; a < o.length; a++) { diff --git a/copyparty/web/md.html b/copyparty/web/md.html index dba71e50..2c01fefb 100644 --- a/copyparty/web/md.html +++ b/copyparty/web/md.html @@ -135,7 +135,7 @@ var md_opt = { }; (function () { - var l = localStorage, + var l = localStorage, drk = l.light != 1, btn = document.getElementById("lightswitch"), f = function (e) { @@ -143,14 +143,14 @@ if (e) { e.preventDefault(); drk = !drk; } document.documentElement.className = drk? "z":"y"; btn.innerHTML = "go " + (drk ? "light":"dark"); l.light = drk? 0:1; - }; + }; btn.onclick = f; f(); })(); - + {%- if edit %} diff --git a/copyparty/web/mde.html b/copyparty/web/mde.html index 5a604476..94d5cbda 100644 --- a/copyparty/web/mde.html +++ b/copyparty/web/mde.html @@ -45,7 +45,7 @@ l.light = drk? 0:1; })(); - + diff --git a/copyparty/web/msg.html b/copyparty/web/msg.html index b6151584..a0e862a9 100644 --- a/copyparty/web/msg.html +++ b/copyparty/web/msg.html @@ -2,49 +2,49 @@ - - {{ svcname }} - - + + {{ svcname }} + + {{ html_head }} - + -
- - {%- if h1 %} -

{{ h1 }}

- {%- endif %} - - {%- if h2 %} -

{{ h2 }}

- {%- endif %} - - {%- if p %} -

{{ p }}

- {%- endif %} +
- {%- if pre %} -
{{ pre }}
- {%- endif %} + {%- if h1 %} +

{{ h1 }}

+ {%- endif %} - {%- if html %} - {{ html }} - {%- endif %} + {%- if h2 %} +

{{ h2 }}

+ {%- endif %} - {%- if click %} - - {%- endif %} -
+ {%- if p %} +

{{ p }}

+ {%- endif %} - {%- if redir %} - - {%- endif %} + {%- if pre %} +
{{ pre }}
+ {%- endif %} + + {%- if html %} + {{ html }} + {%- endif %} + + {%- if click %} + + {%- endif %} +
+ + {%- if redir %} + + {%- endif %} \ No newline at end of file diff --git a/copyparty/web/splash.css b/copyparty/web/splash.css index bebb8e7d..87fe1708 100644 --- a/copyparty/web/splash.css +++ b/copyparty/web/splash.css @@ -1,4 +1,4 @@ -html, body, #wrap { +html { color: #333; background: #f7f7f7; font-family: sans-serif; @@ -38,7 +38,6 @@ a+a { margin: -.2em 0 0 .5em; } .logout, -.btns a, a.r { color: #c04; border-color: #c7a; @@ -88,9 +87,7 @@ blockquote { } -html.z, -html.z body, -html.z #wrap { +html.z { background: #222; color: #ccc; } @@ -103,7 +100,6 @@ html.z a { border-color: #37a; } html.z .logout, -html.z .btns a, html.z a.r { background: #804; border-color: #c28; @@ -120,3 +116,9 @@ html.z input { html.z .num { border-color: #777; } + + +html.bz { + color: #bbd; + background: #11121d; +} diff --git a/copyparty/web/splash.html b/copyparty/web/splash.html index b49b55be..a56cea85 100644 --- a/copyparty/web/splash.html +++ b/copyparty/web/splash.html @@ -2,110 +2,105 @@ - - {{ svcname }} - - + + {{ svcname }} + + {{ html_head }} - - + + -
- refresh +
+ refresh - {%- if this.uname == '*' %} -

howdy stranger   (you're not logged in)

- {%- else %} - logout -

welcome back, {{ this.uname }}

- {%- endif %} + {%- if this.uname == '*' %} +

howdy stranger   (you're not logged in)

+ {%- else %} + logout +

welcome back, {{ this.uname }}

+ {%- endif %} - {%- if msg %} -
- {{ msg }} -
- {%- endif %} + {%- if msg %} +
+ {{ msg }} +
+ {%- endif %} - {%- if avol %} -

admin panel:

-
- - - - - -
scanning{{ scanning }}
hash-q{{ hashq }}
tag-q{{ tagq }}
mtp-q{{ mtpq }}
-
- - - - {% for mp in avol %} - {%- if mp in vstate and vstate[mp] %} - - {%- endif %} - {% endfor %} - -
volactionstatus
{{ mp }}rescan{{ vstate[mp] }}
-
- - {%- endif %} + {%- if avol %} +

admin panel:

+
+ + + + + +
scanning{{ scanning }}
hash-q{{ hashq }}
tag-q{{ tagq }}
mtp-q{{ mtpq }}
+
+ + + + {% for mp in avol %} + {%- if mp in vstate and vstate[mp] %} + + {%- endif %} + {% endfor %} + +
volactionstatus
{{ mp }}rescan{{ vstate[mp] }}
+
+ + {%- endif %} - {%- if rvol %} -

you can browse these:

-
    - {% for mp in rvol %} -
  • {{ mp }}
  • - {% endfor %} -
- {%- endif %} + {%- if rvol %} +

you can browse:

+
    + {% for mp in rvol %} +
  • {{ mp }}
  • + {% endfor %} +
+ {%- endif %} - {%- if wvol %} -

you can upload to:

-
    - {% for mp in wvol %} -
  • {{ mp }}
  • - {% endfor %} -
- {%- endif %} + {%- if wvol %} +

you can upload to:

+
    + {% for mp in wvol %} +
  • {{ mp }}
  • + {% endfor %} +
+ {%- endif %} -

client config:

-
    - {% if k304 %} -
  • disable k304 (currently enabled) - {%- else %} -
  • enable k304 (currently disabled) - {% endif %} -
    enabling this will disconnect your client on every HTTP 304, which can prevent some buggy browsers/proxies from getting stuck (suddenly not being able to load pages), but it will also make things slower in general
  • - -
  • reset client settings
  • -
+

client config:

+
    + {% if k304 %} +
  • disable k304 (currently enabled) + {%- else %} +
  • enable k304 (currently disabled) + {% endif %} +
    enabling this will disconnect your client on every HTTP 304, which can prevent some buggy browsers/proxies from getting stuck (suddenly not being able to load pages), but it will also make things slower in general
  • + +
  • reset client settings
  • +
-

login for more:

-
    -
    - - - -
    -
-
+

login for more:

+
    +
    + + + +
    +
+
π - - + diff --git a/copyparty/web/splash.js b/copyparty/web/splash.js new file mode 100644 index 00000000..048d85a9 --- /dev/null +++ b/copyparty/web/splash.js @@ -0,0 +1,43 @@ +var Ls = { + "nor": { + "a1": "oppdater", + "b1": "halloien   (du er ikke logget inn)", + "c1": "logg ut", + "d1": "tilstand", + "d2": "vis tilstanden til alle tråder", + "e1": "les cfg", + "e2": "leser inn konfigurasjonsfiler på nytt$N(kontoer, volumer, volumbrytere)$Nog kartlegger alle e2ds-volumer", + "f1": "du kan betrakte:", + "g1": "du kan laste opp til:", + "cc1": "klient-konfigurasjon", + "h1": "skru av k304", + "i1": "skru på k304", + "j1": "k304 vil frakople nettleseren fra serveren for hver HTTP 304. Dette kan hjelpe mot at noen nettlesere / mellomtjenere setter seg fast, men det reduserer også ytelsen betydelig", + "k1": "nullstill innstillinger", + "l1": "logg inn:", + "m1": "velkommen tilbake,", + "n1": "404: filen finnes ikke  ┐( ´ -`)┌", + "o1": 'eller kanskje du ikke har tilgang? prøv å logge inn eller gå hjem', + "p1": "403: tilgang nektet  ~┻━┻", + "q1": 'du må logge inn eller gå hjem', + "r1": "gå hjem", + ".s1": "kartlegg", + } +}, + d = Ls[sread("lang") || "{{ this.args.lang }}"]; + +for (var k in (d || {})) { + var f = k.slice(-1), + i = k.slice(0, -1), + o = QSA(i.startsWith('.') ? i : '#' + i); + + for (var a = 0; a < o.length; a++) + if (f == 1) + o[a].innerHTML = d[k]; + else if (f == 2) + o[a].setAttribute("tt", d[k]); +} + +tt.init(); +if (!ebi('c')) + QS('input[name="cppwd"]').focus(); diff --git a/scripts/make-sfx.sh b/scripts/make-sfx.sh index 465bfbd6..8f9856f3 100755 --- a/scripts/make-sfx.sh +++ b/scripts/make-sfx.sh @@ -267,12 +267,12 @@ rm have tmv "$f" } -[ $langs ] && { - f=copyparty/web/browser.js - gzip -d "$f.gz" || true - awk '/^\}/{l=0} !l; /^var Ls =/{l=1;next} o; /^\t["}]/{o=0} /^\t"'"$langs"'"/{o=1;print}' <$f >t - tmv "$f" -} +[ $langs ] && + for f in copyparty/web/{browser.js,splash.js}; do + gzip -d "$f.gz" || true + awk '/^\}/{l=0} !l; /^var Ls =/{l=1;next} o; /^\t["}]/{o=0} /^\t"'"$langs"'"/{o=1;print}' <$f >t + tmv "$f" + done [ $repack ] || find | grep -E '\.py$' | diff --git a/scripts/sfx.ls b/scripts/sfx.ls index 6ae3c847..df68a664 100644 --- a/scripts/sfx.ls +++ b/scripts/sfx.ls @@ -71,6 +71,7 @@ copyparty/web/msg.css, copyparty/web/msg.html, copyparty/web/splash.css, copyparty/web/splash.html, +copyparty/web/splash.js, copyparty/web/ui.css, copyparty/web/up2k.js, copyparty/web/util.js,