diff options
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) { | 
