diff --git a/app.js b/app.js index a3fddac..8952ff5 100644 --- a/app.js +++ b/app.js @@ -1,27 +1,28 @@ -const express = require('express'); -const authRoutes = require('./routes/auth-routes'); -const profileRoutes = require('./routes/profile-routes'); -const passportSetup = require('./config/passport-setup'); -const mongoose = require('mongoose'); -const keys = require('./config/keys'); -const cookieSession = require('cookie-session'); -const passport = require('passport'); -const Contact = require('./models/contact-model'); -const Notice = require('./models/notice-model'); -var bodyParser = require('body-parser'); - -const app = express(); -var urlencodedParser = bodyParser.urlencoded({ extended: false }); +const express = require('express'), + authRoutes = require('./routes/auth-routes'), + profileRoutes = require('./routes/profile-routes'), + passportSetup = require('./config/passport-setup'), + mongoose = require('mongoose'), + keys = require('./config/keys'), + cookieSession = require('cookie-session'), + passport = require('passport'), + Contact = require('./models/contact-model'), + Notice = require('./models/notice-model'), + bodyParser = require('body-parser'), + app = express() +var urlencodedParser = bodyParser.urlencoded({ + extended: false +}); //set up view engine -app.set('view engine','ejs'); +app.set('view engine', 'ejs'); //static files app.use(express.static('./public')); app.use(cookieSession({ - maxAge:24*60*60*1000, - keys:[keys.session.cookieKey] + maxAge: 24 * 60 * 60 * 1000, + keys: [keys.session.cookieKey] })); //initialise passport @@ -29,7 +30,7 @@ app.use(passport.initialize()); app.use(passport.session()); //connect to mongodb -mongoose.connect(keys.mongodb.dbURI, function(){ +mongoose.connect(keys.mongodb.dbURI, function () { console.log('connected to mongodb'); }); @@ -39,49 +40,58 @@ app.use('/profile', profileRoutes); //===================================================================== //create home route -app.get('/', function(req, res){ - //get data from mongodb and pass it to view - Notice.find({}, function (err, data) { - if(err) throw err; - res.render('home', {user: req.user ,notices: data}); - }) - }); - - app.post('/', urlencodedParser, function(req, res){ - //get data from the view and it mongodb - var newNotice = Notice(req.body).save(function (err, data) { - if (err) throw err; - res.json(data); +app.get('/', function (req, res) { + //get data from mongodb and pass it to view + Notice.find({}, function (err, data) { + if (err) throw err; + res.render('home', { + user: req.user, + notices: data }); + }) +}); + +app.post('/', urlencodedParser, function (req, res) { + //get data from the view and it mongodb + var newNotice = Notice(req.body).save(function (err, data) { + if (err) throw err; + res.json(data); }); +}); - app.delete('/:item', function(req, res){ - //delete the requested item from mongodb - Notice.find({item: req.params.item.replace(/\-/g," ")}).remove(function(err,data) { - if(err) throw err; - res.json(data); - }); +app.delete('/:item', function (req, res) { + //delete the requested item from mongodb + Notice.find({ + item: req.params.item.replace(/\-/g, " ") + }).remove(function (err, data) { + if (err) throw err; + res.json(data); }); +}); //====================================================================== -app.get('/contact',function (req, res) { - res.render('contact'); +app.get('/contact', function (req, res) { + res.render('contact', { + user: req.user + }); }); app.post('/contact', urlencodedParser, function (req, res) { console.log(req.body); new Contact({ - email:req.body.email, - message:req.body.message, - branch:req.body.branch, - year:req.body.year + email: req.body.email, + message: req.body.message, + branch: req.body.branch, + year: req.body.year }).save(); - res.render('contact-success', {data: req.body}); + res.render('contact-success', { + data: req.body + }); }); -app.listen(process.env.PORT || 3000,function(){ - console.log("listenning for the request"); -}); +app.listen(process.env.PORT || 3000, function () { + console.log("listenning for the request on 3000"); +}); \ No newline at end of file diff --git a/views/contact.ejs b/views/contact.ejs index cb1fd2e..2b0899b 100644 --- a/views/contact.ejs +++ b/views/contact.ejs @@ -1,96 +1,84 @@ - - - - - - - - - - SPS - - - - - - + + - - menu + + <% include sidebar.ejs %> -
-
+
+
-
-
- email - - -
-
- message - - -
+ +
+ email + + +
- - + message + +
- - + + +
+
+ +
- -
-
-
+ +
+
-
+
+ - - - - - + + + + + - + \ No newline at end of file diff --git a/views/profile.ejs b/views/profile.ejs index ead7e76..186dc53 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -1,132 +1,138 @@ - - - - - - - - - - SPS - - + img { + margin: 20px auto; + } - + #circle { + width: 170px; + height: 170px; + text-align: center; + } - <% include sidebar.ejs %> -
+ #box { + width: 200px; + height: 200px; + padding: 10px 0; + text-align: center; + margin: 10px; + } + + a { + text-decoration: none; + } + + + + + + <% include sidebar.ejs %> +
-
-
-

Welcome to your profile, <%= user.username %>

-
-
-
-
-
-
- person_outline -
- Details +
+
+

Welcome to your profile, + <%= user.username %> +

+
+
+
+
+
+
+ person_outline +
+ Details +
+
+
-
-
-
-
-
-
- person_outline -
- Examinations +
+
+
+ person_outline + +
+
-
-
-
-
-
-
- person_outline -
- Attendance +
+
+
+ person_outline + +
+
-
-
-
-
-
-
-
-
- person_outline -
- Result +
+
+
+
+
+ person_outline +
+ Result +
+
+
-
-
-
-
-
-
- person_outline -
- Notification +
+
+
+ person_outline + +
+
-
-
-
-
-
-
- person_outline -
- Schedule +
+
+
+ person_outline +
+ Schedule +
+
+
-
-
-
-
+
-
-
-
+ +
- - - - - + + + + + + - + \ No newline at end of file diff --git a/views/sidebar.ejs b/views/sidebar.ejs index 0e1af91..b109440 100644 --- a/views/sidebar.ejs +++ b/views/sidebar.ejs @@ -4,12 +4,14 @@
  • logoutLogout
  • <% }else { %> -
  • - +
  • account_circle
  • vpn_keyLogin
  • <% } %>
  • homeHome
  • faceProfile
  • +
  • codeSource + code
  • +
  • contactsContact Us
  • @@ -18,11 +20,13 @@
  • logoutLogout
  • <% }else { %> -
  • +
  • account_circle
  • vpn_keyLogin
  • <% } %>
  • homeHome
  • faceProfile
  • +
  • codeSource + code
  • contactsContact Us
  • menu \ No newline at end of file