This node.js module attempts to setup and bootstrap a working YUI 3 instance.
It does not support any DOM manipulation, but it gives you our class management
and language extras.
This module includes support for remote script loading via Y.Get.script() and remote data fetching via Y.io.
git clone git://github.com/davglass/nodejs-yui3.git git clone git://github.com/yui/yui3.git cd nodejs-yui3/lib ln -s ../../yui3 ./
That should pull in the latest build of the /yui/yui3 repo.
// get the exported YUI object var YUI = require('./lib/node-yui3')).YUI;
// load YUI var YUI = require("./lib/node-yui3").YUI; //sys.puts('After: ' + sys.inspect(process.memoryUsage())); //Now use non-DOM related YUI utilities YUI({ filter: 'debug', debug: true }).use('gallery-yql', 'json', 'base', 'io-nodejs', function(Y) { //sys.puts('Inside: ' + sys.inspect(process.memoryUsage())); //Logger outputs with sys.puts Y.log('This is a test'); //Lang is available Y.log('Test: ' + Y.Lang.isBoolean(true), 'debug', 'myapp'); //Creating a simple class var One = function() { One.superclass.constructor.apply(this, arguments); }; //Extending it with Y.Base so we have Custom Events and a lifecycle Y.extend(One, Y.Base, { test: function() { this.publish('foo', { emitFacade: true }); this.fire('foo'); } }, { NAME: 'one' }); //Create a new instance of our new class var o = new One(); o.on('foo', function(o) { Y.log('Foo Fired', 'debug', 'myapp'); //Y.log(o, 'debug'); }); o.test(); //Should fire the one:foo Event. //Make a YQL query var q1 = new Y.yql('select * from github.user.info where (id = "davglass")'); q1.on('query', function(r) { //Do something here. sys.puts(sys.inspect(r)); }); var url = 'http:/'+'/yuilibrary.com/gallery/api/user/davglass'; //url = 'http:/'+'/query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D90210&format=json'; Y.io(url, { xdr: { use: 'nodejs' }, on: { start: function() { Y.log('Start IO', 'info', 'TEST'); }, success: function(id, o) { //Y.log(o.responseText); Y.log(Y.JSON.parse(o.responseText)); } } }); });
Now you can run node ./test.js