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

Adding zombie #22

Merged
merged 10 commits into from
May 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
logs
*.log
*.swp
*.swo
*~

# Runtime data
Expand Down
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: node_js
node_js:
- '0.12'
- '0.11'
- 'iojs-v2.0.1'
install:
- npm install
- npm install
script:
- npm test
- npm run test-zombie
deploy:
provider: heroku
app: headless-decider
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"start": "node src/server/app.js",
"start-dev": "NODE_ENV=offline node node_modules/nodemon/bin/nodemon.js src/server/app.js",
"test": "node node_modules/mocha/bin/mocha test/",
"test-zombie": "node node_modules/mocha/bin/mocha test/zombie",
"testmon": "node_modules/nodemon/bin/nodemon.js node_modules/mocha/bin/mocha test/"
},
"repository": {
Expand Down Expand Up @@ -48,6 +49,7 @@
"lodash": "^3.8.0",
"mocha": "^2.2.4",
"nodemon": "^1.3.7",
"requirejs": "~2.1.17"
"requirejs": "~2.1.17",
"zombie": "^4.0.10"
}
}
2 changes: 1 addition & 1 deletion src/client/html/result.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="col-xs-4">
</div>
<div class="col-xs-4">
<img src="button_four.png" class="result__retry"></img>
<img id="nextBtn" src="button_four.png" class="result__retry"></img>
</div>
<div class="col-xs-4">
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/client/js/controllers/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ define([

this.container.html($rt);

// Add click listener
document.getElementById('nextBtn').onclick = this._renderOption.bind(this);

console.log('Displaying option for', this._id,'(', option.name, ')');
};

Expand Down
2 changes: 2 additions & 0 deletions src/client/js/controllers/MovieController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ define(['controllers/Controller',

// Show the basic movie info
this.container.html(movieTemplate(option));
// Add click listener
document.getElementById('nextBtn').onclick = this._renderOption.bind(this);
this._updateView(option); // Using OMDB API
};

Expand Down
2 changes: 1 addition & 1 deletion src/client/js/controllers/html/movie.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="col-xs-4">
</div>
<div class="col-xs-4">
<img src="button_four.png" class="result__retry"></img>
<img id="nextBtn" src="button_four.png" class="result__retry"></img>
</div>
<div class="col-xs-4">
</div>
Expand Down
36 changes: 36 additions & 0 deletions src/client/js/lib/require.min.js

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

4 changes: 2 additions & 2 deletions src/client/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ html
script(src="/bower_components/geolib/dist/geolib.min.js")
script(src="/js/GoogleAnalytics.js")
script(src="/bower_components/geolocator/src/geolocator.min.js")
script(data-main='/js/main.js', src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.17/require.min.js")
script(data-main='/js/main.js', src="/js/lib/require.min.js")
body
.container
.row
.col-sm-12
img.logo(src="logo.png")
img#logo.logo(src="logo.png")
.content
block content
11 changes: 8 additions & 3 deletions src/server/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var Server = function(opts) {

this._port = opts.port;
this._app = express();
this._serverInstance = null;
this.initializeApp(opts);
};

Expand Down Expand Up @@ -96,7 +97,7 @@ Server.prototype.initializeApp = function() {
response[c] = results.filter(Utils.hasCategory.bind(null, c.split(',')));
}, this);

console.log('<<< Final Response is', response.movies);
//console.log('<<< Final Response is', response);

return res.send(JSON.stringify(response));
});
Expand All @@ -108,7 +109,7 @@ Server.prototype.initializeApp = function() {
Server.prototype._request = function(req, requestor, callback) {
if (_.intersection(req.types, requestor.getCategories()).length) {
requestor.request(req, function(err, results) {
console.log('<<< Results from '+requestor.getName()+':', results);
console.log('<<< Received '+results.length+' results from '+requestor.getName());
return callback(err, results);
});
} else {
Expand All @@ -126,8 +127,12 @@ Server.prototype.splitCats = function(cats){

Server.prototype.start = function(callback) {
callback = callback || function(){};
this._app.listen(this._port, callback);
this._serverInstance = this._app.listen(this._port, callback);
console.log('App running on port', this._port);
};

Server.prototype.stop = function(callback) {
this._serverInstance.close(callback);
};

module.exports = Server;
1 change: 0 additions & 1 deletion src/server/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var getAttribute = function(attr, obj){
* @return {Boolean}
*/
var hasCategory = function(categories, result) {
console.log('checking categories for', result, '(', categories, ')');
var shared = _.intersection(categories, result.types);
return shared.length > 0;
};
Expand Down
Loading