Rename actions.js to controller.js and rename functions to be more descriptive

Move postNote to NoteController and rename to createFromPost

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2019-10-27 14:40:36 +01:00
parent afb317b551
commit 30487f7c01
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB
3 changed files with 33 additions and 34 deletions

View file

@ -9,7 +9,7 @@ var config = require('./config')
var logger = require('./logger')
var models = require('./models')
const noteUtil = require('./web/note/util')
const noteActions = require('./web/note/actions')
const noteController = require('./web/note/controller')
const errors = require('./errors')
// public
@ -17,7 +17,6 @@ var response = {
showNote: showNote,
showPublishNote: showPublishNote,
showIndex: showIndex,
postNote: postNote,
publishNoteActions: publishNoteActions,
githubActions: githubActions,
gitlabActions: gitlabActions
@ -70,17 +69,6 @@ function responseCodiMD (res, note) {
})
}
function postNote (req, res, next) {
var body = ''
if (req.body && req.body.length > config.documentMaxLength) {
return errors.errorTooLong(res)
} else if (req.body) {
body = req.body
}
body = body.replace(/[\r]/g, '')
return noteUtil.newNote(req, res, body)
}
function showNote (req, res, next) {
noteUtil.findNote(req, res, function (note) {
// force to use note id
@ -156,7 +144,7 @@ function publishNoteActions (req, res, next) {
var action = req.params.action
switch (action) {
case 'download':
noteActions.actionDownload(req, res, note)
noteController.downloadMarkdown(req, res, note)
break
case 'edit':
res.redirect(config.serverURL + '/' + (note.alias ? note.alias : models.Note.encodeNoteId(note.id)) + '?both')