Sotaro KARASAWA 10 лет назад
Родитель
Сommit
31d2279ceb
1 измененных файлов с 18 добавлено и 6 удалено
  1. 18 6
      lib/util/slack.js

+ 18 - 6
lib/util/slack.js

@@ -93,11 +93,18 @@ module.exports = function(crowi) {
   };
 
   slack.convertMarkdownToMrkdwn = function(body) {
+    var config = crowi.getConfig();
+    var url = '';
+    if (config.crowi && config.crowi['app:url']) {
+      url = config.crowi['app:url'];
+    }
 
     body = body
       .replace(/\n\*\s(.+)/g, '\n• $1')
       .replace(/#{1,}\s?(.+)/g, '\n*$1*')
-      .replace(/(\[(.+)\]\((https?:\/\/.+)\))/g, '<$3|$2>');
+      .replace(/(\[(.+)\]\((https?:\/\/.+)\))/g, '<$3|$2>')
+      .replace(/(\[(.+)\]\((\/.+)\))/g, '<' + url + '$3|$2>')
+      ;
 
     return body;
   };
@@ -117,12 +124,17 @@ module.exports = function(crowi) {
 
     diff.diffLines(previousRevision.body, page.revision.body).forEach(function(line) {
       debug('diff line', line)
+      var value = line.value.replace(/\r\n|\r/g, '\n');
       if (line.added) {
-        diffText += '+' + line.value.replace(/\n/g, '\n+ ');
+        diffText += sprintf(':pencil2: ...\n%s', line.value);
       } else if (line.removed) {
-        diffText += '-' + line.value.replace(/\n/g, '\n- ');
+        // diffText += '-' + line.value.replace(/(.+)?\n/g, '- $1\n');
+        // 1以下は無視
+        if (line.count > 1) {
+          diffText += sprintf(':wastebasket: ... %s lines\n', line.count);
+        }
       } else {
-        diffText += '...\n';
+        //diffText += '...\n';
       }
     });
 
@@ -170,9 +182,9 @@ module.exports = function(crowi) {
     var text;
 
     if (updateType == 'create') {
-      text = sprintf('%s created a new page! %s', user.username, path);
+      text = sprintf(':white_check_mark: %s created a new page! %s', user.username, path);
     } else {
-      text = sprintf('%s updated %s', user.username, path);
+      text = sprintf(':up: %s updated %s', user.username, path);
     }
 
     return text;