From 822ac5ade8feedca4b761667ceaef992ad5de0d2 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 23 May 2015 16:50:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=85=AC=E5=85=B1=E8=B4=B4=E5=90=A7?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/memos/quote.js.erb | 3 ++- app/views/memos/show.html.erb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/memos/quote.js.erb b/app/views/memos/quote.js.erb index b3d860916..3dbf9eb95 100644 --- a/app/views/memos/quote.js.erb +++ b/app/views/memos/quote.js.erb @@ -1,4 +1,5 @@ //ckeditor.setData("<%= raw escape_javascript(@content) %>"); $('#message_quote').html("<%= raw escape_javascript(@temp.content.html_safe) %>"); $('#quote').val("<%= raw escape_javascript(@content) %>"); -showAndScrollTo("new_memo", "cke_editor01"); \ No newline at end of file +showAndScrollTo("new_memo", "cke_editor01"); +$("img").removeAttr("align"); \ No newline at end of file diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index fb66c621e..5452aa893 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -182,4 +182,5 @@ } }); }; + $("img").removeAttr("align"); \ No newline at end of file From 26ae4b7d74e157fd55f7b6d2a00c38564ea0b53f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 23 May 2015 17:12:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/avatar_controller.rb | 68 ++++++++++++---------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/app/controllers/avatar_controller.rb b/app/controllers/avatar_controller.rb index afd206c92..b6efaef0c 100644 --- a/app/controllers/avatar_controller.rb +++ b/app/controllers/avatar_controller.rb @@ -29,51 +29,43 @@ class AvatarController < ApplicationController end if @temp_file && (@temp_file.size > 0) - if @temp_file.size > Setting.upload_avatar_max_size.to_i - @status = 1 - @msg = l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i)) - elsif Trustie::Utils::Image.new(@temp_file.tempfile.path).image? - diskfile=disk_filename(@source_type,@source_id) - @urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file)) + diskfile=disk_filename(@source_type,@source_id) + @urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file)) - # 用户头像上传时进行特别处理 - if @source_type == 'User' - diskfile += "temp" - @urlfile += "temp" - end - - logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)") - path = File.dirname(diskfile) - unless File.directory?(path) - FileUtils.mkdir_p(path) - end - md5 = Digest::MD5.new - File.open(diskfile, "wb") do |f| - if @temp_file.respond_to?(:read) - buffer = "" - while (buffer = @temp_file.read(8192)) - f.write(buffer) - md5.update(buffer) - end - else - f.write(@temp_file) - md5.update(@temp_file) - end - end - - Trustie::Utils::Image.new(diskfile,true).compress(300) - @status = 0 - @msg = '' - else - @status = 2 - @msg = l(:not_valid_image_file) + # 用户头像上传时进行特别处理 + if @source_type == 'User' + diskfile += "temp" + @urlfile += "temp" end + + logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)") + path = File.dirname(diskfile) + unless File.directory?(path) + FileUtils.mkdir_p(path) + end + md5 = Digest::MD5.new + File.open(diskfile, "wb") do |f| + if @temp_file.respond_to?(:read) + buffer = "" + while (buffer = @temp_file.read(8192)) + f.write(buffer) + md5.update(buffer) + end + else + f.write(@temp_file) + md5.update(@temp_file) + end + end +# self.digest = md5.hexdigest end @temp_file = nil + image = Trustie::Utils::Image.new(diskfile,true) + image.compress(300) + respond_to do |format| format.json{ - render :inline => {status: @status, message:@msg, url:"#{@urlfile.to_s}?#{Time.now.to_i}"}.to_json,:content_type => 'text/html' + render :inline => "#{@urlfile.to_s}?#{Time.now.to_i}",:content_type => 'text/html' return } format.js