socialforge/app/views/files/_project_list.html.erb

86 lines
5.5 KiB
Plaintext

<% delete_allowed = User.current.allowed_to?(:manage_files, project) %>
<% project_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of?(project) || User.current.admin? %>
<div class="resources mt10"><!--资源库内容开始--->
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTitle break_word">
<%# 如果有历史版本则提供历史版本下载 %>
<% if file.attachment_histories.count == 0 %>
<%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
<% end %>
<%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>">
<% if file.is_public? == false%>
<span class="img_private ml5">私有</span>
<%end %>
</span>
</div>
<div class="mt5">
<span class="fontGrey2 mr15 fl">上传时间:<%= format_time(file.created_on)%></span>
<% if file.tag_list.length > 0%>
<span class="fontGrey2 fl mr15">上传类型:<%= file.tag_list[0] %></span>
<% end %>
<p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p>
<p class="fl ml15 fontGrey2">下载<%= file.downloads%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
</div>
<div class="cl"></div>
<% if User.current.admin? || (User.current.logged? && ( (is_project_manager?(User.current, project) || file.author_id == User.current.id) && project_contains_attachment?(project, file)) && ((delete_allowed || User.current.id == file.author_id) && file.container_id == project.id && file.container_type == "Project")) %>
<div>
<div id="file_description_show_<%= file.id %>" class="fontGrey2 mb4">
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
</div>
<textarea class="homepageSignatureTextarea none" placeholder="请编辑资源描述" id="file_description_edit_<%= file.id %>"
onblur="edit_file_description('<%= update_file_description_project_file_path(project,file)%>','<%= file.id %>');"><%= file.description %></textarea>
</div>
<% else %>
<div class="fontGrey2 mb4">
<% unless file.description.blank? %>
<div class="cl"></div>
<div class="fontGrey2 mb4">资源描述:<%= file.description %></div>
<% end %>
</div>
<% end %>
<div class="tag_h">
<!-- container_type = 1 代表是课程里的资源 -->
<%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
</div>
<div class="homepagePostSetting">
<%= render :partial => 'files/tool_settings', :locals => {:project => @project, :delete_allowed => delete_allowed, :file => file} %>
</div>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
<% else %>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% end %>
<% end %>
<% if project_attachments.count == 10%>
<% if params[:action] == 'search_project' %>
<!--<ul class="wlist">-->
<!--<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>-->
<!--</ul>-->
<%=link_to "点击展开更多", search_project_project_files_path({:project_id => project.id, :page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%else%>
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
<%=link_to "点击展开更多", project_files_path(:project_id => project.id,:page => @page),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%end%>
<% end%>