<%= arr[i].USER %>
+<%= arr[i].TITLE %>
+<%= arr[i].CONTENT %>
+ +0
+diff --git a/models/blog.js b/models/blog.js index 7f8cc0e..8c7129f 100644 --- a/models/blog.js +++ b/models/blog.js @@ -3,8 +3,9 @@ var currBlog = []; module.exports = class newBlog { - constructor(title, content) + constructor(user, title, content) { + this.user = user; this.title = title; this.content = content; this.id = Math.random().toString(); @@ -12,7 +13,7 @@ module.exports = class newBlog save() { - const tmp = {TITLE:this.title, CONTENT:this.content, ID:this.id}; + const tmp = {USER:this.user, TITLE:this.title, CONTENT:this.content, ID:this.id}; arr.push(tmp); currBlog = []; currBlog.push(tmp); diff --git a/public/css/home.css b/public/css/home.css index 342eff0..85bc807 100644 --- a/public/css/home.css +++ b/public/css/home.css @@ -261,6 +261,13 @@ body background-color: rgb(107, 34, 176); } +.null +{ + font:17px helvetica-reg; + color:rgba(0, 0, 0, 0.4); + margin:30px auto 0px auto; +} + @media screen and (min-width:800px) { .topbar diff --git a/public/css/myBlogs.css b/public/css/myBlogs.css index 342eff0..85bc807 100644 --- a/public/css/myBlogs.css +++ b/public/css/myBlogs.css @@ -261,6 +261,13 @@ body background-color: rgb(107, 34, 176); } +.null +{ + font:17px helvetica-reg; + color:rgba(0, 0, 0, 0.4); + margin:30px auto 0px auto; +} + @media screen and (min-width:800px) { .topbar diff --git a/routes/slash-home.js b/routes/slash-home.js index 22fdf93..a03affd 100644 --- a/routes/slash-home.js +++ b/routes/slash-home.js @@ -1,9 +1,12 @@ const exp = require('express'); +const newBlog = require('../models/blog'); const route = exp.Router(); -const path = require('path'); route.get('/home', (req,res) => { - res.sendFile(path.join(__dirname, '../', 'views', 'home.html')); + const arr = newBlog.getAllBLogs(); + const data ={arr:arr}; + + res.render('home', data); }) module.exports = route; \ No newline at end of file diff --git a/routes/slash-post.js b/routes/slash-post.js index 3012c5f..99c3b82 100644 --- a/routes/slash-post.js +++ b/routes/slash-post.js @@ -9,13 +9,13 @@ route.get('/post', (req,res) => { }) route.post('/post', (req,res) => { - const obj = new newBlog(req.body.TITLE, req.body.BLOG); + const currProfile = addProfile.getCurrentUser(); + + const obj = new newBlog(currProfile[0].USERNAME, req.body.TITLE, req.body.BLOG); obj.save(); const latestBlog = newBlog.getLastBlog(); - const currProfile = addProfile.getCurrentUser(); - addProfile.saveBlog(latestBlog[0].ID, currProfile[0].USERNAME); res.redirect('/home'); }) diff --git a/views/home.ejs b/views/home.ejs new file mode 100644 index 0000000..0e7286b --- /dev/null +++ b/views/home.ejs @@ -0,0 +1,75 @@ + + +
+LATEST BLOGS
+ + <% if(arr.length==0){ %> +No Latest Blogs Posted :(
+ <% } else{ %> + <% for(let i=0; i<%= arr[i].USER %>
+<%= arr[i].TITLE %>
+<%= arr[i].CONTENT %>
+ +0
+LATEST BLOGS
+No Latest Blogs Posted :(
+