windhamdavid 4 years ago
parent
commit
9144b79951

+ 3 - 2
app.js

@@ -107,6 +107,7 @@ var apiController = require('./controllers/api_control');
 router.get('/', homeController.index);
 router.get('/login', userController.getLogin);
 router.post('/login', userController.postLogin);
+router.get('/user/:username', userController.getUserURL);
 router.get('/logout', userController.logout);
 router.get('/forgot', userController.getForgot);
 router.post('/forgot', userController.postForgot);
@@ -128,7 +129,7 @@ app.use('/event', eventRouter);
 
 router.get('/event', eventController.getEvent);
 router.get('/event/new', eventController.getEvent_new);
-router.get('/event/new', passportConf.isAuthenticated, eventController.postEvent_new);
+router.post('/event/new', passportConf.isAuthenticated, eventController.postEvent_new);
 
 /********** entry routes **************/
 
@@ -137,7 +138,7 @@ app.use('/entry', entryRouter);
 
 router.get('/entry', entryController.getEntry);
 router.get('/entry/new', entryController.getEntry_new);
-router.get('/entry/new', passportConf.isAuthenticated, entryController.postEntry_new);
+router.post('/entry/new', passportConf.isAuthenticated, entryController.postEntry_new);
 
 
 /********** static routes controllers **************/

+ 1 - 0
controllers/entry_control.js

@@ -4,6 +4,7 @@ var crypto = require('crypto');
 var nodemailer = require('nodemailer');
 var passport = require('passport');
 var User = require('../models/user');
+var Entry = require('../models/entry');
 var secure = require('../config/secure');
 
 

+ 3 - 3
controllers/event_control.js

@@ -30,11 +30,11 @@ exports.getEvent_new = function (req, res) {
 
 exports.postEvent_new= function(req, res, next) {
 
-  var errors = req.validationErrors();
-
   var event = new Event({
-    eventname: req.body.evenname
+    eventname: req.body.eventname
   });
+  
+  var errors = req.validationErrors();
 
   Event.findOne({ eventname: req.body.eventname }, function(err, existingEvent) {
     if (existingEvent) {

+ 1 - 1
controllers/home_control.js

@@ -1,7 +1,7 @@
 exports.index = function(req, res) {
   if (req.user) {
     if (req.user) {
-      return res.redirect('/:username');
+      return res.redirect('/user/:username');
     }
   }
   res.render('pages/index', {

+ 18 - 1
controllers/user_control.js

@@ -19,6 +19,21 @@ exports.getLogin = function (req, res) {
 };
 
 
+/********** User GET / User URL **************/
+
+exports.getUserURL = function (req, res, next) {
+  return User.find({ username: req.params.id }, function (err, username) {
+    if (username) {
+      res.render('404', { url: req.url, error: '404 Not found' });
+      return;
+    }
+    return res.render('account/user', {
+      title: profile.username,
+      url: profile.username
+    });
+  });
+};
+
 /********** POST / Login **************/
 
 exports.postLogin = function(req, res, next) {
@@ -370,4 +385,6 @@ exports.postForgot = function(req, res, next) {
     }
     res.redirect('/forgot');
   });
-};
+};
+
+

+ 2 - 1
gulpfile.js

@@ -110,7 +110,7 @@ var syncTask = function() {
           ws: true
         },
         https: true,
-        files: ['./app/**/*.*'],
+        files: ['./src/**/*.*'],
         port: 7000,
     });
 };
@@ -120,6 +120,7 @@ gulp.task('sync', function() {
   syncTask();
 });
 
+
 var nodemonTask = function() {
   nodemon({
     tasks: ['watch'],

+ 0 - 1
src/css/main.css

@@ -18,7 +18,6 @@ a {
 }
 
 
-
 /* =================================================
 ===================  Navbar ========================
 ==================================================== */

+ 28 - 0
src/views/account/user.jade

@@ -0,0 +1,28 @@
+extends ../layout
+
+block content
+  section#partial
+    .container
+      .row
+        .col-sm-6.col-sm-offset-3.text-center
+          h2 #{user.profile.username}
+      hr
+      .row
+        .col-sm-6.col-sm-offset-3.text-center
+          ul.list-group
+            li.list-group-item
+              if user.profile.picture
+                img(src='#{user.profile.picture}')
+              else
+                img(src='#{user.gravatar()}')
+            li.list-group-item
+              p Name: #{user.profile.name}
+            li.list-group-item
+              p Username: #{user.profile.username}
+            li.list-group-item
+              p Location: #{user.profile.location}
+            li.list-group-item
+              p Bio: #{user.profile.bio}
+
+      hr
+      .row

+ 11 - 2
src/views/entry/entry.jade

@@ -5,6 +5,15 @@ block content
     .container
       .row
         .col-sm-8.col-sm-offset-2.text-center
-          h3 Entry
+          h2 Entry
       hr
-      .row
+      .row
+        .col-sm-8.col-sm-offset-2
+          ul.nav.nav-pills
+            li(role='presentation', class=title=='event'?'active':undefined)
+              a(href='/entry/new') new entry
+            li(role='presentation', class=title=='event'?'active':undefined)
+              a(href='/entry/list') list entries
+            li(role='presentation', class=title=='event'?'active':undefined)
+              a(href='/entry/search') search entries
+      hr

+ 2 - 2
src/views/event/event.jade

@@ -13,7 +13,7 @@ block content
             li(role='presentation', class=title=='event'?'active':undefined)
               a(href='/event/new') new event
             li(role='presentation', class=title=='event'?'active':undefined)
-              a(href='/event/search') seach events
-            li(role='presentation', class=title=='event'?'active':undefined)
               a(href='/event/list') list events
+            li(role='presentation', class=title=='event'?'active':undefined)
+              a(href='/event/search') search events
       hr

+ 2 - 2
src/views/layout.jade

@@ -10,9 +10,9 @@ html
     link(rel='stylesheet', href='/css/style.min.css')
   body
   
-    include partials/header
-    
     include partials/flash
+    
+    include partials/header
                 
     block content
 

+ 1 - 1
src/views/partials/header.jade

@@ -29,7 +29,7 @@
               if user.profile.picture
                 img(src='#{user.profile.picture}')
               else
-                img(src='#{user.gravatar(60)}')
+                img(src='#{user.gravatar(40)}')
               | #{user.profile.name || user.email || user.id} 
               i.caret
             ul.dropdown-menu