Skip to content

Commit 65889d3

Browse files
author
pau1tuck
committed
initial commit
0 parents  commit 65889d3

File tree

177 files changed

+9096
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+9096
-0
lines changed

Diff for: .bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "public/lib"
3+
}

Diff for: .csslintrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"adjoining-classes": false,
3+
"box-model": false,
4+
"box-sizing": false,
5+
"floats": false,
6+
"font-sizes": false,
7+
"important": false,
8+
"known-properties": false,
9+
"overqualified-elements": false,
10+
"qualified-headings": false,
11+
"regex-selectors": false,
12+
"unique-headings": false,
13+
"universal-selector": false,
14+
"unqualified-attributes": false
15+
}

Diff for: .editorconfig

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# Howto with your editor:
4+
# Sublime: https://github.com/sindresorhus/editorconfig-sublime
5+
6+
# top-most EditorConfig file
7+
root = true
8+
9+
# Unix-style newlines with a newline ending every file
10+
[**]
11+
end_of_line = lf
12+
insert_final_newline = true
13+
14+
# Standard at: https://github.com/felixge/node-style-guide
15+
[**.js, **.json]
16+
trim_trailing_whitespace = true
17+
indent_style = tab
18+
quote_type = single
19+
curly_bracket_next_line = false
20+
spaces_around_operators = true
21+
space_after_control_statements = true
22+
space_after_anonymous_functions = false
23+
spaces_in_brackets = false
24+
25+
# No Standard. Please document a standard if different from .js
26+
[**.yml, **.html, **.css]
27+
trim_trailing_whitespace = true
28+
indent_style = tab
29+
30+
# No standard. Please document a standard if different from .js
31+
[**.md]
32+
indent_style = tab
33+
34+
# Standard at:
35+
[Makefile]
36+
indent_style = tab

Diff for: .gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DS_Store
2+
.nodemonignore
3+
.sass-cache/
4+
npm-debug.log
5+
node_modules/
6+
public/lib
7+
app/tests/coverage/
8+
.bower-*/
9+
.idea/
10+
/_files
11+
Procfile
12+
Dockerfile
13+
generate-ssl-certs-sh

Diff for: .htaccess

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Header always unset X-Frame-Options

Diff for: .jshintrc

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
3+
"browser": true, // Standard browser globals e.g. `window`, `document`.
4+
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
5+
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
6+
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
7+
"curly": false, // Require {} for every new block or scope.
8+
"eqeqeq": true, // Require triple equals i.e. `===`.
9+
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
10+
"latedef": true, // Prohibit variable use before definition.
11+
"newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
12+
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
13+
"quotmark": "single", // Define quotes to string values.
14+
"regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
15+
"undef": true, // Require all non-global variables be declared before they are used.
16+
"unused": false, // Warn unused variables.
17+
"strict": true, // Require `use strict` pragma in every file.
18+
"trailing": true, // Prohibit trailing whitespaces.
19+
"smarttabs": false, // Suppresses warnings about mixed tabs and spaces
20+
"globals": { // Globals variables.
21+
"jasmine": true,
22+
"angular": true,
23+
"ApplicationConfiguration": true
24+
},
25+
"predef": [ // Extra globals.
26+
"define",
27+
"require",
28+
"exports",
29+
"module",
30+
"describe",
31+
"before",
32+
"beforeEach",
33+
"after",
34+
"afterEach",
35+
"it",
36+
"inject",
37+
"expect"
38+
],
39+
"indent": 4, // Specify indentation spacing
40+
"devel": true, // Allow development statements e.g. `console.log();`.
41+
"noempty": true // Prohibit use of empty blocks.
42+
}

Diff for: .slugignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/app/tests

Diff for: .travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- "0.10"
4+
env:
5+
- NODE_ENV=travis
6+
services:
7+
- mongodb

Diff for: LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## License
2+
(The MIT License)
3+
4+
Permission is hereby granted, free of charge, to any person obtaining
5+
a copy of this software and associated documentation files (the
6+
'Software'), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish,
8+
distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so, subject to
10+
the following conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# UDM
2+
Underground Dance Music

