Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partials #3

Open
wants to merge 11 commits into
base: partials
Choose a base branch
from
3 changes: 2 additions & 1 deletion models/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
User: require('./user')
User: require('./user'),
Photo: require('./photo')
}
9 changes: 9 additions & 0 deletions models/photo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema;

var Photo = new Schema({
url: {type: String},
filterName: {type: String}
})

module.exports = mongoose.model('Photo', Photo);
5 changes: 4 additions & 1 deletion models/user.js
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ var mongoose = require('mongoose'),
Schema = mongoose.Schema,
passportLocalMongoose = require('passport-local-mongoose');

var Photo = require('./photo');

var User = new Schema({
name: String
name: String,
photos: [{type: mongoose.Schema.Types.ObjectId, ref: 'Photo'}]
});

User.plugin(passportLocalMongoose);
830 changes: 830 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -14,11 +14,12 @@
"cookie-session": "^2.0.0-beta.1",
"ejs": "^2.5.6",
"express": "^4.15.2",
"mongoose": "^4.9.4",
"mongoose": "^5.11.15",
"morgan": "^1.8.1",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^4.0.0",
"serve-favicon": "^2.4.2"
}
},
"devDependencies": {}
}
1 change: 0 additions & 1 deletion public/scripts/app.js
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ $(document).ready(function(){
};

function photoCaptureSuccess(stream){
console.dir(stream)
video.srcObject = stream;
}

17 changes: 12 additions & 5 deletions routes.js
Original file line number Diff line number Diff line change
@@ -2,13 +2,15 @@ var passport = require('passport');
var db = require('./models');
var router = require('express').Router();


//Sign up and login routes
router.get('/', function(req, res) {
res.render('index', {user: req.user});
})
});

router.get('/signup', function(req, res) {
res.render('signup')
})
res.render('signup', {user: req.user})
});

router.post('/signup', function(req, res) {
db.User.register(new db.User({username: req.body.username}), req.body.password, function(err) {
@@ -17,7 +19,7 @@ router.post('/signup', function(req, res) {
return next(err);
}

res.redirect('/');
res.redirect('/camera');

});
});
@@ -27,13 +29,18 @@ router.get('/login', function(req, res) {
});

router.post('/login', passport.authenticate('local'), function(req, res) {
res.redirect('/');
res.redirect('/camera');
});

router.get('/logout', function(req, res) {
req.logout();
res.redirect('/');
});

//Camera page routes
router.get('/camera', function(req, res) {
res.render('camera', {user: req.user});
});


module.exports = router;
1 change: 0 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ var logger = require('morgan');
var cookieParser = require('cookie-parser');
var session = require('cookie-session');
var bodyParser = require('body-parser');

var mongoose = require('mongoose');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
54 changes: 54 additions & 0 deletions views/camera.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<% include ./partials/head %>

<div class="camera">
<video autoplay></video>
<button id="snapshot">Take a photo</button>
</div>

<canvas></canvas>

<div class="output">

<figure class="none">
<img alt="" class="photo">
</figure>

<figure class="brooklyn">
<img alt="" class="photo">
</figure>

<figure class="earlybird">
<img alt="Screen capture" class="photo">
</figure>

<figure class="_1977">
<img alt="" class="photo">
</figure>

<figure class="brannan">
<img alt="Screen capture" class="photo">
</figure>

<figure class="nashville">
<img alt="" class="photo">
</figure>

<figure class="willow">
<img alt="" class="photo">
</figure>

<figure class="inkwell">
<img alt="" class="photo">
</figure>

<figure class="toaster">
<img alt="Screen capture" class="photo">
</figure>

<figure class="xpro2">
<img alt="Screen capture" class="photo">
</figure>

</div>

<% include ./partials/footer %>
73 changes: 4 additions & 69 deletions views/index.ejs
Original file line number Diff line number Diff line change
@@ -1,71 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Close Up</title>
<link rel="stylesheet" href="/styles/vendor/cssgram.min.css">
<link rel="stylesheet" href="/styles/style.css">
<% include ./partials/head %>
<% include ./partials/header %>

<h1>Hi</h1>

<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="/scripts/app.js" ></script>

</head>
<body>
<div class="camera">
<video autoplay></video>
<button id="snapshot">Take a photo</button>
</div>

<canvas></canvas>

<div class="output">

<figure class="none">
<img alt="" class="photo">
</figure>

<figure class="brooklyn">
<img alt="" class="photo">
</figure>

<figure class="earlybird">
<img alt="Screen capture" class="photo">
</figure>

<figure class="_1977">
<img alt="" class="photo">
</figure>

<figure class="brannan">
<img alt="Screen capture" class="photo">
</figure>

<figure class="nashville">
<img alt="" class="photo">
</figure>

<figure class="willow">
<img alt="" class="photo">
</figure>

<figure class="inkwell">
<img alt="" class="photo">
</figure>

<figure class="toaster">
<img alt="Screen capture" class="photo">
</figure>

<figure class="xpro2">
<img alt="Screen capture" class="photo">
</figure>

</div>


</body>
</html>
<% include ./partials/footer %>
13 changes: 3 additions & 10 deletions views/login.ejs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<% include ./partials/head %>
<% include ./partials/header %>

<form action="/login" method="post">
<div class="form-group">
@@ -20,6 +15,4 @@

</form>


</body>
</html>
<% include ./partials/footer %>
3 changes: 3 additions & 0 deletions views/partials/footer.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<footer> Copyright 2017 </footer>
</body>
</html>
16 changes: 16 additions & 0 deletions views/partials/head.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Close Up</title>
<link rel="stylesheet" href="/styles/vendor/cssgram.min.css">
<link rel="stylesheet" href="/styles/style.css">


<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="/scripts/app.js" ></script>
</head>
<body>
18 changes: 18 additions & 0 deletions views/partials/header.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<nav>
<div>
<a href="/">
Close Up
</a>
</div>
<div>
<ul>
<% if (!user) { %>
<li><a href="/signup">Sign up</a></li>
<li><a href="/login">Login</a></li>
<% } %>
<% if (user) { %>
<li><a href="/logout"> Log Out</a></li>
<% } %>
</ul>
</div>
</nav>
13 changes: 3 additions & 10 deletions views/signup.ejs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<% include ./partials/head %>
<% include ./partials/header %>

<form action="/signup" method="post">
<div class="form-group">
@@ -24,6 +19,4 @@

</form>


</body>
</html>
<% include ./partials/footer %>