Commit da85080af9efac681cbe9dab6b28369315965340
1 parent
141aa503
Exists in
master
and in
22 other branches
ActionItem410: putting back people directory
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1895 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
47 additions
and
19 deletions
Show diff stats
app/controllers/public/search_controller.rb
| ... | ... | @@ -86,11 +86,18 @@ class SearchController < ApplicationController |
| 86 | 86 | |
| 87 | 87 | if @results.keys.size == 1 |
| 88 | 88 | specific_action = @results.keys.first |
| 89 | - send(specific_action) | |
| 90 | - render :action => specific_action | |
| 89 | + if respond_to?(specific_action) | |
| 90 | + send(specific_action) | |
| 91 | + render :action => specific_action | |
| 92 | + return | |
| 93 | + end | |
| 91 | 94 | end |
| 95 | + | |
| 96 | + render :action => 'index' | |
| 92 | 97 | end |
| 93 | 98 | |
| 99 | + alias :assets :index | |
| 100 | + | |
| 94 | 101 | def events |
| 95 | 102 | @events = @results[:events] |
| 96 | 103 | @calendar = Event.date_range(params[:year], params[:month]).map do |date| |
| ... | ... | @@ -118,6 +125,10 @@ class SearchController < ApplicationController |
| 118 | 125 | |
| 119 | 126 | end |
| 120 | 127 | |
| 128 | + def people | |
| 129 | + #nothing, just to enable | |
| 130 | + end | |
| 131 | + | |
| 121 | 132 | ####################################################### |
| 122 | 133 | |
| 123 | 134 | # view the summary of one category |
| ... | ... | @@ -139,13 +150,6 @@ class SearchController < ApplicationController |
| 139 | 150 | end |
| 140 | 151 | attr_reader :category |
| 141 | 152 | |
| 142 | - #def assets | |
| 143 | - #@results = { @asset => @finder.recent(@asset, LIST_LIMIT) } | |
| 144 | - | |
| 145 | - #@asset_name = gettext(SEARCH_IN.find { |entry| entry.first == @asset }[1]) | |
| 146 | - #@names = { @asset => @asset_name } | |
| 147 | - #end | |
| 148 | - | |
| 149 | 153 | def directory |
| 150 | 154 | @results = { @asset => @finder.find_by_initial(@asset, params[:initial]) } |
| 151 | 155 | |
| ... | ... | @@ -153,7 +157,7 @@ class SearchController < ApplicationController |
| 153 | 157 | @asset_name = gettext(SEARCH_IN.find { |entry| entry.first == @asset }[1]) |
| 154 | 158 | @names = { @asset => @asset_name } |
| 155 | 159 | |
| 156 | - render :action => 'assets' | |
| 160 | + render :action => @asset | |
| 157 | 161 | end |
| 158 | 162 | |
| 159 | 163 | def tags | ... | ... |
app/helpers/assets_helper.rb
| ... | ... | @@ -2,7 +2,7 @@ module AssetsHelper |
| 2 | 2 | |
| 3 | 3 | def generate_assets_menu() |
| 4 | 4 | |
| 5 | - options = { :controller => 'search', :action => 'assets', :category_path => (@category ? @category.explode_path : []) } | |
| 5 | + options = { :controller => 'search', :action => 'index', :category_path => (@category ? @category.explode_path : []) } | |
| 6 | 6 | [ |
| 7 | 7 | [ options.merge(:asset => 'articles'), "icon-menu-articles", _('Articles') ], |
| 8 | 8 | [ options.merge(:asset => 'people'), "icon-menu-people", _('People') ], | ... | ... |
| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | +<div style='text-align: center'> | |
| 2 | + <%= link_to_unless_current(_('Recent'), :action => 'index') %> | |
| 3 | + | |
| 4 | + <%= (?a..?z).map { |initial| link_to_unless_current(('' << initial).upcase, :action => 'directory', :initial => ('' << initial)) }.join(' ') %> | |
| 5 | +</div> | |
| 6 | +<br style='clear:both'/> | ... | ... |
app/views/search/_display_results.rhtml
| ... | ... | @@ -14,7 +14,9 @@ |
| 14 | 14 | <% if @controller.action_name != 'assets' %> |
| 15 | 15 | <h3> |
| 16 | 16 | <%= @names[name] %> |
| 17 | - <%= link_to _('(see more ...)'), params.merge(:action => 'index', :find_in => [ name ]) %> | |
| 17 | + <% if @results.size != 1 %> | |
| 18 | + <%= link_to _('(see more ...)'), params.merge(:action => 'index', :find_in => [ name ]) %> | |
| 19 | + <% end %> | |
| 18 | 20 | </h3> |
| 19 | 21 | <% end %> |
| 20 | 22 | <% partial = partial_for_class results.first.class %> |
| ... | ... | @@ -24,7 +26,7 @@ |
| 24 | 26 | <%= render :partial => partial, :object => hit %> |
| 25 | 27 | <% end %> |
| 26 | 28 | </ul> |
| 27 | - <hr /> | |
| 29 | + <br /> | |
| 28 | 30 | </div><!-- end class="search-results-innerbox" --> |
| 29 | 31 | |
| 30 | 32 | </div><!-- end class="search-results-<%= name %>" --> | ... | ... |
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | +<% if @query.blank? %> | |
| 2 | + <h1><%= _('People') %></h1> | |
| 3 | + <%= render :partial => 'directory' %> | |
| 4 | +<% else %> | |
| 5 | + <h1> <%= h(@category ? (_('Search results for "%{query}" in "%{category}"') % { :query => @query, :category => @category.name}) : (_('Search results for "%s"') % @query)) %> </h1> | |
| 6 | + <div style='text-align: center'> | |
| 7 | + <%= link_to _('Browse by name'), :action => 'index', :asset => 'people' %> | |
| 8 | + </div> | |
| 9 | +<% end %> | |
| 10 | + | |
| 11 | + | |
| 12 | +<div style='text-align: center'> | |
| 13 | + <%= render :partial => 'search_form', :locals => { :form_title => @query.blank? ? _('Search') : _("Refine your search"), :simple_search => true } %> | |
| 14 | +</div> | |
| 15 | + | |
| 16 | +<%= render :partial => 'display_results' %> | |
| 17 | + | |
| 18 | +<br style="clear:both" /> | ... | ... |
test/functional/search_controller_test.rb
| ... | ... | @@ -515,11 +515,6 @@ class SearchControllerTest < Test::Unit::TestCase |
| 515 | 515 | assert_response 403 |
| 516 | 516 | end |
| 517 | 517 | |
| 518 | - should 'expose asset name in instance variable' do | |
| 519 | - get :assets, :asset => 'products' | |
| 520 | - assert_equal 'Products', assigns(:asset_name) | |
| 521 | - end | |
| 522 | - | |
| 523 | 518 | should 'not use design blocks' do |
| 524 | 519 | get :index |
| 525 | 520 | assert_no_tag :tag => 'div', :attributes => { :id => 'boxes', :class => 'boxes' } |
| ... | ... | @@ -907,7 +902,10 @@ class SearchControllerTest < Test::Unit::TestCase |
| 907 | 902 | end |
| 908 | 903 | end |
| 909 | 904 | |
| 910 | - should 'test somehow the display of events as calendar' | |
| 905 | + should 'provide calendar for events' do | |
| 906 | + get :index, :find_in => [ 'events' ] | |
| 907 | + assert_equal 0, assigns(:calendar).size % 7 | |
| 908 | + end | |
| 911 | 909 | |
| 912 | 910 | ################################################################## |
| 913 | 911 | ################################################################## | ... | ... |