From 62ab273da2b2869a5c1baceffa615fc3ad9da101 Mon Sep 17 00:00:00 2001 From: Anton Maes Date: Wed, 13 Dec 2017 21:30:34 -0800 Subject: [PATCH] first commit --- .gitignore | 2 + app.js | 74 ++ middleware/index.js | 57 ++ models/campground.js | 30 + models/comment.js | 17 + models/user.js | 21 + package-lock.json | 1326 ++++++++++++++++++++++++++++++++ package.json | 32 + public/scripts/search.js | 28 + public/stylesheets/landing.css | 87 +++ public/stylesheets/main.css | 53 ++ readme.md | 4 + routes/campgrounds.js | 139 ++++ routes/comments.js | 88 +++ routes/index.js | 69 ++ seeds.js | 94 +++ views/campgrounds/edit.ejs | 35 + views/campgrounds/index.ejs | 36 + views/campgrounds/new.ejs | 35 + views/campgrounds/show.ejs | 118 +++ views/comments/edit.ejs | 17 + views/comments/new.ejs | 17 + views/landing.ejs | 28 + views/login.ejs | 20 + views/partials/footer.ejs | 17 + views/partials/header.ejs | 50 ++ views/register.ejs | 37 + 27 files changed, 2531 insertions(+) create mode 100755 .gitignore create mode 100755 app.js create mode 100755 middleware/index.js create mode 100755 models/campground.js create mode 100755 models/comment.js create mode 100755 models/user.js create mode 100755 package-lock.json create mode 100755 package.json create mode 100755 public/scripts/search.js create mode 100755 public/stylesheets/landing.css create mode 100755 public/stylesheets/main.css create mode 100755 readme.md create mode 100755 routes/campgrounds.js create mode 100755 routes/comments.js create mode 100755 routes/index.js create mode 100755 seeds.js create mode 100755 views/campgrounds/edit.ejs create mode 100755 views/campgrounds/index.ejs create mode 100755 views/campgrounds/new.ejs create mode 100755 views/campgrounds/show.ejs create mode 100755 views/comments/edit.ejs create mode 100755 views/comments/new.ejs create mode 100755 views/landing.ejs create mode 100755 views/login.ejs create mode 100755 views/partials/footer.ejs create mode 100755 views/partials/header.ejs create mode 100755 views/register.ejs diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..1dcef2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +.env \ No newline at end of file diff --git a/app.js b/app.js new file mode 100755 index 0000000..00f7462 --- /dev/null +++ b/app.js @@ -0,0 +1,74 @@ +var express = require("express"), + app = express(), + bodyParser = require("body-parser"), + mongoose = require("mongoose"), + passport = require("passport"), + cookieParser = require("cookie-parser"), + LocalStrategy = require("passport-local"), + flash = require("connect-flash"), + Campground = require("./models/campground"), + Comment = require("./models/comment"), + User = require("./models/user"), + session = require("express-session"), + seedDB = require("./seeds"), + methodOverride = require("method-override"); +// configure dotenv +require('dotenv').load(); + +//requiring routes +var commentRoutes = require("./routes/comments"), + campgroundRoutes = require("./routes/campgrounds"), + indexRoutes = require("./routes/index") + +// assign mongoose promise library and connect to database +mongoose.Promise = global.Promise; + +const databaseUri = process.env.MONGODB_URI || 'mongodb://localhost/yelp_camp'; + +mongoose.connect(databaseUri, { useMongoClient: true }) + .then(() => console.log(`Database connected`)) + .catch(err => console.log(`Database connection error: ${err.message}`)); + +app.use(bodyParser.urlencoded({extended: true})); +app.set("view engine", "ejs"); +app.use(express.static(__dirname + "/public")); +app.use(methodOverride('_method')); +app.use(cookieParser('secret')); +//require moment +app.locals.moment = require('moment'); +// seedDB(); //seed the database +seedDB(); + + +// PASSPORT CONFIGURATION +app.use(require("express-session")({ + secret: "Once again Rusty wins cutest dog!", + resave: false, + saveUninitialized: false +})); + +app.use(flash()); +app.use(passport.initialize()); +app.use(passport.session()); +passport.use(new LocalStrategy(User.authenticate())); +passport.serializeUser(User.serializeUser()); +passport.deserializeUser(User.deserializeUser()); + +app.use(function(req, res, next){ + res.locals.currentUser = req.user; + res.locals.success = req.flash('success'); + res.locals.error = req.flash('error'); + next(); +}); + + +app.use("/", indexRoutes); +app.use("/campgrounds", campgroundRoutes); +app.use("/campgrounds/:id/comments", commentRoutes); + +const port = process.env.PORT || 3000; +const ip = process.env.IP; + +app.listen(port, ip, function(){ + console.log(`The YelpCamp Server Has Started! on ${ip} : ${port}`); +}); diff --git a/middleware/index.js b/middleware/index.js new file mode 100755 index 0000000..fc8957a --- /dev/null +++ b/middleware/index.js @@ -0,0 +1,57 @@ +var Comment = require('../models/comment'); +var Campground = require('../models/campground'); +module.exports = { + isLoggedIn: function(req, res, next){ + if(req.isAuthenticated()){ + return next(); + } + req.flash('error', 'You must be signed in to do that!'); + res.redirect('/login'); + }, + checkUserCampground: function(req, res, next){ + Campground.findById(req.params.id, function(err, foundCampground){ + if(err || !foundCampground){ + console.log(err); + req.flash('error', 'Sorry, that campground does not exist!'); + res.redirect('/campgrounds'); + } else if(foundCampground.author.id.equals(req.user._id) || req.user.isAdmin){ + req.campground = foundCampground; + next(); + } else { + req.flash('error', 'You don\'t have permission to do that!'); + res.redirect('/campgrounds/' + req.params.id); + } + }); + }, + checkUserComment: function(req, res, next){ + Comment.findById(req.params.commentId, function(err, foundComment){ + if(err || !foundComment){ + console.log(err); + req.flash('error', 'Sorry, that comment does not exist!'); + res.redirect('/campgrounds'); + } else if(foundComment.author.id.equals(req.user._id) || req.user.isAdmin){ + req.comment = foundComment; + next(); + } else { + req.flash('error', 'You don\'t have permission to do that!'); + res.redirect('/campgrounds/' + req.params.id); + } + }); + }, + isAdmin: function(req, res, next) { + if(req.user.isAdmin) { + next(); + } else { + req.flash('error', 'This site is now read only thanks to spam and trolls.'); + res.redirect('back'); + } + }, + isSafe: function(req, res, next) { + if(req.body.image.match(/^https:\/\/images\.unsplash\.com\/.*/)) { + next(); + }else { + req.flash('error', 'Only images from images.unsplash.com allowed.\nSee https://youtu.be/Bn3weNRQRDE for how to copy image urls from unsplash.'); + res.redirect('back'); + } + } +} \ No newline at end of file diff --git a/models/campground.js b/models/campground.js new file mode 100755 index 0000000..f52c7e1 --- /dev/null +++ b/models/campground.js @@ -0,0 +1,30 @@ +var mongoose = require("mongoose"); + +var campgroundSchema = new mongoose.Schema({ + name: String, + image: String, + description: String, + state: String, + party: String, + chamber: String, + general: Number, + primary: Number, + lat: Number, + long: Number, + createdAt: { type: Date, default: Date.now }, + author: { + id: { + type: mongoose.Schema.Types.ObjectId, + ref: "User" + }, + username: String + }, + comments: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "Comment" + } + ] +}); + +module.exports = mongoose.model("campground", campgroundSchema); diff --git a/models/comment.js b/models/comment.js new file mode 100755 index 0000000..03d8b81 --- /dev/null +++ b/models/comment.js @@ -0,0 +1,17 @@ +var mongoose = require("mongoose"); + +var commentSchema = mongoose.Schema({ + text: String, + amount: Number , + campaignID : Number, + createdAt: { type: Date, default: Date.now }, + author: { + id: { + type: mongoose.Schema.Types.ObjectId, + ref: "User" + }, + username: String + } +}); + +module.exports = mongoose.model("Comment", commentSchema); diff --git a/models/user.js b/models/user.js new file mode 100755 index 0000000..a0cea6b --- /dev/null +++ b/models/user.js @@ -0,0 +1,21 @@ +var mongoose = require("mongoose"); +var passportLocalMongoose = require("passport-local-mongoose"); + +var UserSchema = new mongoose.Schema({ + username: String, + password: String, + isAdmin: {type: Boolean, default: false}, + address: { + street1: String, + street2: String, + city: String, + state: String, + zip: String + }, + profession: String, + employer: String + }); + +UserSchema.plugin(passportLocalMongoose) + +module.exports = mongoose.model("User", UserSchema); diff --git a/package-lock.json b/package-lock.json new file mode 100755 index 0000000..1f27b5a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1326 @@ +{ + "name": "v1", + "version": "1.0.0", + "lockfileVersion": 1, + "dependencies": { + "bluebird": { + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.2.tgz", + "integrity": "sha1-AkpVFylTCIV/FPkfEQb8O1VfRGs=" + }, + "body-parser": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.14.1.tgz", + "integrity": "sha1-/+kh66POjxkeKoqIA4RL0CXzxtw=", + "requires": { + "bytes": "2.1.0", + "content-type": "1.0.1", + "debug": "2.2.0", + "depd": "1.1.0", + "http-errors": "1.3.1", + "iconv-lite": "0.4.12", + "on-finished": "2.3.0", + "qs": "5.1.0", + "raw-body": "2.1.4", + "type-is": "1.6.9" + }, + "dependencies": { + "bytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.1.0.tgz", + "integrity": "sha1-rJPEEOL/ycx89LRks4KJBn9eR7Q=" + }, + "content-type": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.1.tgz", + "integrity": "sha1-oZ0iRzJ9wDgFDOYit6FU7FnF5gA=" + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "requires": { + "ms": "0.7.1" + }, + "dependencies": { + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + } + } + }, + "depd": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=" + }, + "http-errors": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.3.1.tgz", + "integrity": "sha1-GX4izevUGYWF6GlO9nhhl7ke2UI=", + "requires": { + "inherits": "2.0.1", + "statuses": "1.2.1" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" + }, + "statuses": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.2.1.tgz", + "integrity": "sha1-3e1FzBglbVHtQK7BQkidXGECbSg=" + } + } + }, + "iconv-lite": { + "version": "0.4.12", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.12.tgz", + "integrity": "sha1-70uyyyj0BtPAX8if7qRQRiS1rIc=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + }, + "dependencies": { + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + } + } + }, + "qs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-5.1.0.tgz", + "integrity": "sha1-TZMuXH6kEcynajEtOaYGIA/VDNk=" + }, + "raw-body": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.1.4.tgz", + "integrity": "sha1-3MOv4uH9/GIKgSN2+OD8PS5iy1A=", + "requires": { + "bytes": "2.1.0", + "iconv-lite": "0.4.12", + "unpipe": "1.0.0" + }, + "dependencies": { + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + } + } + }, + "type-is": { + "version": "1.6.9", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.9.tgz", + "integrity": "sha1-h/Poi5L/WsMPvBrPmp0Ay8OLPXo=", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.7" + }, + "dependencies": { + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "mime-types": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.7.tgz", + "integrity": "sha1-/2A5cOPHMe9vf03zyaD0Y6E8J1U=", + "requires": { + "mime-db": "1.19.0" + }, + "dependencies": { + "mime-db": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.19.0.tgz", + "integrity": "sha1-SWoYGYp86CRFNOJbsQK3T7Qg/VY=" + } + } + } + } + } + } + }, + "bson": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz", + "integrity": "sha1-k8ENOeqltYQVy8QFLz5T5WKwtyw=" + }, + "buffer-shims": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=" + }, + "combined-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz", + "integrity": "sha1-ATfmV7qlp1QcV6w3rF/AfXO03B8=", + "requires": { + "delayed-stream": "0.0.5" + } + }, + "connect-flash": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/connect-flash/-/connect-flash-0.1.1.tgz", + "integrity": "sha1-2GMPJtlaf4UfmVax6MxnMvO2qjA=" + }, + "cookie": { + "version": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-parser": { + "version": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.3.tgz", + "integrity": "sha1-D+MfoZ0AC5X0qt8fU/3CuKIDuqU=", + "requires": { + "cookie": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "cookie-signature": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz" + } + }, + "cookie-signature": { + "version": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "crc": { + "version": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz", + "integrity": "sha1-naHpgOO9RPxck79as9ozeNheRms=" + }, + "debug": { + "version": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz", + "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=", + "requires": { + "ms": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" + } + }, + "delayed-stream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz", + "integrity": "sha1-1LH0OpPoKW3+AmlPRoC8N6MTxz8=" + }, + "depd": { + "version": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=" + }, + "dotenv": { + "version": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz", + "integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=" + }, + "ejs": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.3.4.tgz", + "integrity": "sha1-PHbKoJZks1g7ADevncE2557Gi5g=" + }, + "es6-promise": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz", + "integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q=" + }, + "express": { + "version": "4.13.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.13.3.tgz", + "integrity": "sha1-3bLx+0UCvzNZjSsDKwN5YMpsgKM=", + "requires": { + "accepts": "1.2.13", + "array-flatten": "1.1.1", + "content-disposition": "0.5.0", + "content-type": "1.0.1", + "cookie": "0.1.3", + "cookie-signature": "1.0.6", + "debug": "2.2.0", + "depd": "1.0.1", + "escape-html": "1.0.2", + "etag": "1.7.0", + "finalhandler": "0.4.0", + "fresh": "0.3.0", + "merge-descriptors": "1.0.0", + "methods": "1.1.1", + "on-finished": "2.3.0", + "parseurl": "1.3.0", + "path-to-regexp": "0.1.7", + "proxy-addr": "1.0.8", + "qs": "4.0.0", + "range-parser": "1.0.2", + "send": "0.13.0", + "serve-static": "1.10.0", + "type-is": "1.6.9", + "utils-merge": "1.0.0", + "vary": "1.0.1" + }, + "dependencies": { + "accepts": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.2.13.tgz", + "integrity": "sha1-5fHzkoxtlf2WVYw27D2dDeSm7Oo=", + "requires": { + "mime-types": "2.1.7", + "negotiator": "0.5.3" + }, + "dependencies": { + "mime-types": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.7.tgz", + "integrity": "sha1-/2A5cOPHMe9vf03zyaD0Y6E8J1U=", + "requires": { + "mime-db": "1.19.0" + }, + "dependencies": { + "mime-db": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.19.0.tgz", + "integrity": "sha1-SWoYGYp86CRFNOJbsQK3T7Qg/VY=" + } + } + }, + "negotiator": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.5.3.tgz", + "integrity": "sha1-Jp1cR2gQ7JLtvntsLygxY4T5p+g=" + } + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "content-disposition": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.0.tgz", + "integrity": "sha1-QoT+auBjCHRjnkToCkGMKTQTXp4=" + }, + "content-type": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.1.tgz", + "integrity": "sha1-oZ0iRzJ9wDgFDOYit6FU7FnF5gA=" + }, + "cookie": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.1.3.tgz", + "integrity": "sha1-5zSlwUF/zkctWu+Cw4HKu2TRpDU=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "requires": { + "ms": "0.7.1" + }, + "dependencies": { + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + } + } + }, + "depd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.0.1.tgz", + "integrity": "sha1-gK7GTJ1tl+ZcwqnKqTwKpqv3Oqo=" + }, + "escape-html": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.2.tgz", + "integrity": "sha1-130y+pjjjC9BroXpJ44ODmuhAiw=" + }, + "etag": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz", + "integrity": "sha1-A9MLX2fdbmMtKUXTDWZScxo01dg=" + }, + "finalhandler": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.4.0.tgz", + "integrity": "sha1-llpS2ejQXSuFdUhUH7ibU6JJfZs=", + "requires": { + "debug": "2.2.0", + "escape-html": "1.0.2", + "on-finished": "2.3.0", + "unpipe": "1.0.0" + }, + "dependencies": { + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + } + } + }, + "fresh": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz", + "integrity": "sha1-ZR+DjiJCTnVm3hYdg1jKoZn4PU8=" + }, + "merge-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.0.tgz", + "integrity": "sha1-IWnPdTjhsMyH+4jhUC2EdLv3mGQ=" + }, + "methods": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.1.tgz", + "integrity": "sha1-F+pjZgZtAMWON1uOx9/QRTyJgio=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + }, + "dependencies": { + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + } + } + }, + "parseurl": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.0.tgz", + "integrity": "sha1-tYBG20Ij4UWvp2AJ5hush8wigbM=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.8.tgz", + "integrity": "sha1-21Tsh4vMEFPVdkZgkhmzcVZ4uv4=", + "requires": { + "forwarded": "0.1.0", + "ipaddr.js": "1.0.1" + }, + "dependencies": { + "forwarded": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", + "integrity": "sha1-Ge+YdMSuHCl7zweP3mOgm2aoQ2M=" + }, + "ipaddr.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.0.1.tgz", + "integrity": "sha1-XziAHcc+BAD8cHY4b27VIV+9j5U=" + } + } + }, + "qs": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-4.0.0.tgz", + "integrity": "sha1-wx2bdOwn33XlQ6hseHKO2NRiNgc=" + }, + "range-parser": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.0.2.tgz", + "integrity": "sha1-BqEqQuUTG6jkV82JIESGfyNE5Uk=" + }, + "send": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.13.0.tgz", + "integrity": "sha1-UY+SGusFYK7H3KspkLFM9vPM5d4=", + "requires": { + "debug": "2.2.0", + "depd": "1.0.1", + "destroy": "1.0.3", + "escape-html": "1.0.2", + "etag": "1.7.0", + "fresh": "0.3.0", + "http-errors": "1.3.1", + "mime": "1.3.4", + "ms": "0.7.1", + "on-finished": "2.3.0", + "range-parser": "1.0.2", + "statuses": "1.2.1" + }, + "dependencies": { + "destroy": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.3.tgz", + "integrity": "sha1-tDO0ck5x/YVR2YhRdIUcX8N34sk=" + }, + "http-errors": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.3.1.tgz", + "integrity": "sha1-GX4izevUGYWF6GlO9nhhl7ke2UI=", + "requires": { + "inherits": "2.0.1", + "statuses": "1.2.1" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" + } + } + }, + "mime": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", + "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=" + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + }, + "statuses": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.2.1.tgz", + "integrity": "sha1-3e1FzBglbVHtQK7BQkidXGECbSg=" + } + } + }, + "serve-static": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.10.0.tgz", + "integrity": "sha1-vmMvqmhYIOSkPtPfE3kTXMTzcNc=", + "requires": { + "escape-html": "1.0.2", + "parseurl": "1.3.0", + "send": "0.13.0" + } + }, + "type-is": { + "version": "1.6.9", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.9.tgz", + "integrity": "sha1-h/Poi5L/WsMPvBrPmp0Ay8OLPXo=", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.7" + }, + "dependencies": { + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "mime-types": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.7.tgz", + "integrity": "sha1-/2A5cOPHMe9vf03zyaD0Y6E8J1U=", + "requires": { + "mime-db": "1.19.0" + }, + "dependencies": { + "mime-db": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.19.0.tgz", + "integrity": "sha1-SWoYGYp86CRFNOJbsQK3T7Qg/VY=" + } + } + } + } + }, + "utils-merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=" + }, + "vary": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.0.1.tgz", + "integrity": "sha1-meSYFWaihhGN+yuBc1ffeZM3bRA=" + } + } + }, + "express-session": { + "version": "https://registry.npmjs.org/express-session/-/express-session-1.15.3.tgz", + "integrity": "sha1-21RfBDWnsbIorgLagZf2UUFzXGc=", + "requires": { + "cookie": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "cookie-signature": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "crc": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz", + "debug": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz", + "depd": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "on-headers": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "parseurl": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "uid-safe": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.4.tgz", + "utils-merge": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz" + } + }, + "form-data": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-0.0.10.tgz", + "integrity": "sha1-2zRaU3jYau6x7V1VO4aawZLS9e0=", + "requires": { + "async": "0.2.10", + "combined-stream": "0.0.7", + "mime": "1.2.11" + }, + "dependencies": { + "async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=" + } + } + }, + "geocoder": { + "version": "https://registry.npmjs.org/geocoder/-/geocoder-0.2.2.tgz", + "integrity": "sha1-mvEt0ZUpoNkMYkwkq8lhTuB1Ml8=", + "requires": { + "request": "https://registry.npmjs.org/request/-/request-2.11.1.tgz", + "underscore": "https://registry.npmjs.org/underscore/-/underscore-1.3.3.tgz", + "xml2js": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.0.tgz" + }, + "dependencies": { + "request": { + "version": "https://registry.npmjs.org/request/-/request-2.11.1.tgz", + "integrity": "sha1-JX9GvK9NVOYsC2G6KPrAJo9ljiw=", + "requires": { + "form-data": "0.0.10", + "mime": "1.2.11" + } + } + } + }, + "hooks-fixed": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.0.tgz", + "integrity": "sha1-oB2JTVKsf2WZu7H2PfycQR33DLo=" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "kareem": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-1.5.0.tgz", + "integrity": "sha1-4+QQHZ3P3imXadr0tNtk2JXRdEg=" + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "method-override": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/method-override/-/method-override-2.3.5.tgz", + "integrity": "sha1-LNXNv/AMNnPXrjRRGagSpdlbjI4=", + "requires": { + "debug": "2.2.0", + "methods": "1.1.1", + "parseurl": "1.3.0", + "vary": "1.0.1" + }, + "dependencies": { + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "requires": { + "ms": "0.7.1" + }, + "dependencies": { + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + } + } + }, + "methods": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.1.tgz", + "integrity": "sha1-F+pjZgZtAMWON1uOx9/QRTyJgio=" + }, + "parseurl": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.0.tgz", + "integrity": "sha1-tYBG20Ij4UWvp2AJ5hush8wigbM=" + }, + "vary": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.0.1.tgz", + "integrity": "sha1-meSYFWaihhGN+yuBc1ffeZM3bRA=" + } + } + }, + "mime": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz", + "integrity": "sha1-WCA+7Ybjpe8XrtK32evUfwpg3RA=" + }, + "moment": { + "version": "https://registry.npmjs.org/moment/-/moment-2.17.1.tgz", + "integrity": "sha1-/tlQYGPzaxDwZsi1mhRNf66+HYI=" + }, + "mongodb": { + "version": "2.2.31", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.31.tgz", + "integrity": "sha1-GUBEXGYeGSF7s7+CRdmFSq71SNs=", + "requires": { + "es6-promise": "3.2.1", + "mongodb-core": "2.1.15", + "readable-stream": "2.2.7" + } + }, + "mongodb-core": { + "version": "2.1.15", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.15.tgz", + "integrity": "sha1-hB9TuH//9MdFgYnDXIroJ+EWl2Q=", + "requires": { + "bson": "1.0.4", + "require_optional": "1.0.1" + } + }, + "mongoose": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.11.9.tgz", + "integrity": "sha512-4WTZOex1yGVv5lwjEtIQ4DEP9UaYL8wLhhrxrSBC8meU8l/D+r/cBeNfHMmIptWNonIp9gpgvKu3Vk3IkuXDTw==", + "requires": { + "async": "2.1.4", + "bson": "1.0.4", + "hooks-fixed": "2.0.0", + "kareem": "1.5.0", + "mongodb": "2.2.31", + "mpath": "0.3.0", + "mpromise": "0.5.5", + "mquery": "2.3.1", + "ms": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "muri": "1.2.2", + "regexp-clone": "0.0.1", + "sliced": "1.0.1" + }, + "dependencies": { + "async": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz", + "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=", + "requires": { + "lodash": "4.17.4" + } + } + } + }, + "mpath": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.3.0.tgz", + "integrity": "sha1-elj3iem1/TyUUgY0FXlg8mvV70Q=" + }, + "mpromise": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz", + "integrity": "sha1-9bJCWddjrMIlewoMjG2Gb9UXMuY=" + }, + "mquery": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-2.3.1.tgz", + "integrity": "sha1-mrNnSXFIAP8LtTpoHOS8TV8HyHs=", + "requires": { + "bluebird": "2.10.2", + "debug": "2.6.8", + "regexp-clone": "0.0.1", + "sliced": "0.0.5" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" + } + }, + "sliced": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz", + "integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8=" + } + } + }, + "ms": { + "version": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "muri": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/muri/-/muri-1.2.2.tgz", + "integrity": "sha1-YxmBMmUNsIoEzHnM0A3Tia/SYxw=" + }, + "on-headers": { + "version": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=" + }, + "parseurl": { + "version": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=" + }, + "passport": { + "version": "https://registry.npmjs.org/passport/-/passport-0.3.2.tgz", + "integrity": "sha1-ndAJ+RXo/glbASSgG4+C2gdRAQI=", + "requires": { + "passport-strategy": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "pause": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz" + } + }, + "passport-local": { + "version": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz", + "integrity": "sha1-H+YyaMkudWBmJkN+O5BmYsFbpu4=", + "requires": { + "passport-strategy": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz" + } + }, + "passport-local-mongoose": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/passport-local-mongoose/-/passport-local-mongoose-3.1.0.tgz", + "integrity": "sha1-najQt5KHDDhFAu6x99MONL/xQsY=", + "requires": { + "generaterr": "1.2.0", + "passport-local": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz", + "scmp": "1.0.0" + }, + "dependencies": { + "generaterr": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generaterr/-/generaterr-1.2.0.tgz", + "integrity": "sha1-NdJ2Gd3VsA8q6lg3Xu0Z7skpUrw=" + }, + "scmp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/scmp/-/scmp-1.0.0.tgz", + "integrity": "sha1-oLJyw/xykvdxFWRvAGGLAmJRTgQ=" + } + } + }, + "passport-strategy": { + "version": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=" + }, + "pause": { + "version": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", + "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=" + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, + "random-bytes": { + "version": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=" + }, + "readable-stream": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz", + "integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=", + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "regexp-clone": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz", + "integrity": "sha1-p8LgmJH9vzj7sQ03b7cwA+aKxYk=" + }, + "request": { + "version": "2.65.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.65.0.tgz", + "integrity": "sha1-zBo7xyuWJUc0/DQpbaMi+Uht3ro=", + "requires": { + "aws-sign2": "0.6.0", + "bl": "1.0.0", + "caseless": "0.11.0", + "combined-stream": "1.0.5", + "extend": "3.0.0", + "forever-agent": "0.6.1", + "form-data": "1.0.0-rc3", + "har-validator": "2.0.2", + "hawk": "3.1.1", + "http-signature": "0.11.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.7", + "node-uuid": "1.4.3", + "oauth-sign": "0.8.0", + "qs": "5.2.0", + "stringstream": "0.0.5", + "tough-cookie": "2.2.0", + "tunnel-agent": "0.4.1" + }, + "dependencies": { + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=" + }, + "bl": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.0.0.tgz", + "integrity": "sha1-ramoqJptesYIYvfex9sgeHPgw/U=", + "requires": { + "readable-stream": "2.0.4" + }, + "dependencies": { + "readable-stream": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.4.tgz", + "integrity": "sha1-JSPvJ/+jOde6nahgPy0FmdBu29g=", + "requires": { + "core-util-is": "1.0.1", + "inherits": "2.0.1", + "isarray": "0.0.1", + "process-nextick-args": "1.0.3", + "string_decoder": "0.10.31", + "util-deprecate": "1.0.2" + }, + "dependencies": { + "core-util-is": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz", + "integrity": "sha1-awcIWu+aPMrG7lO/nT3wwVIaVTg=" + }, + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "process-nextick-args": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.3.tgz", + "integrity": "sha1-4nLu2CXV6fTqdNjXOx/jEcO+tjA=" + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + } + } + } + } + }, + "caseless": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=" + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "requires": { + "delayed-stream": "1.0.0" + }, + "dependencies": { + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + } + } + }, + "extend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", + "integrity": "sha1-WkdDU7nzNT3dgXbf03uRyDpG8dQ=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "1.0.0-rc3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.0-rc3.tgz", + "integrity": "sha1-01vGLn+8KTeuePlIqqDTjZBgdXc=", + "requires": { + "async": "1.5.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.7" + }, + "dependencies": { + "async": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.0.tgz", + "integrity": "sha1-J5ZkJyNXOFlWVjP8YnRES+4vjOM=" + } + } + }, + "har-validator": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.2.tgz", + "integrity": "sha1-Iz0PqIe5ik80WWn4EaLuxw2Xrtc=", + "requires": { + "chalk": "1.1.1", + "commander": "2.9.0", + "is-my-json-valid": "2.12.3", + "pinkie-promise": "1.0.0" + }, + "dependencies": { + "chalk": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.1.tgz", + "integrity": "sha1-UJr7ZwZudJn36zU1x3RFdyri0Bk=", + "requires": { + "ansi-styles": "2.1.0", + "escape-string-regexp": "1.0.3", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.0", + "supports-color": "2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz", + "integrity": "sha1-mQ90cUaSe1Wakyv5KVkWPWDA0OI=" + }, + "escape-string-regexp": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.3.tgz", + "integrity": "sha1-ni2LJbwlVcMzZyN1DgPwmcJzW7U=" + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", + "integrity": "sha1-xQYbbg74qBd15Q9dZhUb9r83EQc=" + } + } + }, + "strip-ansi": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz", + "integrity": "sha1-dRC2ZVZ8qRTMtdfgcnY6yWi+NyQ=", + "requires": { + "ansi-regex": "2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", + "integrity": "sha1-xQYbbg74qBd15Q9dZhUb9r83EQc=" + } + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + } + } + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "requires": { + "graceful-readlink": "1.0.1" + }, + "dependencies": { + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" + } + } + }, + "is-my-json-valid": { + "version": "2.12.3", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.3.tgz", + "integrity": "sha1-WjnR12stu4MUC70Vex1e5L3IWtY=", + "requires": { + "generate-function": "2.0.0", + "generate-object-property": "1.2.0", + "jsonpointer": "2.0.0", + "xtend": "4.0.1" + }, + "dependencies": { + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=" + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "requires": { + "is-property": "1.0.2" + }, + "dependencies": { + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=" + } + } + }, + "jsonpointer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz", + "integrity": "sha1-OvHdIP6FRjkQ1GmjheMwF9KgMNk=" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + } + } + }, + "pinkie-promise": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-1.0.0.tgz", + "integrity": "sha1-0dpn9UglY7t89X8oauKCLs+/NnA=", + "requires": { + "pinkie": "1.0.0" + }, + "dependencies": { + "pinkie": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-1.0.0.tgz", + "integrity": "sha1-Wkfyi6EBXQIBvae/DzWOR77Ix+Q=" + } + } + } + } + }, + "hawk": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.1.tgz", + "integrity": "sha1-8tlSuPnIyjDMbUEy1L5wLcFOkbs=", + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + }, + "dependencies": { + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "requires": { + "hoek": "2.16.3" + } + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "requires": { + "boom": "2.10.1" + } + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "requires": { + "hoek": "2.16.3" + } + } + } + }, + "http-signature": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-0.11.0.tgz", + "integrity": "sha1-F5bPZ6ABrVzWhJ3KCZFIXwkIn+Y=", + "requires": { + "asn1": "0.1.11", + "assert-plus": "0.1.5", + "ctype": "0.5.3" + }, + "dependencies": { + "asn1": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz", + "integrity": "sha1-VZvhg3bQik7E2+gId9J4GGObLfc=" + }, + "assert-plus": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz", + "integrity": "sha1-7nQAlBMALYTOxyGcasgRgS5yMWA=" + }, + "ctype": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz", + "integrity": "sha1-gsGMJGH3QRTvFsE1IkrQuRRMoS8=" + } + } + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "mime-types": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.7.tgz", + "integrity": "sha1-/2A5cOPHMe9vf03zyaD0Y6E8J1U=", + "requires": { + "mime-db": "1.19.0" + }, + "dependencies": { + "mime-db": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.19.0.tgz", + "integrity": "sha1-SWoYGYp86CRFNOJbsQK3T7Qg/VY=" + } + } + }, + "node-uuid": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz", + "integrity": "sha1-MZu3pW58tj8AtcDNeFHNS03fHfk=" + }, + "oauth-sign": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.0.tgz", + "integrity": "sha1-k4/ch1dlulJxN9iuydF44k3rxVM=" + }, + "qs": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz", + "integrity": "sha1-qfMRQq9GjLcrJbMBNrokVoNJFr4=" + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" + }, + "tough-cookie": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.0.tgz", + "integrity": "sha1-1M5mEHXl/dt/IDQdP5kxpvu63eA=" + }, + "tunnel-agent": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.1.tgz", + "integrity": "sha1-u+7P9NZ5znU9uUYnYaiN/Ow8WrM=" + } + } + }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "requires": { + "resolve-from": "2.0.0", + "semver": "5.4.1" + } + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "sax": { + "version": "https://registry.npmjs.org/sax/-/sax-1.2.2.tgz", + "integrity": "sha1-/YYxojvHgmvvXYcb24c3jJVkeCg=", + "optional": true + }, + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "uid-safe": { + "version": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.4.tgz", + "integrity": "sha1-Otbzg2jG1MjHXsF2I/t5qh0HHYE=", + "requires": { + "random-bytes": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz" + } + }, + "underscore": { + "version": "https://registry.npmjs.org/underscore/-/underscore-1.3.3.tgz", + "integrity": "sha1-R6xTaD2vgyv6lS4XdEF9pHgXrkI=" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "utils-merge": { + "version": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=" + }, + "xml2js": { + "version": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.0.tgz", + "integrity": "sha1-99pSJ33rtkeYMFOtti2XLe5loaw=", + "optional": true, + "requires": { + "sax": "https://registry.npmjs.org/sax/-/sax-1.2.2.tgz" + } + } + } +} diff --git a/package.json b/package.json new file mode 100755 index 0000000..28a9b7f --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "v1", + "version": "1.0.0", + "engines": { + "node": "6.11.1" + }, + "description": "YelpCamp v1", + "main": "app.js", + "scripts": { + "start": "node app", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Colt Steele", + "license": "ISC", + "dependencies": { + "body-parser": "^1.14.1", + "connect-flash": "^0.1.1", + "cookie-parser": "^1.4.3", + "dotenv": "^4.0.0", + "ejs": "^2.3.4", + "express": "^4.13.3", + "express-session": "^1.11.3", + "geocoder": "^0.2.2", + "method-override": "^2.3.5", + "moment": "^2.17.1", + "mongoose": "^4.11.9", + "passport": "^0.3.0", + "passport-local": "^1.0.0", + "passport-local-mongoose": "^3.1.0", + "request": "^2.65.0" + } +} diff --git a/public/scripts/search.js b/public/scripts/search.js new file mode 100755 index 0000000..1d3bcee --- /dev/null +++ b/public/scripts/search.js @@ -0,0 +1,28 @@ +$('#campground-search').on('input', function() { + var search = $(this).serialize(); + if(search === "search=") { + search = "all" + } + $.get('/campgrounds?' + search, function(data) { + $('#campground-grid').html(''); + data.forEach(function(campground) { + $('#campground-grid').append(` +
+
+ +
+

