Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b4253dd
init
Oct 24, 2017
90f9cfe
login, register, tour, tvshow routes
Oct 25, 2017
ae11453
added slug for tourname and showname
Oct 25, 2017
0cc121e
cart and nav bar
Oct 26, 2017
57e00d4
add reviews
Oct 26, 2017
a34a3c6
cart date and 3 pics per tour cannot work
Oct 26, 2017
872c62e
added date for tour in cart
Oct 26, 2017
135cd01
google api map and sidebar that is not functional
Oct 26, 2017
578e23b
delete tour in cart half
Oct 26, 2017
9fbba86
DELETE CART NOW WORKSSSSSSSS MY LIFEEEEEEEEEEE
Oct 27, 2017
63ecbec
nothing
Oct 27, 2017
bdceea5
initial commit
Oct 27, 2017
2419e5d
add price and many photos per tour
Oct 27, 2017
af5eb52
remove package.json
Oct 27, 2017
fdd9864
trying mobile feature
Oct 27, 2017
b6916b6
testing register page
Oct 27, 2017
6f392e8
test register second try
Oct 27, 2017
a5ce082
adding carousel
Oct 27, 2017
29747c9
navbar and imagesizing carousel
Oct 27, 2017
6478aaf
slider for tourlist details and music
Oct 27, 2017
89206f5
music off
Oct 27, 2017
453bf1d
googlemaps
Oct 27, 2017
6cbeb5e
google maps centering
Oct 27, 2017
654ba23
div colour for google maps words
Oct 27, 2017
ba23202
form css
Oct 27, 2017
2a85a1f
music
Oct 27, 2017
a224ea7
remove showname in tourdetails
Oct 27, 2017
9b0ae96
adding more shows
Oct 28, 2017
c051320
tourlist 4 grid
Oct 28, 2017
6c944d6
style tourdetails page, cart
Oct 28, 2017
3cff7ec
music and map
Oct 29, 2017
2463197
gogole maps live
Oct 29, 2017
0cb5597
finished readme
Oct 29, 2017
35ba75e
more css
Oct 29, 2017
aa6ba76
remove eg
Oct 29, 2017
384487e
tourpic resize
Oct 29, 2017
0d10f08
resize card
Oct 29, 2017
35b567c
music
Oct 30, 2017
01e73b6
music loop
Oct 30, 2017
a3d06a2
music
Oct 30, 2017
9b56596
include photos in img
Oct 30, 2017
b37b6ca
border-radius for pics
Oct 30, 2017
e14e7d1
password circle
Oct 30, 2017
f041975
input password name
Oct 30, 2017
08b9a3b
change live link
liyuan23 Nov 22, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
QUOTEAPI=9tlcYlk6RtW8iiRgt79o522Wv73oL7Iq
MONGODB_URI=mongodb://admin:aaaa@ds127105.mlab.com:27105/tvshowtours
ADMIN_CODE=meandyou23
SESSION_SECRET=tacocat
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
93 changes: 50 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,72 @@
# Your Project Name
# Fantasy Tours

This is the starter code for WDI projects. Please update this README file with information specific to your project. Replace this paragraph for instance, with a short description of your project. Then update the sections below. Refer to your project specificaion for instructions on how to submit your projects.
Fantasy Tours is a leading specialist tour operator featuring stunning locations from some of the biggest TV and film brands.

## Getting Started
We bring you to stunningly beautiful places, most of which are remote and hard to find. We trek you deep into old growth forests, along wild sea cliffs, across rocky beaches, into caves and crumbling medieval ruins. We have costumes, swords and wands available for use, at no extra cost. Experience the magic. Go all the way into your favourite fantasy.

Provide instructions here about how to get your project running on our local machine. Do we just need to clone and open a certain file or do we need to install anything first.

### Prerequisites

What is needed to install and run the project, how do we install them

```
Code example
```

### How to Use

A step by step guide on how to install and use the project, for example if this is a game, how do we play it.


```
Code example
```

