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/response.js | 75 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 74 deletions(-) (limited to 'lib/response.js') diff --git a/lib/response.js b/lib/response.js index 033a83a6..934179fd 100644 --- a/lib/response.js +++ b/lib/response.js @@ -8,7 +8,6 @@ var request = require('request') var config = require('./config') var logger = require('./logger') var models = require('./models') -var utils = require('./utils') const noteUtil = require('./web/note/util') const noteActions = require('./web/note/actions') const errors = require('./errors') @@ -17,11 +16,9 @@ const errors = require('./errors') var response = { showNote: showNote, showPublishNote: showPublishNote, - showPublishSlide: showPublishSlide, showIndex: showIndex, postNote: postNote, publishNoteActions: publishNoteActions, - publishSlideActions: publishSlideActions, githubActions: githubActions, gitlabActions: gitlabActions } @@ -171,19 +168,7 @@ function publishNoteActions (req, res, next) { }) } -function publishSlideActions (req, res, next) { - noteUtil.findNote(req, res, function (note) { - var action = req.params.action - switch (action) { - case 'edit': - res.redirect(config.serverURL + '/' + (note.alias ? note.alias : models.Note.encodeNoteId(note.id)) + '?both') - break - default: - res.redirect(config.serverURL + '/p/' + note.shortid) - break - } - }) -} + function githubActions (req, res, next) { var noteId = req.params.noteId @@ -303,62 +288,4 @@ function gitlabActionProjects (req, res, note) { } } -function showPublishSlide (req, res, next) { - var include = [{ - model: models.User, - as: 'owner' - }, { - model: models.User, - as: 'lastchangeuser' - }] - noteUtil.findNote(req, res, function (note) { - // force to use short id - var shortid = req.params.shortid - if ((note.alias && shortid !== note.alias) || (!note.alias && shortid !== note.shortid)) { return res.redirect(config.serverURL + '/p/' + (note.alias || note.shortid)) } - note.increment('viewcount').then(function (note) { - if (!note) { - return errors.errorNotFound(res) - } - var body = note.content - var extracted = models.Note.extractMeta(body) - var markdown = extracted.markdown - var meta = models.Note.parseMeta(extracted.meta) - var createtime = note.createdAt - var updatetime = note.lastchangeAt - var title = models.Note.decodeTitle(note.title) - title = models.Note.generateWebTitle(meta.title || title) - var data = { - title: title, - description: meta.description || (markdown ? models.Note.generateDescription(markdown) : null), - viewcount: note.viewcount, - createtime: createtime, - updatetime: updatetime, - body: markdown, - theme: meta.slideOptions && utils.isRevealTheme(meta.slideOptions.theme), - meta: JSON.stringify(extracted.meta), - owner: note.owner ? note.owner.id : null, - ownerprofile: note.owner ? models.User.getProfile(note.owner) : null, - lastchangeuser: note.lastchangeuser ? note.lastchangeuser.id : null, - lastchangeuserprofile: note.lastchangeuser ? models.User.getProfile(note.lastchangeuser) : null, - robots: meta.robots || false, // default allow robots - GA: meta.GA, - disqus: meta.disqus, - cspNonce: res.locals.nonce, - dnt: req.headers.dnt - } - return renderPublishSlide(data, res) - }).catch(function (err) { - logger.error(err) - return errors.errorInternalError(res) - }) - }, include) -} - -function renderPublishSlide (data, res) { - res.set({ - 'Cache-Control': 'private' // only cache by client - }) - res.render('slide.ejs', data) -} - module.exports = response -- cgit v1.2.3