diff --git a/docs/available-packages.md b/docs/available-packages.md index d1e27535..c074844b 100644 --- a/docs/available-packages.md +++ b/docs/available-packages.md @@ -1,32 +1,78 @@ + +Available Packages +================== + +You can download and install packages using the `tusk` application that comes with Narwhal. Check out `tusk help` for details. These are some of the packages: + * `activejs`: The Cross Platform JavaScript MVC, http://activejs.org/ +* `appengine`: A port of the Python Google App Engine SDK to JavaScript * `appengine-java-sdk`: Java components necessary for deploying applications on Google's App Engine. -* `appengine`: A port of the Python AppEngine API to JavaScript +* `barista`: An automated user interface testing framework. +* `bogart`: A simple web framework * `browserjs`: A simulated web browser environment, includes XMLHttpRequest, timeouts, console, a DOM, etc +* `cappruby`: Experimental Ruby implementation on top of the Objective-J runtime / JavaScript +* `cappuccino`: Cappuccino module +* `CappuccinoResource`: Cappuccino on Rails * `chiron`: A system of interoperable JavaScript modules, including a Pythonic type system and types +* `closure-compiler`: Closure Compiler +* `coffee-script`: Unfancy JavaScript +* `commonjs-utils` +* `couchdb`: API to access CouchDB servers, a schema-free database of JSON documents * `creolejs`: A JavaScript implementation of the CreoleWiki language, for browsers. -* `env`: -* `inspec`: +* `ejs`: Embedded JavaScript templating framework +* `env` +* `haml-js`: Haml ported to server-side Javascript. This is a traditional server-side templating language. +* `htmlparser`: An HTML parser +* `inspec`: BDD test framwork inspired by rspec +* `jack` * `jack-dav`: A JSGI compatible WebDAV server, based on RackDAV * `jack-servlet`: A Java servlet for running JSGI applications -* `jack`: A library of JSGI middleware, handlers, and utilities, based on Rack -* `jake`: A build system for ServerJS, inspired by Rake -* `jsdocs`: Tool for generating template-formatted, multi-page HTML (or XML, JSON, or any other text-based) documentation from commented JavaScript source code. +* `jake`: A build system for CommonJS, lifted from Rake +* `jaml`: A library of JSGI middleware, handlers, and utilities, based on Rack +* `jdbc` +* `jscrypto`: Fast symmetric cryptography in Javascript +* `jsdocs`: JavaScript documentation generator. Tool for generating template-formatted, multi-page HTML (or XML, JSON, or any other text-based) documentation from commented JavaScript source code. * `json-rpc`: An implementation of JSON-RPC for CommonJS, include a JSGI appliance +* `json-template`: Minimal but powerful templating language implemented in multiple languages. * `jsont`: JSON transforms, akin to XSLT but for JSON: http://goessner.net/articles/jsont/ -* `kupo`: +* `kupo` * `markdown`: A port of markdown to JavaScript +* `mustache`: {{mustaches}} in JavaScript — shameless port from @defunkt +* `mysql-jdbc` * `narcissus`: JavaScript implemented in JavaScript -* `narwhal-jaxer`: +* `narwhal`: A general purpose JavaScript platform +* `narwhal-jaxer` * `narwhal-johnson`: Johnson (Ruby-JavaScript bridge, using SpiderMonkey) engine support for Narwhal * `narwhal-jsc`: JavaScriptCore engine support for Narwhal +* `narwhal-moar-monkeys` * `narwhal-v8`: V8 engine support for Narwhal -* `narwhal-xulrunner`: -* `narwhal`: A general purpose JavaScript platform +* `narwhal-v8cgi`: v8cgi engine support for Narwhal +* `narwhal-xulrunner`: XULRunner engine support for Narwhal * `nitro`: A Web Application Framework -* `objj`: Objective-J and Cappuccino tools +* `normal-template`: A simple, powerful and safe templating engine +* `oauth`: OAuth Library +* `objective-j`: Objective-J and Cappuccino module +* `observable`: JavaScript framework for Observable mixins with plugin support +* `ojmoq`: A mocking library for Objective-J that is inspired by the Moq project. +* `ojunit`: A simple Objective-J unit test framework. +* `ometa-highlighter`: Code highlighter based on Ometa/JS (little inspired by Pygments) +* `ometajs`: A object-oriented language for pattern matching +* `parenscript`: Parenscript is a small Lispy language that compiles to JavaScript. This is the Narwhal module that integrates ParenScript with Narwhal. +* `prototype`: Prototype is a JavaScript Framework that aims to ease development of dynamic web applications. This package implements a subset of Prototype +* `qunit`: An easy-to-use JavaScript Unit Testing framework. +* `qxoo` +* `reform`: A Narwhal module for working with HTML forms, similar to Django's forms. * `seethrough`: Seethrough is a simple XML/XHTML template engine for JavaScript based on E4X. It’s a port of a former project for Erlang. +* `shmakowiki`: Yet another wiki dialect, inspired by WackoWiki and WikiCreole +* `shrinksafe`: ShrinkSafe +* `silk`: A comprehensive set of 16x16px icons. +* `sizzle`: A sizzlin' hot selector engine * `speller`: A JavaScript spell-checker +* `sqlite-jdbc` * `syntax-stroop`: A syntax highlighter based on Google-code-prettify. * `template`: A simple templating engine +* `underscore`: Functional programming aid for JavaScript. Works well with jQuery. * `wiky`: A bidirectional Wiki markup to and from HTML converter written in JavaScript. * `xbin`: A suite of Unix command line tools for enlightened pipelines. +* `yuicompressor`: YUI Compressor +* `zipjs`: An implementation of zip for JavaScript diff --git a/docs/download.md b/docs/download.md index af18a1dd..cc826c5a 100644 --- a/docs/download.md +++ b/docs/download.md @@ -7,13 +7,13 @@ Download a version of Narwhal then follow the [quick start guide](http://narwhal Bleeding Edge ------------- -* [Download zip](http://github.com/tlrobinson/narwhal/zipball/master) -* [Download tar](http://github.com/tlrobinson/narwhal/tarball/master) +* [Download zip](http://github.com/280north/narwhal/zipball/master) +* [Download tar](http://github.com/280north/narwhal/tarball/master) -* Git: `git clone git://github.com/tlrobinson/narwhal.git` +* Git: `git clone git://github.com/280north/narwhal.git` -* [View tree](http://github.com/tlrobinson/narwhal/tree/master) -* [View commit](http://github.com/tlrobinson/narwhal/commit/master) +* [View tree](http://github.com/280north/narwhal/tree/master) +* [View commit](http://github.com/280north/narwhal/commit/master) Releases @@ -21,5 +21,4 @@ Releases
Loading...
- - + diff --git a/docs/posts/2009-07-29-hello-0.1.md b/docs/posts/2009-07-29-hello-0.1.md index 81ef5cc9..e83f6261 100644 --- a/docs/posts/2009-07-29-hello-0.1.md +++ b/docs/posts/2009-07-29-hello-0.1.md @@ -5,8 +5,8 @@ Today we're announcing [Narwhal](http://narwhaljs.org/) 0.1 and [Jack](http://ja ### Download -* Narwhal 0.1: [tar](http://github.com/tlrobinson/narwhal/tarball/0.1), [zip](http://github.com/tlrobinson/narwhal/zipball/0.1) -* Jack 0.1: [tar](http://github.com/tlrobinson/jack/tarball/0.1), [zip](http://github.com/tlrobinson/jack/zipball/0.1) +* Narwhal 0.1: [tar](http://github.com/280north/narwhal/tarball/v0.1), [zip](http://github.com/280north/narwhal/zipball/v0.1) +* Jack 0.1: [tar](http://github.com/280north/jack/tarball/v0.1), [zip](http://github.com/280north/jack/zipball/v0.1) Check out the [quick start guide](http://narwhaljs.org/quick-start.html) for instructions on getting up and running with Narwhal and Jack. diff --git a/engines/rhino/lib/http.js b/engines/rhino/lib/http.js new file mode 100644 index 00000000..a76ad7c1 --- /dev/null +++ b/engines/rhino/lib/http.js @@ -0,0 +1,79 @@ + +// -- tlrobinson Tom Robinson + +var FILE = require("file"); +var IO = require("io").IO; + +exports.open = function(url, mode, options) { + mode = mode || "b"; + options = options || {}; + + options.method = options.method || "GET"; + options.headers = options.headers || {}; + + var connection = new java.net.URL(url).openConnection(); + connection.setDoInput(true); + connection.setDoOutput(true); + connection.setRequestMethod(options.method); + + for (var name in options.headers){ + connection.addRequestProperty(String(name), String(options.headers[name])); + } + + connection.connect(); + + var output = new IO(null, connection.getOutputStream()); + var input = null; + + var request = { + status : null, + headers : {}, + read : function() { + if (!input) { + output.close(); + input = new IO(connection.getInputStream(), null); + this.status = Number(connection.getResponseCode()); + this.statusText = String(connection.getResponseMessage() || ""); + for (var i = 0; ; i++) { + var key = connection.getHeaderFieldKey(i), value = connection.getHeaderField(i) + if (! key && ! value) + break; + if (key) + this.headers[String(key)] = String(value); + } + } + return input.read.apply(input, arguments); + }, + write : function() { + output.write.apply(output, arguments); + return this; + }, + flush : function() { + output.flush.apply(output, arguments); + return this; + }, + close : function() { + if (output) + output.close(); + if (input) + input.close(); + return this; + }, + copy : IO.prototype.copy + } + return request +}; + +exports.read = function(url) { + var stream = exports.open(url); + try { + return stream.read(); + } finally { + stream.close(); + } +}; + +exports.copy = function(source, target, mode) { + mode = mode || "b"; + return FILE.path(target).write(exports.read(source, mode), mode); +}; diff --git a/packages/narwhal-lib/lib/narwhal/util.js b/packages/narwhal-lib/lib/narwhal/util.js index 5b441349..2c5f6c84 100644 --- a/packages/narwhal-lib/lib/narwhal/util.js +++ b/packages/narwhal-lib/lib/narwhal/util.js @@ -10,7 +10,7 @@ // that is, that return a function that can be tested // against various objects if they're only "partially // completed", or fewer arguments than needed are used. -// +// // this enables the idioms: // [1, 2, 3].every(lt(4)) eq true // [1, 2, 3].map(add(1)) eq [2, 3, 4] @@ -302,7 +302,7 @@ exports.isArguments = function (object) { if ( !typeof object == "object" || !Object.prototype.hasOwnProperty.call(object, 'callee') || - !object.callee || + !object.callee || // It should be a Function object ([[Class]] === 'Function') Object.prototype.toString.call(object.callee) !== '[object Function]' || typeof object.length != 'number' @@ -462,7 +462,7 @@ exports.get = exports.operator('get', 2, function (object, key, value) { throw new Error("KeyError: " + exports.repr(key)); } return object[key]; - } + } throw new Error("Object does not have keys: " + exports.repr(object)); }); @@ -593,7 +593,7 @@ exports.all = exports.operator('all', 1, function (array) { return true; }); -exports.any = exports.operator('all', 1, function (array) { +exports.any = exports.operator('any', 1, function (array) { array = exports.array.coerce(array); for (var i = 0; i < array.length; i++) if (array[i]) @@ -673,7 +673,7 @@ exports.eq = exports.operator('eq', 2, function (a, b, stack) { a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline; - if (typeof a === "function") { + if (typeof a === "function") { var caller = stack[stack.length - 1]; // XXX what is this for? can it be axed? // it comes from the "equiv" project code @@ -709,15 +709,15 @@ exports.gt = exports.operator('gt', 2, function (a, b) { return !(exports.lt(a, b) || exports.eq(a, b)); }); -exports.le = exports.operator(2, 'le', function (a, b) { +exports.le = exports.operator('le', 2, function (a, b) { return exports.lt(a, b) || exports.eq(a, b); }); -exports.ge = exports.operator(2, 'ge', function (a, b) { +exports.ge = exports.operator('ge', 2, function (a, b) { return !exports.lt(a, b); }); -exports.mul = exports.operator(2, 'mul', function (a, b) { +exports.mul = exports.operator('mul', 2, function (a, b) { if (typeof a == "string") return exports.string.mul(a, b); return a * b; @@ -758,7 +758,7 @@ exports.by = function (relation) { return comparator; }; -exports.compare = exports.operator(2, 'compare', function (a, b) { +exports.compare = exports.operator('compare', 2, function (a, b) { if (exports.no(a) !== exports.no(b)) return exports.no(b) - exports.no(a); if (typeof a === "number" && typeof b === "number") @@ -813,11 +813,11 @@ exports.reversed = function (array) { return exports.reverse(exports.array.copy(array)); }; -exports.hash = exports.operator(1, 'hash', function (object) { +exports.hash = exports.operator('hash', 1, function (object) { return '' + object; }); -exports.unique = exports.operator(1, 'unique', function (array, eq, hash) { +exports.unique = exports.operator('unique', 1, function (array, eq, hash) { var visited = {}; if (!eq) eq = exports.eq; if (!hash) hash = exports.hash; @@ -834,7 +834,7 @@ exports.unique = exports.operator(1, 'unique', function (array, eq, hash) { // string -exports.string = exports.operator(1, 'toString', function (object) { +exports.string = exports.operator('toString', 1, function (object) { return '' + object; }); @@ -874,7 +874,7 @@ exports.escape = function (value, strictJson) { exports.repr(value) ); return value.replace( - escapeExpression, + escapeExpression, function (match) { if (escapePatterns[match]) return escapePatterns[match]; @@ -902,6 +902,17 @@ exports.enquote = function (value, strictJson) { return '"' + exports.escape(value, strictJson) + '"'; }; +/** + * remove adjacent characters + * todo: i'm not sure if this works correctly without the second argument + */ +exports.squeeze = function (s) { + var set = arguments.length > 0 ? "["+Array.prototype.join.call(arguments.slice(1), '')+"]" : ".|\\n", + regex = new RegExp("("+set+")\\1+", "g"); + + return s.replace(regex, "$1"); +}; + /*** expand transforms tabs to an equivalent number of spaces. */ @@ -941,12 +952,12 @@ exports.expand = function (str, tabLength) { var trimBeginExpression = /^\s\s*/g; exports.trimBegin = function (value) { - return String(value).replace(trimBeginExpression, ""); + return String(value).replace(trimBeginExpression, ""); }; var trimEndExpression = /\s\s*$/g; exports.trimEnd = function (value) { - return String(value).replace(trimEndExpression, ""); + return String(value).replace(trimEndExpression, ""); }; exports.trim = function (value) { diff --git a/packages/narwhal-lib/lib/uri.js b/packages/narwhal-lib/lib/uri.js index b836531a..3e1e8544 100644 --- a/packages/narwhal-lib/lib/uri.js +++ b/packages/narwhal-lib/lib/uri.js @@ -71,20 +71,20 @@ URI.prototype.from = function (other) { */ URI.prototype.toString = function () { return exports.format(this); -} +}; URI.parse = function(uri) { require("narwhal/deprecated").deprecated("URI.parse is deprecated, use require('uri').parse"); return new URI(uri); -} +}; exports.unescape = URI.unescape = function(uri, plus) { return decodeURI(uri).replace(/\+/g, " "); -} +}; exports.unescapeComponent = URI.unescapeComponent = function(uri, plus) { return decodeURIComponent(uri).replace(/\+/g, " "); -} +}; // from Chiron's HTTP module: @@ -166,7 +166,7 @@ exports.strictExpression = new RegExp( /* url */ /**** Parser returns a URI parser function given - a regular expression that renders + a regular expression that renders `expressionKeys` and returns an `Object` mapping all `keys` to values. */ @@ -179,8 +179,9 @@ exports.Parser = function (expression) { var items = this instanceof URI ? this : Object.create(URI.prototype); var parts = expression.exec(url); + var i; - for (var i = 0; i < parts.length; i++) { + for (i = 0; i < parts.length; i++) { items[exports.expressionKeys[i]] = parts[i] ? parts[i] : ""; } @@ -193,7 +194,7 @@ exports.Parser = function (expression) { /* normalize */ var directories = []; - for (var i = 0; i < items.directories.length; i++) { + for (i = 0; i < items.directories.length; i++) { var directory = items.directories[i]; if (directory == '.') { } else if (directory == '..') { @@ -233,11 +234,11 @@ exports.format = function (object) { object.domain; var userInfo = ( object.user || - object.password + object.password ) ? ( - (object.user || "") + - (object.password ? ":" + object.password : "") + (object.user || "") + + (object.password ? ":" + object.password : "") ) : object.userInfo; var authority = ( @@ -246,7 +247,7 @@ exports.format = function (object) { object.port ) ? ( (userInfo ? userInfo + "@" : "") + - (domain || "") + + (domain || "") + (object.port ? ":" + object.port : "") ) : object.authority; @@ -276,7 +277,7 @@ exports.format = function (object) { a relative location and a source location. */ exports.resolveObject = function (source, relative) { - if (!source) + if (!source) return relative; source = exports.parse(source); diff --git a/tests/util/string.js b/tests/util/string.js index 5cb4d568..f1862e40 100644 --- a/tests/util/string.js +++ b/tests/util/string.js @@ -29,6 +29,22 @@ exports.testPadEnd = function () { }; */ +exports.testSqueeze = function () { + assert.isEqual("http://imperium.gov/", + util.squeeze("http://imperium.gov/")); + assert.isEqual("http:/imperium.gov/", + util.squeeze("http://imperium.gov/", "/")); + assert.isEqual("htp://imperium.gov/", + util.squeeze("http://imperium.gov/", "t")); + assert.isEqual("", + util.squeeze("")); + assert.isEqual(" ", + util.squeeze(" ", " ")); + assert.isEqual("o", + util.squeeze("ooo", "o")); +}; + + if (require.main == module.id) require("os").exit(require("test/runner").run(exports));