From cc2cce22cf3e7cba793151a3ec0f99eecbb1d45d Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 27 Mar 2015 16:23:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/attachments_helper.rb | 10 +++ .../attachments/_course_file_links.html.erb | 72 +++++++++++++++++++ app/views/messages/_course_show.html.erb | 4 +- public/stylesheets/courses.css | 3 +- 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 app/views/attachments/_course_file_links.html.erb diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 50dd79a08..2e07421f8 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -34,6 +34,16 @@ module AttachmentsHelper :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)} end end + + def link_to_attachments_course(container, options = {}) + options.assert_valid_keys(:author, :thumbnails) + + if container.attachments.any? + options = {:deletable => container.attachments_deletable?, :author => true}.merge(options) + render :partial => 'attachments/course_file_links', + :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)} + end + end def attach_delete(project) if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id) diff --git a/app/views/attachments/_course_file_links.html.erb b/app/views/attachments/_course_file_links.html.erb new file mode 100644 index 000000000..d32025787 --- /dev/null +++ b/app/views/attachments/_course_file_links.html.erb @@ -0,0 +1,72 @@ +
+ <% is_float ||= false %> + <% for attachment in attachments %> +

+ <%if is_float%> +

+ <% end%> + + <% if options[:length] %> + <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%> + <% else %> + <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true -%> + <% end %> + + <%if is_float%> +
+ <% end%> + + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', + :action => 'show', + :id => attachment, + :filename => attachment.filename%> + <% end %> + + <%= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %> + + ( + <%= number_to_human_size attachment.filesize %>) + + <% if options[:deletable] %> + <% if attachment.container_type == 'HomeworkAttach' %> + <%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id}, + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete delete-homework-icon', + :remote => true, + :title => l(:button_delete) %> + <% else %> + <%= link_to image_tag('delete.png'), attachment_path(attachment), + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + #:remote => true, + #:id => "attachments_" + attachment.id.to_s, + :title => l(:button_delete) %> + <% end %> + <% end %> + <% if options[:wrap] %> +
+   + <% end %> + <% if options[:author] %> + + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author) %>, + <%= format_time(attachment.created_on) %> + + <% end %> +

+ <% end %> + <% if defined?(thumbnails) && thumbnails %> + <% images = attachments.select(&:thumbnailable?) %> + <% if images.any? %> +
+ <% images.each do |attachment| %> +
<%= thumbnail_tag(attachment) %>
+ <% end %> +
+ <% end %> + <% end %> +
diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index e79913380..d3d392c31 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -81,7 +81,7 @@ ) if @message.course_destroyable_by?(User.current) %>
<%= textilizable(@topic, :content) %>
-
<%= link_to_attachments @topic, :author => false %>
+
<%= link_to_attachments_course @topic, :author => false %>
<% if User.current.logged? %> @@ -109,7 +109,7 @@ <%= format_time(message.created_on) %>
<%= textilizable message,:content,:attachments => message.attachments %> - <%= link_to_attachments message, :author => false %> + <%= link_to_attachments_course message, :author => false %>
<%= link_to( diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 388f3a822..ae96ef066 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -370,7 +370,8 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;} .ui-widget-header{border:1px solid #628db6;background:#759fcf url(jquery/images/ui-bg_gloss-wave_35_759fcf_500x100.png) 50% 50% repeat-x;color:#fff;font-weight:bold} .ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px} .link_file{ background:url(../images/pic_file.png) 0 7px no-repeat !important; padding-left:20px !important; color:#64bdd9 !important; } - +a:hover.link_file_board{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} +a.link_file_board{ background:url(../images/pic_file.png) 0 3px no-repeat !important; padding-left:20px !important; color:#64bdd9 !important; } /* colorbox *******************************************************************************/ From e10c747a5febe3e13f2b22d4343dbf5155a4449d Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 27 Mar 2015 16:41:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/messages/_form_course.html.erb | 4 ++-- app/views/news/_course_show.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/messages/_form_course.html.erb b/app/views/messages/_form_course.html.erb index 7b5d47c71..615de9778 100644 --- a/app/views/messages/_form_course.html.erb +++ b/app/views/messages/_form_course.html.erb @@ -34,8 +34,8 @@
  • - - <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %> + + <%= render :partial => 'attachments/new_form', :locals => {:container => @message,:isReply => @isReply} %>
  • diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index a876e2401..0a6410374 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -85,7 +85,7 @@ <%= delete_link(news_path(@news),:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %>
    <%= textilizable(@news, :description) %>
    <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
    - <%= link_to_attachments @news %> + <%= link_to_attachments_course @news %>
  • From a1e1e2dedf6cc32478d0c817b874131faccda48c Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 27 Mar 2015 16:53:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=EF=BC=8C=E6=96=B0=E5=BB=BA=EF=BC=8C=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/messages/_course_new.html.erb | 3 ++- app/views/messages/edit.html.erb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/messages/_course_new.html.erb b/app/views/messages/_course_new.html.erb index ba83b271e..ad2db8281 100644 --- a/app/views/messages/_course_new.html.erb +++ b/app/views/messages/_course_new.html.erb @@ -7,7 +7,8 @@ <%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'form_course', :locals => {:f => f,:is_new => true} %> <%= l(:button_submit)%> - <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form' ,target='preview',{:class => 'blue_btn grey_btn fl c_white'} )%> + <%#= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form' ,target='preview',{:class => 'blue_btn grey_btn fl c_white'} )%> + <%= link_to l(:button_cancel), course_boards_path(@course), :class => "blue_btn grey_btn fl c_white"%> <% end %> diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index b37619b19..9a9ab3640 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -21,7 +21,7 @@ <%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "ButtonColor m3p10" %> <% end %> <% elsif @message.course %> - <%= course_board_breadcrumb(@message) %> + <%#= course_board_breadcrumb(@message) %>
      <%= form_for @message, {