From ea346a785dc1b3f7c156f6fc33da634e1f1a627b Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Tue, 12 Aug 2014 21:56:44 +0200 Subject: Adding jquery, flot and openlayers to be included with the GEM. --- misc/openlayers/tools/closure_ws.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 misc/openlayers/tools/closure_ws.py (limited to 'misc/openlayers/tools/closure_ws.py') diff --git a/misc/openlayers/tools/closure_ws.py b/misc/openlayers/tools/closure_ws.py new file mode 100644 index 0000000..3bf925a --- /dev/null +++ b/misc/openlayers/tools/closure_ws.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +import httplib, urllib, sys +import time +# Define the parameters for the POST request and encode them in +# a URL-safe format. + +def minimize(code): + + params = urllib.urlencode([ + ('js_code', code), + ('compilation_level', 'SIMPLE_OPTIMIZATIONS'), + ('output_format', 'text'), + ('output_info', 'compiled_code'), + ]) + + t = time.time() + # Always use the following value for the Content-type header. + headers = { "Content-type": "application/x-www-form-urlencoded" } + conn = httplib.HTTPConnection('closure-compiler.appspot.com') + conn.request('POST', '/compile', params, headers) + response = conn.getresponse() + data = response.read() + conn.close() + if data.startswith("Error"): + raise Exception(data) + print "%.3f seconds to compile" % (time.time() - t) + return data -- cgit v1.2.3