Diff for: app/controllers/articles.server.controller.js

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var mongoose = require('mongoose'),
7+
errorHandler = require('./errors.server.controller'),
8+
Article = mongoose.model('Article'),
9+
_ = require('lodash');
10+
11+
/**
12+
* Create a article
13+
*/
14+
exports.create = function(req, res) {
15+
var article = new Article(req.body);
16+
article.user = req.user;
17+
18+
article.save(function(err) {
19+
if (err) {
20+
return res.status(400).send({
21+
message: errorHandler.getErrorMessage(err)
22+
});
23+
} else {
24+
res.json(article);
25+
}
26+
});
27+
};
28+
29+
/**
30+
* Show the current article
31+
*/
32+
exports.read = function(req, res) {
33+
res.json(req.article);
34+
};
35+
36+
/**
37+
* Update a article
38+
*/
39+
exports.update = function(req, res) {
40+
var article = req.article;
41+
42+
article = _.extend(article, req.body);
43+
44+
article.save(function(err) {
45+
if (err) {
46+
return res.status(400).send({
47+
message: errorHandler.getErrorMessage(err)
48+
});
49+
} else {
50+
res.json(article);
51+
}
52+
});
53+
};
54+
55+
/**
56+
* Delete an article
57+
*/
58+
exports.delete = function(req, res) {
59+
var article = req.article;
60+
61+
article.remove(function(err) {
62+
if (err) {
63+
return res.status(400).send({
64+
message: errorHandler.getErrorMessage(err)
65+
});
66+
} else {
67+
res.json(article);
68+
}
69+
});
70+
};
71+
72+
/**
73+
* List of Articles
74+
*/
75+
exports.list = function(req, res) {
76+
Article.find().sort('-created').populate('user', 'displayName').exec(function(err, articles) {
77+
if (err) {
78+
return res.status(400).send({
79+
message: errorHandler.getErrorMessage(err)
80+
});
81+
} else {
82+
res.json(articles);
83+
}
84+
});
85+
};
86+
87+
/**
88+
* Article middleware
89+
*/
90+
exports.articleByID = function(req, res, next, id) {
91+
Article.findById(id).populate('user', 'displayName').exec(function(err, article) {
92+
if (err) return next(err);
93+
if (!article) return next(new Error('Failed to load article ' + id));
94+
req.article = article;
95+
next();
96+
});
97+
};
98+
99+
/**
100+
* Article authorization middleware
101+
*/
102+
exports.hasAuthorization = function(req, res, next) {
103+
if (req.article.user.id !== req.user.id) {
104+
return res.status(403).send({
105+
message: 'User is not authorized'
106+
});
107+
}
108+
next();
109+
};

Diff for: app/controllers/core.server.controller.js

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

Diff for: app/controllers/errors.server.controller.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
/**
4+
* Get unique error field name
5+
*/
6+
var getUniqueErrorMessage = function(err) {
7+
var output;
8+
9+
try {
10+
var fieldName = err.err.substring(err.err.lastIndexOf('.$') + 2, err.err.lastIndexOf('_1'));
11+
output = fieldName.charAt(0).toUpperCase() + fieldName.slice(1) + ' already exists';
12+
13+
} catch (ex) {
14+
output = 'Unique field already exists';
15+
}
16+
17+
return output;
18+
};
19+
20+
/**
21+
* Get the error message from error object
22+
*/
23+
exports.getErrorMessage = function(err) {
24+
var message = '';
25+
26+
if (err.code) {
27+
switch (err.code) {
28+
case 11000:
29+
case 11001:
30+
message = getUniqueErrorMessage(err);
31+
break;
32+
default:
33+
message = 'Something went wrong';
34+
}
35+
} else {
36+
for (var errName in err.errors) {
37+
if (err.errors[errName].message) message = err.errors[errName].message;
38+
}
39+
}
40+
41+
return message;
42+
};

0 commit comments

Comments
 (0)