Merge branch 'bigchange' of 10.0.47.245:/home/trustie2 into bigchange
This commit is contained in:
commit
3f54d24e52
|
@ -625,7 +625,7 @@ class ApplicationController < ActionController::Base
|
|||
@obj_count = obj.count
|
||||
@obj_pages = Paginator.new @obj_count, pre_size, params['page']
|
||||
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
|
||||
obj.limit(@obj_pages.per_page).offset(@obj_pages.offset).all
|
||||
obj.limit(@obj_pages.per_page).offset(@obj_pages.offset)
|
||||
elsif obj.kind_of? Array
|
||||
obj[@obj_pages.offset, @obj_pages.per_page]
|
||||
else
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# encoding: utf-8
|
||||
# Trustie - education management software
|
||||
# Copyright (C) 2013-2014
|
||||
class StoresController < ApplicationController
|
||||
|
@ -9,10 +10,14 @@ class StoresController < ApplicationController
|
|||
|
||||
def search
|
||||
name = params[:name] ||= ''
|
||||
@searched_attach = Attachment.includes(:project).where("projects.is_public = ? AND filename LIKE '%"<< name <<"%' ", 1)
|
||||
# @searched_attach = Attachment.all[0..20]
|
||||
@searched_attach.take 20
|
||||
# reutrn @searched_attach
|
||||
redirect_to stores_path, :notice => '为何不写点东西?' if name.blank?
|
||||
# 按文件名搜索
|
||||
#result = Attachment.includes(:project).where("projects.is_public = 1 AND filename LIKE '%" << name << "%' ")
|
||||
result = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE '%" + name + "%' ").
|
||||
reorder("created_on DESC")
|
||||
result = result.to_a
|
||||
result.map { |res| result.delete(res) if res.container.nil?}
|
||||
@searched_attach = paginateHelper result
|
||||
end
|
||||
|
||||
LIMIT = 12 unless const_defined?(:LIMIT)
|
||||
|
@ -47,12 +52,12 @@ class StoresController < ApplicationController
|
|||
where("projects.project_type=#{project_type}").
|
||||
reorder("downloads DESC").
|
||||
limit(LIMIT)
|
||||
doc_attach = join_tools_project "documents", project_type
|
||||
issue_attach = join_tools_project "issues", project_type
|
||||
mess_attach = []#join_tools_project "messages", project_type
|
||||
news_attach = join_tools_project "news", project_type
|
||||
vers_attach = join_tools_project "versions", project_type
|
||||
wiki_attach = []#join_tools_project "wiki_pages", project_type
|
||||
doc_attach = join_tools_project Document, project_type
|
||||
issue_attach = join_tools_project Issue, project_type
|
||||
mess_attach = []#join_tools_project Message, project_type
|
||||
news_attach = join_tools_project News"news", project_type
|
||||
vers_attach = join_tools_project Version"versions", project_type
|
||||
wiki_attach = []#join_tools_project WikiPage, project_type
|
||||
|
||||
tmp = pro_attach+doc_attach+issue_attach+mess_attach+news_attach+vers_attach+wiki_attach
|
||||
tmp.sort { |a, b| b.downloads <=> a.downloads }
|
||||
|
@ -64,9 +69,9 @@ class StoresController < ApplicationController
|
|||
limit(LIMIT)
|
||||
end
|
||||
|
||||
def str_join_table tableName
|
||||
str = "LEFT JOIN #{tableName} ON attachments.container_id = #{tableName}.id
|
||||
LEFT JOIN projects ON #{tableName}.project_id = projects.id"
|
||||
def str_join_table tableClass
|
||||
str = "LEFT JOIN #{tableClass.table_name} ON attachments.container_id = #{tableClass.table_name}.id
|
||||
LEFT JOIN projects ON #{tableClass.table_name}.project_id = projects.id"
|
||||
str
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,114 @@ module StoresHelper
|
|||
when 'Bid'
|
||||
bid_path(container)
|
||||
else
|
||||
'#'#logger.error "StoresHelper#attachUrl unkown type ==> #{container}"
|
||||
Rails.logger.error "ERROR: StoresHelper#attachUrl unkown type ==> #{container}"
|
||||
'#'
|
||||
end
|
||||
end
|
||||
|
||||
def result_come_from attachment
|
||||
come_from_local(attachment).join(" > ").html_safe
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
WORD_LIMIT = 100
|
||||
def come_from_local attachment
|
||||
|
||||
container = attachment.container
|
||||
case container.class.to_s
|
||||
when 'Message'
|
||||
# '项目 > zzz > 论坛 > 帖子xxx'
|
||||
# topic_str = container.project.project_type == 0 ? l(:label_board) : l(:label_new_course)
|
||||
topic_list = link_to l(:label_board), project_boards_path(container.project)
|
||||
topic_item = link_to container.subject.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
|
||||
project_link(container.project).push(topic_list, topic_item)
|
||||
when 'Issue'
|
||||
# '项目 > zzz > 缺陷 > 问题xxx'
|
||||
issue_list = link_to l(:label_project_issues), project_issues_path(container.project)
|
||||
issue_item = link_to container.subject.truncate(WORD_LIMIT, omission: '...'), issue_path(container), title: container.subject
|
||||
project_link(container.project).push(issue_list, issue_item)
|
||||
when 'Document'
|
||||
# '项目 > zzz > 文档 > 文档xxx'
|
||||
doc_list = link_to l(:label_document), project_documents_path(container.project)
|
||||
doc_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), document_path(container), title: container.title
|
||||
project_link(container.project).push(doc_list, doc_item)
|
||||
when 'News'
|
||||
# '课程 > zzz > 新闻 > 新闻xxx'
|
||||
news_str = container.project.project_type == 0 ? l(:label_news) : l(:label_course_news)
|
||||
news_list = link_to news_str, project_news_index_path(container.project)
|
||||
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
|
||||
project_link(container.project).push(news_list, news_item)
|
||||
when 'Project'
|
||||
# '项目 > zzz '
|
||||
file_str = container.project.project_type == 0 ? l(:project_module_files) : l(:label_course_file)
|
||||
files_list = link_to file_str, project_files_path(container.project)
|
||||
project_link(container).push(files_list)
|
||||
when 'Version'
|
||||
# '项目 > zzz > 里程碑 > xxx'
|
||||
ver_list = link_to l(:label_roadmap), project_roadmap_path(container.project)
|
||||
files_list = link_to l(:label_course_file), project_files_path(container.project)
|
||||
ver_item = link_to container.name.truncate(WORD_LIMIT, omission: '...'), version_path(container), title: container.name
|
||||
project_link(container.project).push(ver_list, files_list, ver_item)
|
||||
when 'WikiPage'
|
||||
# '项目 > zzz > 维基 > xxx' 有点问题
|
||||
wiki_list = link_to l(:label_wiki), project_wiki_path(container.project)
|
||||
project_link(container.project).push(wiki_list)
|
||||
when 'HomeworkAttach'
|
||||
# '课程 > zzz > 作业 > 作业xxx'
|
||||
bid_link(container.bid)
|
||||
when 'Memo'
|
||||
# '贴吧 > 讨论区 > 帖子 xxx'
|
||||
return [link_to(attachment.id, '#')] if container.forum.nil?
|
||||
forums_list = link_to l(:label_forum), forums_path
|
||||
memo_list = link_to container.forum.name, forum_path(container.forum)
|
||||
memo_item = link_to container.subject, forum_memo_path(container.forum, container)
|
||||
[forums_list, memo_list, memo_item]
|
||||
when 'Bid'
|
||||
# '竞赛 > xxx '
|
||||
bid_link(container)
|
||||
else
|
||||
Rails.logger.error "ERROR: attachment type unkown"
|
||||
[link_to('unkown', '')]
|
||||
end
|
||||
end
|
||||
|
||||
def project_link project
|
||||
if project.nil?
|
||||
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil?"
|
||||
return [link_to('unkown', '')]
|
||||
end
|
||||
project_list = nil
|
||||
if project.project_type == 0
|
||||
project_list = link_to l(:label_project_plural), projects_path
|
||||
else
|
||||
project_list = link_to l(:label_new_course), course_path
|
||||
end
|
||||
project_item = link_to project.to_s, project_path(project)
|
||||
[project_list, project_item]
|
||||
end
|
||||
|
||||
def bid_link bid
|
||||
bid_list = nil
|
||||
bid_item = nil
|
||||
case bid.reward_type
|
||||
when 1 # 众包
|
||||
bid_list = link_to l(:label_requirement_enterprise_list), calls_path
|
||||
bid_item = link_to bid.name, respond_path(bid)
|
||||
when 2 # 竞赛
|
||||
bid_list = link_to l(:label_contest_list), contest_path
|
||||
bid_item = link_to bid.name, respond_path(bid)
|
||||
when 3 # 作业
|
||||
if bid.courses.first.nil?
|
||||
Rails.logger.error "ERROR: attachment type unkown #bid_link/when 3"
|
||||
return [link_to('unkown', '#')]
|
||||
end
|
||||
bid_list = link_to l(:label_homework), project_homework_path(bid.courses.first)
|
||||
bid_item = link_to bid.name, respond_path(bid)
|
||||
return project_link(bid.courses.first).push(bid_list, bid_item)
|
||||
else
|
||||
xxx
|
||||
end
|
||||
[bid_list, bid_item]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
<% end -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<tr class="file <%= cycle("odd", "even") %>">
|
||||
<td class="filename" style="font-size: 13px; max-width: 240px; "><%= link_to_attachment file, :download => true, :title => file.description, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||
<td class="filename" style="font-size: 13px; max-width: 240px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||
<td class="created_on"><%= format_time(file.created_on) %></td>
|
||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||
<td class="downloads"><%= file.downloads %></td>
|
||||
|
|
|
@ -38,10 +38,11 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><%= link_to stores_url , stores_url %></td>
|
||||
<td><p class="top-content-list"><%=link_to l(:label_home),home_path %> > <%=link_to l(:label_course_file),:controller => 'projects', :action => 'index', :project_type => 0 %> > <%=link_to @project, '' %></p></td>
|
||||
<td><p class="top-content-list"><%=link_to l(:label_home),home_path %> > <%=link_to l(:label_course_file),stores_url %> </p></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<%= render_flash_messages %>
|
||||
<div id="top_field">
|
||||
<%= yield :top_field %>
|
||||
</div>
|
||||
|
@ -50,7 +51,6 @@
|
|||
<%= view_layouts_base_sidebar_hook_response %>
|
||||
</div>
|
||||
<div id="store_content" style="padding-top: 0px;">
|
||||
<%= render_flash_messages %>
|
||||
<%= yield %>
|
||||
<%= call_hook :view_layouts_base_content %>
|
||||
</div>
|
||||
|
|
|
@ -9,63 +9,14 @@
|
|||
max-width: 100%;
|
||||
margin: 20px auto;
|
||||
}
|
||||
.line_block{
|
||||
display: inline-block;
|
||||
width: 49%;
|
||||
margin: 10px auto;
|
||||
vertical-align: top;
|
||||
padding: 0px 2%;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-box-sizing: border-box;
|
||||
}
|
||||
.resource_sum{
|
||||
height: auto;
|
||||
}
|
||||
.line_block p{
|
||||
margin: 1em 0px auto;
|
||||
/*background: linear-gradient(#ffffff, #e5e5e5) repeat scroll 0% 0% transparent;*/
|
||||
border-bottom: 1px solid rgb(226,226,226);
|
||||
border-top-left-radius : 6px;
|
||||
border-top-right-radius : 6px;
|
||||
box-shadow: 0px 1px 0px white, 0px, -1px 0px rgb(245,245,245);
|
||||
height: 39px;
|
||||
font-size: 15px;
|
||||
line-height: 26px;
|
||||
height: 30px;
|
||||
font-size: 1.5em;
|
||||
padding-left: 4%;
|
||||
border-bottom: 1px solid rgb(21, 165, 200);
|
||||
}
|
||||
.resource_sum, .line_blo{
|
||||
border: 1px solid #eeeeee;
|
||||
}
|
||||
.line_block table{
|
||||
border: 1px solid #eeeeee;
|
||||
}
|
||||
.line_block table thead tr{
|
||||
/*background-color: #d1d1d1;*/
|
||||
}
|
||||
.line_block table td{
|
||||
height: 2em;
|
||||
}
|
||||
.filename {
|
||||
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 247px;
|
||||
}
|
||||
/*.filename a:after {
|
||||
content: "...";
|
||||
}*/
|
||||
|
||||
</style>
|
||||
|
||||
<% content_for :top_field do%>
|
||||
<div style="margin: 10px 5%;">
|
||||
<div style="margin: 10px 5%;vertical-align: bottom;">
|
||||
<%= form_tag( search_stores_path, method: 'get') do %>
|
||||
<%= text_field_tag 'name', nil, size:"100", placeholder:'请输入要搜索的关键字' %>
|
||||
<%= submit_tag l(:label_search), class:"whiteButton m3p10 h30"%>
|
||||
<%= text_field_tag 'name', nil, size:"100", placeholder:'请输入要搜索的关键字', :class => 'blueinputbar' %>
|
||||
<%= submit_tag l(:label_search), class:"whiteButton", style: "padding: 0px 10px;"%>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -79,17 +30,19 @@
|
|||
<table style="width: 100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>文件名</td>
|
||||
<td>下载次数</td>
|
||||
<td>下载</td>
|
||||
<td><%=l(:label_attachment)%></td>
|
||||
<td><%=l(:field_downloads)%></td>
|
||||
<td><%=l(:button_download)%></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% k.each do |c1|%>
|
||||
<tr class="<%= cycle 'odd', 'even' %>">
|
||||
<td class="filename" style="width:62%;"><%= link_to c1.filename, (attachFromUrl c1), {:title => c1.filename, :target => "_blank"} %> </td>
|
||||
<td style="width:19%;"><%= c1.downloads %> </td>
|
||||
<td class="filename" style="width:19%;"><%= link_to_attachment c1, {:text => "下载"}%></td>
|
||||
<td style="width:19%; text-align: center;"><%= c1.downloads %> </td>
|
||||
<td class="filename download_icon" style="width:19%; text-align: center;">
|
||||
<%= link_to_attachment c1, {:text => image_tag("/images/button/download.png", width: "22px", alt: "l(:button_download)") }%>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
@ -97,3 +50,15 @@
|
|||
</div>
|
||||
<% reset_cycle; end %>
|
||||
</div>
|
||||
<script type='text/javascript'>
|
||||
$(document).ready(function($) {
|
||||
$('.download_icon').each(function(){
|
||||
$(this).mouseenter(function(event) {
|
||||
$(this).find('img').attr("src", "/images/button/download_focus.png")
|
||||
});
|
||||
$(this).mouseleave(function(event) {
|
||||
$(this).find('img').attr("src", "/images/button/download.png")
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -1,7 +1,19 @@
|
|||
<style type="text/css">
|
||||
#main *{
|
||||
/*border: 1px solid #eeeeee;*/
|
||||
}
|
||||
#content {
|
||||
max-width: 100%;
|
||||
}
|
||||
#top_field {
|
||||
max-width: 100%;
|
||||
margin: 20px auto;
|
||||
}
|
||||
</style>
|
||||
<% content_for :top_field do%>
|
||||
<div style="margin: 10px 5%;">
|
||||
<%= form_tag( search_stores_path, method: 'get') do %>
|
||||
<%= text_field_tag 'name', nil, size:"100", placeholder:'请输入要搜索的关键字' %>
|
||||
<%= text_field_tag 'name', nil, size:"100", placeholder:'请输入要搜索的关键字', :value => params[:name] , :class => 'blueinputbar'%>
|
||||
<%= submit_tag l(:label_search), class:"whiteButton m3p10 h30"%>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -18,7 +30,7 @@
|
|||
class=f16 href="http://ishare.iask.sina.com.cn/f/23680389.html"
|
||||
target=_blank> --><SPAN style="COLOR: #c03; font-size: 14px;"><%= result.filename %></SPAN><span style="margin-left: 4px;"><%= link_to_attachment result, {:text => "下载"}%></span><!-- </A> --> </DIV><%= result.description %> <!-- <SPAN
|
||||
style="COLOR: #c03">Java</SPAN> ... -->
|
||||
<DIV class=c9>所属分类:<A class=c9ul
|
||||
<DIV class=c9>所属分类:<%=result_come_from result%>=====================<A class=c9ul
|
||||
href="http://ishare.iask.sina.com.cn/c/1822.html">IT资料</A> > <A
|
||||
class=c9ul
|
||||
href="http://ishare.iask.sina.com.cn/c/1909.html">常用软件</A> > <A
|
||||
|
@ -31,4 +43,6 @@
|
|||
<% end %>
|
||||
|
||||
|
||||
<!-- <%= @searched_attach.to_s %> -->
|
||||
<!-- <%= @searched_attach.to_s %> -->
|
||||
|
||||
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
|
@ -14,6 +14,13 @@
|
|||
.clear_both{
|
||||
clear: both;
|
||||
}
|
||||
.btn_download{
|
||||
display: inline-block;
|
||||
background: url('images/button/download.png') no-repeat transparent;
|
||||
}
|
||||
.btn_download a{
|
||||
background: url('images/button/download.png') no-repeat transparent;
|
||||
}
|
||||
* {
|
||||
font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", STXihei, "华文细黑", Heiti, "黑体", sans-serif;
|
||||
}
|
||||
|
@ -359,4 +366,102 @@ table.content-text-list tbody tr td.locked, div.memo-section .locked{
|
|||
.project_acts .project_acts_right{
|
||||
height: 100%;
|
||||
margin-left: 61%;
|
||||
}
|
||||
}
|
||||
/* stores 资源库
|
||||
*******************************************************************************/
|
||||
.line_block{
|
||||
display: inline-block;
|
||||
width: 49%;
|
||||
margin: 10px auto;
|
||||
vertical-align: top;
|
||||
padding: 0px 2%;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-box-sizing: border-box;
|
||||
}
|
||||
.resource_sum{
|
||||
height: auto;
|
||||
}
|
||||
.line_block p{
|
||||
margin: 1em 0px auto;
|
||||
/*background: linear-gradient(#ffffff, #e5e5e5) repeat scroll 0% 0% transparent;*/
|
||||
border-bottom: 1px solid rgb(226,226,226);
|
||||
border-top-left-radius : 6px;
|
||||
border-top-right-radius : 6px;
|
||||
box-shadow: 0px 1px 0px white, 0px, -1px 0px rgb(245,245,245);
|
||||
height: 39px;
|
||||
font-size: 15px;
|
||||
line-height: 26px;
|
||||
height: 30px;
|
||||
font-size: 1.5em;
|
||||
padding-left: 4%;
|
||||
border-bottom: 1px solid rgb(21, 165, 200);
|
||||
}
|
||||
.resource_sum, .line_blo{
|
||||
border: 1px solid #eeeeee;
|
||||
}
|
||||
.line_block table{
|
||||
border: 1px solid #eeeeee;
|
||||
}
|
||||
.line_block table thead tr{
|
||||
/*background-color: #d1d1d1;*/
|
||||
text-align: center;
|
||||
}
|
||||
.line_block table td{
|
||||
height: 2em;
|
||||
}
|
||||
.filename {
|
||||
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 247px;
|
||||
}
|
||||
/*.filename a:after {
|
||||
content: "...";
|
||||
}*/
|
||||
.blueinputbar{
|
||||
-o-transform-origin: 138px 46.5px;
|
||||
-o-transition: background 0.2s cubic-bezier(0, 0, 1, 1);
|
||||
-webkit-border-bottom-left-radius: 3px;
|
||||
-webkit-border-bottom-right-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
-webkit-border-top-left-radius: 3px;
|
||||
-webkit-border-top-right-radius: 3px;
|
||||
-webkit-transform-origin: 138px 46.5px;
|
||||
-webkit-transition: background 0.2s cubic-bezier(0, 0, 1, 1);
|
||||
-webkit-transition-delay: 0;
|
||||
-webkit-transition-duration: 0.2s;
|
||||
-webkit-transition-property: background;
|
||||
-webkit-transition-timing-function: cubic-bezier(0, 0, 1, 1);
|
||||
align-content: stretch;
|
||||
align-items: stretch;
|
||||
align-self: stretch;
|
||||
background: #FFFFFF;
|
||||
border-bottom: 1px solid #56B4EF;
|
||||
border-left: 1px solid #56B4EF;
|
||||
border-radius: 3px;
|
||||
border-right: 1px solid #56B4EF;
|
||||
border-top: 1px solid #56B4EF;
|
||||
color: #333333;
|
||||
justify-content: flex-start;
|
||||
margin: 0px;
|
||||
order: 0;
|
||||
outline: #333333 0px;
|
||||
overflow-wrap: break-word;
|
||||
resize: none;
|
||||
text-shadow: none;
|
||||
transform-origin: 138px 46.5px;
|
||||
transition: background 0.2s cubic-bezier(0, 0, 1, 1);
|
||||
unicode-bidi: embed;
|
||||
vertical-align: top;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
input.blueinputbar:focus {
|
||||
box-shadow: rgba(0, 0, 0, 0.047) 0px 1px 3px 0px inset, rgba(82, 168, 236, 0.600) 0px 0px 5px 0px;
|
||||
border-bottom: 1px solid #56B4EF;
|
||||
border-left: 1px solid #56B4EF;
|
||||
border-radius: 3px;
|
||||
border-right: 1px solid #56B4EF;
|
||||
border-top: 1px solid #56B4EF;
|
||||
}
|
Loading…
Reference in New Issue