diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb
index bbaecbb..e0dc981 100644
--- a/app/controllers/public/search_controller.rb
+++ b/app/controllers/public/search_controller.rb
@@ -29,8 +29,8 @@ class SearchController < ApplicationController
end
def check_search_whole_site
- if params[:search_whole_site] == 'yes'
- redirect_to params.merge(:category_path => [], :search_whole_site => nil)
+ if params[:search_whole_site_yes] or params[:search_whole_site] == 'yes'
+ redirect_to params.merge(:category_path => [], :search_whole_site => nil, :search_whole_site_yes => nil)
end
end
diff --git a/app/models/category.rb b/app/models/category.rb
index 5bd02b0..f0be803 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -54,6 +54,7 @@ class Category < ActiveRecord::Base
def display_in_menu?
# FIXME don't hardcode like this. Should be a setting of the environment, maybe
total_items >= 10
+ true
end
end
diff --git a/app/views/search/_display_results.rhtml b/app/views/search/_display_results.rhtml
index 1599aa5..cf0d7f1 100644
--- a/app/views/search/_display_results.rhtml
+++ b/app/views/search/_display_results.rhtml
@@ -1,15 +1,8 @@
-<% if @category && !@query.blank? %>
-
-<%= link_to _('Search for "%s" in the whole site') % @query,
- :controller => 'search', :action => 'index', :category_path => [], :query => @query %>
-
-<% end %>
-
<%
- pos2 = :odd # allow to format in a two colons layout
- pos3 = 3 # allow to format in a thre colons layout
+ pos2 = :odd # allow to format in a two columns layout
+ pos3 = 3 # allow to format in a thre columns layout
%>
<% @results.each do |name,results| %>
<%
diff --git a/app/views/search/_search_form.rhtml b/app/views/search/_search_form.rhtml
index edd6e23..728617a 100644
--- a/app/views/search/_search_form.rhtml
+++ b/app/views/search/_search_form.rhtml
@@ -7,20 +7,13 @@
<%= text_field_tag 'query', @query, :id => ( lightbox? ? 'popup-search-input' : '' ), :size => 50 %>
<%= javascript_tag '$("popup-search-input").focus()' if lightbox? %>
- <%= submit_button(:search, _('Search')) %>
+ <%= submit_button(:search, _('Search'), :name => :search_whole_site_no) %>
+ <% if @category %>
+ <%= submit_button(:search, _('Search in whole site'), :name => :search_whole_site_yes) %>
+ <% end %>
- <% if @category %>
-
-
<%= _('Search in:') %>
-
- <%= labelled_radio_button _('Only in %s') % @category.name, :search_whole_site, 'no', true %>
- <%= labelled_radio_button _('Whole site'), :search_whole_site, 'yes' %>
-
-
- <% end %>
-
-
+
<%= _('Search for:') %>
<% @search_in.map { |t,n| [t,gettext(n)] } .
@@ -33,6 +26,13 @@
+ <% if simple_search %>
+ <%= link_to_function(_('Advanced search'), nil, :id => 'advanced_search_link') do |page|
+ page['advanced_search_link'].hide
+ page['advanced-search-options'].toggle
+ end %>
+ <% end %>
+
<% if lightbox?; button_bar do %>
<%= lightbox_close_button _('Close') %>
<% end; end %>
diff --git a/app/views/search/index.rhtml b/app/views/search/index.rhtml
index a7bd3df..8eb85a9 100644
--- a/app/views/search/index.rhtml
+++ b/app/views/search/index.rhtml
@@ -1,7 +1,7 @@
<%=h @category ? (_('Search results for "%{query}" in "%{category}"') % { :query => @query, :category => @category.name}) : (_('Search results for "%s"') % @query) %>
+<%= render :partial => 'search_form', :locals => { :form_title => _("Refine your search"), :simple_search => true } %>
+
<%= render :partial => 'display_results' %>
-<%= render :partial => 'search_form', :locals => { :form_title => _("Refine your search") } %>
-
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
index dad45d0..8364fd9 100644
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -393,8 +393,8 @@ class SearchControllerTest < Test::Unit::TestCase
Category.create!(:name => 'sub', :environment => Environment.default, :parent => parent)
get :popup, :category_path => [ 'cat', 'sub']
- assert_tag :tag => 'input', :attributes => { :type => 'radio', :name => 'search_whole_site', :value => 'yes' }
- assert_tag :tag => 'input', :attributes => { :type => 'radio', :name => 'search_whole_site', :value => 'no', :checked => 'checked' }
+ assert_tag :tag => 'input', :attributes => { :type => 'submit', :name => 'search_whole_site_yes' }
+ assert_tag :tag => 'input', :attributes => { :type => 'submit', :name => 'search_whole_site_no' }
end
should 'search in whole site when told so' do
@@ -534,9 +534,9 @@ class SearchControllerTest < Test::Unit::TestCase
}
end
- should 'offer link to do the same search as before in general context' do
+ should 'offer button search in the whole site' do
get :index, :category_path => [ 'my-category' ], :query => 'a sample search'
- assert_tag :tag => 'a', :attributes => { :href => "/search?query=a+sample+search" }, :content => 'Search for "a sample search" in the whole site'
+ assert_tag :tag => 'input', :attributes => { :type => 'submit', :name => 'search_whole_site_yes' }
end
should 'display only category name in "search results for ..." title' do
@@ -562,6 +562,7 @@ class SearchControllerTest < Test::Unit::TestCase
assert_includes assigns(:results)[:people], p
end
+ # FIXME how do test link_to_remote?
should 'keep asset selection for new searches' do
get :index, :query => 'a sample query', :find_in => [ 'people', 'communities' ]
assert_tag :tag => 'input', :attributes => { :name => 'find_in[]', :value => 'people', :checked => 'checked' }
--
libgit2 0.21.2