summaryrefslogtreecommitdiff
path: root/lib/response.js
diff options
context:
space:
mode:
authorWu Cheng-Han2016-08-15 11:25:27 +0800
committerWu Cheng-Han2016-08-15 11:25:27 +0800
commita013c9d3bc0eb98c935e80bdb694c1a1cf7bd4c4 (patch)
tree5078a64286601b5b476f9613ecaee39e6837aa1d /lib/response.js
parente12fae699981762a69a72f6f164c0ec0254ddcf2 (diff)
Update slide mode to show extra info and support url actions and support disqus via yaml-metadata
Diffstat (limited to 'lib/response.js')
-rwxr-xr-x[-rw-r--r--]lib/response.js39
1 files changed, 35 insertions, 4 deletions
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) {