-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe8701a
commit 0791719
Showing
7 changed files
with
86 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const arr = []; | ||
var currBlog = []; | ||
|
||
module.exports = class newBlog | ||
{ | ||
constructor(title, content) | ||
{ | ||
this.title = title; | ||
this.content = content; | ||
this.id = Math.random().toString(); | ||
} | ||
|
||
save() | ||
{ | ||
const tmp = {TITLE:this.title, CONTENT:this.content, ID:this.id}; | ||
arr.push(tmp); | ||
currBlog = []; | ||
currBlog.push(tmp); | ||
} | ||
|
||
static getAllBLogs(){return arr}; | ||
static getLastBlog(){return currBlog}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
const exp = require('express'); | ||
const route = exp.Router(); | ||
const path = require('path'); | ||
const newBlog = require('../models/blog'); | ||
const addProfile = require('../models/credentials'); | ||
|
||
route.get('/post', (req,res) => { | ||
res.sendFile(path.join(__dirname, '../', 'views', 'post.html')); | ||
}) | ||
|
||
route.post('/post', (req,res) => { | ||
const obj = new newBlog(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'); | ||
}) | ||
|
||
module.exports = route; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters