wiki pages: fix redirects to exact matches during search.
Change wiki page search to redirect to exact matches only when using the quick search bar. Fixes searches sometimes unexpectedly redirecting when doing a regular (non-quick) search that happens to return a single result. Also remove the logic that tries to expand the search when no results are found. This will eventually be replaced with a smarter "did you mean?" search.
This commit is contained in:
@@ -17,16 +17,11 @@ class WikiPagesController < ApplicationController
|
||||
|
||||
def index
|
||||
@wiki_pages = WikiPage.paginated_search(params)
|
||||
respond_with(@wiki_pages) do |format|
|
||||
format.html do
|
||||
if params[:page].nil? || params[:page].to_i == 1
|
||||
if @wiki_pages.length == 1
|
||||
redirect_to(wiki_page_path(@wiki_pages.first))
|
||||
elsif @wiki_pages.length == 0 && params[:search][:title].present? && params[:search][:title] !~ /\*/
|
||||
redirect_to(wiki_pages_path(:search => {:title => "*#{params[:search][:title]}*"}))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if params[:redirect].to_s.truthy? && @wiki_pages.one?
|
||||
redirect_to @wiki_pages.first
|
||||
else
|
||||
respond_with(@wiki_pages)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user