${ campground.name }

+
+

+ More Info +

+
+
+ `); + }); + }); +}); + +$('#campground-search').submit(function(event) { + event.preventDefault(); +}); \ No newline at end of file diff --git a/public/stylesheets/landing.css b/public/stylesheets/landing.css new file mode 100755 index 0000000..534884c --- /dev/null +++ b/public/stylesheets/landing.css @@ -0,0 +1,87 @@ +body { + background-color: #000; +} + +h1 { + font-size: 4em; + text-shadow: 2px 2px 10px black; +} + +#landing-header { + z-index: 1; + position: relative; + text-align: center; + padding-top: 40vh; +} + +#landing-header h1 { + color: #fff; +} + +.slideshow { + position: fixed; + width: 100%; + height: 100%; + top: 0; + left: 0; + z-index: 0; + list-style: none; + margin: 0; + padding: 0; +} + +.slideshow li { + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + background-size: cover; + background-position: 50% 50%; + background-repeat: no-repeat; + opacity: 0; + z-index: 0; + animation: imageAnimation 15s linear infinite; +} + +.slideshow li:nth-child(1) { + background-image: url(http://i.imgur.com/K3mPv14.jpg) +} +.slideshow li:nth-child(2) { + background-image: url(http://i.imgur.com/SBEmFpv.jpg); + animation-delay: 10s; +} +.slideshow li:nth-child(3) { + background-image: url(http://i.imgur.com/emvhOnb.jpg); + animation-delay: 20s; +} +.slideshow li:nth-child(4) { + background-image: url(http://i.imgur.com/2LSMCmJ.jpg); + animation-delay: 30s; +} +.slideshow li:nth-child(5) { + background-image: url(http://i.imgur.com/TVGe0Ef.jpg); + animation-delay: 40s; +} + +@keyframes imageAnimation { + 0% { + opacity: 0; + animation-timing-function: ease-in; + } + 10% { + opacity: 1; + animation-timing-function: ease-out; + } + 20% { + opacity: 1 + } + 30% { + opacity: 0 + } +} + +/* Older browser support - .no-cssanimations class added by modernizr */ +.no-cssanimations .slideshow li { + opacity: 1; +} diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css new file mode 100755 index 0000000..e2176c4 --- /dev/null +++ b/public/stylesheets/main.css @@ -0,0 +1,53 @@ +/* Sticky footer styles +-------------------------------------------------- */ +html { + position: relative; + min-height: 100%; +} +body { + /* Margin bottom by footer height */ + margin-bottom: 60px; + background-color: rgb(250,250,250); +} +.footer { + position: absolute; + bottom: 0; + width: 100%; + /* Set the fixed height of the footer here */ + height: 60px; + background-color: #f5f5f5; +} + +.container .text-muted { + margin: 20px 0; +} + +/* Thumbnail styles */ +.thumbnail img { + width: 100%; +} + +.thumbnail { + padding: 0; +} + +.thumbnail .caption-full { + padding: 9px; +} + +/* Google Map styles */ +#map { + height: 400px; + width: 100%; +} + +/* Campground show page delete button */ +.delete-form { + display: inline-block; +} + +/* Flexbox grid fix */ +.flex-wrap { + display:flex; + flex-wrap: wrap; +} diff --git a/readme.md b/readme.md new file mode 100755 index 0000000..f41f333 --- /dev/null +++ b/readme.md @@ -0,0 +1,4 @@ +# YelpCamp + +### Refactored by Ian Schoonover +# dwnate diff --git a/routes/campgrounds.js b/routes/campgrounds.js new file mode 100755 index 0000000..93c99ac --- /dev/null +++ b/routes/campgrounds.js @@ -0,0 +1,139 @@ +var express = require("express"); +var router = express.Router(); +var Campground = require("../models/campground"); +var Comment = require("../models/comment"); +var middleware = require("../middleware"); +var geocoder = require('geocoder'); +var { isLoggedIn, checkUserCampground, checkUserComment, isAdmin, isSafe } = middleware; // destructuring assignment + +// Define escapeRegex function for search feature +function escapeRegex(text) { + return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); +}; + +//INDEX - show all campgrounds +router.get("/", function(req, res){ + if(req.query.search && req.xhr) { + const regex = new RegExp(escapeRegex(req.query.search), 'gi'); + // Get all campgrounds from DB + Campground.find({name: regex}, function(err, allCampgrounds){ + if(err){ + console.log(err); + } else { + res.status(200).json(allCampgrounds); + } + }); + } else { + // Get all campgrounds from DB + Campground.find({}, function(err, allCampgrounds){ + if(err){ + console.log(err); + } else { + if(req.xhr) { + res.json(allCampgrounds); + } else { + res.render("campgrounds/index",{campgrounds: allCampgrounds, page: 'campgrounds'}); + } + } + }); + } +}); + +//CREATE - add new campground to DB +router.post("/", isLoggedIn, isSafe, function(req, res){ + // get data from form and add to campgrounds array + var name = req.body.name; + var image = req.body.image; + var desc = req.body.description; + var author = { + id: req.user._id, + username: req.user.username + } + var cost = req.body.cost; + geocoder.geocode(req.body.location, function (err, data) { + var lat = data.results[0].geometry.location.lat; + var lng = data.results[0].geometry.location.lng; + var location = data.results[0].formatted_address; + var newCampground = {name: name, image: image, description: desc, cost: cost, author:author, location: location, lat: lat, lng: lng}; + // Create a new campground and save to DB + Campground.create(newCampground, function(err, newlyCreated){ + if(err){ + console.log(err); + } else { + //redirect back to campgrounds page + console.log(newlyCreated); + res.redirect("/campgrounds"); + } + }); + }); +}); + +//NEW - show form to create new campground +router.get("/new", isLoggedIn, function(req, res){ + res.render("campgrounds/new"); +}); + +// SHOW - shows more info about one campground +router.get("/:id", function(req, res){ + //find the campground with provided ID + Campground.findById(req.params.id).populate("comments").exec(function(err, foundCampground){ + if(err || !foundCampground){ + console.log(err); + req.flash('error', 'Sorry, that campground does not exist!'); + return res.redirect('/campgrounds'); + } + console.log(foundCampground) + //render show template with that campground + res.render("campgrounds/show", {campground: foundCampground}); + }); +}); + +// EDIT - shows edit form for a campground +router.get("/:id/edit", isLoggedIn, checkUserCampground, function(req, res){ + //render edit template with that campground + res.render("campgrounds/edit", {campground: req.campground}); +}); + +// PUT - updates campground in the database +router.put("/:id", isSafe, function(req, res){ + geocoder.geocode(req.body.location, function (err, data) { + var lat = data.results[0].geometry.location.lat; + var lng = data.results[0].geometry.location.lng; + var location = data.results[0].formatted_address; + var newData = {name: req.body.name, image: req.body.image, description: req.body.description, cost: req.body.cost, location: location, lat: lat, lng: lng}; + Campground.findByIdAndUpdate(req.params.id, {$set: newData}, function(err, campground){ + if(err){ + req.flash("error", err.message); + res.redirect("back"); + } else { + req.flash("success","Successfully Updated!"); + res.redirect("/campgrounds/" + campground._id); + } + }); + }); +}); + +// DELETE - removes campground and its comments from the database +router.delete("/:id", isLoggedIn, checkUserCampground, function(req, res) { + Comment.remove({ + _id: { + $in: req.campground.comments + } + }, function(err) { + if(err) { + req.flash('error', err.message); + res.redirect('/'); + } else { + req.campground.remove(function(err) { + if(err) { + req.flash('error', err.message); + return res.redirect('/'); + } + req.flash('error', 'Campground deleted!'); + res.redirect('/campgrounds'); + }); + } + }) +}); + +module.exports = router; diff --git a/routes/comments.js b/routes/comments.js new file mode 100755 index 0000000..c902d23 --- /dev/null +++ b/routes/comments.js @@ -0,0 +1,88 @@ +const express = require("express"); +const router = express.Router({mergeParams: true}); +const Campground = require("../models/campground"); +const Comment = require("../models/comment"); +const middleware = require("../middleware"); +const { isLoggedIn, checkUserComment, isAdmin } = middleware; + +//Comments New +router.get("/new", isLoggedIn, function(req, res){ + // find campground by id + console.log(req.params.id); + Campground.findById(req.params.id, function(err, campground){ + if(err){ + console.log(err); + } else { + res.render("comments/new", {campground: campground}); + } + }) +}); + +//Comments Create +router.post("/", isLoggedIn, function(req, res){ + //lookup campground using ID + Campground.findById(req.params.id, function(err, campground){ + if(err){ + console.log(err); + res.redirect("/campgrounds"); + } else { + Comment.create(req.body.comment, function(err, comment){ + if(err){ + console.log(err); + } else { + //add username and id to comment + comment.author.id = req.user._id; + comment.author.username = req.user.username; + //save comment + comment.save(); + campground.comments.push(comment); + campground.save(); + console.log(comment); + req.flash('success', 'Created a comment!'); + res.redirect('/campgrounds/' + campground._id); + } + }); + } + }); +}); + +router.get("/:commentId/edit", isLoggedIn, checkUserComment, function(req, res){ + res.render("comments/edit", {campground_id: req.params.id, comment: req.comment}); +}); + +router.put("/:commentId", isAdmin, function(req, res){ + Comment.findByIdAndUpdate(req.params.commentId, req.body.comment, function(err, comment){ + if(err){ + console.log(err); + res.render("edit"); + } else { + res.redirect("/campgrounds/" + req.params.id); + } + }); +}); + +router.delete("/:commentId", isLoggedIn, checkUserComment, function(req, res){ + // find campground, remove comment from comments array, delete comment in db + Campground.findByIdAndUpdate(req.params.id, { + $pull: { + comments: req.comment.id + } + }, function(err) { + if(err){ + console.log(err) + req.flash('error', err.message); + res.redirect('/'); + } else { + req.comment.remove(function(err) { + if(err) { + req.flash('error', err.message); + return res.redirect('/'); + } + req.flash('error', 'Comment deleted!'); + res.redirect("/campgrounds/" + req.params.id); + }); + } + }); +}); + +module.exports = router; \ No newline at end of file diff --git a/routes/index.js b/routes/index.js new file mode 100755 index 0000000..d707d23 --- /dev/null +++ b/routes/index.js @@ -0,0 +1,69 @@ +var express = require("express"); +var router = express.Router(); +var passport = require("passport"); +var User = require("../models/user"); + + +//root route +router.get("/", function(req, res){ + //res.render("index"); + res.redirect("/campgrounds"); +}); + +// show register form +router.get("/register", function(req, res){ + res.render("register", {page: 'register'}); +}); + +//handle sign up logic +router.post("/register", function(req, res){ + + var newUser = new User({username: req.body.username, + address: { + street1: req.body.address.street1, + street2: req.body.address.street2, + city: req.body.address.city, + state: req.body.address.state, + zip: req.body.address.zip}, + profession: req.body.profession, + employer: req.body.employer}); + if(req.body.adminCode === process.env.ADMIN_CODE) { + newUser.isAdmin = true; + } + + User.register(newUser, req.body.password, function(err, user){ + if(err){ + console.log(err); + return res.render("register", {error: err.message}); + } + passport.authenticate("local")(req, res, function(){ + req.flash("success", "Successfully Signed Up! Nice to meet you " + req.body.username); + res.redirect("/campgrounds"); + }); + }); +}); + +//show login form +router.get("/login", function(req, res){ + res.render("login", {page: 'login'}); +}); + +//handling login logic +router.post("/login", passport.authenticate("local", + { + successRedirect: "/campgrounds", + failureRedirect: "/login", + failureFlash: true, + successFlash: 'Welcome to YelpCamp!' + }), function(req, res){ +}); + +// logout route +router.get("/logout", function(req, res){ + req.logout(); + req.flash("success", "See you later!"); + res.redirect("/campgrounds"); +}); + + +module.exports = router; diff --git a/seeds.js b/seeds.js new file mode 100755 index 0000000..dee13be --- /dev/null +++ b/seeds.js @@ -0,0 +1,94 @@ +var mongoose = require("mongoose"); +var Campground = require("./models/campground"); +var Comment = require("./models/comment"); + + + +var data = [ + { + name: "Waylon Dalton", + party: "whig", + state: "MA", + chamber: "senate", + image: "https://www.designzzz.com/wp-content/uploads/2012/12/freestock_image_by_goldman555-d495w4s.jpg", + description: "I ate a baby", + general: 5000, + primary: 1000, + lat: 42.4, + long: -71, + author:{ + id: "59ecef01d17ab7684953ccb7", + username: "twonius" } + }, + { + name: "Justine Henderson", + party: "bull-moose", + state: "OR", + chamber: "house", + image: "http://productshow.ispeboston.org/wp-content/uploads/2015/06/Example-Headshot-A1.jpg", + description: "Who ya gonna call", + general: 5000, + primary: 1000, + lat: 42.4, + long: -71, + author:{ + id: "59ecef01d17ab7684953ccb7", + username: "twonius" } + }, + { + name: "Abdullah Lang", + party: "whig", + state: "MS", + chamber: "house", + image: "https://thumbs.dreamstime.com/z/attractive-40-year-old-businessman-headshot-761108.jpg", + description: "Can't touch this", + general: 5000, + primary: 1000, + lat: 42.4, + long: -71, + author:{ + id: "59ecef01d17ab7684953ccb7", + username: "twonius" } + } +] + +function seedDB(){ + //Remove all campgrounds + Campground.remove({}, function(err){ + if(err){ + console.log(err); + } + console.log("removed campaigns!"); + //add a few campgrounds + data.forEach(function(seed){ + Campground.create(seed, function(err, campground){ + if(err){ + console.log(err) + } else { + console.log("added a campaign"); + //create a comment + + Comment.create( + { + text: "#DontEatTheBaby", + amount: 5, + author: { + id: "59ecef01d17ab7684953ccb7" + } + }, function(err, comment){ + if(err){ + console.log(err); + } else { + campground.comments.push(comment); + campground.save(); + console.log("Created new comment"); + } + }); + } + }); + }); + }); + //add a few comments +} + +module.exports = seedDB; diff --git a/views/campgrounds/edit.ejs b/views/campgrounds/edit.ejs new file mode 100755 index 0000000..b16dd79 --- /dev/null +++ b/views/campgrounds/edit.ejs @@ -0,0 +1,35 @@ +<% include ../partials/header %> +
+

Edit <%= campground.name %>

+
+
+
+ + +
+
+ + + Click here for tutorial on how to copy unsplash urls. +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ Go Back +
+
+<% include ../partials/footer %> + diff --git a/views/campgrounds/index.ejs b/views/campgrounds/index.ejs new file mode 100755 index 0000000..79633b4 --- /dev/null +++ b/views/campgrounds/index.ejs @@ -0,0 +1,36 @@ +<% include ../partials/header %> + +
+
+

DWNATE

+

Money talks

+ <%#

+ Add New Campground +

%> +

+

+

+
+
+ +
+ <% campgrounds.forEach(function(campground){ %> +
+
+ +
+

<%= campground.name %>

+
+

+ More Info +

+
+
+ <% }); %> +
+ +<% include ../partials/footer %> diff --git a/views/campgrounds/new.ejs b/views/campgrounds/new.ejs new file mode 100755 index 0000000..8e980ae --- /dev/null +++ b/views/campgrounds/new.ejs @@ -0,0 +1,35 @@ +<% include ../partials/header %> +
+

Create a New Campground

+
+
+
+ + +
+
+ + + Click here for tutorial on how to copy unsplash urls. +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ Go Back +
+
+<% include ../partials/footer %> + diff --git a/views/campgrounds/show.ejs b/views/campgrounds/show.ejs new file mode 100755 index 0000000..ba5cdc3 --- /dev/null +++ b/views/campgrounds/show.ejs @@ -0,0 +1,118 @@ +<% include ../partials/header %> + +
+
+

<%=campground.name%>

+

<%= campground.description %>

+
+ +
+ +
+
+
+ +
+
+
+
+

Totals

+
+
+

Support

+ +
+

$<%= campground.general %> General Election

+
+ General +
+
+
+

$<%= campground.primary %> Party Primary

+
+ Primary +
+
+
+ +

DWNATE

+
+

-$<%= campground.general %> General Election

+
+ General +
+
+
+

-$<%= campground.primary %> Party Primary

+
+ Primary +
+
+ +
+

Info

+
+
+
State: <%= campground.state %>
+
Party: <%= campground.party %>
+
Chamber: <%= campground.chamber %>
+
+
+ + + + +
+ +
+ +
+

Trending Tags

+
+
+ <% campground.comments.forEach(function(comment){ %> +
+
+ <%= comment.author.username %> + <%= moment(comment.createdAt).fromNow() %> +
+ <%= comment.text %> : -$<%= comment.amount %> + +
+
+
+
+ <% }) %> +
+ + + + + +<% include ../partials/footer %> diff --git a/views/comments/edit.ejs b/views/comments/edit.ejs new file mode 100755 index 0000000..104f37a --- /dev/null +++ b/views/comments/edit.ejs @@ -0,0 +1,17 @@ +<% include ../partials/header %> +
+

Edit Comment

+
+
+
+ +
+
+ +
+
+ Go Back +
+
+<% include ../partials/footer %> + diff --git a/views/comments/new.ejs b/views/comments/new.ejs new file mode 100755 index 0000000..0001c9e --- /dev/null +++ b/views/comments/new.ejs @@ -0,0 +1,17 @@ +<% include ../partials/header %> +
+

DWNATE <%= campground.name %>

+
+
+
+ + +
+
+ +
+
+ Go Back +
+
+<% include ../partials/footer %> diff --git a/views/landing.ejs b/views/landing.ejs new file mode 100755 index 0000000..9bc9d3c --- /dev/null +++ b/views/landing.ejs @@ -0,0 +1,28 @@ + + + + + + + DWNATE + + + + + + +
+

DWNATE

+ Get Started +
+ + + + + diff --git a/views/login.ejs b/views/login.ejs new file mode 100755 index 0000000..e21e912 --- /dev/null +++ b/views/login.ejs @@ -0,0 +1,20 @@ +<% include ./partials/header %> +
+

Login

+
+
+
+ +
+
+ +
+
+ +
+
+ Go Back +
+
+<% include ./partials/footer %> + diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs new file mode 100755 index 0000000..fa4b129 --- /dev/null +++ b/views/partials/footer.ejs @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/views/partials/header.ejs b/views/partials/header.ejs new file mode 100755 index 0000000..dd27982 --- /dev/null +++ b/views/partials/header.ejs @@ -0,0 +1,50 @@ + + + + + + + DWNATE + + + + + + +
+ <% if(error && error.length > 0) { %> +

<%=error %>

+ <% } %> + + <% if(success && success.length > 0) { %> +

<%= success %>

+ <% } %> +
+
diff --git a/views/register.ejs b/views/register.ejs new file mode 100755 index 0000000..e3864c0 --- /dev/null +++ b/views/register.ejs @@ -0,0 +1,37 @@ +<% include ./partials/header %> +
+

Sign Up

+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ Go Back +
+
+<% include ./partials/footer %>