Skip to content

Commit

Permalink
Merged upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfrear committed Nov 22, 2013
2 parents 2038b85 + db56846 commit 583d7d8
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 124 deletions.
3 changes: 1 addition & 2 deletions app/controllers/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Module dependencies.
*/
var mongoose = require('mongoose'),
async = require('async'),
Article = mongoose.model('Article'),
_ = require('underscore');

Expand Down Expand Up @@ -88,4 +87,4 @@ exports.all = function(req, res) {
res.jsonp(articles);
}
});
};
};
3 changes: 1 addition & 2 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
* Module dependencies.
*/
var mongoose = require('mongoose'),
async = require('async'),
_ = require('underscore');


exports.render = function(req, res) {
res.render('index', {
user: req.user ? JSON.stringify(req.user) : "null"
});
};
};
2 changes: 1 addition & 1 deletion app/views/includes/foot.jade
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ script(type='text/javascript', src='lib/angular-cookies/angular-cookies.js')
script(type='text/javascript', src='lib/angular-resource/angular-resource.js')

//Angular UI
script(type='text/javascript', src='/lib/angular-bootstrap/ui-bootstrap-tpls.js')
script(type='text/javascript', src='/lib/angular-bootstrap/ui-bootstrap.js')
script(type='text/javascript', src='/lib/angular-bootstrap/ui-bootstrap-tpls.js')
script(type='text/javascript', src='/lib/angular-ui-utils/modules/route/route.js')

//Application Init
Expand Down
2 changes: 1 addition & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ var _ = require('underscore');

module.exports = _.extend(
require(__dirname + '/../config/env/all.js'),
require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.json') || {});
require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {});
26 changes: 26 additions & 0 deletions config/env/development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
db: "mongodb://localhost/mean-dev",
app: {
name: "MEAN - A Modern Stack - Development"
},
facebook: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/facebook/callback"
},
twitter: {
clientID: "CONSUMER_KEY",
clientSecret: "CONSUMER_SECRET",
callbackURL: "http://localhost:3000/auth/twitter/callback"
},
github: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/github/callback"
},
google: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/google/callback"
}
}
26 changes: 0 additions & 26 deletions config/env/development.json

This file was deleted.

26 changes: 26 additions & 0 deletions config/env/production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
db: "mongodb://localhost/mean",
app: {
name: "MEAN - A Modern Stack - Production"
},
facebook: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/facebook/callback"
},
twitter: {
clientID: "CONSUMER_KEY",
clientSecret: "CONSUMER_SECRET",
callbackURL: "http://localhost:3000/auth/twitter/callback"
},
github: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/github/callback"
},
google: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/google/callback"
}
}
26 changes: 0 additions & 26 deletions config/env/production.json

This file was deleted.

27 changes: 27 additions & 0 deletions config/env/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
db: "mongodb://localhost/mean-test",
port: 3001,
app: {
name: "MEAN - A Modern Stack - Test"
},
facebook: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/facebook/callback"
},
twitter: {
clientID: "CONSUMER_KEY",
clientSecret: "CONSUMER_SECRET",
callbackURL: "http://localhost:3000/auth/twitter/callback"
},
github: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/github/callback"
},
google: {
clientID: "APP_ID",
clientSecret: "APP_SECRET",
callbackURL: "http://localhost:3000/auth/google/callback"
}
}
27 changes: 0 additions & 27 deletions config/env/test.json

This file was deleted.

