Skip to content

Commit

Permalink
Merge pull request #2 from moonpatel/branch1
Browse files Browse the repository at this point in the history
boilerplate added
  • Loading branch information
moonpatel authored Aug 16, 2022
2 parents 59c8b66 + 46596ab commit ee93c13
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 83 deletions.
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const express = require('express')
const mongoose = require('mongoose')
const methodOverride = require('method-override')
const ejsMate = require('ejs-mate')
const path = require('path')
// require models
const Campground = require('./models/campgrounds')
Expand All @@ -19,6 +20,7 @@ db.once("open", () => console.log("Database connected"))
// create an express application object
const app = express()

app.engine('ejs',ejsMate)
// set parameters for rendering templates
app.set('view engine','ejs')
app.set('views',path.join(__dirname,'views'))
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"license": "ISC",
"dependencies": {
"ejs": "^3.1.8",
"ejs-mate": "^4.0.0",
"express": "^4.18.1",
"method-override": "^3.0.0",
"mongoose": "^6.5.2"
Expand Down
17 changes: 2 additions & 15 deletions views/campgrounds/index.ejs
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Campgrounds</title>
</head>

<body>
<% layout('layouts/boilerplate.ejs') %>
<h1>YelpCamp Campgrounds</h1>
<p>
<a href="/campgrounds/new">Add new campground</a>
Expand All @@ -21,7 +11,4 @@
</a>
</li>
<% } %>
</ul>
</body>

</html>
</ul>
41 changes: 13 additions & 28 deletions views/campgrounds/show.ejs
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<%= c.title %>
</title>
</head>

<body>
<h1><%= c.title %></h1>
<p>
Title: <%= c.title %>
<% layout('layouts/boilerplate.ejs') %>
<h1><%= c.title %></h1>
<p>
Title: <%= c.title %>
<br>
Location: <%= c.location %>
</p>
<p>
<a href="/campgrounds">Back</a>
<a href="/campgrounds/<%= c._id %>/edit">Edit campground</a>
<form action="/campgrounds/<%= c._id %>?_method=DELETE" method="post">
<button>Delete Campground</button>
</form>
</p>
</body>

</html>
Location: <%= c.location %>
</p>
<p>
<a href="/campgrounds">Back</a>
<a href="/campgrounds/<%= c._id %>/edit">Edit campground</a>
<form action="/campgrounds/<%= c._id %>?_method=DELETE" method="post">
<button>Delete Campground</button>
</form>
</p>
16 changes: 4 additions & 12 deletions views/edit.ejs
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit campground</title>
</head>
<body>
<% layout('layouts/boilerplate.ejs') %>


<h1>Edit campground</h1>
<form action="/campgrounds/<%= cg._id %>?_method=PUT" method="post">
<input type="text" name="campground[title]" value="<%=cg.title%>" placeholder="Title">
<input type="text" name="campground[location]" value="<%=cg.location%>" placeholder="Location">
<button>Edit campground</button>
</form>
</body>
</html>
</form>
14 changes: 2 additions & 12 deletions views/home.ejs
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
</head>
<body>
<h1>YelpCamp</h1>
</body>
</html>
<% layout('./layouts/boilerplate.ejs') %>
<h1>YelpCamp</h1>
12 changes: 12 additions & 0 deletions views/layouts/boilerplate.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> YelpCamp </title>
</head>
<body>
<%- body -%>
</body>
</html>
19 changes: 3 additions & 16 deletions views/new.ejs
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Campground</title>
<style>
input, button {
display: block;
}
</style>
</head>
<body>
<% layout('layouts/boilerplate.ejs') %>


<h1>Add a new Campground</h1>
<form action="/campgrounds" method="post">
<input type="text" name="campground[title]" id="title" placeholder="Title">
<input type="text" name="campground[location]" id="location" placeholder="Location">
<button>Submit</button>
</form>
</body>
</html>

0 comments on commit ee93c13

Please sign in to comment.