diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 69d775c1..f1d5c655 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -556,7 +556,7 @@ class ProjectsController < ApplicationController @question = params[:q] || "" @question.strip! @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? # tokens must be at least 3 character long @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.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.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(" ") end end diff --git a/app/views/projects/search.rhtml b/app/views/projects/search.rhtml index e699d873..d38cb3b4 100644 --- a/app/views/projects/search.rhtml +++ b/app/views/projects/search.rhtml @@ -5,7 +5,11 @@

<%= text_field_tag 'q', @question, :size => 30 %> <%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> <%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> -<%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %>
+<%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> +<% if @project.wiki %> +<%= check_box_tag 'scope[]', 'wiki', (@scope.include? 'wiki') %> +<% end %> +
<%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %>

<%= submit_tag l(:button_submit), :name => 'submit' %> <% end %> @@ -28,6 +32,10 @@ <%=l(:label_document)%>: <%= link_to highlight_tokens(h(e.title), @tokens), :controller => 'documents', :action => 'show', :id => e %>
<%= highlight_tokens(e.description, @tokens) %>
<%= format_time(e.created_on) %> + <% 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 %>
+ <%= highlight_tokens(e.content.text, @tokens) %>
+ <%= e.content.author ? e.content.author.name : "Anonymous" %>, <%= format_time(e.content.updated_on) %> <% end %>

<% end %>