More steps...
## Live Version
[Fantasy Tours](https://fantasytours.herokuapp.com)

```
until finished
```
## Table of Contents
1. Workflow
2. Time Management
6. Potential Improvements
8. External Libraries/Frameworks
9. Acknowledgements

## Workflow

## Tests
### User stories
As a user, I want to add tours that are related to my favourite films/tvshows into my cart so that I can book the tours for my future plans. I should not be able to add shows and tours.

Did you write automated tests? If so, how do we run them.
As an administrator, I want to add shows and the available tours for each show so that I can make sure they are appropriate.

### Wireframes
<img src="/public/img/wireframes.jpg" border = 2px solid black>

```
Code example
```
### ERD
<img src="/public/img/erd.png" border = 2px solid black>

## Live Version
### Routes
<img src="/public/img/routes.jpg" border = 2px solid black>

Where is this deployed online (github pages, heroku etc), give us the link and any access details we need.
## Time Management
* **Day 1, Monday**: Drew up wireframes, ERD, routes and Pseudocode. Added login, register and started making forms for creating tours and shows

## Built With
* **Day 2, Tuesday**: Added tvshow, tour routes for admin to add shows and tours to populate the database thereby finishing CRUD

What did you use to build it, list the technologies, plugins, gems, packages etc.
* **Day 3, Wednesday**: Added user routes for cart and show routes for general users to book tours

* [jQuery](http://jquery.com/) - jQuery for example is something you likely used
* **Day 4, Thursday**: Added reviews and google maps API

## Workflow
* **Day 5, Friday**: Spent a considerable amount of time on the delete tour in cart function and learning how to use materialize CSS

Did you write user stories, draw wireframes, use task tracking, produce ERDs? Did you use source control, with regular commits? Include links to them here.
* **Day 6/7, Saturday/Sunday**: More CSS

## Authors
## Potential Improvements
* Add an admin function so only admins can add shows/tours
* Add blackout dates for tours/specific tour dates with radio buttons for users to choose from
* Fix error when users who are not logged in try to make reviews
* Add proper payment function

Did you collaborate with others on this project, list them here
## External Libraries/Frameworks

* **John McClain** - *Responsible for keeping vests white* - [GithubUserName](https://github.com/GithubUserName)
* [jQuery](http://jquery.com/)
* [Materialize](http://materializecss.com/)
* [Font-Awesome Icon Library](http://fontawesome.io/)
* [Uploadcare PAAS](https://uploadcare.com/)
* [Node.js](https://nodejs.org/en/)
* [Express](http://expressjs.com/)
* [mLab (mongoDB Hosting)](https://mlab.com)
* [Heroku Cloud Server](https://www.heroku.com)
* [Mongoose](http://mongoosejs.com/)
* [Google Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/)

## Acknowledgments

* Hat tip to anyone who's code was used, for example [this was a useful starting point for creating this template](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2).

* [Brit Movie Tours](https://britmovietours.com/)
* [Games of Thrones Tours](http://www.gameofthronestours.com/)
* [Viator](https://www.viator.com/)
* [Propie, by Chris Ke](https://github.com/chriskejw/propie)
* [CityFix, by Jonathan Lim](https://github.com/jonathanlimes/cityfix)
* Instructors and Classmates at GA Singapore
30 changes: 30 additions & 0 deletions config/ppConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const passport = require('passport')
const LocalStrategy = require('passport-local').Strategy
const User = require('../models/user')

passport.serializeUser(function (user, done) {
done(null, user.id)
})

passport.deserializeUser(function(id, done) {
User.findById(id, function(err, user) {
done(err, user)
})
})

passport.use(new LocalStrategy({
usernameField: 'user[email]',
passwordField: 'user[password]'
}, function (email, password, done) {
User.findOne({ email: email }, function (err, user) {
if (err) return done(err)
if (!user) return done(null, false)
user.validPassword(password, (err, isMatch) => {
if (err) return done(null, false)
if (isMatch) return done(null, user)
return done(null, false, { message: 'mismatched'})
})
})
}))

module.exports = passport
20 changes: 20 additions & 0 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const isLoggedIn = (req, res, next) => {
if(req.user) {
res.redirect('/')
} else {
next()
}
}

const hasLoggedOut = (req, res, next) => {
if(req.user) {
next()
} else {
res.redirect('/')
}
}

module.exports = {
hasLoggedOut,
isLoggedIn
}
104 changes: 104 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
require('dotenv').config({ silent: true })

const dbUrl =
process.env.NODE_ENV === 'production' ? process.env.MONGODB_URI : 'mongodb://localhost/project2'
const port = process.env.PORT || 4000 // this is for our express server

const express = require('express')
const path = require('path') // for Public files
const mongoose = require('mongoose') // for DB
const exphbs = require('express-handlebars') // for Handlebars
const bodyParser = require('body-parser') // for accessing POST request
const methodOverride = require('method-override') // for accessing PUT / DELETE

const session = require('express-session')
const MongoStore = require('connect-mongo')(session)
const passport = require('./config/ppConfig')

const { hasLoggedOut, isLoggedIn } = require('./helpers')

const User = require('./models/user')
const Show = require('./models/show')

const register_routes = require('./routes/register_routes')
const tvshow_routes = require('./routes/tvshow_routes')
const login_routes = require('./routes/login_routes')
const tour_routes = require('./routes/tour_routes')
const review_routes = require('./routes/review_routes')
const show_routes = require('./routes/show_routes')
const user_routes = require('./routes/user_routes')

const app = express()

app.engine('handlebars', exphbs({ defaultLayout: 'main'}))
app.set('view engine', 'handlebars')

// MIDDLEWARES (explained on thursday)

app.use(express.static(path.join(__dirname, 'public')))
app.use(function (req, res, next) {
console.log('Method: ' + req.method + ' Path: ' + req.url)
next()
})

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: true
}))

app.use(methodOverride('_method'))

mongoose.Promise = global.Promise
mongoose.connect(dbUrl, {
useMongoClient: true
})
.then(
() => { console.log('db is connected') },
(err) => { console.log(err) }
)

app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true,
store: new MongoStore({ mongooseConnection: mongoose.connection })
}))

app.use(passport.initialize())
app.use(passport.session())

///----------------------------------------
app.use((req, res, next) => {
app.locals.user = req.user // we'll only `req.user` if we managed to log in
next()
})

// HOMEPAGE
app.get('/', (req, res) => {
Show.find()
.then((data) => {
res.render('home', { showlist: data })
})
})

app.use('/login', login_routes)
app.use('/register', register_routes)
app.use('/addtvshows', tvshow_routes)
app.use('/addtours', tour_routes)
app.use('/review', review_routes)
app.use('/show', show_routes)
app.use(`/:slug`, user_routes)

app.get('/profile', hasLoggedOut, (req, res) => {
res.send(req.user)
})

app.get('/logout', hasLoggedOut, (req, res) => {
req.logout()
res.redirect('/')
})

// opening the port for express
app.listen(port, () => {
console.log(`Server is running on ${port}`)
})
16 changes: 16 additions & 0 deletions models/review.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const mongoose = require('mongoose')
const Schema = mongoose.Schema

const reviewSchema = new Schema({
title: String,
description: String,
author: {
type: Schema.Types.ObjectId,
ref: 'User'
},
tourSlug: String
})

const Review = mongoose.model('Review', reviewSchema)

module.exports = Review
13 changes: 13 additions & 0 deletions models/show.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mongoose = require('mongoose')
const Schema = mongoose.Schema

const showSchema = new Schema({
name: String,
description: String,
showpic: String,
slug: String
})

const Show = mongoose.model('Show', showSchema)

module.exports = Show
18 changes: 18 additions & 0 deletions models/tour.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const mongoose = require('mongoose')
const Schema = mongoose.Schema

const tourSchema = new Schema({
showname: String, // how to join with other database for the show name
name: String,
slug: String,
overview: String,
highlights: String,
price: String,
pictureurl1: String,
pictureurl2: String,
pictureurl3: String
})

const Tour = mongoose.model('Tour', tourSchema)

module.exports = Tour
40 changes: 40 additions & 0 deletions models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const mongoose = require('mongoose')
const Schema = mongoose.Schema

const bcrypt = require('bcrypt')
const tourId = { type: Schema.Types.ObjectId, ref: 'Tour' }

const userSchema = new Schema({
name: String,
email: String,
password: String,
slug: String,
admin: Boolean,
cart:
[{
tourDate: String,
bookedTour: tourId
}]
})

userSchema.pre('save', function(next) {
var user = this
user.slug = user.name.toLowerCase().split(' ').join('-')

// to avoid rehashing the password everytime user.save() is called
if (!user.isModified('password')) return next()

bcrypt.hash(user.password, 10)
.then(hash => {
user.password = hash
next()
})
})

userSchema.methods.validPassword = function (plainPassword, callback) {
bcrypt.compare(plainPassword, this.password, callback)
}

const User = mongoose.model('User', userSchema)

module.exports = User
21 changes: 20 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,24 @@
"main": "index.js",
"repository": "https://github.com/wdi-sg/project-2.git",
"author": "Prima Aulia Gusta <primaulia@gmail.com>",
"license": "MIT"
"license": "MIT",
"scripts": {
"start": "nodemon index"
},
"dependencies": {
"bcrypt": "^1.0.3",
"body-parser": "^1.18.2",
"connect-mongo": "^2.0.0",
"dotenv": "^4.0.0",
"express": "^4.16.2",
"express-handlebars": "^3.0.0",
"express-session": "^1.15.6",
"heroku": "^0.2.0",
"materialize-css": "^0.100.2",
"method-override": "^2.3.10",
"mongoose": "^4.12.4",
"nodemon": "^1.12.1",
"passport": "^0.4.0",
"passport-local": "^1.0.0"
}
}
Binary file added public/.DS_Store
Binary file not shown.
Binary file added public/audio/.DS_Store
Binary file not shown.
Binary file added public/audio/song.mp3
Binary file not shown.
Loading