From f78540c3fbf109d6ccf2d92c5b1cf0148c88f722 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 27 Oct 2019 13:51:53 +0100 Subject: Move note actions to their own file. Because of circular import problems, this commit also moves the error messages from response.js to errors.js Signed-off-by: David Mehren --- lib/web/note/router.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/web/note/router.js (limited to 'lib/web/note/router.js') diff --git a/lib/web/note/router.js b/lib/web/note/router.js new file mode 100644 index 00000000..e23b7f64 --- /dev/null +++ b/lib/web/note/router.js @@ -0,0 +1,32 @@ +'use strict' + +const Router = require('express').Router + +const response = require('../../response') + +const { markdownParser } = require('../utils') + +const router = module.exports = Router() + +const noteActions = require('./actions') + +// get new note +router.get('/new', response.postNote) +// post new note with content +router.post('/new', markdownParser, response.postNote) +// post new note with content and alias +router.post('/new/:noteId', markdownParser, response.postNote) +// get publish note +router.get('/s/:shortid', response.showPublishNote) +// publish note actions +router.get('/s/:shortid/:action', response.publishNoteActions) +// get publish slide +router.get('/p/:shortid', response.showPublishSlide) +// publish slide actions +router.get('/p/:shortid/:action', response.publishSlideActions) +// get note by id +router.get('/:noteId', response.showNote) +// note actions +router.get('/:noteId/:action', noteActions.doAction) +// note actions with action id +router.get('/:noteId/:action/:actionId', noteActions.doAction) -- cgit v1.2.3 From afb317b55155eed2cfcad0fee5aba2107dc0b106 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 27 Oct 2019 14:27:15 +0100 Subject: Move slide actions to own file Signed-off-by: David Mehren --- lib/web/note/router.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/web/note/router.js') diff --git a/lib/web/note/router.js b/lib/web/note/router.js index e23b7f64..2a6bf2aa 100644 --- a/lib/web/note/router.js +++ b/lib/web/note/router.js @@ -9,6 +9,7 @@ const { markdownParser } = require('../utils') const router = module.exports = Router() const noteActions = require('./actions') +const slide = require('./slide') // get new note router.get('/new', response.postNote) @@ -21,9 +22,9 @@ router.get('/s/:shortid', response.showPublishNote) // publish note actions router.get('/s/:shortid/:action', response.publishNoteActions) // get publish slide -router.get('/p/:shortid', response.showPublishSlide) +router.get('/p/:shortid', slide.showPublishSlide) // publish slide actions -router.get('/p/:shortid/:action', response.publishSlideActions) +router.get('/p/:shortid/:action', slide.publishSlideActions) // get note by id router.get('/:noteId', response.showNote) // note actions -- cgit v1.2.3 From 30487f7c01dc15435d86d95d24257853d7930154 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 27 Oct 2019 14:40:36 +0100 Subject: 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 --- lib/web/note/router.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/web/note/router.js') diff --git a/lib/web/note/router.js b/lib/web/note/router.js index 2a6bf2aa..39da4c2c 100644 --- a/lib/web/note/router.js +++ b/lib/web/note/router.js @@ -8,15 +8,15 @@ const { markdownParser } = require('../utils') const router = module.exports = Router() -const noteActions = require('./actions') +const noteController = require('./controller') const slide = require('./slide') // get new note -router.get('/new', response.postNote) +router.get('/new', noteController.createFromPOST) // post new note with content -router.post('/new', markdownParser, response.postNote) +router.post('/new', markdownParser, noteController.createFromPOST) // post new note with content and alias -router.post('/new/:noteId', markdownParser, response.postNote) +router.post('/new/:noteId', markdownParser, noteController.createFromPOST) // get publish note router.get('/s/:shortid', response.showPublishNote) // publish note actions @@ -28,6 +28,6 @@ router.get('/p/:shortid/:action', slide.publishSlideActions) // get note by id router.get('/:noteId', response.showNote) // note actions -router.get('/:noteId/:action', noteActions.doAction) +router.get('/:noteId/:action', noteController.doAction) // note actions with action id -router.get('/:noteId/:action/:actionId', noteActions.doAction) +router.get('/:noteId/:action/:actionId', noteController.doAction) -- cgit v1.2.3 From dee62ce571cc3e33f60499e3ed9cfa4cc5c2f0da Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 27 Oct 2019 14:59:44 +0100 Subject: Move showNote to note controller Signed-off-by: David Mehren --- lib/web/note/router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/web/note/router.js') diff --git a/lib/web/note/router.js b/lib/web/note/router.js index 39da4c2c..e4f867b2 100644 --- a/lib/web/note/router.js +++ b/lib/web/note/router.js @@ -26,7 +26,7 @@ router.get('/p/:shortid', slide.showPublishSlide) // publish slide actions router.get('/p/:shortid/:action', slide.publishSlideActions) // get note by id -router.get('/:noteId', response.showNote) +router.get('/:noteId', noteController.showNote) // note actions router.get('/:noteId/:action', noteController.doAction) // note actions with action id -- cgit v1.2.3 From 2bc4233ba80346e60ed4840714a9aa347ccdb361 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 27 Oct 2019 15:22:14 +0100 Subject: Move showPublishNote and publishNoteActions to note controller Signed-off-by: David Mehren --- lib/web/note/router.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lib/web/note/router.js') diff --git a/lib/web/note/router.js b/lib/web/note/router.js index e4f867b2..cf6fdf43 100644 --- a/lib/web/note/router.js +++ b/lib/web/note/router.js @@ -1,9 +1,6 @@ 'use strict' const Router = require('express').Router - -const response = require('../../response') - const { markdownParser } = require('../utils') const router = module.exports = Router() @@ -18,9 +15,9 @@ router.post('/new', markdownParser, noteController.createFromPOST) // post new note with content and alias router.post('/new/:noteId', markdownParser, noteController.createFromPOST) // get publish note -router.get('/s/:shortid', response.showPublishNote) +router.get('/s/:shortid', noteController.showPublishNote) // publish note actions -router.get('/s/:shortid/:action', response.publishNoteActions) +router.get('/s/:shortid/:action', noteController.publishNoteActions) // get publish slide router.get('/p/:shortid', slide.showPublishSlide) // publish slide actions -- cgit v1.2.3