From 84a79ac8e28e630a42132422e987a80388a5253e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 3 Jun 2015 10:53:08 +0800 Subject: [PATCH 01/31] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E3=80=81=E9=A1=B9=E7=9B=AE=E9=A6=96=E9=A1=B5=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/course.html.erb | 4 +--- app/views/welcome/index.html.erb | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 256a976c4..16c191d5e 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -140,9 +140,7 @@ <%break if Time.new.strftime("%Y").to_i - year_now >= 2%> <% all_new_hot_course += find_all_new_hot_course(course_count-all_new_hot_course.count, @school_id, year_now, course_term)%> <% end%> - <% cache all_new_hot_course.max().created_at do %> - <%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %> - <% end %> + <%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %> <% else %> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 3acee0acf..c03b0de76 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -68,7 +68,6 @@
-<% cache :expire_in => 2.hours do%>

<%= l(:lable_hot_projects)%>

<% if User.current.logged? %> @@ -113,7 +112,6 @@
-<% end %>
From 87e7db1a4b3f349e61d5fe42652bd870251976cb Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 11:14:33 +0800 Subject: [PATCH 04/31] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=97=B6=E8=BD=AC=E6=8D=A2office=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 11 ++++++++++- app/tasks/office_conver_task.rb | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/tasks/office_conver_task.rb diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 7ac7d786d..1e477ed04 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -72,7 +72,7 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - after_create :be_user_score ,:act_as_forge_activity# user_score + after_create :office_conver, :be_user_score ,:act_as_forge_activity# user_score after_update :be_user_score after_destroy :delete_from_disk,:down_user_score @@ -258,6 +258,15 @@ class Attachment < ActiveRecord::Base filename end + def office_conver + saved_path = File.join(Rails.root, "files", "convered_office") + unless Dir.exist?(saved_path) + Dir.mkdir(saved_path) + end + convered_file = File.join(saved_path, self.disk_filename + ".html") + OfficeConverTask.new.conver(self.diskfile, convered_file) + end + # Copies the temporary file to its final location # and computes its MD5 hash def files_to_final_location diff --git a/app/tasks/office_conver_task.rb b/app/tasks/office_conver_task.rb new file mode 100644 index 000000000..da950bf2e --- /dev/null +++ b/app/tasks/office_conver_task.rb @@ -0,0 +1,12 @@ +#coding=utf-8 +# +class OfficeConverTask + def conver(source_file, saved_file) + office = Trustie::Utils::Office.new(source_file) + if office.conver(saved_file) + Rails.logger.info "process ok: #{saved_file} " + end + end + handle_asynchronously :conver,:queue => 'office_conver' +end + From 00745f127009f9adfa8b4bdc4822395a09b00bcf Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 11:40:00 +0800 Subject: [PATCH 05/31] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=A2=84=E8=A7=88bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 +- lib/trustie/utils/office.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From 437287d93b4277e6b44646bf929dd04c88c2a788 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 12:14:39 +0800 Subject: [PATCH 06/31] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/kindeditor/kindeditor.js | 2 +- .../assets/kindeditor/plugins/media/media.js | 23 +-- .../kindeditor/plugins/media/media.old.js | 170 ++++++++++++++++++ 3 files changed, 176 insertions(+), 19 deletions(-) create mode 100644 public/assets/kindeditor/plugins/media/media.old.js 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); +}); From 3ef46fd8f5fa0708b0caac12a9986ff0d5c0e190 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 3 Jun 2015 13:54:49 +0800 Subject: [PATCH 07/31] 11 --- public/stylesheets/courses.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 1706098aa..457d6da75 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -502,9 +502,6 @@ blockquote { } a.member_search_edit {width: 43px;background: #15bccf;color: #fff;text-align: center;text-decoration: none;padding: 2px;} .min_search_edit {width: 150px;height: 20px;border: 1px solid #d0d0d0 !important;color: #666;} - -a.link_file{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; color:#64bdd9; } -a:hover.link_file{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} .r_txt_tit{max-width:450px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color:#15bccf; float:left; color:#09658c; font-size:14px;} /*日历选择图*/ From 1c4ca0c9131485f3378007cfa9c2b1a0410e0f57 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 3 Jun 2015 14:33:53 +0800 Subject: [PATCH 08/31] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E8=AF=BE=E7=A8=8B=E3=80=81=E9=A1=B9=E7=9B=AE=E3=80=81?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E6=96=B0=E6=89=93=E5=BC=80?= =?UTF-8?q?=E4=B8=80=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_new_header.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/_new_header.html.erb b/app/views/layouts/_new_header.html.erb index e4d2658b1..46a2eff63 100644 --- a/app/views/layouts/_new_header.html.erb +++ b/app/views/layouts/_new_header.html.erb @@ -18,15 +18,15 @@ <% if User.current.logged? -%>
  • - <%= link_to "#{User.current.login}".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.host_user}, :class => "uses_name"%> + <%= link_to "#{User.current.login}".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.host_user}, target:"_blank", :class => "uses_name"%>