Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith committed Dec 10, 2011
2 parents f246d37 + f29e32a commit ec52f07
Show file tree
Hide file tree
Showing 106 changed files with 3,603 additions and 1,650 deletions.
28 changes: 20 additions & 8 deletions build/app-base/app-base-debug.js
Expand Up @@ -8,9 +8,10 @@ Provides a top-level application component which manages navigation and views.
**/

var Lang = Y.Lang,
View = Y.View,
Router = Y.Router,
PjaxBase = Y.PjaxBase,
Router = Y.Router,
View = Y.View,
YObject = Y.Object,

win = Y.config.win,

Expand Down Expand Up @@ -109,13 +110,24 @@ App = Y.Base.create('app', Y.Base, [View, Router, PjaxBase], {
initializer: function (config) {
config || (config = {});

// Create a shallow copy of specified `config.views` metadata to
// preserve the caller's intention.
var views = Y.merge(config.views);
var views = {};

// Merges-in specified view metadata into local `views` object.
function mergeViewConfig(view, name) {
views[name] = Y.merge(views[name], view);
}

// First, each view in the `views` prototype object has its metadata
// merged-in, providing the defaults.
YObject.each(this.views, mergeViewConfig);

// Then, each view in the specified in the `config.views` object has its
// metadata merged-in.
YObject.each(config.views, mergeViewConfig);

// Mix-in default `views` metadata from the prototype (deep merge), and
// give every instance its own copy of a `views` Object.
this.views = Y.mix(views, this.views, false, null, 0, true);
// The resulting hodgepodge of metadata is then stored as the instance's
// `views` object, and no one's objects were harmed in the making.
this.views = views;

this._viewInfoMap = {};

Expand Down
2 changes: 1 addition & 1 deletion build/app-base/app-base-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 20 additions & 8 deletions build/app-base/app-base.js
Expand Up @@ -8,9 +8,10 @@ Provides a top-level application component which manages navigation and views.
**/

var Lang = Y.Lang,
View = Y.View,
Router = Y.Router,
PjaxBase = Y.PjaxBase,
Router = Y.Router,
View = Y.View,
YObject = Y.Object,

win = Y.config.win,

Expand Down Expand Up @@ -109,13 +110,24 @@ App = Y.Base.create('app', Y.Base, [View, Router, PjaxBase], {
initializer: function (config) {
config || (config = {});

// Create a shallow copy of specified `config.views` metadata to
// preserve the caller's intention.
var views = Y.merge(config.views);
var views = {};

// Merges-in specified view metadata into local `views` object.
function mergeViewConfig(view, name) {
views[name] = Y.merge(views[name], view);
}

// First, each view in the `views` prototype object has its metadata
// merged-in, providing the defaults.
YObject.each(this.views, mergeViewConfig);

// Then, each view in the specified in the `config.views` object has its
// metadata merged-in.
YObject.each(config.views, mergeViewConfig);

// Mix-in default `views` metadata from the prototype (deep merge), and
// give every instance its own copy of a `views` Object.
this.views = Y.mix(views, this.views, false, null, 0, true);
// The resulting hodgepodge of metadata is then stored as the instance's
// `views` object, and no one's objects were harmed in the making.
this.views = views;

this._viewInfoMap = {};

Expand Down
84 changes: 75 additions & 9 deletions build/get-nodejs/get-debug.js
Expand Up @@ -2,9 +2,8 @@ YUI.add('get', function(Y) {

/**
* NodeJS specific Get module used to load remote resources. It contains the same signature as the default Get module so there is no code change needed.
* Note: There is an added method called Get.domScript, which is the same as Get.script in a browser, it simply loads the script into the dom tree
* so that you can call outerHTML on the document to print it to the screen.
* @module get-nodejs
* @class GetNodeJS
*/

var path = require('path'),
Expand All @@ -15,26 +14,81 @@ YUI.add('get', function(Y) {
https = require('https');

Y.Get = function() {};
Y.config.base = path.join(__dirname, '../');

//Setup the default config base path
Y.config.base = path.join(__dirname, '../');

/**
* Get the port number from a URL based on the port from the URL module or http(s)
* @method urlInfoPort
* @param {Object} urlInfo Info from `require('url').parse(url)`
* @return {Number} The port number
*/
Y.Get.urlInfoPort = function(urlInfo) {
return urlInfo.port ? parseInt(urlInfo.port, 10) :
urlInfo.protocol === 'http:' ? 80 : 443;
};


YUI.require = require;
YUI.process = process;

/**
* Escape the path for Windows, they need to be double encoded when used as `__dirname` or `__filename`
* @method escapeWinPath
* @protected
* @param {String} p The path to modify
* @return {String} The encoded path
*/
var escapeWinPath = function(p) {
return p.replace(/\\/g, '\\\\');
};

/**
* Takes the raw JS files and wraps them to be executed in the YUI context so they can be loaded
* into the YUI object
* @method _exec
* @private
* @param {String} data The JS to execute
* @param {String} url The path to the file that was parsed
* @param {Callback} cb The callback to execute when this is completed
* @param {Error} cb.err=null Error object
* @param {String} cb.url The URL that was just parsed
*/

Y.Get._exec = function(data, url, cb) {
var mod = "(function(YUI) { " + data + ";return YUI; })";
var dirName = escapeWinPath(path.dirname(url));
var fileName = escapeWinPath(url);

if (dirName.match(/^https?:\/\//)) {
dirName = '.';
fileName = 'remoteResource';
}

var mod = "(function(YUI) { var __dirname = '" + dirName + "'; "+
"var __filename = '" + fileName + "'; " +
"var process = YUI.process;" +
"var require = function(file) {" +
" if (file.indexOf('./') === 0) {" +
" file = __dirname + file.replace('./', '/'); }" +
" return YUI.require(file); }; " +
data + " ;return YUI; })";

//var mod = "(function(YUI) { " + data + ";return YUI; })";
var script = vm.createScript(mod, url);
var fn = script.runInThisContext(mod);
YUI = fn(YUI);
cb(null);
cb(null, url);
};


/**
* Fetches the content from a remote URL or a file from disc and passes the content
* off to `_exec` for parsing
* @method _include
* @private
* @param {String} url The URL/File path to fetch the content from
* @param {Callback} cb The callback to fire once the content has been executed via `_exec`
*/
Y.Get._include = function(url, cb) {
if (url.match(/^https?:\/\//)) {
var u = n_url.parse(url, parseQueryString=false),
Expand Down Expand Up @@ -99,17 +153,28 @@ YUI.add('get', function(Y) {

/**
* Override for Get.script for loading local or remote YUI modules.
* @method script
* @param {Array|String} s The URL's to load into this context
* @param {Callback} cb The callback to execute once the transaction is complete.
*/
Y.Get.script = function(s, cb) {
var A = Y.Array,
urls = A(s), url, i, l = urls.length;
urls = A(s), url, i, l = urls.length, c= 0,
check = function() {
if (c === l) {
pass(cb);
}
};



for (i=0; i<l; i++) {
url = urls[i];

url = url.replace(/'/g, '%27');
Y.log('URL: ' + url, 'info', 'get');
// doesn't need to be blocking, so don't block.
Y.Get._include(url, function(err) {
Y.Get._include(url, function(err, url) {
if (!Y.config) {
Y.config = {
debug: true
Expand All @@ -127,7 +192,8 @@ YUI.add('get', function(Y) {
}
Y.log('----------------------------------------------------------', 'error', 'nodejsYUI3');
} else {
pass(cb);
c++;
check();
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion build/get-nodejs/get-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ec52f07

Please sign in to comment.