Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit eae6f2d

Browse files
committed
Moving to MEAN.JS
1 parent 17e089e commit eae6f2d

File tree

39 files changed

+1086
-0
lines changed

39 files changed

+1086
-0
lines changed

app/controllers/core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
exports.index = function(req, res) {
7+
res.render('index.html', {
8+
user: req.user || null
9+
});
10+
};

app/routes/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
module.exports = function(app) {
4+
// Root routing
5+
var core = require('../../app/controllers/core');
6+
app.get('/', core.index);
7+
};

app/tests/articles.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var should = require('should'),
7+
mongoose = require('mongoose'),
8+
User = mongoose.model('User'),
9+
Article = mongoose.model('Article');
10+
11+
//Globals
12+
var user;
13+
var article;
14+
15+
//The tests
16+
describe('<Unit Test>', function() {
17+
describe('Model Article:', function() {
18+
beforeEach(function(done) {
19+
user = new User({
20+
firstName: 'Full',
21+
lastName: 'Name',
22+
displayName: 'Full Name',
23+
24+
username: 'username',
25+
password: 'password'
26+
});
27+
28+
user.save(function() {
29+
article = new Article({
30+
title: 'Article Title',
31+
content: 'Article Content',
32+
user: user
33+
});
34+
35+
done();
36+
});
37+
});
38+
39+
describe('Method Save', function() {
40+
it('should be able to save without problems', function(done) {
41+
return article.save(function(err) {
42+
should.not.exist(err);
43+
done();
44+
});
45+
});
46+
47+
it('should be able to show an error when try to save without title', function(done) {
48+
article.title = '';
49+
50+
return article.save(function(err) {
51+
should.exist(err);
52+
done();
53+
});
54+
});
55+
});
56+
57+
afterEach(function(done) {
58+
Article.remove().exec();
59+
User.remove().exec();
60+
done();
61+
});
62+
});
63+
});

app/tests/users.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var should = require('should'),
7+
mongoose = require('mongoose'),
8+
User = mongoose.model('User');
9+
10+
//Globals
11+
var user, user2;
12+
13+
//The tests
14+
describe('<Unit Test>', function() {
15+
describe('Model User:', function() {
16+
before(function(done) {
17+
user = new User({
18+
firstName: 'Full',
19+
lastName: 'Name',
20+
displayName: 'Full Name',
21+
22+
username: 'username',
23+
password: 'password',
24+
provider: 'local'
25+
});
26+
user2 = new User({
27+
firstName: 'Full',
28+
lastName: 'Name',
29+
displayName: 'Full Name',
30+
31+
username: 'username',
32+
password: 'password',
33+
provider: 'local'
34+
});
35+
36+
done();
37+
});
38+
39+
describe('Method Save', function() {
40+
it('should begin with no users', function(done) {
41+
User.find({}, function(err, users) {
42+
users.should.have.length(0);
43+
done();
44+
});
45+
});
46+
47+
it('should be able to save whithout problems', function(done) {
48+
user.save(done);
49+
});
50+
51+
it('should fail to save an existing user again', function(done) {
52+
user.save();
53+
return user2.save(function(err) {
54+
should.exist(err);
55+
done();
56+
});
57+
});
58+
59+
it('should be able to show an error when try to save without first name', function(done) {
60+
user.firstName = '';
61+
return user.save(function(err) {
62+
should.exist(err);
63+
done();
64+
});
65+
});
66+
});
67+
68+
after(function(done) {
69+
User.remove().exec();
70+
done();
71+
});
72+
});
73+
});

app/views/layout.html

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
3+
4+
<head>
5+
<title>{{title}}</title>
6+
7+
<!-- General META -->
8+
<meta charset="utf-8">
9+
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
10+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
11+
<meta name="viewport" content="width=device-width,initial-scale=1">
12+
13+
<!-- Semantic META -->
14+
<meta name="keywords" content="{{keywords}}">
15+
<meta name="description" content="{{description}}">
16+
17+
<!-- Social META -->
18+
<meta property="fb:app_id" content="{{facebookAppId}}">
19+
<meta property="og:site_name" content="{{title}}">
20+
<meta property="og:title" content="{{title}}">
21+
<meta property="og:description" content="{{description}}">
22+
<meta property="og:url" content="{{url}}">
23+
<meta property="og:image" content="/img/brand/logo.png">
24+
<meta property="og:type" content="website">
25+
26+
<!-- Fav Icon -->
27+
<link href="/img/brand/favicon.ico" rel="shortcut icon" type="image/x-icon">
28+
29+
<!-- Bootstrap CSS -->
30+
<link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.css">
31+
<link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap-theme.css">
32+
33+
<!-- Application CSS -->
34+
<link rel="stylesheet" href="/css/common.css">
35+
36+
<!--Application Modules CSS-->
37+
{% for modulesCSSFile in modulesCSSFiles %}
38+
<link rel="stylesheet" href="{{modulesCSSFile}}">
39+
{% endfor %}
40+
41+
<!-- HTML5 Shim -->
42+
<!--[if lt IE 9]>
43+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
44+
<![endif]-->
45+
</head>
46+
47+
<body>
48+
<header data-ng-include="'/modules/core/views/header.html'" class="navbar navbar-fixed-top navbar-inverse"></header>
49+
<section class="content">
50+
<section class="container">
51+
{% block content %}{% endblock %}
52+
</section>
53+
</section>
54+
55+
<!--Embedding The User Object-->
56+
<script type="text/javascript">
57+
var user = {{user | json | safe}};
58+
</script>
59+
60+
<!--AngularJS-->
61+
<script type="text/javascript" src="/lib/angular/angular.js"></script>
62+
<script type="text/javascript" src="/lib/angular-route/angular-route.js"></script>
63+
<script type="text/javascript" src="/lib/angular-resource/angular-resource.js"></script>
64+
<script type="text/javascript" src="/lib/angular-cookies/angular-cookies.js"></script>
65+
<script type="text/javascript" src="/lib/angular-animate/angular-animate.js"></script>
66+
67+
<!--Angular UI-->
68+
<script type="text/javascript" src="/lib/angular-bootstrap/ui-bootstrap.js"></script>
69+
<script type="text/javascript" src="/lib/angular-ui-utils/ui-utils.js"></script>
70+
71+
<!--AngularJS Application Init-->
72+
<script type="text/javascript" src="/js/config.js"></script>
73+
<script type="text/javascript" src="/js/application.js"></script>
74+
75+
<!--Application Modules-->
76+
{% for modulesJSFile in modulesJSFiles %}
77+
<script type="text/javascript" src="{{modulesJSFile}}"></script>
78+
{% endfor %}
79+
80+
{% if process.env.NODE_ENV === 'development' %}
81+
<!--Livereload script rendered -->
82+
<script type="text/javascript" src="http://localhost:35729/livereload.js"></script>
83+
{% endif %}
84+
</body>
85+
</html>