5 changes: 3 additions & 2 deletions config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ module.exports = function(app, passport, db) {
//cookieParser should be above session
app.use(express.cookieParser());

//bodyParser should be above methodOverride
app.use(express.bodyParser());
// request body parsing middleware should be above methodOverride
app.use(express.urlencoded());
app.use(express.json());
app.use(express.methodOverride());

//express/mongo session storage
Expand Down
2 changes: 1 addition & 1 deletion config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function(passport) {
passport.deserializeUser(function(id, done) {
User.findOne({
_id: id
}, function(err, user) {
}, '-salt -hashed_password', function(err, user) {
done(err, user);
});
});
Expand Down
4 changes: 1 addition & 3 deletions config/routes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var async = require('async');

module.exports = function(app, passport, auth) {
//User Routes
var users = require('../app/controllers/users');
Expand Down Expand Up @@ -89,4 +87,4 @@ module.exports = function(app, passport, auth) {
var index = require('../app/controllers/index');
app.get('/', index.render);

};
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"passport-github": "latest",
"passport-google-oauth": "latest",
"underscore": "latest",
"async": "latest",
"view-helpers": "latest",
"mean-logger": "latest",
"forever": "latest",
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
window.app = angular.module('mean', ['ngCookies', 'ngResource', 'ui.bootstrap', 'ui.route', 'mean.system', 'mean.articles', 'mean.tabs']);
angular.module('mean', ['ngCookies', 'ngResource', 'ui.bootstrap', 'ui.route', 'mean.system', 'mean.articles', 'mean.tabs']);

angular.module('mean.system', []);
angular.module('mean.articles', []);
Expand Down
4 changes: 2 additions & 2 deletions public/js/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Setting up route
window.app.config(['$routeProvider',
angular.module('mean').config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/articles', {
Expand Down Expand Up @@ -36,7 +36,7 @@ window.app.config(['$routeProvider',
]);

//Setting HTML5 Location Mode
window.app.config(['$locationProvider',
angular.module('mean').config(['$locationProvider',
function($locationProvider) {
$locationProvider.hashPrefix("!");
}
Expand Down
14 changes: 10 additions & 4 deletions public/js/controllers/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ angular.module('mean.articles').controller('ArticlesController', ['$scope', '$ro
};

$scope.remove = function(article) {
article.$remove();
if (article) {
article.$remove();

for (var i in $scope.articles) {
if ($scope.articles[i] == article) {
$scope.articles.splice(i, 1);
for (var i in $scope.articles) {
if ($scope.articles[i] == article) {
$scope.articles.splice(i, 1);
}
}
}
else {
$scope.article.$remove();
$location.path('articles');
}
};

$scope.update = function() {
Expand Down
10 changes: 1 addition & 9 deletions public/js/init.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
window.bootstrap = function() {
angular.bootstrap(document, ['mean']);
};

window.init = function() {
window.bootstrap();
};

angular.element(document).ready(function() {
//Fixing facebook bug with redirect
if (window.location.hash == "#_=_") window.location.hash = "";

//Then init the app
window.init();
angular.bootstrap(document, ['mean']);
});
19 changes: 11 additions & 8 deletions public/js/services/global.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
angular.module('mean.system').factory("Global", [function() {
var _this = this;
_this._data = {
user: window.user,
authenticated: !! window.user
};
//Global service for global variables
angular.module('mean.system').factory("Global", [
function() {
var _this = this;
_this._data = {
user: window.user,
authenticated: !! window.user
};

return _this._data;
}]);
return _this._data;
}
]);
18 changes: 13 additions & 5 deletions public/views/articles/view.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<section data-ng-controller="ArticlesController" data-ng-init="findOne()">
<span>{{article.created | date:'medium'}}</span> /
<span>{{article.user.name}}</span>
<h2>{{article.title}} <a data-ng-show="global.user._id == article.user._id" href="/#!/articles/{{article._id}}/edit">edit</a></h2>
<div>{{article.content}}</div>
</section>
<span>{{article.created | date:'medium'}}</span>/
<span>{{article.user.name}}</span>
<h2>{{article.title}}</h2>
<div data-ng-show="global.user._id == article.user._id">
<a class="btn" href="/#!/articles/{{article._id}}/edit">
<i class="icon-edit"></i>
</a>
<a class="btn" data-ng-click="remove();">
<i class="icon-trash"></i>
</a>
</div>
<div>{{article.content}}</div>
</section>
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var walk = function(path) {
var newPath = path + '/' + file;
var stat = fs.statSync(newPath);
if (stat.isFile()) {
if (/(.*)\.(js|coffee)/.test(file)) {
if (/(.*)\.(js$|coffee$)/.test(file)) {
require(newPath);
}
} else if (stat.isDirectory()) {
Expand Down
2 changes: 1 addition & 1 deletion test/article/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('<Unit Test>', function() {
});
});

it('should be able to show an error when try to save witout title', function(done) {
it('should be able to show an error when try to save without title', function(done) {
article.title = '';

return article.save(function(err) {
Expand Down
2 changes: 1 addition & 1 deletion test/user/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('<Unit Test>', function() {
});
});

it('should be able to show an error when try to save witout name', function(done) {
it('should be able to show an error when try to save without name', function(done) {
user.name = '';
return user.save(function(err) {
should.exist(err);
Expand Down

0 comments on commit 583d7d8

Please sign in to comment.