-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
177 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,26 @@ | ||
#!/usr/bin/env node | ||
|
||
var argv = require('optimist').argv; | ||
var server = require('../wrapit'); | ||
|
||
if(!argv.q) { | ||
console.log('usage:'); | ||
console.log(' wrapit [options]'); | ||
console.log(''); | ||
console.log('this starts a wrapit web service using the specified command-line options'); | ||
console.log(''); | ||
console.log('options:'); | ||
console.log(''); | ||
console.log(' -p port to listen on (example, 80)'); | ||
console.log(' -q suppress this message'); | ||
console.log(''); | ||
} | ||
|
||
var port = argv.p || 80; | ||
|
||
require('http').createServer(function (req, res) { | ||
require('../wrapit').handleRequest(req, res); | ||
}).listen(81); | ||
}).listen(port); | ||
|
||
console.log('listening on port ' + port); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | ||
|
||
<!-- IE has problems if go to github directly, but is happy when we use wrapit instead --> | ||
<script src="http://omphalos.wrapit.jit.su/?url=https://raw.github.com/omphalos/require-shim/master/require-shim.js" ></script> | ||
|
||
<!-- four parts to the query string: | ||
wrapit url: <script src="http://omphalos.wrapit.jit.su/ | ||
file header: ?header= provide('uglify-js/uglify-js', function(require, exports, module){ | ||
url to wrap: &url= https://raw.github.com/mishoo/UglifyJS/master/uglify-js.js | ||
file footer: &footer= });"></script> | ||
--> | ||
|
||
<!-- reference to uglify-js/lib/consolidator --> | ||
<script src="http://omphalos.wrapit.jit.su/ | ||
?header= provide('uglify-js/lib/consolidator', function(require, exports, module){ | ||
&url= https://raw.github.com/mishoo/UglifyJS/master/lib/consolidator.js | ||
&footer= });"> | ||
</script> | ||
|
||
<!-- reference to uglify-js/lib/parse-js --> | ||
<script src="http://omphalos.wrapit.jit.su/ | ||
?header= provide('uglify-js/lib/parse-js', function(require, exports, module){ | ||
&url= https://raw.github.com/mishoo/UglifyJS/master/lib/parse-js.js | ||
&footer= });"> | ||
</script> | ||
|
||
<!-- reference to uglify-js/lib/process --> | ||
<script src="http://omphalos.wrapit.jit.su/ | ||
?header= provide('uglify-js/lib/process', function(require, exports, module){ | ||
&url= https://raw.github.com/mishoo/UglifyJS/master/lib/process.js | ||
&footer= });"> | ||
</script> | ||
|
||
<!-- reference to uglify-js/lib/squeeze-more --> | ||
<script src="http://omphalos.wrapit.jit.su/ | ||
?header= provide('uglify-js/lib/squeeze-more',function(require, exports, module){ | ||
&url= https://raw.github.com/mishoo/UglifyJS/master/lib/squeeze-more.js | ||
&footer= });"> | ||
</script> | ||
|
||
<!-- include uglify-js/uglify-js --> | ||
<script src="http://omphalos.wrapit.jit.su/ | ||
?header= provide('uglify-js/uglify-js', function(require, exports, module){ | ||
&url= https://raw.github.com/mishoo/UglifyJS/master/uglify-js.js | ||
&footer= });"> | ||
</script> | ||
|
||
<!-- map uglify-js/uglify-js to uglify-js so we can just call require('uglify-js') instead of require('uglify-js/uglify-js') --> | ||
<script type="text/javascript"> | ||
provide('uglify-js', function(require, exports, module) { | ||
module.exports = require('uglify-js/uglify-js'); | ||
}); | ||
</script> | ||
<body> | ||
</body> | ||
<h3>Demo of running a Node.js module (<a href="https://github.com/mishoo/UglifyJS/">uglify-js</a>) from the browser</h3> | ||
<p><strong>Step #1.</strong> Put some javascript here:</p> | ||
<textarea id="in" cols="80" rows="20" style="width:100%;" > | ||
$('input').click(function() { | ||
try { | ||
var js = $('#in').val(); // grab the user's javascript | ||
|
||
// this code is adapted from uglify-js's homepage | ||
var uglify = require('uglify-js'); | ||
var parser = uglify.parser; | ||
var ast = parser.parse(js); | ||
var pro = uglify.uglify; | ||
ast = pro.ast_mangle(ast); | ||
ast = pro.ast_squeeze(ast); | ||
var finalCode = pro.gen_code(ast); | ||
|
||
// give the ugly version to the user | ||
$('#main').html(finalCode); | ||
} catch(err) { | ||
$('#main').html('error: ' + err); | ||
} | ||
});</textarea> | ||
<span><strong>Step #2.</strong></span> | ||
<input type="button" id="btn" value="Click to uglify" /> | ||
<p id="main" /> | ||
<script type="text/javascript" > | ||
$('input').click(function() { | ||
try { | ||
var uglify = require('uglify-js'); | ||
var parser = uglify.parser; | ||
var js = $('#in').val(); | ||
var ast = parser.parse(js); | ||
var pro = uglify.uglify; | ||
ast = pro.ast_mangle(ast); | ||
ast = pro.ast_squeeze(ast); | ||
var finalCode = pro.gen_code(ast); | ||
$('#main').html(finalCode); | ||
} catch(err) { | ||
$('#main').html('error: ' + err); | ||
} | ||
}); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters