Browse Source

routes views

windhamdavid 3 years ago
parent
commit
678841ff7d

+ 42 - 8
app.js

@@ -102,17 +102,19 @@ app.use(function(req, res, next) {
 
 var router = express.Router();
 app.use(router);
-require('./routes/routes');
+var routes = require('./routes/routes');
 
 var homeController = require('./controllers/home');
-var staticController = require('./controllers/static');
 var userController = require('./controllers/user');
 var contactController = require('./controllers/contact');
+var eventsController = require('./controllers/events');
+var entriesController = require('./controllers/entries');
 var apiController = require('./controllers/api');
 
 
+/********** user routes **************/
+
 router.get('/', homeController.index);
-router.get('/terms', staticController.static);
 
 router.get('/login', userController.getLogin);
 router.post('/login', userController.postLogin);
@@ -131,14 +133,35 @@ router.post('/account/password', passportConf.isAuthenticated, userController.po
 router.post('/account/delete', passportConf.isAuthenticated, userController.postDeleteAccount);
 router.get('/account/unlink/:provider', passportConf.isAuthenticated, userController.getOauthUnlink);
 
+/********** event routes **************/
 
-/********** static routes controllers **************/
+router.get('/events', eventsController.getEvent);
+
+
+/********** entry routes **************/
 
+router.get('/entry', entriesController.getEntry);
+
+
+/********** static routes controllers **************/
 
-app.get('/privacy', function(req, res) {
-  res.render('pages/privacy', {
-    title: 'Privacy Policy'
-  });
+router.get('/about', function(req, res) {
+  res.render('pages/about', { title: 'About' });
+});
+router.get('/docs', function(req, res) {
+  res.render('pages/docs', { title: 'Documentation' });
+});
+router.get('/privacy', function(req, res) {
+  res.render('pages/privacy', { title: 'Privacy Policy' });
+});
+router.get('/terms', function(req, res) {
+  res.render('pages/terms', { title: 'Terms & Conditions' });
+});
+router.get('/status', function(req, res) {
+  res.render('pages/status', { title: 'System Status' });
+});
+router.get('/support', function(req, res) {
+  res.render('pages/support', { title: 'Support' });
 });
 
 
@@ -162,6 +185,17 @@ logger.on('newEvent', function(event, data) {
 
 /************* errors **************/
 
+app.use(function handleNotFound(req, res, next){
+  res.status(404);
+  if (req.accepts('html')) {
+    res.render('404', { url: req.url, error: '404 Not found' });
+    return;
+  }
+  if (req.accepts('json')) {
+    res.send({ error: 'Not found' });
+    return;
+  };
+});
 
 if (process.env.NODE_ENV === 'development') {
   app.use(errorHandler())

+ 16 - 0
controllers/entries.js

@@ -0,0 +1,16 @@
+var _ = require('lodash');
+var async = require('async');
+var crypto = require('crypto');
+var nodemailer = require('nodemailer');
+var passport = require('passport');
+var User = require('../models/user');
+var secure = require('../config/secure');
+
+
+/********** GET / Login **************/
+
+exports.getEntry = function (req, res) {
+  res.render('entries/entry', {
+    title: 'Entry'
+  });
+};

+ 16 - 0
controllers/events.js

@@ -0,0 +1,16 @@
+var _ = require('lodash');
+var async = require('async');
+var crypto = require('crypto');
+var nodemailer = require('nodemailer');
+var passport = require('passport');
+var User = require('../models/user');
+var secure = require('../config/secure');
+
+
+/********** GET / Login **************/
+
+exports.getEvent = function (req, res) {
+  res.render('events/event', {
+    title: 'Events'
+  });
+};

+ 0 - 5
controllers/static.js

@@ -1,5 +0,0 @@
-exports.static = function(req, res) {
-  res.render('pages/terms', {
-    title: 'Terms & Conditions'
-  });
-};

+ 27 - 33
controllers/user.js

@@ -75,7 +75,7 @@ exports.getSignup = function(req, res) {
 
 exports.postSignup = function(req, res, next) {
   req.assert('email', 'Email is not valid').isEmail();
-  req.assert('password', 'Password must be at least 4 characters long').len(4);
+  req.assert('password', 'Password must be at least 6 characters long').len(6);
   req.assert('confirmPassword', 'Passwords do not match').equals(req.body.password);
 
   var errors = req.validationErrors();
@@ -128,6 +128,7 @@ exports.postUpdateProfile = function(req, res, next) {
     }
     user.email = req.body.email || '';
     user.profile.name = req.body.name || '';
+    user.profile.username = req.body.username || '';
     user.profile.gender = req.body.gender || '';
     user.profile.location = req.body.location || '';
     user.profile.website = req.body.website || '';
@@ -141,10 +142,9 @@ exports.postUpdateProfile = function(req, res, next) {
   });
 };
 
-/**
- * POST /account/password
- * Update current password.
- */
+
+/********** POST / Account / Password **************/
+
 exports.postUpdatePassword = function(req, res, next) {
   req.assert('password', 'Password must be at least 4 characters long').len(4);
   req.assert('confirmPassword', 'Passwords do not match').equals(req.body.password);
@@ -171,10 +171,9 @@ exports.postUpdatePassword = function(req, res, next) {
   });
 };
 
-/**
- * POST /account/delete
- * Delete user account.
- */
+
+/********** POST / Account / Delete **************/
+
 exports.postDeleteAccount = function(req, res, next) {
   User.remove({ _id: req.user.id }, function(err) {
     if (err) {
@@ -186,10 +185,9 @@ exports.postDeleteAccount = function(req, res, next) {
   });
 };
 
-/**
- * GET /account/unlink/:provider
- * Unlink OAuth provider.
- */
+
+/********** POST / Account / Oauth **************/
+
 exports.getOauthUnlink = function(req, res, next) {
   var provider = req.params.provider;
   User.findById(req.user.id, function(err, user) {
@@ -206,10 +204,8 @@ exports.getOauthUnlink = function(req, res, next) {
   });
 };
 
-/**
- * GET /reset/:token
- * Reset Password page.
- */
+/********** GET / Password / :Token **************/
+
 exports.getReset = function(req, res) {
   if (req.isAuthenticated()) {
     return res.redirect('/');
@@ -231,10 +227,9 @@ exports.getReset = function(req, res) {
     });
 };
 
-/**
- * POST /reset/:token
- * Process the reset password request.
- */
+
+/********** POST / Password / :Token **************/
+
 exports.postReset = function(req, res, next) {
   req.assert('password', 'Password must be at least 4 characters long.').len(4);
   req.assert('confirm', 'Passwords must match.').equals(req.body.password);
@@ -282,8 +277,8 @@ exports.postReset = function(req, res, next) {
       });
       var mailOptions = {
         to: user.email,
-        from: 'hackathon@starter.com',
-        subject: 'Your Hackathon Starter password has been changed',
+        from: 'admin@juryd.com',
+        subject: 'Your Juryd password has been changed',
         text: 'Hello,\n\n' +
           'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n'
       };
@@ -300,10 +295,9 @@ exports.postReset = function(req, res, next) {
   });
 };
 
-/**
- * GET /forgot
- * Forgot Password page.
- */
+
+/********** GET / Password / Forgot **************/
+
 exports.getForgot = function(req, res) {
   if (req.isAuthenticated()) {
     return res.redirect('/');
@@ -313,10 +307,10 @@ exports.getForgot = function(req, res) {
   });
 };
 
-/**
- * POST /forgot
- * Create a random token, then the send user an email with a reset link.
- */
+
+
+/********** Post / Password / Forgot / Email **************/
+
 exports.postForgot = function(req, res, next) {
   req.assert('email', 'Please enter a valid email address.').isEmail();
 
@@ -357,8 +351,8 @@ exports.postForgot = function(req, res, next) {
       });
       var mailOptions = {
         to: user.email,
-        from: 'hackathon@starter.com',
-        subject: 'Reset your password on Hackathon Starter',
+        from: 'admin@juryd.com',
+        subject: 'Juryd - Reset your password',
         text: 'You are receiving this email because you (or someone else) have requested the reset of the password for your account.\n\n' +
           'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
           'http://' + req.headers.host + '/reset/' + token + '\n\n' +

+ 7 - 0
models/entry.js

@@ -0,0 +1,7 @@
+var _ = require('lodash');
+var async = require('async');
+var crypto = require('crypto');
+var nodemailer = require('nodemailer');
+var passport = require('passport');
+var User = require('../models/user');
+var secure = require('../config/secure');

+ 10 - 0
models/event.js

@@ -0,0 +1,10 @@
+var bcrypt = require('bcrypt-nodejs');
+var crypto = require('crypto');
+var mongoose = require('mongoose');
+
+var eventSchema = new mongoose.Schema({
+  tokens: Array,
+  event: {
+    eventname: { type: String, default: '' }
+  }
+});

+ 1 - 0
models/user.js

@@ -9,6 +9,7 @@ var userSchema = new mongoose.Schema({
 
   profile: {
     name: { type: String, default: '' },
+    username: { type: String, default: '' },
     gender: { type: String, default: '' },
     location: { type: String, default: '' },
     website: { type: String, default: '' },

+ 15 - 11
routes/routes.js

@@ -1,25 +1,23 @@
 var express = require('express');
 var app = express();
 var router = express.Router();
+
 var path = require('path');
 var secure = require('../config/secure');
 var passportConf = require('../config/passport');
 
-app.use(express.static(path.join(__dirname, './app'), { maxAge: 31557600000 }));
-
 
 /********** routes controllers **************/
 
 var homeController = require('../controllers/home');
-var staticController = require('../controllers/static');
 var userController = require('../controllers/user');
 var contactController = require('../controllers/contact');
 var apiController = require('../controllers/api');
 
 
-router.get('/', homeController.index);
-router.get('/terms', staticController.static);
+/*************** routes *******************/
 
+router.get('/', homeController.index);
 router.get('/login', userController.getLogin);
 router.post('/login', userController.postLogin);
 router.get('/logout', userController.logout);
@@ -38,17 +36,23 @@ router.post('/account/delete', passportConf.isAuthenticated, userController.post
 router.get('/account/unlink/:provider', passportConf.isAuthenticated, userController.getOauthUnlink);
 
 
-/********** static routes controllers **************/
+/********** oauth routes controllers **************/
 
 
-app.get('/privacy', function(req, res) {
-  res.render('pages/privacy', {
-    title: 'Privacy Policy'
-  });
+/********** static routes controllers **************/
+
+router.get('/about', function(req, res) {
+  res.render('pages/about', { title: 'Privacy Policy' });
+});
+router.get('/privacy', function(req, res) {
+  res.render('pages/privacy', { title: 'Privacy Policy' });
+});
+router.get('/terms', function(req, res) {
+  res.render('pages/terms', { title: 'Terms & Conditions' });
 });
 
 
-/********** oauth routes controllers **************/
+
 
 
 module.exports = router

+ 10 - 0
src/views/404.jade

@@ -0,0 +1,10 @@
+extends layout
+
+block content
+  section#partial
+    .container
+      .row
+        .col-sm-8.col-sm-offset-2.text-center
+          h1 Error 404
+          h2 Page Not Found
+      hr

+ 11 - 0
src/views/500.jade

@@ -0,0 +1,11 @@
+extends layout
+
+block content
+  section#partial
+    .container
+      .row
+        .col-sm-8.col-sm-offset-2.text-center
+          h1 Error 500
+          h2 Application Error
+          
+      hr

+ 14 - 40
src/views/account/profile.jade

@@ -19,6 +19,10 @@ block content
             .col-sm-7
               input.form-control(type='text', name='name', id='name', value='#{user.profile.name}')
           .form-group
+            label.col-sm-3.control-label(for='username') Username
+            .col-sm-7
+              input.form-control(type='text', name='username', id='username', value='#{user.profile.username}')
+          .form-group
             label.col-sm-3.control-label(for='gender') Gender
             .col-sm-4
               label.radio.col-sm-4
@@ -45,9 +49,11 @@ block content
                 i.fa.fa-pencilr
                 | Update Profile
 
-        .page-header
-          h3 Change Password
-
+        .row
+          .col-sm-8.col-sm-offset-2.text-center
+            h3 Password
+        hr
+        .row
         form.form-horizontal(action='/account/password', method='POST')
           input(type='hidden', name='_csrf', value=_csrf)
           .form-group
@@ -64,9 +70,11 @@ block content
                 i.fa.fa-lock
                 | Change Password
 
-        .page-header
-          h3 Delete Account
-
+        .row
+          .col-sm-8.col-sm-offset-2.text-center
+            h3 Delete Account
+        hr
+        .row
         form.form-horizontal(action='/account/delete', method='POST')
           .form-group
             p.col-sm-offset-3.col-sm-4 You can delete your account, but keep in mind this action is irreversible.
@@ -76,37 +84,3 @@ block content
                 i.fa.fa-trash
                 | Delete my account
 
-        .page-header
-          h3 Linked Accounts
-        .form-horizontal
-          .form-group
-            .col-sm-offset-3.col-sm-4
-              if user.instagram
-                p: a.text-danger(href='/account/unlink/instagram') Unlink your Instagram account
-              else
-                p: a(href='/auth/instagram') Link your Instagram account
-            .col-sm-offset-3.col-sm-4
-              if user.google
-                p: a.text-danger(href='/account/unlink/google') Unlink your Google account
-              else
-                p: a(href='/auth/google') Link your Google account
-            .col-sm-offset-3.col-sm-4
-              if user.facebook
-                p: a.text-danger(href='/account/unlink/facebook') Unlink your Facebook account
-              else
-                p: a(href='/auth/facebook') Link your Facebook account
-            .col-sm-offset-3.col-sm-4
-              if user.twitter
-                p: a.text-danger(href='/account/unlink/twitter') Unlink your Twitter account
-              else
-                p: a(href='/auth/twitter') Link your Twitter account
-            .col-sm-offset-3.col-sm-4
-              if user.github
-                p: a.text-danger(href='/account/unlink/github') Unlink your GitHub account
-              else
-                p: a(href='/auth/github') Link your GitHub account
-            .col-sm-offset-3.col-sm-4
-              if user.linkedin
-                p: a.text-danger(href='/account/unlink/linkedin') Unlink your LinkedIn account
-              else
-                p: a(href='/auth/linkedin') Link your LinkedIn account

+ 10 - 0
src/views/entries/entries.jade

@@ -0,0 +1,10 @@
+extends ../layout
+
+block content
+  section#partial
+    .container
+      .row
+        .col-sm-8.col-sm-offset-2.text-center
+          h3 Entries
+      hr
+      .row

+ 10 - 0
src/views/entries/entry.jade

@@ -0,0 +1,10 @@
+extends ../layout
+
+block content
+  section#partial
+    .container
+      .row
+        .col-sm-8.col-sm-offset-2.text-center
+          h3 Entry
+      hr
+      .row

+ 13 - 0
src/views/events/event.jade

@@ -0,0 +1,13 @@
+extends ../layout
+
+block content
+  section#partial
+    .container
+      .row
+        .col-sm-8.col-sm-offset-2.text-center
+          h3 Event
+          
+          
+          
+      hr
+      .row

+ 10 - 0
src/views/events/events.jade

@@ -0,0 +1,10 @@
+extends ../layout
+
+block content
+  section#partial
+    .container
+      .row
+        .col-sm-8.col-sm-offset-2.text-center
+          h3 Events
+      hr
+      .row

File diff suppressed because it is too large
+ 16 - 0
src/views/pages/status.jade


File diff suppressed because it is too large
+ 16 - 0
src/views/pages/support.jade