Skip to content

Commit

Permalink
added applications, reus, new formatting stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
smithy545 committed Jul 21, 2016
1 parent a55d720 commit 4d89d55
Show file tree
Hide file tree
Showing 19 changed files with 331 additions and 171 deletions.
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ app.use(flash());
// Routing
app.use('/', require('./routes/index'));
app.use('/profile', require('./routes/profile'));
app.use('/reu', require('./routes/reu'));
app.use('/apps', require('./routes/application'));

// catch 404 and forward to error handler
app.use(function(req, res, next) {
Expand Down
11 changes: 11 additions & 0 deletions models/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var mongoose = require('mongoose');

var appSchema = mongoose.Schema({
name: String,
location: String,
school: String,
professors: [String],
status: String,
});

module.exports = mongoose.model('Application', appSchema);
2 changes: 2 additions & 0 deletions models/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var models = {};

models.User = require('./user');
models.REU = require('./reu');
models.Application = require('./application');

module.exports = models;
10 changes: 10 additions & 0 deletions models/reu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var mongoose = require('mongoose');

var reuSchema = mongoose.Schema({
name: String,
location: String,
school: String,
professors: [String],
});

module.exports = mongoose.model('REU', reuSchema);
45 changes: 23 additions & 22 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,30 @@ var userSchema = mongoose.Schema({
profile : {
first_name : String,
last_name : String,
full_name : String,
headline : String,
industry : String,
positions : [String],
summary : String,
linkedin_url : String,
associations : [String],
interests : [String],
publications : [String],
patents : [String],
languages : [String],
skills : [String],
certifications : [String],
educations : [String],
volunteer : [String],
recommendations_recieved : [String],
dob : String,
honors_awards : [String],
full_name : String,
headline : String,
industry : String,
positions : [String],
summary : String,
linkedin_url : String,
associations : [String],
interests : [String],
publications : [String],
patents : [String],
languages : [String],
skills : [String],
certifications : [String],
educations : [String],
volunteer : [String],
recommendations_recieved : [String],
dob : String,
honors_awards : [String],
courses : [String],
location : String,
major : String,
picture_url : String,
}
location : String,
major : String,
picture_url : String,
},
applications: [String],
});

userSchema.methods.generateHash = function(password) {
Expand Down
20 changes: 20 additions & 0 deletions public/javascripts/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$(function() {
var idIndex = window.location.href.indexOf("#");
if(idIndex != -1) {
var id = window.location.href.substring(idIndex);
$("div.content-container").not(id).hide();
$(id).show();
}

var sbnav = $(".sb-nav");
var content = $("div.content");
if(sbnav.height() < content.height()) {
sbnav.height(content.height());
}
});

$("ul.sb-select li a").click(function(evt) {
var id = this.href.substring(this.href.indexOf("#"));
$("div.content-container").not(id).hide();
$(id).show();
});
69 changes: 45 additions & 24 deletions public/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,37 @@ a {
color: #00B7FF;
}

.main-outer {
background-color: rgba(0,0,0,0.1);
border-radius: 5px;
padding: 0px;
}

.main-inner {
background-color: #FFF;
margin: 15px;
}

.tb-highlighted {
color: #FFFFFF !important;
background-color: rgba(0,0,0,0.3) !important;
background-color: rgba(0,0,0,0.1) !important;
}

.navbar-fixed-top {
border-bottom: 0px;
}

.sb-nav {
display: block;
float: left;
background-color: rgba(0,0,0,0.2);
padding: 10px;
width: 10%;
padding: 0px;
min-width: 100px;
}

.sb-nav {
clear: left;
margin-right: 10px;
margin-bottom: 0px;
border: 0px;
height: 100%;
border-radius: 0px;
}

.sb-nav ul {
Expand All @@ -41,29 +56,21 @@ a {

.sb-header {
color: #000;
display: block;
float: left;
clear: left;
}

.main {
margin-top: 10px;
padding-left: 15px;
padding-top: 5px;
padding-right: 10px;
padding-bottom: 10px;
background-color: #0A304E;
width: 100%;
color: white;
}

.content {
float: left;
margin-left: 10px;
padding: 10px;
border: 1px solid #000000;
width: 80%;
}

.content-wide {
float: left;
margin-left: 10px;
padding: 10px;
border: 1px solid #000000;
width: 90%;
overflow: hidden;
height: 100%;
}

.content-header {
Expand All @@ -85,4 +92,18 @@ a {
}

#profile-email {
}

.reu-search-results {
margin-top: 20px;
}

.reu-search-list {
list-style: none;
padding: 0px;
}

.reu-search-list li {
background-color: rgba(0,0,0,0.1);
padding: 10px;
}
26 changes: 26 additions & 0 deletions routes/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var express = require('express');

var User = require('../models/user');
var Application = require('../models/application');

var apps = express.Router();

apps.get('/', function(req, res) {
var ctx = {
user: req.user,
tb_highlighted: 'apps',
};

User.findById(req.user._id, function(err, user) {
if(err) throw err;
Application.find({
'_id': { $in: user.applications }
}, function(err, apps) {
if(err) throw err;
ctx.applications = apps;
return res.render('application', ctx);
});
});
});

module.exports = apps;
63 changes: 27 additions & 36 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var validator = require('validator');
var request = require('request');

var User = require('../models/user');
var Application = require('../models/application');

var router = express.Router();

Expand Down Expand Up @@ -33,28 +34,20 @@ router.use(isLoggedIn);

/* GET home page. */
router.get('/home', function(req, res) {
var side_menu = {
title: "Home",
items: [
{ href: "#",
text: "tset 1" },
{ href: "#",
text: "test2" },
{ href: "#",
text: "test 3"},
],
};

var ctx = {
side_menu: side_menu,
tb_highlighted: "dashboard",
};

res.render('home', ctx);
});

router.get('/about', function(req, res) {
res.render('about');
User.findById(req.user._id, function(err, user) {
if(err) throw err;
Application.find({
'_id': { $in: user.applications }
}, function(err, apps) {
if(err) throw err;
ctx.applications = apps;
return res.render('home', ctx);
});
});
});

router.get('/forgotten-password', function(req, res) {
Expand All @@ -81,28 +74,26 @@ router.get('/auth/linkedin/callback', function(req, res) {
getLinkedInProfile(user, res);
} else {
var options = {
uri: 'https://www.linkedin.com/oauth/v2/accessToken',
headers: {
},
qs: {
client_id: '77tgqz6flgej2j',
client_secret: 'jGjoCdApJjgkGtdG',
grant_type: 'authorization_code',
redirect_uri: 'http://reu-apply.com/auth/linkedin/callback',
code: req.query.code,
scope: 'r_fullprofile'
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
}
uri: 'https://www.linkedin.com/oauth/v2/accessToken',
qs: {
client_id: '77tgqz6flgej2j',
client_secret: 'jGjoCdApJjgkGtdG',
grant_type: 'authorization_code',
redirect_uri: 'http://reu-apply.com/auth/linkedin/callback',
code: req.query.code,
scope: 'r_fullprofile'
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
}
};

request.post(options, function(err, resp, body) {
if(err) throw err;
var data = JSON.parse(body)
var data = JSON.parse(body);
if(data.error) throw data.error;
if(data["access_token"] == undefined || data["access_token"] == 'undefined') throw "undefined return error"
user.linkedin.token = data["access_token"];
if(data.access_token === undefined || data.access_token === 'undefined') throw "undefined return error";
user.linkedin.token = data.access_token;
user.linkedin.timestamp = new Date();
user.save();

Expand Down Expand Up @@ -150,7 +141,7 @@ function getLinkedInProfile(user, res) {
user.recommendations_received = data.recommendationsReceived;
user.dob = data.dateOfBirth;
user.honors_awards = data.honorsAwards;
user.save()
user.save();
console.log(data);
res.render('profile', { user: user });
});
Expand Down
40 changes: 40 additions & 0 deletions routes/reu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var express = require('express');

var User = require('../models/user');
var REU = require('../models/reu');

var reu = express.Router();

reu.get('/', function(req, res) {
var ctx = {
user: req.user,
tb_highlighted: 'reu',
};
res.render('reu', ctx);
});

reu.post('/search', function(req, res) {
var ctx = {
user: req.user,
tb_highlighted: 'reu',
};

var searchRXP = new RegExp(req.body.reu_search_info);

REU.find({
name: searchRXP,
school: searchRXP,
location: searchRXP,
professors: searchRXP
}, function(err, reus) {
if(err) {
console.log(err);
ctx.results = [];
return res.render('reu', ctx);
}
ctx.results = reus;
return res.render('reu', ctx);
});
});

module.exports = reu;
5 changes: 0 additions & 5 deletions views/about.jade

This file was deleted.

Loading

0 comments on commit 4d89d55

Please sign in to comment.