aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/general_controller.rb11
-rw-r--r--app/views/general/search.html.erb10
-rw-r--r--app/views/public_body/_search_ahead.html.erb4
3 files changed, 12 insertions, 13 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 540f67ec9..beefef4e6 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -178,6 +178,7 @@ class GeneralController < ApplicationController
@xapian_requests_hits = @xapian_requests.results.size
@xapian_requests_total_hits = @xapian_requests.matches_estimated
@total_hits += @xapian_requests.matches_estimated
+ @request_for_spelling = @xapian_requests
end
if @bodies
@xapian_bodies = perform_search([PublicBody], @query, @sortby, nil, 5)
@@ -186,6 +187,7 @@ class GeneralController < ApplicationController
@xapian_bodies_hits = @xapian_bodies.results.size
@xapian_bodies_total_hits = @xapian_bodies.matches_estimated
@total_hits += @xapian_bodies.matches_estimated
+ @request_for_spelling = @xapian_bodies
end
if @users
@xapian_users = perform_search([User], @query, @sortby, nil, 5)
@@ -194,14 +196,13 @@ class GeneralController < ApplicationController
@xapian_users_hits = @xapian_users.results.size
@xapian_users_total_hits = @xapian_users.matches_estimated
@total_hits += @xapian_users.matches_estimated
+ @request_for_spelling = @xapian_users
end
# Spelling and highight words are same for all three queries
- if !@xapian_requests.nil?
- @highlight_words = @xapian_requests.words_to_highlight
- if !(@xapian_requests.spelling_correction =~ /[a-z]+:/)
- @spelling_correction = @xapian_requests.spelling_correction
- end
+ @highlight_words = @request_for_spelling.words_to_highlight
+ if !(@request_for_spelling.spelling_correction =~ /[a-z]+:/)
+ @spelling_correction = @request_for_spelling.spelling_correction
end
@track_thing = TrackThing.create_track_for_search_query(@query, @variety_postfix)
diff --git a/app/views/general/search.html.erb b/app/views/general/search.html.erb
index d526a93c0..18f258444 100644
--- a/app/views/general/search.html.erb
+++ b/app/views/general/search.html.erb
@@ -116,7 +116,7 @@
<% end # if @advanced %>
- <% if !@query.nil? %>
+ <% if !@query.nil? && @total_hits > 0 %>
<p id="search_controls">
<%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_path([params[:query], @variety_postfix, 'relevant'], params) %>
|
@@ -137,6 +137,9 @@
<div style="clear:both;"></div>
<% if @total_hits == 0 %>
<h2><%=@title %></h2>
+ <% if @spelling_correction %>
+ <p id="did_you_mean"><%= _('Did you mean: {{correction}}', :correction => search_link(@spelling_correction)) %></p>
+ <% end %>
<% end %>
<% if not @query.nil? %>
@@ -155,10 +158,7 @@
</div>
<%= will_paginate WillPaginate::Collection.new(@page, @bodies_per_page, @xapian_bodies.matches_estimated) %>
- <% elsif @bodies && !@query.nil? && @xapian_bodies.results.size == 0 && @page == 1 %>
- <% if @spelling_correction %>
- <p id="did_you_mean"><%= _('Did you mean: {{correction}}', :correction => search_link(@spelling_correction)) %></p>
- <% end %>
+ <% elsif @variety_postfix == 'bodies' %>
<p><%= raw(_('<a href="{{browse_url}}">Browse all</a> or <a href="{{add_url}}">ask us to add one</a>.', :browse_url => list_public_bodies_default_path.html_safe, :add_url => (help_requesting_path + '#missing_body').html_safe)) %></p>
<% end %>
</div>
diff --git a/app/views/public_body/_search_ahead.html.erb b/app/views/public_body/_search_ahead.html.erb
index 3d1dc8f93..2de638034 100644
--- a/app/views/public_body/_search_ahead.html.erb
+++ b/app/views/public_body/_search_ahead.html.erb
@@ -14,7 +14,5 @@
<% end %>
</div>
<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated), :params => {:controller=>"request", :action => "select_authority"} %>
+ <p><%= raw(_('<a href="{{browse_url}}">Browse all</a> or <a href="{{add_url}}">ask us to add one</a>.', :browse_url => list_public_bodies_default_path.html_safe, :add_url => (help_requesting_path + '#missing_body').html_safe)) %></p>
<% end %>
-
-
-