首页搜索分类
This commit is contained in:
parent
6bef7029bc
commit
575fc48ff0
|
@ -80,6 +80,32 @@ class WelcomeController < ApplicationController
|
|||
@student = User.student
|
||||
end
|
||||
|
||||
def search
|
||||
search_condition = params[:q]
|
||||
search_type = params[:search_type].to_sym unless search_condition.blank?
|
||||
|
||||
respond_to do |format|
|
||||
format.html{
|
||||
case search_type
|
||||
when :projects
|
||||
redirect_to projects_search_path(:name => search_condition,
|
||||
:project_type => Project::ProjectType_project)
|
||||
when :courses
|
||||
redirect_to projects_search_path(:name => search_condition,
|
||||
:project_type => Project::ProjectType_course)
|
||||
when :users
|
||||
redirect_to users_search_path(:name => search_condition)
|
||||
when :users_teacher
|
||||
redirect_to users_search_path(:name => search_condition, :role => :teacher)
|
||||
when :users_student
|
||||
redirect_to users_search_path(:name => search_condition, :role => :student)
|
||||
else
|
||||
redirect_to home_path, :alert => l(:label_sumbit_empty)
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
|
||||
<%
|
||||
select_option = []
|
||||
(select_option << ['项目', 'projects']) if project_type == Project::ProjectType_project
|
||||
(select_option << ['课程', 'courses']) if project_type == Project::ProjectType_course
|
||||
select_option << ['用户', 'users']
|
||||
#select_option << ['教师', 'users_teacher'],
|
||||
#select_option << ['学生', 'users_student']
|
||||
%>
|
||||
<%= form_tag({controller: :welcome, action: :search }, method: :get) do %>
|
||||
<div class="project-search" style="float: right">
|
||||
<%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', :size => 30 %>
|
||||
<%= hidden_field_tag 'project_type', project_type %>
|
||||
<%= text_field_tag :q, nil, placeholder:'请输入要搜索的关键字', :size => 27 %>
|
||||
<%= select_tag(:search_type, options_for_select(select_option) ) %>
|
||||
<%#= hidden_field_tag 'project_type', project_type %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -95,8 +95,7 @@
|
|||
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %> </span><span class="font_welcome_Mdescription"><%= l(:label_welcome_trustie_course) %> </span><span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
|
||||
</div>
|
||||
<div class="search-bar">
|
||||
<%= render :partial => "search_project", :locals => {:project_type => 1}%>
|
||||
<div class='font_lighter' style="margin: 0; padding: 0; margin-top: 4px;">全站课程搜索。</div>
|
||||
<%= render :partial => "search_project", :locals => {:project_type => Project::ProjectType_course}%>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
|
|
@ -96,7 +96,6 @@
|
|||
</div>
|
||||
<div class="search-bar">
|
||||
<%= render :partial => "search_project", :locals => {:project_type => 0}%>
|
||||
<div class='font_lighter' style="margin: 0; padding: 0; margin-top: 4px;">全站项目搜索。不会搜索私有项目</div>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
|
|
@ -56,8 +56,8 @@ RedmineApp::Application.routes.draw do
|
|||
match 'git_usage/ch_usage', :controller => 'git_usage', :action => 'ch_usage', :via => :get, :as => 'ch_usage'
|
||||
match 'git_usage/en_usage', :controller => 'git_usage', :action => 'en_usage', :via => :get, :as => 'en_usage'
|
||||
#added by nie
|
||||
match '/projects/search', :controller => 'projects', :action => 'search', :via => [:get, :post], :as => 'search'
|
||||
match '/users/search', :controller => 'users', :action => 'search', :via => [:get, :post], :as => 'search'
|
||||
match '/projects/search', :controller => 'projects', :action => 'search', :via => [:get, :post]
|
||||
match '/users/search', :controller => 'users', :action => 'search', :via => [:get, :post]
|
||||
#end
|
||||
match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post]
|
||||
match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post]
|
||||
|
@ -553,4 +553,6 @@ RedmineApp::Application.routes.draw do
|
|||
match 'tags/remove_tag',:to=>'tags#remove_tag',:as=>"remove_tag"
|
||||
|
||||
match 'words/add_brief_introdution', :controller => 'words', :action => 'add_brief_introdution'
|
||||
|
||||
get ':controller(/:action(/:id))'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue