Skip to content

Commit 69e5080

Browse files
not sure
1 parent 5f41296 commit 69e5080

File tree

8 files changed

+27
-90
lines changed

8 files changed

+27
-90
lines changed

.vscode/launch.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use IntelliSense to learn about possible Node.js debug attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"program": "${workspaceRoot}\\server.js"
12+
}
13+
]
14+
}

models/blog.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ module.exports = function(sequelize, DataTypes) {
55
allowNull: false,
66
validate: {
77
len: [1]
8-
},
9-
set(val) {
10-
this.setDataValue('routename', this.title.replace(/\s+/g, "").toLowerCase());
118
}
129
},
1310
website: {
@@ -32,12 +29,7 @@ module.exports = function(sequelize, DataTypes) {
3229
cumulative_rating: {
3330
type: DataTypes.DECIMAL(3,2),
3431
len: [1]
35-
},
36-
routename: {
37-
type: DataTypes.STRING,
38-
allowNull: false,
39-
defaultValue: "",
40-
}
32+
}
4133
},
4234
{
4335
timestamps: false

routes/blog-api-routes.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ module.exports = function(app) {
1010
});
1111
});
1212

13-
// Add blogs
14-
app.post("api/blogs", function(req, res) {
15-
db.Blog.create(req.body).then(function(dbBlog) {
16-
res.json(dbBlog);
17-
});
13+
// Add blog
14+
app.post("/api/blogs", function(req, res) {
15+
console.log("hey")
16+
console.log(req.body)
17+
// db.Blog.create(req.body).then(function(dbBlog) {
18+
// res.json(dbBlog);
19+
// });
1820
});
1921
};

routes/html-routes.js

-15
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,5 @@ module.exports = function(app) {
4949
})
5050

5151
});
52-
app.get("/users/:username", function(req, res) {
53-
var user;
54-
// Get users sorted by number of reviews
55-
db.User.findOne({
56-
include: [db.Review],
57-
where: {
58-
name: req.params.username
59-
}
60-
}).then(function(dbUser){
61-
user = res.json(dbUser);
62-
})
63-
console.log(JSON.stringify(user))
64-
// Send info to handlebars
65-
res.render();
66-
});
6752

6853
};

views/blog.handlebars

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{> layouts/navbar}}
2+
{{> navbar/navbar}}
33

44
<div class ="container">
55
<!-- Add cumulative rating later -->

views/index.handlebars

+2-58
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,7 @@
11
<!--page wrapper-->
22
<div class="container">
3-
<!--navbar-->
4-
<nav class="navbar navbar-expand-lg navbar-light bg-light">
5-
<a class="navbar-brand" href="#">The Blog Review</a>
6-
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
7-
aria-expanded="false" aria-label="Toggle navigation">
8-
<span class="navbar-toggler-icon"></span>
9-
</button>
10-
<div class="collapse navbar-collapse" id="navbarSupportedContent">
11-
<ul class="navbar-nav mr-auto">
12-
13-
<!--Modal to add a new blog-->
14-
<li class="nav-item">
15-
<button class="btn btn-outline-warning" data-toggle="modal" data-target=".bd-example-modal-lg">Add Blog</button>
16-
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
17-
<div class="modal-dialog modal-lg">
18-
<div class="modal-content addOne">
19-
<form>
20-
<div class="form-group row">
21-
<label for="inputEmail3" class="col-sm-2 col-form-label">Blog Title</label>
22-
<div class="col-sm-10">
23-
<input type="text" class="form-control" id="inputEmail3" placeholder="Title">
24-
</div>
25-
</div>
26-
<div class="form-group row">
27-
<label for="inputPassword3" class="col-sm-2 col-form-label">Website</label>
28-
<div class="col-sm-10">
29-
<input type="text" class="form-control" id="inputPassword3" placeholder="http://example.com">
30-
</div>
31-
</div>
32-
<div class="form-group row">
33-
<label for="inputPassword3" class="col-sm-2 col-form-label">Description</label>
34-
<div class="col-sm-10">
35-
<input type="text" class="form-control" id="inputPassword3">
36-
</div>
37-
</div>
38-
<div class="form-group row">
39-
<label for="inputPassword3" class="col-sm-2 col-form-label">Rating</label>
40-
<div class="col-sm-10">
41-
<input type="text" class="form-control" id="inputPassword3">
42-
</div>
43-
</div>
44-
<div class="form-group row">
45-
<div class="col-sm-10">
46-
<button type="submit" class="btn btn-outline-danger">Add</button>
47-
</div>
48-
</div>
49-
</form>
50-
</div>
51-
</div>
52-
</div>
53-
</li>
54-
</ul>
55-
<form class="form-inline my-2 my-lg-0">
56-
<input class="form-control mr-sm-2" type="text" placeholder="Search for a blog" aria-label="Search">
57-
<button class="btn btn-outline-primary my-2 my-sm-0" type="submit">Search</button>
58-
</form>
59-
</div>
60-
</nav>
3+
4+
{{> /navbar/navbar}}
615
<!--page header-->
626
<div class="row">
637
<div class="col header">

views/layouts/navbar.handlebars views/partials/navbar/navbar.handlebars

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
1414
<div class="modal-dialog modal-lg">
1515
<div class="modal-content addOne">
16-
<form>
16+
<form action="/api/blogs" method="POST">
1717
<div class="form-group row">
1818
<label for="inputEmail3" class="col-sm-2 col-form-label">Blog Title</label>
1919
<div class="col-sm-10">

views/user.handlebars

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{> layouts/navbar}}
2+
{{> navbar/navbar}}
33

44
<div class ="container">
55
<h1 class="mt-3 mb-3">{{user.name}}</h1>

0 commit comments

Comments
 (0)