diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb
index 15a8dfa..b1880a8 100644
--- a/app/controllers/public/search_controller.rb
+++ b/app/controllers/public/search_controller.rb
@@ -86,11 +86,18 @@ class SearchController < ApplicationController
if @results.keys.size == 1
specific_action = @results.keys.first
- send(specific_action)
- render :action => specific_action
+ if respond_to?(specific_action)
+ send(specific_action)
+ render :action => specific_action
+ return
+ end
end
+
+ render :action => 'index'
end
+ alias :assets :index
+
def events
@events = @results[:events]
@calendar = Event.date_range(params[:year], params[:month]).map do |date|
@@ -118,6 +125,10 @@ class SearchController < ApplicationController
end
+ def people
+ #nothing, just to enable
+ end
+
#######################################################
# view the summary of one category
@@ -139,13 +150,6 @@ class SearchController < ApplicationController
end
attr_reader :category
- #def assets
- #@results = { @asset => @finder.recent(@asset, LIST_LIMIT) }
-
- #@asset_name = gettext(SEARCH_IN.find { |entry| entry.first == @asset }[1])
- #@names = { @asset => @asset_name }
- #end
-
def directory
@results = { @asset => @finder.find_by_initial(@asset, params[:initial]) }
@@ -153,7 +157,7 @@ class SearchController < ApplicationController
@asset_name = gettext(SEARCH_IN.find { |entry| entry.first == @asset }[1])
@names = { @asset => @asset_name }
- render :action => 'assets'
+ render :action => @asset
end
def tags
diff --git a/app/helpers/assets_helper.rb b/app/helpers/assets_helper.rb
index a1e84a0..d0f75e5 100644
--- a/app/helpers/assets_helper.rb
+++ b/app/helpers/assets_helper.rb
@@ -2,7 +2,7 @@ module AssetsHelper
def generate_assets_menu()
- options = { :controller => 'search', :action => 'assets', :category_path => (@category ? @category.explode_path : []) }
+ options = { :controller => 'search', :action => 'index', :category_path => (@category ? @category.explode_path : []) }
[
[ options.merge(:asset => 'articles'), "icon-menu-articles", _('Articles') ],
[ options.merge(:asset => 'people'), "icon-menu-people", _('People') ],
diff --git a/app/views/search/_directory.rhtml b/app/views/search/_directory.rhtml
new file mode 100644
index 0000000..6af2623
--- /dev/null
+++ b/app/views/search/_directory.rhtml
@@ -0,0 +1,6 @@
+
+ <%= link_to_unless_current(_('Recent'), :action => 'index') %>
+
+ <%= (?a..?z).map { |initial| link_to_unless_current(('' << initial).upcase, :action => 'directory', :initial => ('' << initial)) }.join(' ') %>
+
+
diff --git a/app/views/search/_display_results.rhtml b/app/views/search/_display_results.rhtml
index 9127a9b..043375b 100644
--- a/app/views/search/_display_results.rhtml
+++ b/app/views/search/_display_results.rhtml
@@ -14,7 +14,9 @@
<% if @controller.action_name != 'assets' %>
<%= @names[name] %>
- <%= link_to _('(see more ...)'), params.merge(:action => 'index', :find_in => [ name ]) %>
+ <% if @results.size != 1 %>
+ <%= link_to _('(see more ...)'), params.merge(:action => 'index', :find_in => [ name ]) %>
+ <% end %>
<% end %>
<% partial = partial_for_class results.first.class %>
@@ -24,7 +26,7 @@
<%= render :partial => partial, :object => hit %>
<% end %>
-
+
diff --git a/app/views/search/people.rhtml b/app/views/search/people.rhtml
new file mode 100644
index 0000000..3e977a7
--- /dev/null
+++ b/app/views/search/people.rhtml
@@ -0,0 +1,18 @@
+<% if @query.blank? %>
+ <%= _('People') %>
+ <%= render :partial => 'directory' %>
+<% else %>
+ <%= h(@category ? (_('Search results for "%{query}" in "%{category}"') % { :query => @query, :category => @category.name}) : (_('Search results for "%s"') % @query)) %>
+
+ <%= link_to _('Browse by name'), :action => 'index', :asset => 'people' %>
+
+<% end %>
+
+
+
+ <%= render :partial => 'search_form', :locals => { :form_title => @query.blank? ? _('Search') : _("Refine your search"), :simple_search => true } %>
+
+
+<%= render :partial => 'display_results' %>
+
+
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
index 8269ce6..1f2ff6b 100644
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -515,11 +515,6 @@ class SearchControllerTest < Test::Unit::TestCase
assert_response 403
end
- should 'expose asset name in instance variable' do
- get :assets, :asset => 'products'
- assert_equal 'Products', assigns(:asset_name)
- end
-
should 'not use design blocks' do
get :index
assert_no_tag :tag => 'div', :attributes => { :id => 'boxes', :class => 'boxes' }
@@ -907,7 +902,10 @@ class SearchControllerTest < Test::Unit::TestCase
end
end
- should 'test somehow the display of events as calendar'
+ should 'provide calendar for events' do
+ get :index, :find_in => [ 'events' ]
+ assert_equal 0, assigns(:calendar).size % 7
+ end
##################################################################
##################################################################
--
libgit2 0.21.2