diff options
-rw-r--r-- | Makefile | 16 | ||||
-rwxr-xr-x | compile.py | 26 |
2 files changed, 42 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0767e67 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +VERSION = 1.0.0 + +all: dist + +distclean: + rm -f polldance-$(VERSION).js polldance-$(VERSION).min.js + +clean: + +dist: polldance-$(VERSION).min.js + +polldance-$(VERSION).js: polldance.js + cp polldance.js polldance-$(VERSION).js + +polldance-$(VERSION).min.js: polldance-$(VERSION).js + ./compile.py polldance-$(VERSION).js > polldance-$(VERSION).min.js diff --git a/compile.py b/compile.py new file mode 100755 index 0000000..28247eb --- /dev/null +++ b/compile.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +import httplib, urllib, sys + +# Define the parameters for the POST request and encode them in +# a URL-safe format. + +file = open(sys.argv[1]) +js_code = file.read() +file.close() + +params = urllib.urlencode([ + ('js_code', js_code), + ('compilation_level', 'SIMPLE_OPTIMIZATIONS'), + ('output_format', 'text'), + ('output_info', 'compiled_code'), + ]) + +# 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() +print data +conn.close() |