Login
Immutable PageDiscussionInfoAttachments

Please use a more selective search term instead of ""

Clear message
ytoku/daily-record/2015-11-26

MMA

Let's chatがリバースプロキシ下でおかしくなるのを修正するパッチ

Let's chatをサブディレクトリ下にマッピングするとアップロードしたファイルへのリンクが/直下に設置されている時のパスで表示されるのを修正

   1 --- media/js/util/message.js.orig       2015-11-26 01:42:53.466444362 +0900
   2 +++ media/js/util/message.js    2015-11-26 01:57:08.003064272 +0900
   3 @@ -85,7 +85,16 @@
   4          var pattern = /^\s*(upload:\/\/[-A-Z0-9+&*@#\/%?=~_|!:,.;'"!()]*)\s*$/i;
   5  
   6          return text.replace(pattern, function(url) {
   7 -            return getBaseUrl() + url.substring(9);
   8 +            var file = url.substring(9);
   9 +            if (localImagePattern.test(text)) {
  10 +                var uri = encodeEntities(_.unescape(file));
  11 +                return '<a class="thumbnail" href="' + uri +
  12 +                       '" target="_blank"><img src="' + uri +
  13 +                       '" alt="Pasted Image" /></a>';
  14 +            } else {
  15 +                var uri = encodeEntities(_.unescape(file));
  16 +                return '<a href="' + uri + '" target="_blank">' + url + '</a>';
  17 +            }
  18          });
  19      }
  20  
  21 @@ -137,6 +146,7 @@
  22          // Match everything outside of normal chars and " (quote character)
  23          nonAlphanumericRegexp = /([^\#-~| |!])/g,
  24          imagePattern = /^\s*((https?|ftp):\/\/[-A-Z0-9\u00a1-\uffff+&@#\/%?=~_|!:,.;'"!()]*[-A-Z0-9\u00a1-\uffff+&@#\/%=~_|][.](jpe?g|png|gif))\s*$/i,
  25 +        localImagePattern = /^\s*([-A-Z0-9\u00a1-\uffff+&@#\/%?=~_|!:,.;'"!()]*[-A-Z0-9\u00a1-\uffff+&@#\/%=~_|][.](jpe?g|png|gif))\s*$/i,
  26          linkPattern = /((https?|ftp):\/\/[-A-Z0-9\u00a1-\uffff+&*@#\/%?=~_|!:,.;'"!()]*[-A-Z0-9\u00a1-\uffff+&@#\/%=~_|])/ig;
  27  
  28      exports.format = function(text, data) {