From a013c9d3bc0eb98c935e80bdb694c1a1cf7bd4c4 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 15 Aug 2016 11:25:27 +0800 Subject: Update slide mode to show extra info and support url actions and support disqus via yaml-metadata --- lib/response.js | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) mode change 100644 => 100755 lib/response.js (limited to 'lib/response.js') diff --git a/lib/response.js b/lib/response.js old mode 100644 new mode 100755 index 23818da8..39d83ca2 --- a/lib/response.js +++ b/lib/response.js @@ -47,6 +47,7 @@ var response = { showIndex: showIndex, noteActions: noteActions, publishNoteActions: publishNoteActions, + publishSlideActions: publishSlideActions, githubActions: githubActions, gitlabActions: gitlabActions }; @@ -241,7 +242,8 @@ function showPublishNote(req, res, next) { useCDN: config.usecdn, lastchangeuserprofile: note.lastchangeuser ? models.User.parseProfile(note.lastchangeuser.profile) : null, robots: meta.robots || false, //default allow robots - GA: meta.GA + GA: meta.GA, + disqus: meta.disqus }; return renderPublish(data, res); }).catch(function (err) { @@ -410,6 +412,20 @@ function publishNoteActions(req, res, next) { }); } +function publishSlideActions(req, res, next) { + findNote(req, res, function (note) { + var action = req.params.action; + switch (action) { + case "edit": + res.redirect(config.serverurl + '/' + (note.alias ? note.alias : LZString.compressToBase64(note.id))); + break; + default: + res.redirect(config.serverurl + '/p/' + note.shortid); + break; + } + }); +} + function githubActions(req, res, next) { var noteId = req.params.noteId; findNote(req, res, function (note) { @@ -530,6 +546,13 @@ function gitlabActionProjects(req, res, note) { } function showPublishSlide(req, res, next) { + var include = [{ + model: models.User, + as: "owner" + }, { + model: models.User, + as: "lastchangeuser" + }]; findNote(req, res, function (note) { // force to use short id var shortid = req.params.shortid; @@ -549,26 +572,34 @@ function showPublishSlide(req, res, next) { //na } if (!meta) meta = {}; + var createtime = note.createdAt; + var updatetime = note.lastchangeAt; var text = S(body).escapeHTML().s; var title = models.Note.decodeTitle(note.title); title = models.Note.generateWebTitle(meta.title || title); var slides = md.slidify(text, slideOptions); var origin = config.serverurl; var data = { - url: origin, title: title, description: meta.description, + viewcount: note.viewcount, + createtime: createtime, + updatetime: updatetime, + url: origin, slides: slides, meta: JSON.stringify(obj.meta || {}), + useCDN: config.usecdn, + lastchangeuserprofile: note.lastchangeuser ? models.User.parseProfile(note.lastchangeuser.profile) : null, + robots: meta.robots || false, //default allow robots GA: meta.GA, - useCDN: config.usecdn + disqus: meta.disqus }; return renderPublishSlide(data, res); }).catch(function (err) { logger.error(err); return response.errorInternalError(res); }); - }); + }, include); } function renderPublishSlide(data, res) { -- cgit v1.2.3