diff options
author | Wu Cheng-Han | 2016-08-15 11:25:27 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2016-08-15 11:25:27 +0800 |
commit | a013c9d3bc0eb98c935e80bdb694c1a1cf7bd4c4 (patch) | |
tree | 5078a64286601b5b476f9613ecaee39e6837aa1d /lib | |
parent | e12fae699981762a69a72f6f164c0ec0254ddcf2 (diff) |
Update slide mode to show extra info and support url actions and support disqus via yaml-metadata
Diffstat (limited to '')
-rw-r--r-- | lib/models/note.js | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | lib/response.js | 39 |
2 files changed, 37 insertions, 4 deletions
diff --git a/lib/models/note.js b/lib/models/note.js index 81013047..d1c073e9 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -241,6 +241,8 @@ module.exports = function (sequelize, DataTypes) { _meta.robots = meta.robots; if (meta.GA && (typeof meta.GA == "string" || typeof meta.GA == "number")) _meta.GA = meta.GA; + if (meta.disqus && (typeof meta.disqus == "string" || typeof meta.disqus == "number")) + _meta.disqus = meta.disqus; if (meta.slideOptions && (typeof meta.slideOptions == "object")) _meta.slideOptions = meta.slideOptions; } diff --git a/lib/response.js b/lib/response.js index 23818da8..39d83ca2 100644..100755 --- 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) { |