diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-10-06 20:37:51 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-10-06 20:37:51 +0200 |
commit | 4632cd7ff2783dcab33f3d88a1a5d8bb48d04fb4 (patch) | |
tree | 990d61d7fc83733024b83b25b68c91fbe547ee62 | |
parent | added little pie chart (diff) | |
download | pyload-4632cd7ff2783dcab33f3d88a1a5d8bb48d04fb4.tar.xz |
task to optimize js code
-rw-r--r-- | module/web/static/js/app.build.js | 8 | ||||
-rw-r--r-- | module/web/static/js/mobile.js | 4 | ||||
-rw-r--r-- | module/web/static/js/views/headerView.js | 2 | ||||
-rw-r--r-- | pavement.py | 42 |
4 files changed, 31 insertions, 25 deletions
diff --git a/module/web/static/js/app.build.js b/module/web/static/js/app.build.js index 88b96cb89..ad40b02b6 100644 --- a/module/web/static/js/app.build.js +++ b/module/web/static/js/app.build.js @@ -10,13 +10,13 @@ // Modules to be optimized: modules: [ - { - name: "mobile" - }, +// { +// name: "mobile" +// }, { name: "default" } ] -})
\ No newline at end of file +}) diff --git a/module/web/static/js/mobile.js b/module/web/static/js/mobile.js index 58ccf5800..75450cc89 100644 --- a/module/web/static/js/mobile.js +++ b/module/web/static/js/mobile.js @@ -10,7 +10,7 @@ require.config({ fastClick:"libs/jquery.fastClick-0.2", omniwindow: "libs/jquery.omniwindow", - underscore:"libs/lodash-0.5.2", + underscore:"libs/lodash-0.7.0", backbone:"libs/backbone-0.9.2", // Require.js Plugins @@ -39,4 +39,4 @@ define('mobile', ['routers/mobileRouter', 'transit', 'fastClick'], function(Mobi }; return {"init":init}; -});
\ No newline at end of file +}); diff --git a/module/web/static/js/views/headerView.js b/module/web/static/js/views/headerView.js index 21b591a3d..6a4ac270d 100644 --- a/module/web/static/js/views/headerView.js +++ b/module/web/static/js/views/headerView.js @@ -1,4 +1,4 @@ -define(['jquery', 'backbone', 'flot', 'jqueryui/progressbar'], function($, Backbone){ +define(['jquery', 'backbone', 'flot'], function($, Backbone){ // Renders the header with all information return Backbone.View.extend({ diff --git a/pavement.py b/pavement.py index b2162e91e..6ed9b8689 100644 --- a/pavement.py +++ b/pavement.py @@ -58,11 +58,11 @@ setup( include_package_data=True, exclude_package_data={'pyload': ['docs*', 'scripts*', 'tests*']}, #exluced from build but not from sdist # 'bottle >= 0.10.0' not in list, because its small and contain little modifications - install_requires=['jinja2', 'pycurl', 'Beaker >= 1.6'] + extradeps, + install_requires=['pycurl', 'jinja2', 'Beaker >= 1.6'] + extradeps, extras_require={ 'SSL': ["pyOpenSSL"], 'DLC': ['pycrypto'], - 'lightweight webserver': ['bjoern'], + 'Lightweight webserver': ['bjoern'], 'RSS plugins': ['feedparser'], 'Few Hoster plugins': ['BeautifulSoup>=3.2, <3.3'] }, @@ -98,6 +98,9 @@ options( ttypes=Bunch( path="thrift", ), + optimize_js=Bunch( + r="r.js" + ), virtualenv=Bunch( dir="env", python="python2", @@ -175,10 +178,10 @@ def sdist(): ('path=', 'p', 'Thrift path'), ]) def ttypes(options): - """ Generate Thrift stubs """ + """ Generate data types stubs """ - outdir = path("module") / "remote" + outdir = PROJECT_DIR / "module" / "remote" (outdir / "gen-py").rmtree() cmd = [options.ttypes.path, "-strict", "-o", outdir, "--gen", "py:slots,dynamic", outdir / "pyload.thrift"] @@ -198,20 +201,23 @@ def ttypes(options): (outdir / "thriftgen").rmtree() @task -def compile_js(): - """ Compile .coffee files to javascript""" - - root = path("module") / "web" / "media" / "js" - for f in root.glob("*.coffee"): - print "generate", f - coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE) - yui = Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE) - coffee.stdout.close() - content = yui.communicate()[0] - with open(root / f.name.replace(".coffee", ".js"), "wb") as js: - js.write("{% autoescape true %}\n") - js.write(content) - js.write("\n{% endautoescape %}") +@cmdopts([ + ('r=', 'r', 'R.js path') +]) +def optimize_js(options): + """ Generate optimized version of the js code """ + + webdir = PROJECT_DIR / "module" / "web" / "static" + target = webdir / "js" / "app.build.js" + + (webdir / "js-optimized").rmtree() + + cmd = ["node", options.optimize_js.r, "-o", target] + + print "running", cmd + p = Popen(cmd) + p.communicate() + @task |