[Build] Fix WebUI js minifying error
Some users encoutered a bug where WebUI in browser show a white screen, which indicates a problem with loading javascript files. The problem was due to closure minifying failure leaving a zero-length deluge-all.js file which broke the usual fallback mechanism to debug files. * Fixed usage of ES6 const declaration breaking closure minifying. * Cleanup minified files upon errors so no zero length files left * Replaced broken and unmaintained slimit with rjsmin. * Fixed unable to set dev or debug query args due to request args requiring bytes.
This commit is contained in:
parent
073bbbc09d
commit
a03e649da6
|
@ -13,7 +13,7 @@ All modules will require the [common](#common) section dependencies.
|
|||
|
||||
- [setuptools]
|
||||
- [intltool] - Optional: Desktop file translation for \*nix.
|
||||
- [closure-compiler] - Minify javascript (alternative is [slimit])
|
||||
- [closure-compiler] - Minify javascript (alternative is [rjsmin])
|
||||
|
||||
## Common
|
||||
|
||||
|
@ -71,7 +71,7 @@ All modules will require the [common](#common) section dependencies.
|
|||
[setuptools]: https://setuptools.readthedocs.io/en/latest/
|
||||
[intltool]: https://freedesktop.org/wiki/Software/intltool/
|
||||
[closure-compiler]: https://developers.google.com/closure/compiler/
|
||||
[slimit]: https://slimit.readthedocs.io/en/latest/
|
||||
[rjsmin]: https://pypi.org/project/rjsmin/
|
||||
[openssl]: https://www.openssl.org/
|
||||
[pyopenssl]: https://pyopenssl.org
|
||||
[twisted]: https://twistedmatrix.com
|
||||
|
|
|
@ -51,7 +51,7 @@ Deluge.CopyMagnet = Ext.extend(Ext.Window, {
|
|||
},
|
||||
show: function (a) {
|
||||
Deluge.CopyMagnet.superclass.show.call(this);
|
||||
const torrent = deluge.torrents.getSelected();
|
||||
var torrent = deluge.torrents.getSelected();
|
||||
deluge.client.core.get_magnet_uri(torrent.id, {
|
||||
success: this.onRequestComplete,
|
||||
scope: this,
|
||||
|
|
|
@ -592,13 +592,13 @@ class TopLevel(resource.Resource):
|
|||
uri_false = ('false', 'no', 'off', '0')
|
||||
|
||||
debug_arg = None
|
||||
req_dbg_arg = request.args.get('debug', [b''])[-1].decode().lower()
|
||||
req_dbg_arg = request.args.get(b'debug', [b''])[-1].decode().lower()
|
||||
if req_dbg_arg in uri_true:
|
||||
debug_arg = True
|
||||
elif req_dbg_arg in uri_false:
|
||||
debug_arg = False
|
||||
|
||||
dev_arg = request.args.get('dev', [b''])[-1].decode().lower() in uri_true
|
||||
dev_arg = request.args.get(b'dev', [b''])[-1].decode().lower() in uri_true
|
||||
dev_ver = 'dev' in common.get_version()
|
||||
|
||||
script_type = 'normal'
|
||||
|
|
|
@ -55,14 +55,14 @@ def minify_closure(file_in, file_out):
|
|||
return False
|
||||
|
||||
|
||||
# Closure outputs smallest files but it is a java-based command, so have slimit
|
||||
# Closure outputs smallest files but java-based command, can use rJSmin
|
||||
# as a python-only fallback.
|
||||
#
|
||||
# deluge-all.js: Closure 127K, Slimit: 143K, JSMin: 162K
|
||||
# deluge-all.js: Closure 131K, rJSmin: 148K
|
||||
#
|
||||
if not closure_cmd:
|
||||
try:
|
||||
from slimit import minify as minify
|
||||
from rjsmin import jsmin as minify
|
||||
except ImportError:
|
||||
print('Warning: No minifying command found.')
|
||||
minify = None
|
||||
|
@ -124,6 +124,8 @@ def minify_js_dir(source_dir):
|
|||
print('Minifying %s' % source_dir)
|
||||
if not minify_file(file_debug_js, file_minified_js):
|
||||
print('Warning: Failed minifying files %s, debug only' % source_dir)
|
||||
if os.path.isfile(file_minified_js):
|
||||
os.remove(file_minified_js)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -11,3 +11,4 @@ flake8-comprehensions
|
|||
flake8-debugger
|
||||
flake8-mock
|
||||
flake8-mutable
|
||||
rjsmin
|
||||
|
|
Loading…
Reference in New Issue