mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
Allow posting new note with content
Signed-off-by: Dustin Frisch <fooker@lab.sh>
This commit is contained in:
parent
a8fa888317
commit
f47601857e
3 changed files with 13 additions and 1 deletions
|
@ -117,7 +117,8 @@ function newNote (req, res, next) {
|
||||||
}
|
}
|
||||||
models.Note.create({
|
models.Note.create({
|
||||||
ownerId: owner,
|
ownerId: owner,
|
||||||
alias: req.alias ? req.alias : null
|
alias: req.alias ? req.alias : null,
|
||||||
|
content: req.body ? req.body : ''
|
||||||
}).then(function (note) {
|
}).then(function (note) {
|
||||||
return res.redirect(config.serverurl + '/' + LZString.compressToBase64(note.id))
|
return res.redirect(config.serverurl + '/' + LZString.compressToBase64(note.id))
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
|
|
|
@ -4,10 +4,14 @@ const Router = require('express').Router
|
||||||
|
|
||||||
const response = require('../response')
|
const response = require('../response')
|
||||||
|
|
||||||
|
const {markdownParser} = require('./utils')
|
||||||
|
|
||||||
const noteRouter = module.exports = Router()
|
const noteRouter = module.exports = Router()
|
||||||
|
|
||||||
// get new note
|
// get new note
|
||||||
noteRouter.get('/new', response.newNote)
|
noteRouter.get('/new', response.newNote)
|
||||||
|
// post new note with content
|
||||||
|
noteRouter.post('/new', markdownParser, response.newNote)
|
||||||
// get publish note
|
// get publish note
|
||||||
noteRouter.get('/s/:shortid', response.showPublishNote)
|
noteRouter.get('/s/:shortid', response.showPublishNote)
|
||||||
// publish note actions
|
// publish note actions
|
||||||
|
|
|
@ -7,3 +7,10 @@ exports.urlencodedParser = bodyParser.urlencoded({
|
||||||
extended: false,
|
extended: false,
|
||||||
limit: 1024 * 1024 * 10 // 10 mb
|
limit: 1024 * 1024 * 10 // 10 mb
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// create text/markdown parser
|
||||||
|
exports.markdownParser = bodyParser.text({
|
||||||
|
inflate: true,
|
||||||
|
type: ['text/plain', 'text/markdown'],
|
||||||
|
limit: 1024 * 1024 * 10 // 10 mb
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue