From 94bffb54582ed262a83b963692dc1366adbc293f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sat, 10 Oct 2015 11:37:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E5=85=A5=E5=A4=B4=E5=83=8F=20?= =?UTF-8?q?=EF=BC=8C=20=E7=B2=98=E8=B4=B4=E5=9B=BE=E7=89=87=20=EF=BC=8C?= =?UTF-8?q?=E6=8F=92=E5=85=A5=E5=9B=BE=E7=89=87=EF=BC=8C=E9=83=BD=E8=A6=81?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=9F=9F=E5=90=8D=E3=80=82=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E4=B8=AD=E5=87=BA=E7=8E=B0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controllers/kindeditor/assets_controller.rb | 2 +- lib/rails_kindeditor/lib/rails_kindeditor/helper.rb | 6 ++++-- public/assets/kindeditor/kindeditor.js | 6 +++++- public/assets/kindeditor/plugins/emoticons/emoticons.js | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/rails_kindeditor/app/controllers/kindeditor/assets_controller.rb b/lib/rails_kindeditor/app/controllers/kindeditor/assets_controller.rb index 0e1177563..d7d5948d4 100644 --- a/lib/rails_kindeditor/app/controllers/kindeditor/assets_controller.rb +++ b/lib/rails_kindeditor/app/controllers/kindeditor/assets_controller.rb @@ -13,7 +13,7 @@ class Kindeditor::AssetsController < ApplicationController logger.warn '========= Warning: the owner_id is 0, "delete uploaded files automatically" will not work. =========' if defined?(logger) && @asset.owner_id == 0 @asset.asset_type = @dir if @asset.save - render :text => ({:error => 0, :url => @asset.asset.url,:asset_id => @asset.id}.to_json) + render :text => ({:error => 0, :url => "http://"+Setting.host_name + "/" + @asset.asset.url,:asset_id => @asset.id}.to_json) else show_error(@asset.errors.full_messages) end diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index f30ee2236..eef2eb576 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -9,7 +9,8 @@ module RailsKindeditor output << text_area_tag(name, content, input_html) output << javascript_tag(js_replace(id, options.merge(window_onload: 'true', :autoHeightMode=>true, - afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})' + afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})', + emotionsBasePath: 'http://' + Setting.host_name ))) end @@ -21,7 +22,8 @@ module RailsKindeditor output_buffer << build_text_area_tag(name, method, self, options, input_html) output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true', :autoHeightMode=>true, - afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})' + afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})', + emotionsBasePath: 'http://' + Setting.host_name ))) end diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 448585376..da7434d9b 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -243,6 +243,7 @@ K.options = { shadowMode : true, loadStyleMode : true, basePath : K.basePath, + emotionsBasePath: 'http://forge.trustie.net', //TODO themesPath : K.basePath + 'themes/', langPath : K.basePath + 'lang/', pluginsPath : K.basePath + 'plugins/', @@ -5459,6 +5460,7 @@ function _editor(options) { _instances = []; function _create(expr, options) { options = options || {}; + options.emotionsBasePath = _undef(options.emotionsBasePath,'http://forge.trustie.net') // TODO options.basePath = _undef(options.basePath, K.basePath); options.themesPath = _undef(options.themesPath, options.basePath + 'themes/'); options.langPath = _undef(options.langPath, options.basePath + 'lang/'); @@ -5623,7 +5625,9 @@ _plugin('core', function(K) { url:K.addParam('/kindeditor/upload', 'dir=image'), afterUpload : function(data) { if (data.error === 0) { - var url = K.formatUrl(data.url, 'absolute'); + + var url = data.url//K.formatUrl(data.url, 'absolute'); + // console.log(url) self.exec('insertimage', url, 'image','','','1',''); //self.exec('insertimage', url, 'image','','','1','left'); //self.insertHtml(''); diff --git a/public/assets/kindeditor/plugins/emoticons/emoticons.js b/public/assets/kindeditor/plugins/emoticons/emoticons.js index b9dfec431..7884f53fb 100644 --- a/public/assets/kindeditor/plugins/emoticons/emoticons.js +++ b/public/assets/kindeditor/plugins/emoticons/emoticons.js @@ -9,7 +9,8 @@ KindEditor.plugin('emoticons', function(K) { var self = this, name = 'emoticons', - path = (self.emoticonsPath || self.pluginsPath + 'emoticons/images/'), + + path = self.emotionsBasePath + (self.emoticonsPath || self.pluginsPath + 'emoticons/images/'), allowPreview = self.allowPreviewEmoticons === undefined ? true : self.allowPreviewEmoticons, currentPageNum = 1; self.clickToolbar(name, function() {