Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 106 lines (80 sloc) 2.685 kb
a608d331 »
2010-02-17 Initial Import
1 h1. YUI Bootstrapper for Node.js
2
3 This node.js module attempts to setup and bootstrap a working YUI 3 instance.
4 It does not support any DOM manipulation, but it gives you our class management
5 and language extras.
6
45e90aae »
2010-03-23 Updated README with new IO calls
7 This module includes support for remote script loading via Y.Get.script() and remote data fetching via Y.io.
a608d331 »
2010-02-17 Initial Import
8
9 h2. Setup this repo
10
11 <pre class="console">
5c831199 »
2010-04-05 Updated README and removed submodule
12 git clone git://github.com/davglass/nodejs-yui3.git
13
14 git clone git://github.com/yui/yui3.git
15
16 cd nodejs-yui3/lib
17
18 ln -s ../../yui3 ./
a608d331 »
2010-02-17 Initial Import
19 </pre>
20
5c831199 »
2010-04-05 Updated README and removed submodule
21
a608d331 »
2010-02-17 Initial Import
22 That should pull in the latest build of the /yui/yui3 repo.
23
24 h2. Including the files
25
26 <pre class="console">
fc71bd3e »
2010-02-17 Update documentation
27 // get the exported YUI object
28 var YUI = require('./lib/node-yui3')).YUI;
a608d331 »
2010-02-17 Initial Import
29 </pre>
30
31 h2. Using YUI
32
33 <pre class="console">
9d1d174b »
2010-02-17 Add a TODO regarding YUI 3's global usage.
34 // load YUI
fc71bd3e »
2010-02-17 Update documentation
35 var YUI = require("./lib/node-yui3").YUI;
a608d331 »
2010-02-17 Initial Import
36
37 //sys.puts('After: ' + sys.inspect(process.memoryUsage()));
38
39 //Now use non-DOM related YUI utilities
40 YUI({
41 filter: 'debug',
42 debug: true
7470ed5b »
2010-03-23 Updated README with new IO calls
43 }).use('gallery-yql', 'json', 'base', 'io-nodejs', function(Y) {
a608d331 »
2010-02-17 Initial Import
44
45 //sys.puts('Inside: ' + sys.inspect(process.memoryUsage()));
46 //Logger outputs with sys.puts
47 Y.log('This is a test');
48 //Lang is available
49 Y.log('Test: ' + Y.Lang.isBoolean(true), 'debug', 'myapp');
50
51 //Creating a simple class
52 var One = function() {
53 One.superclass.constructor.apply(this, arguments);
54 };
55 //Extending it with Y.Base so we have Custom Events and a lifecycle
56 Y.extend(One, Y.Base, {
57 test: function() {
58 this.publish('foo', {
59 emitFacade: true
60 });
61 this.fire('foo');
62 }
63 }, {
64 NAME: 'one'
65 });
66
67 //Create a new instance of our new class
68 var o = new One();
69 o.on('foo', function(o) {
70 Y.log('Foo Fired', 'debug', 'myapp');
71 //Y.log(o, 'debug');
72 });
73 o.test(); //Should fire the one:foo Event.
2997c101 »
2010-02-18 Updated README
74
75 //Make a YQL query
76 var q1 = new Y.yql('select * from github.user.info where (id = "davglass")');
77 q1.on('query', function(r) {
78 //Do something here.
79 sys.puts(sys.inspect(r));
80 });
45e90aae »
2010-03-23 Updated README with new IO calls
81
82 var url = 'http:/'+'/yuilibrary.com/gallery/api/user/davglass';
83 //url = 'http:/'+'/query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D90210&format=json';
84
85 Y.io(url, {
86 xdr: {
87 use: 'nodejs'
88 },
89 on: {
90 start: function() {
91 Y.log('Start IO', 'info', 'TEST');
92 },
93 success: function(id, o) {
94 //Y.log(o.responseText);
95 Y.log(Y.JSON.parse(o.responseText));
96 }
97 }
98 });
99
100
a608d331 »
2010-02-17 Initial Import
101 });
102 </pre>
103
104
105 Now you can run @node ./test.js@
Something went wrong with that request. Please try again.