summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-05 19:37:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-05 19:37:13 +0000
commit8dcc041244822db6d994bc04dea94306216c4ee0 (patch)
tree10fba9adf860ba474109bc58ab78a4c4545e470d
parentc27106d8595c4ce668ae95cff776be932a525a9e (diff)
downloadredmine-8dcc041244822db6d994bc04dea94306216c4ee0.tar.gz
redmine-8dcc041244822db6d994bc04dea94306216c4ee0.zip
Issue notes are now included in search.
Fixed: search results too long when there are many matches. Fixed: search results not escaped. git-svn-id: http://redmine.rubyforge.org/svn/trunk@705 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/search_controller.rb4
-rw-r--r--app/helpers/search_helper.rb7
2 files changed, 10 insertions, 1 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 01c72f182..2a3fe4f7c 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -51,6 +51,10 @@ class SearchController < ApplicationController
@results = []
if @project
@results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(subject) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues'
+ Journal.with_scope :find => {:conditions => ["#{Issue.table_name}.project_id = ?", @project.id]} do
+ @results += Journal.find(:all, :include => :issue, :limit => limit, :conditions => [ (["(LOWER(notes) like ? OR LOWER(notes) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ).collect(&:issue) if @scope.include? 'issues'
+ end
+ @results.uniq!
@results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news'
@results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents'
@results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(title) like ? OR LOWER(text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki')
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index bc408a305..676a7e8e3 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -21,7 +21,12 @@ module SearchHelper
regexp = Regexp.new "(#{tokens.join('|')})", Regexp::IGNORECASE
result = ''
text.split(regexp).each_with_index do |words, i|
- result << (i.even? ? (words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words) : content_tag('span', words, :class => 'highlight'))
+ if result.length > 1200
+ # maximum length of the preview reached
+ result << '...'
+ break
+ end
+ result << (i.even? ? h(words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words) : content_tag('span', h(words), :class => 'highlight'))
end
result
end