extended the search to wiki content
git-svn-id: http://redmine.rubyforge.org/svn/trunk@325 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
290485b144
commit
dd83445fd7
|
@ -556,7 +556,7 @@ class ProjectsController < ApplicationController
|
||||||
@question = params[:q] || ""
|
@question = params[:q] || ""
|
||||||
@question.strip!
|
@question.strip!
|
||||||
@all_words = params[:all_words] || (params[:submit] ? false : true)
|
@all_words = params[:all_words] || (params[:submit] ? false : true)
|
||||||
@scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) )
|
@scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents wiki) )
|
||||||
if !@question.empty?
|
if !@question.empty?
|
||||||
# tokens must be at least 3 character long
|
# tokens must be at least 3 character long
|
||||||
@tokens = @question.split.uniq.select {|w| w.length > 2 }
|
@tokens = @question.split.uniq.select {|w| w.length > 2 }
|
||||||
|
@ -570,6 +570,7 @@ class ProjectsController < ApplicationController
|
||||||
@results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(issues.subject) like ? OR LOWER(issues.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues'
|
@results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(issues.subject) like ? OR LOWER(issues.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues'
|
||||||
@results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(news.title) like ? OR LOWER(news.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news'
|
@results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(news.title) like ? OR LOWER(news.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.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(wiki_pages.title) like ? OR LOWER(wiki_contents.text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki')
|
||||||
@question = @tokens.join(" ")
|
@question = @tokens.join(" ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,11 @@
|
||||||
<p><%= text_field_tag 'q', @question, :size => 30 %>
|
<p><%= text_field_tag 'q', @question, :size => 30 %>
|
||||||
<%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> <label><%= l(:label_issue_plural) %></label>
|
<%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> <label><%= l(:label_issue_plural) %></label>
|
||||||
<%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> <label><%= l(:label_news_plural) %></label>
|
<%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> <label><%= l(:label_news_plural) %></label>
|
||||||
<%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> <label><%= l(:label_document_plural) %></label><br />
|
<%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> <label><%= l(:label_document_plural) %></label>
|
||||||
|
<% if @project.wiki %>
|
||||||
|
<%= check_box_tag 'scope[]', 'wiki', (@scope.include? 'wiki') %> <label><%= l(:label_wiki) %></label>
|
||||||
|
<% end %>
|
||||||
|
<br />
|
||||||
<%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></p>
|
<%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></p>
|
||||||
<%= submit_tag l(:button_submit), :name => 'submit' %>
|
<%= submit_tag l(:button_submit), :name => 'submit' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -28,6 +32,10 @@
|
||||||
<%=l(:label_document)%>: <%= link_to highlight_tokens(h(e.title), @tokens), :controller => 'documents', :action => 'show', :id => e %><br />
|
<%=l(:label_document)%>: <%= link_to highlight_tokens(h(e.title), @tokens), :controller => 'documents', :action => 'show', :id => e %><br />
|
||||||
<%= highlight_tokens(e.description, @tokens) %><br />
|
<%= highlight_tokens(e.description, @tokens) %><br />
|
||||||
<i><%= format_time(e.created_on) %></i>
|
<i><%= format_time(e.created_on) %></i>
|
||||||
|
<% elsif e.is_a? WikiPage %>
|
||||||
|
<%=l(:label_wiki)%>: <%= link_to highlight_tokens(h(e.pretty_title), @tokens), :controller => 'wiki', :action => 'index', :id => @project, :page => e.title %><br />
|
||||||
|
<%= highlight_tokens(e.content.text, @tokens) %><br />
|
||||||
|
<i><%= e.content.author ? e.content.author.name : "Anonymous" %>, <%= format_time(e.content.updated_on) %></i>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p></li>
|
</p></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in New Issue