diff options
-rw-r--r-- | app/controllers/system.js (renamed from controllers/system.js) | 35 | ||||
-rw-r--r-- | app/controllers/users.js (renamed from controllers/users.js) | 31 | ||||
-rw-r--r-- | app/models/Access.js (renamed from models/Access.js) | 0 | ||||
-rw-r--r-- | app/models/Project.js (renamed from models/Project.js) | 0 | ||||
-rw-r--r-- | app/models/User.js (renamed from models/User.js) | 0 | ||||
-rw-r--r-- | app/models/pPost.js (renamed from models/pPost.js) | 0 | ||||
-rw-r--r-- | app/views/contact.ejs (renamed from views/contact.ejs) | 6 | ||||
-rw-r--r-- | app/views/dashboard.ejs (renamed from views/dashboard.ejs) | 6 | ||||
-rw-r--r-- | app/views/error.ejs (renamed from views/error.ejs) | 0 | ||||
-rw-r--r-- | app/views/faq.ejs (renamed from views/faq.ejs) | 6 | ||||
-rw-r--r-- | app/views/home.ejs (renamed from views/home.ejs) | 0 | ||||
-rw-r--r-- | app/views/index.ejs (renamed from views/index.ejs) | 6 | ||||
-rw-r--r-- | app/views/project/newProject.ejs (renamed from views/newProject.ejs) | 6 | ||||
-rw-r--r-- | app/views/project/participants.ejs (renamed from views/projectParticipants.ejs) | 6 | ||||
-rw-r--r-- | app/views/project/post.ejs (renamed from views/projectPost.ejs) | 6 | ||||
-rw-r--r-- | app/views/project/project.ejs (renamed from views/project.ejs) | 6 | ||||
-rw-r--r-- | app/views/template.ejs (renamed from views/template.ejs) | 6 | ||||
-rw-r--r-- | app/views/templates/footer.ejs (renamed from views/footer.ejs) | 0 | ||||
-rw-r--r-- | app/views/templates/header.ejs (renamed from views/header.ejs) | 0 | ||||
-rw-r--r-- | app/views/templates/navbar.ejs (renamed from views/navbar.ejs) | 0 | ||||
-rw-r--r-- | app/views/test.ejs (renamed from views/test.ejs) | 6 | ||||
-rw-r--r-- | app/views/users/registerEmail.ejs (renamed from views/registerEmail.ejs) | 4 | ||||
-rw-r--r-- | app/views/users/signup.ejs (renamed from views/signup.ejs) | 6 | ||||
-rw-r--r-- | config/express.js | 2 | ||||
-rw-r--r-- | config/routes.js (renamed from routes.js) | 12 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | server.js (renamed from app.js) | 6 | ||||
-rw-r--r-- | views/login.ejs | 60 |
28 files changed, 61 insertions, 157 deletions
diff --git a/controllers/system.js b/app/controllers/system.js index c29e06f..0e63083 100644 --- a/controllers/system.js +++ b/app/controllers/system.js @@ -4,7 +4,7 @@ */ var mongoose = require('mongoose') , env = process.env.NODE_ENV || 'development' - , config = require('../config/config.js')[env] + , config = require('../../config/config.js')[env] , Project = mongoose.model('Project') , Access = mongoose.model('Access') , User = mongoose.model('User') @@ -36,23 +36,6 @@ exports.index = function(req, res) { }; - -exports.test = function(req, res) { - res.render('test', { - title: 'test', - user: req.user - }); -}; - - -exports.home = function(req, res) { - res.render('home', { - title: 'home', - user: req.user - }); -}; - - exports.faq = function(req, res) { res.render('faq', { title: 'faq', @@ -159,7 +142,7 @@ exports.dashboard = function(req, res) { exports.project = function(req, res) { Project.loadShort(req.params.short, function(err, project) { - if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); + if (err || !project) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err }); Access.loadProject(project._id, function(err, access) { if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); pPost.loadProject(project._id, function(err, posts) { @@ -207,7 +190,7 @@ exports.project = function(req, res) { if (pro.user[i].diff > 0) pro.user[i].coeff = pro.user[i].diff / pro.otot; } console.log(pro); - res.render('project', { + res.render('project/project', { title: project.name , user: req.user , req: req @@ -228,7 +211,7 @@ exports.projectParticipants = function(req, res) { if (req.header('Referer') === undefined) { return res.status(403).render('error', { title: 403, text: 'Du har ikke tilgang til denne siden. Du må registrere deg først. Sjekk mailen din for å se invitekode.' }); } else { return res.redirect('back'); } } - res.render('projectParticipants', { title: 'Prosjektdeltakere', user: req.user }); + res.render('project/participants', { title: 'Prosjektdeltakere', user: req.user }); } @@ -241,7 +224,7 @@ exports.projectPost = function(req, res) { Project.loadShort(req.params.short, function(err, project) { if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); req.project = project; - res.render('projectPost', { title: 'Legg til utgift', user: req.user, req: req, project: project }); + res.render('project/post', { title: 'Legg til utgift', user: req.user, req: req, project: project }); }); @@ -278,7 +261,7 @@ exports.postProjectPost = function(req, res) { ppost.value = sanitize(req.body.value).toInt(); // this will remove leading zeroes. '0123' => '123' ppost.when = new Date(sanitize(req.body.date).escape() + ' ' + sanitize(req.body.time).escape() + ':00'); ppost.save(function(err) { - if (err) return res.render('projectPost', { title: 'Legg til utgift - en feil oppstod', user: req.user, req: req, project: project }); + if (err) return res.render('project/post', { title: 'Legg til utgift - en feil oppstod', user: req.user, req: req, project: project }); return res.redirect('/project/' + project.shortURL); }); }); @@ -290,7 +273,7 @@ exports.newProject = function(req, res) { else { return res.redirect('back'); } } - res.render('newProject', { title: 'Nytt prosjekt', user: req.user }); + res.render('project/newProject', { title: 'Nytt prosjekt', user: req.user }); } exports.postNewProject = function(req, res) { @@ -304,7 +287,7 @@ exports.postNewProject = function(req, res) { project.save(function(err) { if (err) { console.log(err.errors); - return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', user: req.user, errors: err.errors, project: project }); + return res.render('project/newProject', { title: 'Nytt prosjekt - en feil oppstod', user: req.user, errors: err.errors, project: project }); } var access = new Access(); access.user = req.user._id; @@ -314,7 +297,7 @@ exports.postNewProject = function(req, res) { access.save(function(err) { if (err) { console.log(err.errors); - return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', user: req.user }); + return res.render('project/newProject', { title: 'Nytt prosjekt - en feil oppstod', user: req.user }); } return res.redirect('/dashboard'); }); diff --git a/controllers/users.js b/app/controllers/users.js index 86cbd35..725fa3e 100644 --- a/controllers/users.js +++ b/app/controllers/users.js @@ -8,7 +8,7 @@ var mongoose = require('mongoose') , Project = mongoose.model('Project') , Access = mongoose.model('Access') , env = process.env.NODE_ENV || 'development' - , config = require('../config/config')[env] + , config = require('../../config/config')[env] , Validator = require('validator').Validator , v = new Validator() , sanitize = require('validator').sanitize; @@ -26,17 +26,6 @@ Validator.prototype.getErrors = function() { /** - * Login - */ -exports.login = function(req, res) { - res.render('login', { - title: 'Login' - }); - -} - - -/** * Logout */ exports.logout = function(req, res) { @@ -66,7 +55,7 @@ exports.randomLogin = function(req, res) { * Signup */ exports.signup = function(req, res) { - res.render('signup', { title: 'Registrer deg', invite: false }); + res.render('users/signup', { title: 'Registrer deg', invite: false }); } /** @@ -76,7 +65,7 @@ exports.create = function(req, res) { var user = new User(req.body); user.provider = 'local'; user.save(function(err) { - if (err) return res.render('signup', { errors: err.errors, user: user }); + if (err) return res.render('users/signup', { errors: err.errors, user: user }); req.logIn(user, function(err) { if (err) return next(err); return res.redirect('/dashboard'); @@ -106,7 +95,7 @@ exports.authCallback = function(req, res, next) { exports.registerEmail = function(req, res) { // in case some user who has alreadu registered an email gets on this page if (req.user.email !== undefined) return res.redirect('/dashboard'); - res.render('registerEmail', { title: 'Registrer din e-post' }); + res.render('users/registerEmail', { title: 'Registrer din e-post' }); } @@ -125,7 +114,7 @@ exports.postRegisterEmail = function(req, res) { if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); // if mail is in use.. - if (user) return res.render('registerEmail', { title: 'Den e-posten er allerede i bruk. Vennligs registrer en annen.' }); + if (user) return res.render('users/registerEmail', { title: 'Den e-posten er allerede i bruk. Vennligs registrer en annen.' }); User.update({ _id: req.user._id }, { email: req.body.email, status: 3 }, function(err) { if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); @@ -183,7 +172,7 @@ exports.postProjectParticipants = function(req, res) { newUser.password = newUser.generateRandomToken(32); newUser.randomToken = newUser.generateRandomToken(10, true); newUser.save(function(err) { - if (err) return res.render('projectParticipants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); + if (err) return res.render('project/participants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); console.log('made new user ' + newUser._id); var access = new Access(); access.user = newUser._id; @@ -193,7 +182,7 @@ exports.postProjectParticipants = function(req, res) { access.save(function(err) { if (err) { console.log(err.errors); - return res.render('projectParticipants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); + return res.render('project/participants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); } console.log('made new access for user ' + newUser._id); message.to = newUser.email; @@ -204,7 +193,7 @@ exports.postProjectParticipants = function(req, res) { } else { // if the user exists, add him to the project Access.checkAccess(user._id, project._id, 0, function(err, acc) { - if (err) return res.render('projectParticipants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); + if (err) return res.render('project/participants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); if (acc) { // if the user already has access to the project.. do nothing console.log('user ' + user.email + ' already has access to project ' + project.name); } else { @@ -221,7 +210,7 @@ exports.postProjectParticipants = function(req, res) { access.save(function(err) { if (err) { console.log(err.errors); - return res.render('projectParticipants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); + return res.render('project/participants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); } console.log('made new access for user ' + user.username); message.to = user.email; @@ -251,7 +240,7 @@ exports.claimInvite = function(req, res) { if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); if (!user) return res.render('error', { title: 'This invite does not exist', text: 'Invitasjonen din er ugyldig' }); - res.render('signup', { + res.render('users/signup', { invite: true, title: 'Registrer deg!', email: user.email } diff --git a/models/Access.js b/app/models/Access.js index b9570e6..b9570e6 100644 --- a/models/Access.js +++ b/app/models/Access.js diff --git a/models/Project.js b/app/models/Project.js index ba0e8e7..ba0e8e7 100644 --- a/models/Project.js +++ b/app/models/Project.js diff --git a/models/User.js b/app/models/User.js index 0dc38f3..0dc38f3 100644 --- a/models/User.js +++ b/app/models/User.js diff --git a/models/pPost.js b/app/models/pPost.js index 1f53984..1f53984 100644 --- a/models/pPost.js +++ b/app/models/pPost.js diff --git a/views/contact.ejs b/app/views/contact.ejs index 4fed4c5..72268cb 100644 --- a/views/contact.ejs +++ b/app/views/contact.ejs @@ -1,8 +1,8 @@ -<% include header %> +<% include templates/header %> </head> <body> - <% include navbar %> + <% include templates/navbar %> <!-- Wrapper ================================================== --> @@ -12,6 +12,6 @@ <p>Se gjerne igjennom vår <a href="https://divid.no/faq">faq</a> - ofte stilte spørsmål - før dere sender mail på support(at)divid.no.</p> <h3>Business</h3> <p>Ønsker du å kontakte oss for kjøp av annonseplass, forretninger og lignende ta kontakt på hallo(at)divid.no.</p> -<% include footer %> +<% include templates/footer %> </body> </html> diff --git a/views/dashboard.ejs b/app/views/dashboard.ejs index c759add..f2979b3 100644 --- a/views/dashboard.ejs +++ b/app/views/dashboard.ejs @@ -1,8 +1,8 @@ -<% include header %> +<% include templates/header %> </head> <body> - <% include navbar %> + <% include templates/navbar %> <!-- Wrapper ================================================== --> @@ -124,7 +124,7 @@ </div><!-- /div.#wrapper --> -<% include footer %> +<% include templates/footer %> <script src="/js/Chart.min.js"></script> <script> var data = { diff --git a/views/error.ejs b/app/views/error.ejs index 47cc546..47cc546 100644 --- a/views/error.ejs +++ b/app/views/error.ejs diff --git a/views/faq.ejs b/app/views/faq.ejs index 34121b7..d3473eb 100644 --- a/views/faq.ejs +++ b/app/views/faq.ejs @@ -1,8 +1,8 @@ -<% include header %>
+<% include templates/header %>
</head>
<body>
- <% include navbar %>
+ <% include templates/navbar %>
<!-- Wrapper
================================================== -->
@@ -110,6 +110,6 @@ </div><!-- /div#wrapper -->
- <% include footer %>
+ <% include templates/footer %>
</body>
</html>
diff --git a/views/home.ejs b/app/views/home.ejs index 70dbb0f..70dbb0f 100644 --- a/views/home.ejs +++ b/app/views/home.ejs diff --git a/views/index.ejs b/app/views/index.ejs index 7a853b3..0768773 100644 --- a/views/index.ejs +++ b/app/views/index.ejs @@ -1,9 +1,9 @@ -<% include header %> +<% include templates/header %> </head> <body> - <% include navbar %> + <% include templates/navbar %> <div class="indexwrapper" id="index1"> <div class="container"> <div class="row-fluid"> @@ -126,6 +126,6 @@ -<% include footer %> +<% include templates/footer %> </body> </html> diff --git a/views/newProject.ejs b/app/views/project/newProject.ejs index facedcf..2101138 100644 --- a/views/newProject.ejs +++ b/app/views/project/newProject.ejs @@ -1,8 +1,8 @@ -<% include header %> +<% include ../templates/header %> </head> <body> - <% include navbar %> + <% include ../templates/navbar %> <!-- Wrapper ================================================== --> @@ -74,6 +74,6 @@ </div><!-- /div.#wrapper --> -<% include footer %> +<% include ../templates/footer %> </body> </html> diff --git a/views/projectParticipants.ejs b/app/views/project/participants.ejs index 3af9c10..4341a4f 100644 --- a/views/projectParticipants.ejs +++ b/app/views/project/participants.ejs @@ -1,8 +1,8 @@ -<% include header %> +<% include ../templates/header %> </head> <body> - <% include navbar %> + <% include ../templates/navbar %> <!-- Wrapper ================================================== --> @@ -50,6 +50,6 @@ </div><!-- /div.#wrapper --> -<% include footer %> +<% include ../templates/footer %> </body> </html> diff --git a/views/projectPost.ejs b/app/views/project/post.ejs index 710726e..5e8f283 100644 --- a/views/projectPost.ejs +++ b/app/views/project/post.ejs @@ -1,8 +1,8 @@ -<% include header %> +<% include ../templates/header %> </head> <body> - <% include navbar %> + <% include ../templates/navbar %> <!-- Wrapper ================================================== --> @@ -91,7 +91,7 @@ </div><!-- /div.#wrapper --> -<% include footer %> +<% include ../templates/footer %> <!-- <script> $(".selectAll").click(function() { $('#participants').children().attr('selected','selected'); diff --git a/views/project.ejs b/app/views/project/project.ejs index dedd5e4..7e06dad 100644 --- a/views/project.ejs +++ b/app/views/project/project.ejs @@ -1,8 +1,8 @@ -<% include header %> +<% include ../templates/header %> </head> <body> - <% include navbar %> + <% include ../templates/navbar %> <!-- Wrapper ================================================== --> @@ -190,7 +190,7 @@ </div><!-- /div.#wrapper --> -<% include footer %> +<% include ../templates/footer %> <script src="/js/Chart.min.js"></script> <script> var data = { diff --git a/views/template.ejs b/app/views/template.ejs index ef05996..6803c37 100644 --- a/views/template.ejs +++ b/app/views/template.ejs @@ -1,8 +1,8 @@ -<% include header %> +<% include templates/header %> </head> <body> - <% include navbar %> + <% include templates/navbar %> <!-- Wrapper ================================================== --> @@ -13,6 +13,6 @@ </div><!-- /div.#wrapper --> -<% include footer %> +<% include templates/footer %> </body> </html> diff --git a/views/footer.ejs b/app/views/templates/footer.ejs index 2421d82..2421d82 100644 --- a/views/footer.ejs +++ b/app/views/templates/footer.ejs diff --git a/views/header.ejs b/app/views/templates/header.ejs index 815be5c..815be5c 100644 --- a/views/header.ejs +++ b/app/views/templates/header.ejs diff --git a/views/navbar.ejs b/app/views/templates/navbar.ejs index f72947d..f72947d 100644 --- a/views/navbar.ejs +++ b/app/views/templates/navbar.ejs diff --git a/views/test.ejs b/app/views/test.ejs index 65a63b3..03a8aee 100644 --- a/views/test.ejs +++ b/app/views/test.ejs @@ -1,8 +1,8 @@ -<% include header %> +<% include templates/header %> </head> <body> - <% include navbar %> + <% include templates/navbar %> <!-- Wrapper ================================================== --> @@ -41,6 +41,6 @@ </div><!-- /div.row --> </div><!-- /div#wrapper --> -<% include footer %> +<% include templates/footer %> </body> </html> diff --git a/views/registerEmail.ejs b/app/views/users/registerEmail.ejs index c346882..bdf5b65 100644 --- a/views/registerEmail.ejs +++ b/app/views/users/registerEmail.ejs @@ -1,4 +1,4 @@ -<% include header %> +<% include ../templates/header %> </head> <body> @@ -38,6 +38,6 @@ </div><!-- /div.#wrapper --> -<% include footer %> +<% include ../templates/footer %> </body> </html> diff --git a/views/signup.ejs b/app/views/users/signup.ejs index c058402..611c052 100644 --- a/views/signup.ejs +++ b/app/views/users/signup.ejs @@ -1,4 +1,4 @@ -<% include header %> +<% include ../templates/header %> <link rel="stylesheet" href="/css/login.css" /> </head> <body> @@ -81,6 +81,6 @@ <script src="/js/views/signup.js"></script> <script src="/js/form-validators/accountValidator.js"></script> <script src="/js/controllers/signupController.js"></script> - -<% include footer %> + +<% include ../templates/footer %> diff --git a/config/express.js b/config/express.js index eb10b20..4c09b17 100644 --- a/config/express.js +++ b/config/express.js @@ -13,7 +13,7 @@ var express = require('express'); module.exports = function (app, config, passport) { //sets view engine and path - app.set('views', config.root + '/views'); + app.set('views', config.root + '/app/views'); app.set('view engine', 'ejs'); app.use(express.static(config.root + '/public')); diff --git a/routes.js b/config/routes.js index 1062f08..8ba83a9 100644 --- a/routes.js +++ b/config/routes.js @@ -3,8 +3,8 @@ * Dependencies */ -var users = require('./controllers/users') - , system = require('./controllers/system'); +var users = require('../app/controllers/users') + , system = require('../app/controllers/system'); /* @@ -16,24 +16,16 @@ var users = require('./controllers/users') module.exports = function(app, passport, auth) { app.get('/', system.index); - app.get('/test', system.test); - - app.get('/home', system.home); - app.get('/faq', system.faq); app.get('/contact', system.contact); - app.get('/login', users.login); - app.post('/login', passport.authenticate('local', { failureRedirect: '/' }), users.signin); app.get('/signup', users.signup); app.post('/signup', users.create); - app.post('/test', users.signin); - app.get('/auth/facebook', passport.authenticate('facebook', { failureRedirect: '/' }), users.signin); app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/' }), users.authCallback); diff --git a/package.json b/package.json index f7d3ac9..e053186 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ , "npm": "1.2.x" } , "scripts": { - "start": "NODE_ENV=development ./node_modules/.bin/nodemon app.js" + "start": "NODE_ENV=development ./node_modules/.bin/nodemon server.js" , "test": "NODE_ENV=test ./node_modules/.bin/mocha --reporter spec test/test-*.js" } , "dependencies": { @@ -29,8 +29,8 @@ db.once('open', function callback(){ // Bootstrap models -// This gets all model files in ./models -var models_path = __dirname + '/models'; +// This gets all model files in ./app/models +var models_path = __dirname + '/app/models'; fs.readdirSync(models_path).forEach( function(file) { require(models_path + '/' + file); }); @@ -53,7 +53,7 @@ require('./config/express')(app, config, passport); * Routes */ -require('./routes')(app, passport, auth); +require('./config/routes')(app, passport, auth); /** diff --git a/views/login.ejs b/views/login.ejs deleted file mode 100644 index 70ddf01..0000000 --- a/views/login.ejs +++ /dev/null @@ -1,60 +0,0 @@ -<% include header %> - <link rel="stylesheet" href="/css/login.css" /> -</head> -<body> -<div id="login-container"> - <form method="post" id="login-form" class="well span4"> - <h1>Hello!</h1> - <p class="subheading">Please Login To Your Account</p> - <label>Username </label> - <input type="text" name="email" id="email" class="span4 required"> - <label>Password</label> - <input type="password" name="password" id="password" class="span4 required"> - <button type="submit" id="btn-login" class="btn btn-primary"><i class="icon-lock icon-white"></i>Sign in</button> - <label id="remember-me" class="checkbox">Remember Me - <input name="remember-me" type="checkbox" checked="checked"> - </label> - <div class="clear-fix"></div> - <hr> - <div class="btm-links"><a href="#" id="forgot-password">Forgot Your Password? </a><a href="/signup" id="create-account">Create An Account</a></div> - </form> -</div> -<div class="modal-alert modal hide fade"> - <div class="modal-header"> - <button data-dismiss="modal" class="close">x</button> - <h3></h3> - </div> - <div class="modal-body"> - <p></p> - </div> - <div class="modal-footer"> - <button data-dismiss="modal" id="ok" class="btn btn-warning">OK</button> - </div> -</div> -<div id="get-credentials" class="modal-single-input modal hide fade"> - <div class="modal-header"> - <button data-dismiss="modal" class="close">x</button> - <h3>Retrieve Password</h3> - </div> - <div class="modal-body"> - <form method="post" id="get-credentials-form" class="well span5"> - <p>Please enter the username associated with your account</p> - <input type="text" name="username" id="username" class="span5 required"> - <button type="submit" id="submit" class="btn btn-primary">Submit</button> - <button data-dismiss="modal" id="cancel" class="btn">Cancel</button> - <div class="alert alert-error hide"></div> - <button data-dismiss="alert" class="close"></button> - </form> - </div> - <div class="modal-footer"></div> -</div> - - - -<script src="/js/views/login.js"></script> -<script src="/js/jquery.form.js"></script> -<script src="/js/controllers/loginController.js"></script> -<script src="/js/form-validators/loginValidator.js"></script> -<script src="/js/form-validators/emailValidator.js"></script> - -<% include footer %> |