Mercurial > hg > soundsoftware-site
diff app/controllers/search_controller.rb @ 511:107d36338b70 live
Merge from branch "cannam"
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:43:07 +0100 |
parents | 851510f1b535 |
children | 5e80956cc792 |
line wrap: on
line diff
--- a/app/controllers/search_controller.rb Thu Jun 09 16:51:06 2011 +0100 +++ b/app/controllers/search_controller.rb Thu Jul 14 10:43:07 2011 +0100 @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -24,8 +24,8 @@ def index @question = params[:q] || "" @question.strip! - @all_words = params[:all_words] || (params[:submit] ? false : true) - @titles_only = !params[:titles_only].nil? + @all_words = params[:all_words] ? params[:all_words].present? : true + @titles_only = params[:titles_only] ? params[:titles_only].present? : false projects_to_search = case params[:scope] @@ -69,6 +69,7 @@ # no more than 5 tokens to search for @tokens.slice! 5..-1 if @tokens.size > 5 + @project_matches = [] @results = [] @results_by_type = Hash.new {|h,k| h[k] = 0} @@ -82,6 +83,12 @@ :before => params[:previous].nil?) @results += r @results_by_type[s] += c + if s == 'projects' + r, c = s.singularize.camelcase.constantize.search(@tokens, nil, + :all_words => @all_words, + :titles_only => 1) + @project_matches += r + end end @results = @results.sort {|a,b| b.event_datetime <=> a.event_datetime} if params[:previous].nil?