config/env/travis.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
module.exports = {
4+
db: 'mongodb://localhost/mean-travis',
5+
port: 3001,
6+
app: {
7+
title: 'MEAN.JS - Travis Environment'
8+
},
9+
facebook: {
10+
clientID: 'APP_ID',
11+
clientSecret: 'APP_SECRET',
12+
callbackURL: 'http://localhost:3000/auth/facebook/callback'
13+
},
14+
twitter: {
15+
clientID: 'CONSUMER_KEY',
16+
clientSecret: 'CONSUMER_SECRET',
17+
callbackURL: 'http://localhost:3000/auth/twitter/callback'
18+
},
19+
google: {
20+
clientID: 'APP_ID',
21+
clientSecret: 'APP_SECRET',
22+
callbackURL: 'http://localhost:3000/auth/google/callback'
23+
},
24+
linkedin: {
25+
clientID: 'APP_ID',
26+
clientSecret: 'APP_SECRET',
27+
callbackURL: 'http://localhost:3000/auth/linkedin/callback'
28+
}
29+
};

config/utilities.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var fs = require('fs');
7+
8+
// Walk function to recursively get files
9+
var _walk = function(root, regex, exclude, removePath) {
10+
var output = [];
11+
var directories = [];
12+
13+
// First read through files
14+
fs.readdirSync(root).forEach(function(file) {
15+
var newPath = root + '/' + file;
16+
var stat = fs.statSync(newPath);
17+
18+
if (stat.isFile()) {
19+
if (regex.test(file) && (!exclude || !exclude.test(file))) {
20+
output.push(newPath.replace(removePath, ''));
21+
}
22+
} else if (stat.isDirectory()) {
23+
directories.push(newPath);
24+
}
25+
});
26+
27+
// Then recursively add directories
28+
directories.forEach(function(directory) {
29+
output = output.concat(_walk(directory, regex, exclude, removePath));
30+
});
31+
32+
return output;
33+
};
34+
35+
/**
36+
* Exposing the walk function
37+
*/
38+
exports.walk = _walk;

karma.conf.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var utilities = require('./config/utilities');
7+
8+
// Grabbing module files using the walk function
9+
var modulesJSFiles = utilities.walk('./public/modules', /(.*)\.(js)/, null, null);
10+
11+
// Karma configuration
12+
module.exports = function(config) {
13+
config.set({
14+
// Frameworks to use
15+
frameworks: ['jasmine'],
16+
17+
// List of files / patterns to load in the browser
18+
files: [
19+
'public/lib/angular/angular.js',
20+
'public/lib/angular-mocks/angular-mocks.js',
21+
'public/lib/angular-cookies/angular-cookies.js',
22+
'public/lib/angular-resource/angular-resource.js',
23+
'public/lib/angular-route/angular-route.js',
24+
'public/lib/angular-bootstrap/ui-bootstrap.js',
25+
'public/lib/angular-ui-utils/ui-utils.js',
26+
'public/js/config.js',
27+
'public/js/application.js',
28+
].concat(modulesJSFiles),
29+
30+
// Test results reporter to use
31+
// Possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
32+
//reporters: ['progress'],
33+
reporters: ['progress'],
34+
35+
// Web server port
36+
port: 9876,
37+
38+
// Enable / disable colors in the output (reporters and logs)
39+
colors: true,
40+
41+
// Level of logging
42+
// Possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
43+
logLevel: config.LOG_INFO,
44+
45+
// Enable / disable watching file and executing tests whenever any file changes
46+
autoWatch: true,
47+
48+
// Start these browsers, currently available:
49+
// - Chrome
50+
// - ChromeCanary
51+
// - Firefox
52+
// - Opera
53+
// - Safari (only Mac)
54+
// - PhantomJS
55+
// - IE (only Windows)
56+
browsers: ['PhantomJS'],
57+
58+
// If browser does not capture in given timeout [ms], kill it
59+
captureTimeout: 60000,
60+
61+
// Continuous Integration mode
62+
// If true, it capture browsers, run tests and exit
63+
singleRun: true
64+
});
65+
};

public/img/brand/favicon.ico

31.3 KB
Binary file not shown.

public/img/brand/logo.png

4.4 KB
Loading

0 commit comments

Comments
 (0)