Merge branch 'bigchange' of 10.0.47.245:/home/trustie2 into bigchange
This commit is contained in:
commit
346e9574ca
|
@ -25,13 +25,15 @@ class StoresController < ApplicationController
|
|||
|
||||
LIMIT = 12 unless const_defined?(:LIMIT)
|
||||
def index
|
||||
@projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).
|
||||
reorder("#{Attachment.table_name}.downloads DESC").
|
||||
limit(LIMIT)
|
||||
@projects_attach = project_classification(0).take(LIMIT)
|
||||
@courses_attach = project_classification(1).take(LIMIT)
|
||||
# @projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).
|
||||
# reorder("#{Attachment.table_name}.downloads DESC").
|
||||
# limit(LIMIT)
|
||||
|
||||
@courses_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 1, 1).
|
||||
reorder("#{Attachment.table_name}.downloads DESC").
|
||||
limit(LIMIT)
|
||||
# @courses_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 1, 1).
|
||||
# reorder("#{Attachment.table_name}.downloads DESC").
|
||||
# limit(LIMIT)
|
||||
@homeworks_attach = Attachment.where("container_type = 'HomeworkAttach'").
|
||||
reorder("downloads DESC").
|
||||
limit(LIMIT)
|
||||
|
@ -49,30 +51,45 @@ class StoresController < ApplicationController
|
|||
private
|
||||
|
||||
def project_classification project_type=0
|
||||
pro_attach = Attachment.joins("LEFT JOIN projects ON attachments.container_id = projects.id").
|
||||
where("projects.project_type=#{project_type}").
|
||||
reorder("downloads DESC").
|
||||
limit(LIMIT)
|
||||
# pro_attach = Attachment.joins("LEFT JOIN projects ON attachments.container_id = projects.id").
|
||||
# where("attachments.container_type='Project' AND projects.is_public=1 AND projects.project_type=#{project_type}").
|
||||
# reorder("downloads DESC").
|
||||
# limit(LIMIT)
|
||||
pro_attach = join_tools_project Project, project_type
|
||||
doc_attach = join_tools_project Document, project_type
|
||||
issue_attach = join_tools_project Issue, project_type
|
||||
mess_attach = []
|
||||
news_attach = join_tools_project News"news", project_type
|
||||
vers_attach = join_tools_project Version"versions", project_type
|
||||
wiki_attach = []
|
||||
mess_attach = join_tools_project Message, project_type
|
||||
news_attach = join_tools_project News, project_type
|
||||
vers_attach = join_tools_project Version, 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 = pro_attach
|
||||
tmp = pro_attach+doc_attach+issue_attach+mess_attach+news_attach+vers_attach+wiki_attach
|
||||
tmp.sort { |a, b| b.downloads <=> a.downloads }
|
||||
end
|
||||
def join_tools_project tableName, project_type=0
|
||||
Attachment.joins(str_join_table(tableName)).
|
||||
where("projects.project_type=#{project_type}").
|
||||
where("attachments.container_type='#{tableName.to_s}' AND projects.is_public=1 AND projects.project_type=#{project_type}").
|
||||
reorder('downloads DESC').
|
||||
limit(LIMIT)
|
||||
end
|
||||
|
||||
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
|
||||
case tableClass.to_s
|
||||
when 'Project'
|
||||
"LEFT JOIN projects ON attachments.container_id = projects.id"
|
||||
when 'Document', 'Issue', 'Version', 'News' # 连接子表即有 project_id 字段,即两层连接
|
||||
"LEFT JOIN #{tableClass.table_name} ON attachments.container_id = #{tableClass.table_name}.id
|
||||
LEFT JOIN projects ON #{tableClass.table_name}.project_id = projects.id"
|
||||
when 'Message' # 三层连接
|
||||
"LEFT JOIN #{tableClass.table_name} ON attachments.container_id = #{tableClass.table_name}.id
|
||||
LEFT JOIN boards ON boards.id = #{tableClass.table_name}.board_id
|
||||
LEFT JOIN projects ON boards.project_id = projects.id"
|
||||
when 'WikiPage'# 三层连接
|
||||
"LEFT JOIN #{tableClass.table_name} ON attachments.container_id = #{tableClass.table_name}.id
|
||||
LEFT JOIN wikis ON wikis.id = #{tableClass.table_name}.wiki_id
|
||||
LEFT JOIN projects ON wikis.project_id = projects.id"
|
||||
else
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<html lang="<%= current_language %>">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title><%= h html_title %></title>
|
||||
<meta name="description" content="<%= Redmine::Info.app_name %>" />
|
||||
<meta name="keywords" content="issue,bug,tracker" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% content_for :top_field do%>
|
||||
<div style="margin: 10px 5%;vertical-align: bottom;">
|
||||
<%= form_tag( search_stores_path, method: 'get') do %>
|
||||
<%= text_field_tag 'name', nil, size:"100", placeholder:'请输入要搜索的关键字', :class => 'blueinputbar' %>
|
||||
<%= form_tag( search_stores_path, method: 'post') do %>
|
||||
<%= text_field_tag 'name', nil, size:"100", placeholder:'请输入要搜索的关键字', :class => 'blueinputbar', :required => true %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise"%>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
<style type='text/css'>
|
||||
.highlight {
|
||||
background-color: #fff34d;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-moz-box-shadow: 0px 1px 4px rgba(0,0,0,0.7);
|
||||
-webkit-box-shadow: 0px 1px 4px rgba(0,0,0,0.7);
|
||||
box-shadow: 0px 1px 4px rgba(0,0,0,0.7);
|
||||
}
|
||||
.highlight {
|
||||
padding: 1px 4px;
|
||||
margin: 0 -4px;
|
||||
}
|
||||
</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:'请输入要搜索的关键字', :value => params[:name] , :class => 'blueinputbar'%>
|
||||
<%= form_tag( search_stores_path, method: 'post') do %>
|
||||
<%= text_field_tag 'name', nil, size:"100", placeholder:'请输入要搜索的关键字', :value => params[:name] , :class => 'blueinputbar', :required => true %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise"%>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -32,3 +47,36 @@
|
|||
<div style="height: 20px; width: 100%;"></div>
|
||||
<% end %>
|
||||
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
|
||||
<script type='text/javascript'>
|
||||
jQuery.fn.highlight = function(pat) {
|
||||
function innerHighlight(node, pat) {
|
||||
var skip = 0;
|
||||
if (node.nodeType == 3) {
|
||||
var pos = node.data.toUpperCase().indexOf(pat);
|
||||
if (pos >= 0) {
|
||||
var spannode = document.createElement('span');
|
||||
spannode.className = 'highlight';
|
||||
var middlebit = node.splitText(pos);
|
||||
var endbit = middlebit.splitText(pat.length);
|
||||
var middleclone = middlebit.cloneNode(true);
|
||||
spannode.appendChild(middleclone);
|
||||
middlebit.parentNode.replaceChild(spannode, middlebit);
|
||||
skip = 1;
|
||||
}
|
||||
}
|
||||
else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
|
||||
for (var i = 0; i < node.childNodes.length; ++i) {
|
||||
i += innerHighlight(node.childNodes[i], pat);
|
||||
}
|
||||
}
|
||||
return skip;
|
||||
}
|
||||
return this.each(function() {
|
||||
innerHighlight(this, pat.toUpperCase());
|
||||
});
|
||||
};
|
||||
$(document).ready(function($) {
|
||||
$('.cb span').highlight('<%=params[:name]%>')
|
||||
// $('#main').highlight('<%=params[:name]%>')
|
||||
});
|
||||
</script>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 41 KiB |
Binary file not shown.
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 41 KiB |
Loading…
Reference in New Issue