Skip to content

Commit 268c81a

Browse files
authored
Merge pull request #673 from fooker/master
Allow posting new note with content
2 parents 5d9a2c3 + f476018 commit 268c81a

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/response.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ function newNote (req, res, next) {
119119
}
120120
models.Note.create({
121121
ownerId: owner,
122-
alias: req.alias ? req.alias : null
122+
alias: req.alias ? req.alias : null,
123+
content: req.body ? req.body : ''
123124
}).then(function (note) {
124125
return res.redirect(config.serverurl + '/' + LZString.compressToBase64(note.id))
125126
}).catch(function (err) {

lib/web/noteRouter.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ const Router = require('express').Router
44

55
const response = require('../response')
66

7+
const {markdownParser} = require('./utils')
8+
79
const noteRouter = module.exports = Router()
810

911
// get new note
1012
noteRouter.get('/new', response.newNote)
13+
// post new note with content
14+
noteRouter.post('/new', markdownParser, response.newNote)
1115
// get publish note
1216
noteRouter.get('/s/:shortid', response.showPublishNote)
1317
// publish note actions

lib/web/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@ exports.urlencodedParser = bodyParser.urlencoded({
77
extended: false,
88
limit: 1024 * 1024 * 10 // 10 mb
99
})
10+
11+
// create text/markdown parser
12+
exports.markdownParser = bodyParser.text({
13+
inflate: true,
14+
type: ['text/plain', 'text/markdown'],
15+
limit: 1024 * 1024 * 10 // 10 mb
16+
})

0 commit comments

Comments
 (0)