Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #641 from zhouyaoji/code_exs_getting-started-jslin…
Browse files Browse the repository at this point in the history
…t_errs

[gh 546] Fixed JSLint errors in getting-started-guide examples.
  • Loading branch information
Joe Catera committed Oct 18, 2012
2 parents 434f56b + ba5d1d0 commit 5a83c42
Show file tree
Hide file tree
Showing 39 changed files with 209 additions and 227 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"settings": [ "master" ],

"specs": {
"hello": {
"type": "HelloMojit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* See the accompanying LICENSE file for terms.
*/

YUI.add('HelloMojit', function(Y, NAME) {
YUI.add('HelloMojit', function (Y, NAME) {

"use strict";
/**
* The HelloMojit module.
*
Expand All @@ -26,7 +27,7 @@ YUI.add('HelloMojit', function(Y, NAME) {
* @param ac {Object} The action context that provides access
* to the Mojito API.
*/
index: function(ac) {
index: function (ac) {
ac.done('Mojito is working.');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
[
{

"settings" : ["master"],

"specs": {
"flickr": {
"type": "Flickr"
}
}

}
]
8 changes: 4 additions & 4 deletions examples/getting-started-guide/part2/basic_yql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ process.chdir(__dirname);
* @param {object} token Token used to identify the application.
*/
module.exports = function(config, token) {
var server = require('./server.js');
var YUI = require('mojito').YUI;
var server = require('./server.js'),
YUI = require('mojito').YUI;

YUI().use('mojito-server', function(Y) {
YUI().use('mojito-server', function (Y) {
var app = server(Y);

// Signal the app is ready, providing the token and app references.
process.emit("application-ready", token, app);
});
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* See the accompanying LICENSE file for terms.
*/

YUI.add('Flickr', function(Y, NAME) {
YUI.add('Flickr', function (Y, NAME) {

"use strict";
/**
* The Flickr module.
*
Expand All @@ -21,8 +22,8 @@ YUI.add('Flickr', function(Y, NAME) {
* to the Mojito API.
* @return {}
*/
index: function(ac) {
ac.models.flickr.getFlickrImages('mojito', function(images) {
index: function (ac) {
ac.models.FlickrModel.getFlickrImages('mojito', function (images) {

ac.flush({images: images});

Expand All @@ -32,4 +33,4 @@ YUI.add('Flickr', function(Y, NAME) {

};

}, '0.0.1', {requires: []});
}, '0.0.1', {requires: ['FlickrModel']});
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
* See the accompanying LICENSE file for terms.
*/

YUI.add('FlickrModel', function(Y) {
/*jslint plusplus:true */
YUI.add('FlickrModel', function (Y, NAME) {
"use strict";

var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e';

/**
* The FlickrModel module.
*
* @module FlickrModel
*/

Y.mojito.models.flickr = {
function buildFlickrUrlFromRecord(record) {
return 'http://farm' + record.farm
+ '.static.flickr.com/' + record.server
+ '/' + record.id + '_' + record.secret + '.jpg';
}
Y.namespace('mojito.models')[NAME] = {

/**
* Method that will be invoked by the mojit controller to obtain data.
Expand All @@ -22,17 +29,17 @@ YUI.add('FlickrModel', function(Y) {
* data has been retrieved.
* @return {Object} photots
*/
getFlickrImages: function(queryString, callback) {
getFlickrImages: function (queryString, callback) {
var q = 'select * from flickr.photos.search where text="' + queryString + '" and api_key="' + API_KEY + '"';
Y.YQL(q, function(rawYqlData) {
Y.YQL(q, function (rawYqlData) {
Y.log(rawYqlData);
var rawPhotos = rawYqlData.query.results.photo,
rawPhoto = null
rawPhoto = null,
photos = [],
photo = null,
i = 0;

for (; i<rawPhotos.length; i++) {
for (i = 0; i < rawPhotos.length; i++) {
rawPhoto = rawPhotos[i];
photo = {
title: rawPhoto.title,
Expand All @@ -53,11 +60,5 @@ YUI.add('FlickrModel', function(Y) {

};

function buildFlickrUrlFromRecord(record) {
return 'http://farm' + record.farm
+ '.static.flickr.com/' + record.server
+ '/' + record.id + '_' + record.secret + '.jpg';
}

// TODO: remove 'jsonp-url' requirement when YUI fix for bug http://yuilibrary.com/projects/yui3/ticket/2530251 is deployed.
// TODO: remove 'jsonp-url' requirement when YUI fix for bug http://yuilibrary.com/projects/yui3/ticket/2530251 is deployed.
}, '0.0.1', {requires: ['mojito', 'yql', 'jsonp-url']});
10 changes: 4 additions & 6 deletions examples/getting-started-guide/part2/basic_yql/routes.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
[{
[
{
"settings": [ "master" ],

"route one": {
"verbs": [ "get" ],
"path": "/flickr",
"call": "flickr.index"
},

"route two": {
"verbs": [ "get" ],
"path": "/booyah",
"call": "flickr.index"
},

"route three": {
"verbs": [ "get" ],
"path": "/pineapples",
"call": "flickr.index"
}

}]
}
]
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"settings": [ "master" ],

"specs": {
"flickr" : {
"type": "Flickr"
}
}

}
]
6 changes: 3 additions & 3 deletions examples/getting-started-guide/part3/intl-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ process.chdir(__dirname);
* @param {object} token Token used to identify the application.
*/
module.exports = function(config, token) {
var server = require('./server.js');
var YUI = require('mojito').YUI;
var server = require('./server.js'),
YUI = require('mojito').YUI;

YUI().use('mojito-server', function(Y) {
var app = server(Y);

// Signal the app is ready, providing the token and app references.
process.emit("application-ready", token, app);
});
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* See the accompanying LICENSE file for terms.
*/

YUI.add('Flickr', function(Y, NAME) {
YUI.add('Flickr', function (Y, NAME) {

"use strict";
/**
* The Flickr module.
*
Expand All @@ -20,19 +21,19 @@ YUI.add('Flickr', function(Y, NAME) {
* @param ac {Object} The action context that provides access
* to the Mojito API.
*/
index: function(ac) {
ac.models.flickr.getFlickrImages('mojito', function(images) {
var dateString = ac.intl.formatDate(new Date());
var data = {
images: images,
date: dateString,
greeting: ac.intl.lang("TITLE"),
url: ac.url.make('flickr','index')
};
index: function (ac) {
ac.models.FlickrModel.getFlickrImages('mojito', function (images) {
var dateString = ac.intl.formatDate(new Date()),
data = {
images: images,
date: dateString,
greeting: ac.intl.lang("TITLE"),
url: ac.url.make('flickr', 'index')
};
ac.done(data);
});
}

};

}, '0.0.1', {requires: ['mojito-intl-addon']});
}, '0.0.1', {requires: ['mojito-intl-addon', 'FlickrModel']});
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* See the accompanying LICENSE file for terms.
*/

YUI.add("lang/Flickr", function(Y) {

YUI.add("lang/Flickr", function (Y) {
"use strict";
Y.Intl.add(

"Flickr", // associated module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* See the accompanying LICENSE file for terms.
*/

YUI.add("lang/Flickr_de", function(Y) {
YUI.add("lang/Flickr_de", function (Y) {

"use strict";
Y.Intl.add(

"Flickr", // associated module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,39 @@
* See the accompanying LICENSE file for terms.
*/

YUI.add('FlickrModel', function(Y) {
/*jslint plusplus: true */
YUI.add('FlickrModel', function (Y, NAME) {
"use strict";
var API_KEY = '84921e87fb8f2fc338c3ff9bf51a412e';

/**
* The FlickrModel module.
*
* @module FlickrModel
*/
function buildFlickrUrlFromRecord(record) {
return 'http://farm' + record.farm
+ '.static.flickr.com/' + record.server
+ '/' + record.id + '_' + record.secret + '.jpg';
}

Y.mojito.models.flickr = {

Y.namespace('mojito.models')[NAME] = {
/**
* Method that will be invoked by the mojit controller to obtain data.
*
* @param callback {Function} The callback function to call when the
* data has been retrieved.
*/
getFlickrImages: function(queryString, callback) {
getFlickrImages: function (queryString, callback) {
var q = 'select * from flickr.photos.search where text="' + queryString + '" and api_key="' + API_KEY + '"';
Y.YQL(q, function(rawYqlData) {
Y.YQL(q, function (rawYqlData) {
Y.log(rawYqlData);
var rawPhotos = rawYqlData.query.results.photo,
rawPhoto = null,
photos = [],
photo = null,
i = 0;

for (; i<rawPhotos.length; i++) {
for (i = 0; i < rawPhotos.length; i++) {
rawPhoto = rawPhotos[i];
photo = {
title: rawPhoto.title,
Expand All @@ -52,11 +57,6 @@ YUI.add('FlickrModel', function(Y) {

};

function buildFlickrUrlFromRecord(record) {
return 'http://farm' + record.farm
+ '.static.flickr.com/' + record.server
+ '/' + record.id + '_' + record.secret + '.jpg';
}

// TODO: remove 'jsonp-url' requirement when YUI fix for bug http://yuilibrary.com/projects/yui3/ticket/2530251 is deployed.
}, '0.0.1', {requires: ['mojito', 'yql', 'jsonp-url']});
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[
{
"settings": [ "master" ],

"root": {
"verbs": ["get"],
"path": "/flickr",
"call": "flickr.index"
}
}
]
]
4 changes: 2 additions & 2 deletions examples/getting-started-guide/part3/intl-templates/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/

module.exports = require('mojito').createServer({dir:__dirname});
/*jslint nomen: true */
module.exports = require('mojito').createServer({dir: __dirname});
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"settings": [ "master" ],

"specs": {
"flickr": {
"type": "HTMLFrameMojit",
Expand Down
6 changes: 3 additions & 3 deletions examples/getting-started-guide/part4/paged-yql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ process.chdir(__dirname);
* @param {object} token Token used to identify the application.
*/
module.exports = function(config, token) {
var server = require('./server.js');
var YUI = require('mojito').YUI;
var server = require('./server.js'),
YUI = require('mojito').YUI;

YUI().use('mojito-server', function(Y) {
var app = server(Y);

// Signal the app is ready, providing the token and app references.
process.emit("application-ready", token, app);
});
});
};
Loading

0 comments on commit 5a83c42

Please sign in to comment.