diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 662a85fe1..c8b6a6fda 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -71,7 +71,7 @@ class AttachmentsController < ApplicationController if stale?(:etag => @attachment.digest) convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".html") if File.exist?(convered_file) - render :text => File.open(convered_file).read + send_file convered_file, :type => 'text/html; charset=utf-8', :disposition => 'inline' else send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), :type => detect_content_type(@attachment), diff --git a/lib/trustie/utils/office.rb b/lib/trustie/utils/office.rb index 3d58bb047..1bc18cb84 100644 --- a/lib/trustie/utils/office.rb +++ b/lib/trustie/utils/office.rb @@ -21,7 +21,7 @@ module Trustie :open_timeout => -1 ) req = resource.post :txtDes => File.new(@file, 'rb') - File.new(saved_file, "ab+") do |f| + File.open(saved_file, "wb+") do |f| f.write(req.body) end return true diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index fbec91afb..d97f1cd2e 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -260,7 +260,7 @@ K.options = { items : [ 'emoticons', 'source','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', '|', 'formatblock', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', - 'italic', 'underline', 'removeformat', '|','imagedirectupload','table', 'link',"more" + 'italic', 'underline', 'removeformat', '|','imagedirectupload','table', 'media',"more" ], noDisableItems : ['source', 'fullscreen'], colorTable : [ diff --git a/public/assets/kindeditor/plugins/media/media.js b/public/assets/kindeditor/plugins/media/media.js index 58034662a..6d0d3a387 100644 --- a/public/assets/kindeditor/plugins/media/media.js +++ b/public/assets/kindeditor/plugins/media/media.js @@ -9,9 +9,9 @@ KindEditor.plugin('media', function(K) { var self = this, name = 'media', lang = self.lang(name + '.'), - allowMediaUpload = K.undef(self.allowMediaUpload, true), + allowMediaUpload = K.undef(self.allowMediaUpload, false), allowFileManager = K.undef(self.allowFileManager, false), - formatUploadUrl = K.undef(self.formatUploadUrl, true), + formatUploadUrl = K.undef(self.formatUploadUrl, false), extraParams = K.undef(self.extraFileUploadParams, {}), filePostName = K.undef(self.filePostName, 'imgFile'), uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'); @@ -22,10 +22,8 @@ KindEditor.plugin('media', function(K) { //url '
', '', - '  ', - '  ', + '  (支持优酷的flash地址)', '', - '', '', '
', //width @@ -38,11 +36,6 @@ KindEditor.plugin('media', function(K) { '', '', '', - //autostart - '
', - '', - ' ', - '
', '' ].join(''); var dialog = self.createDialog({ @@ -72,14 +65,8 @@ KindEditor.plugin('media', function(K) { heightBox[0].focus(); return; } - var html = K.mediaImg(self.themesPath + 'common/blank.gif', { - src : url, - type : K.mediaType(url), - width : width, - height : height, - autostart : autostartBox[0].checked ? 'true' : 'false', - loop : 'true' - }); + + var html = ''; self.insertHtml(html).hideDialog().focus(); } } diff --git a/public/assets/kindeditor/plugins/media/media.old.js b/public/assets/kindeditor/plugins/media/media.old.js new file mode 100644 index 000000000..58034662a --- /dev/null +++ b/public/assets/kindeditor/plugins/media/media.old.js @@ -0,0 +1,170 @@ +/******************************************************************************* +* KindEditor - WYSIWYG HTML Editor for Internet +* Copyright (C) 2006-2011 kindsoft.net +* +* @author Roddy +* @site http://www.kindsoft.net/ +* @licence http://www.kindsoft.net/license.php +*******************************************************************************/ + +KindEditor.plugin('media', function(K) { + var self = this, name = 'media', lang = self.lang(name + '.'), + allowMediaUpload = K.undef(self.allowMediaUpload, true), + allowFileManager = K.undef(self.allowFileManager, false), + formatUploadUrl = K.undef(self.formatUploadUrl, true), + extraParams = K.undef(self.extraFileUploadParams, {}), + filePostName = K.undef(self.filePostName, 'imgFile'), + uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'); + self.plugin.media = { + edit : function() { + var html = [ + '
', + //url + '
', + '', + '  ', + '  ', + '', + '', + '', + '
', + //width + '
', + '', + '', + '
', + //height + '
', + '', + '', + '
', + //autostart + '
', + '', + ' ', + '
', + '
' + ].join(''); + var dialog = self.createDialog({ + name : name, + width : 450, + height : 230, + title : self.lang(name), + body : html, + yesBtn : { + name : self.lang('yes'), + click : function(e) { + var url = K.trim(urlBox.val()), + width = widthBox.val(), + height = heightBox.val(); + if (url == 'http://' || K.invalidUrl(url)) { + alert(self.lang('invalidUrl')); + urlBox[0].focus(); + return; + } + if (!/^\d*$/.test(width)) { + alert(self.lang('invalidWidth')); + widthBox[0].focus(); + return; + } + if (!/^\d*$/.test(height)) { + alert(self.lang('invalidHeight')); + heightBox[0].focus(); + return; + } + var html = K.mediaImg(self.themesPath + 'common/blank.gif', { + src : url, + type : K.mediaType(url), + width : width, + height : height, + autostart : autostartBox[0].checked ? 'true' : 'false', + loop : 'true' + }); + self.insertHtml(html).hideDialog().focus(); + } + } + }), + div = dialog.div, + urlBox = K('[name="url"]', div), + viewServerBtn = K('[name="viewServer"]', div), + widthBox = K('[name="width"]', div), + heightBox = K('[name="height"]', div), + autostartBox = K('[name="autostart"]', div); + urlBox.val('http://'); + + if (allowMediaUpload) { + var uploadbutton = K.uploadbutton({ + button : K('.ke-upload-button', div)[0], + fieldName : filePostName, + extraParams : extraParams, + url : K.addParam(uploadJson, 'dir=media'), + afterUpload : function(data) { + dialog.hideLoading(); + if (data.error === 0) { + var url = data.url; + if (formatUploadUrl) { + url = K.formatUrl(url, 'absolute'); + } + urlBox.val(url); + if (self.afterUpload) { + self.afterUpload.call(self, url, data, name); + } + alert(self.lang('uploadSuccess')); + } else { + alert(data.message); + } + }, + afterError : function(html) { + dialog.hideLoading(); + self.errorDialog(html); + } + }); + uploadbutton.fileBox.change(function(e) { + dialog.showLoading(self.lang('uploadLoading')); + uploadbutton.submit(); + }); + } else { + K('.ke-upload-button', div).hide(); + } + + if (allowFileManager) { + viewServerBtn.click(function(e) { + self.loadPlugin('filemanager', function() { + self.plugin.filemanagerDialog({ + viewType : 'LIST', + dirName : 'media', + clickFn : function(url, title) { + if (self.dialogs.length > 1) { + K('[name="url"]', div).val(url); + if (self.afterSelectFile) { + self.afterSelectFile.call(self, url); + } + self.hideDialog(); + } + } + }); + }); + }); + } else { + viewServerBtn.hide(); + } + + var img = self.plugin.getSelectedMedia(); + if (img) { + var attrs = K.mediaAttrs(img.attr('data-ke-tag')); + urlBox.val(attrs.src); + widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0); + heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0); + autostartBox[0].checked = (attrs.autostart === 'true'); + } + urlBox[0].focus(); + urlBox[0].select(); + }, + 'delete' : function() { + self.plugin.getSelectedMedia().remove(); + // [IE] 删除图片后立即点击图片按钮出错 + self.addBookmark(); + } + }; + self.clickToolbar(name, self.plugin.media.edit); +});