Sotaro KARASAWA 10 лет назад
Родитель
Сommit
fd78df91be
4 измененных файлов с 38 добавлено и 19 удалено
  1. 1 0
      lib/routes/index.js
  2. 25 2
      lib/routes/page.js
  3. 12 10
      resource/js/crowi-form.js
  4. 0 7
      resource/js/crowi.js

+ 1 - 0
lib/routes/index.js

@@ -85,6 +85,7 @@ module.exports = function(crowi, app) {
   // HTTP RPC Styled API (に徐々に移行していいこうと思う)
   app.get('/_api/users.list'          , accessTokenParser(crowi, app) , loginRequired(crowi, app) , user.api.list);
   app.get('/_api/pages.get'           , accessTokenParser(crowi, app) , loginRequired(crowi, app) , page.api.get);
+  app.get('/_api/pages.updatePost'    , accessTokenParser(crowi, app) , loginRequired(crowi, app) , page.api.getUpdatePost);
   app.post('/_api/pages.seen'         , accessTokenParser(crowi, app) , loginRequired(crowi, app) , page.api.seen);
   app.post('/_api/pages.rename'       , accessTokenParser(crowi, app) , loginRequired(crowi, app) , page.api.rename);
   app.get('/_api/comments.get'        , accessTokenParser(crowi, app) , loginRequired(crowi, app) , comment.api.get);

+ 25 - 2
lib/routes/page.js

@@ -277,8 +277,10 @@ module.exports = function(crowi, app) {
         //}
         if (notify.slack.on && notify.slack.channel) {
           if (crowi.slack) {
-            var message = crowi.slack.prepareSlackMessage(pageData, req.user, notify.slack.channel, updateOrCreate);
-            crowi.slack.post(message).then(function(){}).catch(function(){});
+            notify.slack.channel.split(',').map(function(chan) {
+              var message = crowi.slack.prepareSlackMessage(pageData, req.user, chan, updateOrCreate);
+              crowi.slack.post(message).then(function(){}).catch(function(){});
+            });
           }
         }
       }
@@ -495,6 +497,27 @@ module.exports = function(crowi, app) {
     });
   };
 
+  /**
+   * @api {get} /pages.updatePost
+   * @apiName Get UpdatePost setting list
+   * @apiGroup Page
+   *
+   * @apiParam {String} path
+   */
+  api.getUpdatePost = function(req, res) {
+    var path = req.body.path;
+    var UpdatePost = crowi.model('UpdatePost');
+
+    UpdatePost.findSettingsByPath(pageData.path)
+    .then(function(data) {
+      var result = {updatePost: data};
+      return res.json(ApiResponse.success(result));
+    }).catch(function(err) {
+      debug('Error occured while get setting', err);
+      return res.json(ApiResponse.error({}));
+    });
+  };
+
   /**
    * @api {post} /pages.rename Rename page
    * @apiName SeenPage

+ 12 - 10
resource/js/crowi-form.js

@@ -1,5 +1,17 @@
 $(function() {
 
+  // show/hide
+  $('a[data-toggle="tab"][href="#edit-form"]').on('show.bs.tab', function() {
+    $('.content-main').addClass('on-edit');
+
+    var pathData = $('#content-main').data('path');
+    $.get('/_api/pages.updatePost', {path: pathData}, function(res) {
+      console.log(res);
+    });
+  });
+  $('a[data-toggle="tab"][href="#edit-form"]').on('hide.bs.tab', function() {
+    $('.content-main').removeClass('on-edit');
+  });
 
   $('[data-toggle="popover"]').popover();
 
@@ -36,16 +48,6 @@ $(function() {
     isFormChanged = false;
   });
 
-  var watchTimer = setInterval(function() {
-    var content = $('#form-body').val();
-    if (prevContent != content) {
-      var renderer = new Crowi.renderer($('#form-body').val(), $('#preview-body'));
-      renderer.render();
-
-      prevContent = content;
-    }
-  }, 500);
-
   var getCurrentLine = function(event) {
     var $target = $(event.target);
 

+ 0 - 7
resource/js/crowi.js

@@ -231,13 +231,6 @@ $(function() {
   $('[data-toggle="tooltip"]').tooltip();
   $('[data-tooltip-stay]').tooltip('show');
 
-  $('a[data-toggle="tab"][href="#edit-form"]').on('show.bs.tab', function() {
-    $('.content-main').addClass('on-edit');
-  });
-  $('a[data-toggle="tab"][href="#edit-form"]').on('hide.bs.tab', function() {
-    $('.content-main').removeClass('on-edit');
-  });
-
 
   $('.copy-link').on('click', function () {
     $(this).select();