aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb81
-rw-r--r--app/controllers/general_controller.rb114
-rw-r--r--app/controllers/public_body_controller.rb18
-rw-r--r--app/controllers/request_controller.rb6
-rwxr-xr-xapp/helpers/link_to_helper.rb21
-rw-r--r--app/models/info_request_event.rb12
-rw-r--r--app/models/public_body.rb2
-rw-r--r--app/models/track_thing.rb12
-rw-r--r--app/views/general/advanced_search.rhtml0
-rw-r--r--app/views/general/search.rhtml164
-rw-r--r--app/views/public_body/list.rhtml1
-rw-r--r--app/views/public_body/show.rhtml2
-rw-r--r--app/views/request/_request_filter_form.rhtml2
-rw-r--r--config/routes.rb3
-rw-r--r--public/stylesheets/main.css18
15 files changed, 292 insertions, 164 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 31a6ef3db..caf613f8d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -351,22 +351,15 @@ class ApplicationController < ActionController::Base
def param_exists(item)
return params[item] && !params[item].empty?
- end
-
- def alter_query_from_params
- # various forms are used to customise queries and hide
- # xapian's complexity. This parses the form fields and turns
- # them into a xapian query string
- if params[:latest_status].nil?
- params[:latest_status] = params[:view] || "all"
- end
- query = params[:query]
- query = "" if query.nil?
+ end
+
+ def get_request_variety_from_params
+ query = ""
sortby = "newest"
- if params[:request_variety] && !(query =~ /variety:/)
- sortby = "described"
- varieties = []
+ varieties = []
+ if params[:request_variety] && !(query =~ /variety:/)
if params[:request_variety].include? "sent"
+ varieties -= ['variety:sent', 'variety:followup_sent', 'variety:response', 'variety:comment']
varieties << ['variety:sent', 'variety:followup_sent']
end
if params[:request_variety].include? "response"
@@ -375,48 +368,50 @@ class ApplicationController < ActionController::Base
if params[:request_variety].include? "comment"
varieties << ['variety:comment']
end
- query += " (#{varieties.join(' OR ')})"
end
- if params[:latest_status] && !(query =~ /latest_status:/)
+ if !varieties.empty?
+ query = " (#{varieties.join(' OR ')})"
+ end
+ return query
+ end
+
+ def get_status_from_params
+ query = ""
+ if params[:latest_status]
statuses = []
if params[:latest_status].class == String
params[:latest_status] = [params[:latest_status]]
end
if params[:latest_status].include?("recent") || params[:latest_status].include?("all")
- if !(query =~ /variety:/)
- query += " (variety:sent)"
- end
+ query += " (variety:sent)"
end
if params[:latest_status].include? "successful"
statuses << ['latest_status:successful', 'latest_status:partially_successful']
- sortby = "described"
end
if params[:latest_status].include? "unsuccessful"
statuses << ['latest_status:rejected', 'latest_status:not_held']
- sortby = "described"
end
if params[:latest_status].include? "awaiting"
statuses << ['latest_status:waiting_response', 'latest_status:waiting_clarification', 'waiting_classification:true']
- sortby = "described"
end
if params[:latest_status].include? "internal_review"
statuses << ['status:internal_review']
- sortby = "described"
end
if params[:latest_status].include? "other"
statuses << ['latest_status:gone_postal', 'latest_status:error_message', 'latest_status:requires_admin', 'latest_status:user_withdrawn']
- sortby = "described"
end
if params[:latest_status].include? "gone_postal"
statuses << ['latest_status:gone_postal']
- sortby = "described"
end
- query += " (#{statuses.join(' OR ')})"
-
- end
- if query.empty?
- query = "variety:sent"
+ if !statuses.empty?
+ query = " (#{statuses.join(' OR ')})"
+ end
end
+ return query
+ end
+
+ def get_date_range_from_params
+ query = ""
if param_exists(:request_date_after) && !param_exists(:request_date_before)
params[:request_date_before] = Date.now.strftime("%d/%m/%Y")
query += " #{params[:request_date_after]}..#{params[:request_date_before]}"
@@ -424,10 +419,32 @@ class ApplicationController < ActionController::Base
params[:request_date_after] = "01/01/2008"
end
if param_exists(:request_date_after)
- query = "#{params[:request_date_after]}..#{params[:request_date_before]} " + query
+ query = " #{params[:request_date_after]}..#{params[:request_date_before]}"
end
- return query, sortby
+ return query
+ end
+ def get_tags_from_params
+ query = ""
+ tags = []
+ if param_exists(:tags)
+ params[:tags].split().each do |tag|
+ tags << "tag:#{tag}"
+ end
+ end
+ if !tags.empty?
+ query = " (#{tags.join(' OR ')})"
+ end
+ return query
+ end
+
+ def make_query_from_params
+ query = params[:query] || "" if query.nil?
+ query += get_date_range_from_params
+ query += get_request_variety_from_params
+ query += get_status_from_params
+ query += get_tags_from_params
+ return query
end
# URL generating functions are needed by all controllers (for redirects),
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index e9325c3c5..2d0527d3a 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -82,23 +82,34 @@ class GeneralController < ApplicationController
# Just does a redirect from ?query= search to /query
def search_redirect
- @query = alter_query_from_params
+ if params[:advanced].nil?
+ @query, _ = make_query_from_params
+ else
+ @query, _ = params[:query]
+ end
@sortby = params[:sortby]
- @bodies = params[:bodies]
- [:latest_status, :request_variety, :request_date_after, :request_date_before, :query].each do |x|
+ path = request.path.split("/")
+ if path.size > 0 && (['newest', 'described', 'relevant'].include?(path[-1]))
+ @sort_postfix = path.pop
+ end
+ if path.size > 0 && (['bodies', 'requests', 'users', 'all'].include?(path[-1]))
+ @variety_postfix = path.pop
+ end
+ @variety_postfix = params[:bodies] if @variety_postfix.nil? && !params[:bodies].nil?
+ @variety_postfix = "all" if @variety_postfix.nil?
+ if @variety_postfix != "users"
+ @common_query = get_tags_from_params
+ end
+ [:latest_status, :request_variety, :request_date_after, :request_date_before, :query, :tags].each do |x|
session[x] = params[x]
end
if @query.nil? || @query.empty?
@query = nil
@page = 1
+ @advanced = !params[:advanced].nil?
render :action => "search"
else
- if (@bodies == '1') && (@sortby.nil? || @sortby.empty?)
- @postfix = 'bodies'
- else
- @postfix = @sortby
- end
- redirect_to search_url(@query, @postfix)
+ redirect_to search_url(@query, @variety_postfix, @sort_postfix, params[:advanced])
end
end
@@ -106,26 +117,49 @@ class GeneralController < ApplicationController
def search
# XXX Why is this so complicated with arrays and stuff? Look at the route
# in config/routes.rb for comments.
- [:latest_status, :request_variety, :request_date_after, :request_date_before, :query].each do |x|
+ if !params[:commit].nil?
+ search_redirect
+ return
+ end
+ [:latest_status, :request_variety, :request_date_after, :request_date_before, :query, :tags].each do |x|
params[x] = session[x]
end
combined = params[:combined]
@sortby = nil
- @bodies = false # searching from front page, largely for a public authority
+ @bodies = @requests = @users = true
+ if combined.size > 0 && (['advanced'].include?(combined[-1]))
+ combined.pop
+ @advanced = true
+ else
+ @advanced = false
+ end
# XXX currently /described isn't linked to anywhere, just used in RSS and for /list/successful
# This is because it's confusingly different from /newest - but still useful for power users.
- if combined.size > 1 && (['newest', 'described', 'bodies', 'relevant'].include?(combined[-1]))
- @postfix = combined[-1]
- combined = combined[0..-2]
- if @postfix == 'bodies'
+ if combined.size > 0 && (['newest', 'described', 'relevant'].include?(combined[-1]))
+ @sort_postfix = combined.pop
+ @sortby = @sort_postfix
+ end
+
+ if combined.size > 0 && (['bodies', 'requests', 'users', 'all'].include?(combined[-1]))
+ @variety_postfix = combined.pop
+ case @variety_postfix
+ when 'bodies'
@bodies = true
- else
- @sortby = @postfix
+ @requests = false
+ @users = false
+ when 'requests'
+ @bodies = false
+ @requests = true
+ @users = false
+ when 'users'
+ @bodies = false
+ @requests = false
+ @users = true
end
end
@query = combined.join("/")
-
@inputted_sortby = @sortby
+ @common_query = get_tags_from_params
if @sortby.nil?
# Parse query, so can work out if it has prefix terms only - if so then it is a
# structured query which should show newest first, rather than a free text search
@@ -151,21 +185,41 @@ class GeneralController < ApplicationController
if params[:requests_per_page]
requests_per_page = params[:requests_per_page].to_i
end
- @xapian_requests = perform_search([InfoRequestEvent], @query, @sortby, 'request_collapse', requests_per_page)
- @requests_per_page = @per_page
- @xapian_bodies = perform_search([PublicBody], @query, @sortby, nil, 5)
- @bodies_per_page = @per_page
- @xapian_users = perform_search([User], @query, @sortby, nil, 5)
- @users_per_page = @per_page
-
- @this_page_hits = @xapian_requests.results.size + @xapian_bodies.results.size + @xapian_users.results.size
- @total_hits = @xapian_requests.matches_estimated + @xapian_bodies.matches_estimated + @xapian_users.matches_estimated
+ @this_page_hits = @total_hits = @xapian_requests_hits = @xapian_bodies_hits = @xapian_users_hits = 0
+ if @requests
+ @xapian_requests = perform_search([InfoRequestEvent], @query, @sortby, 'request_collapse', requests_per_page)
+ @requests_per_page = @per_page
+ @this_page_hits += @xapian_requests.results.size
+ @xapian_requests_hits = @xapian_requests.results.size
+ @xapian_requests_total_hits = @xapian_requests.matches_estimated
+ @total_hits += @xapian_requests.matches_estimated
+ end
+ if @bodies
+ @xapian_bodies = perform_search([PublicBody], @query, @sortby, nil, 5)
+ @bodies_per_page = @per_page
+ @this_page_hits += @xapian_bodies.results.size
+ @xapian_bodies_hits = @xapian_bodies.results.size
+ @xapian_bodies_total_hits = @xapian_bodies.matches_estimated
+ @total_hits += @xapian_bodies.matches_estimated
+ end
+ if @users
+ @xapian_users = perform_search([User], @query, @sortby, nil, 5)
+ @users_per_page = @per_page
+ @this_page_hits += @xapian_users.results.size
+ @xapian_users_hits = @xapian_users.results.size
+ @xapian_users_total_hits = @xapian_users.matches_estimated
+ @total_hits += @xapian_users.matches_estimated
+ end
# Spelling and highight words are same for all three queries
- @spelling_correction = @xapian_requests.spelling_correction
- @highlight_words = @xapian_requests.words_to_highlight
+ 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
+ end
- @track_thing = TrackThing.create_track_for_search_query(@query)
+ @track_thing = TrackThing.create_track_for_search_query(@query, @variety_postfix)
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ]
end
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index cb27e78f0..d7d8c2c56 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -38,13 +38,14 @@ class PublicBodyController < ApplicationController
if !referrer.nil? && referrer.match(%r{^#{top_url}search/.*/bodies$})
@searched_to_send_request = true
end
- query, sortby = alter_query_from_params
- if !query.empty?
- query = "(#{query})"
- end
- query += "requested_from:#{@public_body.url_name}"
+ @view = params[:view]
+ params[:latest_status] = @view
+
+ query = make_query_from_params
+ query += " requested_from:#{@public_body.url_name}"
# Use search query for this so can collapse and paginate easily
# XXX really should just use SQL query here rather than Xapian.
+ sortby = "described"
begin
@xapian_requests = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
if (@page > 1)
@@ -86,12 +87,7 @@ class PublicBodyController < ApplicationController
def list
long_cache
# XXX move some of these tag SQL queries into has_tag_string.rb
- if params[:commit] != _('Show all')
- @query = "%#{params[:public_body_query].nil? ? "" : params[:public_body_query]}%"
- else
- redirect_to list_public_bodies_url(:tag => "all")
- return
- end
+ @query = "%#{params[:public_body_query].nil? ? "" : params[:public_body_query]}%"
@tag = params[:tag]
@locale = self.locale_from_params()
locale_condition = "upper(public_body_translations.name) LIKE upper(?) AND public_body_translations.locale = ?"
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index bb91cc854..3c283baae 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -129,10 +129,10 @@ class RequestController < ApplicationController
def list
medium_cache
@view = params[:view]
- params[:request_status] = "recent" if params[:query].nil? && params[:request_status].nil?
- query, sortby = alter_query_from_params
+ params[:latest_status] = @view
+ query = make_query_from_params
@title = "View and search requests"
-
+ sortby = "newest"
@page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect
behavior_cache :tag => [@view, @page] do
xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 1299e53eb..54b8d69d0 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -135,11 +135,10 @@ module LinkToHelper
end
end
- # General pages. postfix is either the sort order, or 'bodies' to show you
- # came from the front page and are looking for public bodies
- def search_url(query, postfix = nil)
+ # General pages.
+ def search_url(query, variety_postfix = nil, sort_postfix = nil, advanced = nil)
+ query = query - ["", nil] if query.kind_of?(Array)
url = search_general_url(:combined => query)
-
# Here we can't escape the slashes, as RFC 2396 doesn't allow slashes
# within a path component. Rails is assuming when generating URLs that
# either there aren't slashes, or we are in a query part where you can
@@ -151,13 +150,19 @@ module LinkToHelper
# http://rails.lighthouseapp.com/projects/8994/tickets/144-patch-bug-in-rails-route-globbing
url = url.gsub("%2F", "/")
- if !postfix.nil? && !postfix.empty?
- url = url + "/" + postfix
+ if !variety_postfix.nil? && !variety_postfix.empty?
+ url = url + "/" + variety_postfix
+ end
+ if !sort_postfix.nil? && !sort_postfix.empty?
+ url = url + "/" + sort_postfix
+ end
+ if !advanced.nil? && (advanced)
+ url = url + "/advanced"
end
return url
end
- def search_link(query, postfix = nil)
- link_to h(query), search_url(query, postfix)
+ def search_link(query, variety_postfix = nil, sort_postfix = nil, advanced = nil)
+ link_to h(query), search_url(query, variety_postfix, sort_postfix, advanced)
end
# Admin pages
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index fbf70332d..4003217b0 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -134,11 +134,19 @@ class InfoRequestEvent < ActiveRecord::Base
end
def latest_variety
- self.info_request.get_last_event.variety
+ for event in self.info_request.info_request_events.reverse
+ if !event.variety.nil? and !event.variety.empty?
+ return event.variety
+ end
+ end
end
def latest_status
- self.info_request.get_last_event.calculated_state
+ for event in self.info_request.info_request_events.reverse
+ if !event.calculated_state.nil? and !event.calculated_state.empty?
+ return event.calculated_state
+ end
+ end
end
def waiting_classification
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index c19433704..81149e3c2 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -206,7 +206,7 @@ class PublicBody < ActiveRecord::Base
return self.created_at.strftime("%Y%m%d%H%M%S")
end
def variety
- "authority"
+ return "authority"
end
# if the URL name has changed, then all requested_from: queries
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index f993b4fe8..1cd957549 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -105,9 +105,19 @@ class TrackThing < ActiveRecord::Base
return track_thing
end
- def TrackThing.create_track_for_search_query(query)
+ def TrackThing.create_track_for_search_query(query, variety_postfix = nil)
track_thing = TrackThing.new
track_thing.track_type = 'search_query'
+ if !(query =~ /variety:/)
+ case variety_postfix
+ when "requests"
+ query += " variety:sent"
+ when "users"
+ query += " variety:user"
+ when "authorities"
+ query += " variety:authority"
+ end
+ end
track_thing.track_query = query
return track_thing
end
diff --git a/app/views/general/advanced_search.rhtml b/app/views/general/advanced_search.rhtml
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/app/views/general/advanced_search.rhtml
diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml
index c66c41774..853765a8a 100644
--- a/app/views/general/search.rhtml
+++ b/app/views/general/search.rhtml
@@ -10,31 +10,76 @@
<% @include_request_link_in_authority_listing = true %>
<h1><%=@title%></h1>
-
-<% if @bodies && (@page == 1 || @xapian_bodies.results.size > 0) %>
- <div id="stepwise_instructions">
- <p><strong><%=_("Next, select the public authority you'd like to make the request from.") %></strong></p>
- <p><% _('Can\'t find it? <a href="%s">Browse all</a> or <a href="%s">ask us to add it</a>.') % [list_public_bodies_default, "#{help_requesting_path}#missing_body"] %></p>
- <p>
- </div>
-<% end %>
-
<script>
$(function() {
- $(".use-datepicker").datepicker();
+ $(".use-datepicker").datepicker({dateFormat: 'yy-mm-dd'});
});
</script>
-<div id="list-filter">
- <div class="list-search-item">
- <% form_tag(search_redirect_url, :method => "get") do %>
+<% if @advanced %>
+ <p><%= _('To use the advanced search, combine phrases and labels as described in the search tips below.') %></p>
+ <% form_tag(advanced_search_url, :method => "get") do %>
+ <%= label_tag(:query, _("Search for:")) %>
+ <%= text_field_tag(:query, params[:query], { :size => 40 }) %>
+ <%= submit_tag("Search") %>
+ <% end %>
+ <p><%= link_to(_("Simple search"), search_redirect_url) %></p>
+
+<% else %>
+
+<div id="list-filter">
+ <div id="simple-search-box">
+ <% form_tag(request.url, :method => "get") do %>
<%= label_tag(:query, _("Search for:")) %>
<%= text_field_tag(:query, params[:query], { :size => 40 }) %>
<%= submit_tag("Search") %>
</div>
- <div class="list-filter-item">
- <%= _("Restrict search to:") %> <br />
+
+ <fieldset>
+ <legend>
+ <%= _("Filters:") %>
+ </legend>
+<div id="common-subfilters">
+ <div id="variety-filter">
+ <ul>
+ <% for variety, label in [
+ ["all", _("everything")],
+ ["requests", _("requests")],
+ ["users", _("users")],
+ ["bodies", _("authorities")]]%>
+ <li>
+ <% if @variety_postfix != variety %>
+ <% if variety != "users" %>
+ <%= link_to label, search_url([params[:query], @common_query], variety, @sort_postfix), :method => :get %>
+ <% else %>
+ <%= link_to label, search_url(params[:query], variety, @sort_postfix), :method => :get %>
+ <% end %>
+ <% else %>
+ <%= label %>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+ </div>
+
+<% if false %>
+<%-# Commented out for now as tags are of limited use when users can't see them. This will change in the future! -%>
+<% if @variety_postfix != "users" %>
+ <div>
+ <%= label_tag(:query, _("Tags (separated by a space):")) %><%= text_field_tag(:tags, params[:tags], { :size => 20 }) %>
+ <% for tag in InfoRequest.get_tags %>
+ <%= tag.name_and_value %>
+ <% end %>
+ </div>
+<% end %>
+<% end %>
+</div>
+
+<% if @variety_postfix == "requests" %>
+<div id="requests-subfilters">
+ <div>
+ <%= _("Only show:") %> <br />
<% [["successful", _("successful requests")],
["unsuccessful", _("unsuccessful requests")],
["awaiting", _("unresolved requests")],
@@ -45,7 +90,7 @@
<%= label_tag("latest_status_#{index}", title) %> <br/>
<% end %>
</div>
- <div class="list-filter-item">
+ <div>
<%= _("Search for words in:") %> <br/>
<% [["sent", _("messages from users")],
["response", _("messages from authorities")],
@@ -56,51 +101,43 @@
<%= label_tag("request_variety_#{index}", title) %> <br/>
<% end %>
</div>
- <div class="list-filter-item">
+ <div>
Search between dates:
<%= text_field_tag(:request_date_after, params[:request_date_after], {:class => "use-datepicker", :size => 10}) %> -
<%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %>
</div>
+</div>
<% end %>
-
- <% if not @show_tips %>
- &nbsp;&nbsp;<%= link_to _('Advanced search tips'), search_redirect_path %>
- <% end %>
-
-
+ <%= submit_tag("Filter") %>
+<% end %>
+ </fieldset>
</div>
+
+<p><%= link_to(_("Advanced search"), advanced_search_url) %></p>
+<% end %>
<% if !@query.nil? %>
<p>
- <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url(@query, 'relevant') %>
+ <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url(@query, @variety_postfix, 'relevant', @advanced) %>
|
- <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url(@query, 'newest') %>
+ <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url(@query, @variety_postfix, 'newest', @advanced) %>
<% if @sortby == 'described' %>
| <%= _('Recently described results first') %>
<% end %>
</p>
<% end %>
-<% if @bodies && !@query.nil? && @xapian_bodies.results.size == 0 && @page == 1 %>
- <h1><%= _('No public authorities found') %></h1>
- <% if @spelling_correction %>
- <p id="did_you_mean"><%= _('Did you mean: {{correction}}',
- :correction => search_link(@spelling_correction, @postfix)) %></p>
- <% end %>
- <p><%= _('<a href="%s">Browse all</a> or <a href="%s">ask us to add one</a>.') % [list_public_bodies_default, help_requesting_path + '#missing_body'] %></p>
-<% end %>
-
<% if not @query.nil? %>
<% if @spelling_correction %>
- <p id="did_you_mean"><%= _('Did you mean: {{correction}}', :correction => search_link(@spelling_correction, @postfix)) %></p>
+ <p id="did_you_mean"><%= _('Did you mean: {{correction}}', :correction => search_link(@spelling_correction, @variety_postfix, @sort_postfix, @advanced)) %></p>
<% end %>
- <% if (!@bodies || @xapian_requests.results.size == 0) && @track_thing && (@xapian_bodies.results.size > 0 || @xapian_users.results.size > 0 || @total_hits == 0)%>
+ <% if (!@bodies || @xapian_requests_hits == 0) && @track_thing && (@xapian_bodies_hits > 0 || @xapian_users_hits > 0 || @total_hits == 0)%>
<%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %>
<% end %>
- <% if @xapian_bodies.results.size > 0 %>
- <% if @xapian_bodies.results.size == 1 && @page == 1 %>
+ <% if @xapian_bodies_hits > 0 %>
+ <% if @xapian_bodies_hits == 1 && @page == 1 %>
<h1><%= _('One public authority matching your search', :user_search_query => h(@query)) %></h1>
<% else %>
<h1><%= _('Public authorities {{start_count}} to {{end_count}} of {{total_count}} for {{user_search_query}}', :start_count => ((@page-1)*@bodies_per_page+1).to_s, :end_count => [@page*@bodies_per_page, @xapian_bodies.matches_estimated].min.to_s, :total_count => @xapian_bodies.matches_estimated.to_s, :user_search_query => h(@query)) %></h1>
@@ -113,8 +150,8 @@
<%= will_paginate WillPaginate::Collection.new(@page, @bodies_per_page, @xapian_bodies.matches_estimated) %>
<% end %>
- <% if @xapian_users.results.size > 0 %>
- <% if @xapian_users.results.size == 1 && @page == 1 %>
+ <% if @xapian_users_hits > 0 %>
+ <% if @xapian_users_hits == 1 && @page == 1 %>
<h1><%= _("One person matching &#x2018;{{user_search_query}}&#x2019;", :user_search_query => h(@query)) %></h1>
<% else %>
<h1><%= _("People {{start_count}} to {{end_count}} of {{total_count}} for &#x2018;{{user_search_query}}&#x2019;", :start_count => ((@page-1)*@users_per_page+1).to_s, :end_count => [@page*@users_per_page, @xapian_users.matches_estimated].min.to_s, :total_count => @xapian_users.matches_estimated.to_s, :user_search_query => h(@query)) %></h1>
@@ -127,9 +164,9 @@
<%= will_paginate WillPaginate::Collection.new(@page, @users_per_page, @xapian_users.matches_estimated) %>
<% end %>
- <% if @xapian_requests.results.size > 0 %>
- <% if @xapian_requests.results.size == 1 && @page == 1 %>
- <h1><%= _("One FOI request matching &#x2018;{{user_search_query}}&#x2019;", :user_search_query => h(@query)) %></h1>
+ <% if @xapian_requests_hits > 0 %>
+ <% if @xapian_requests_hits == 1 && @page == 1 %>
+ <h1><%= _("One FOI request matching your search", :user_search_query => h(@query)) %></h1>
<% else %>
<h1><%= _("FOI requests {{start_count}} to {{end_count}} of {{total_count}}", :start_count => ((@page-1)*@requests_per_page+1).to_s, :end_count => [@page*@requests_per_page, @xapian_requests.matches_estimated].min.to_s, :total_count => @xapian_requests.matches_estimated.to_s, :user_search_query => h(@query)) %></h1>
<% end %>
@@ -150,7 +187,10 @@
<% end %>
<% end %>
-<% if @show_tips %>
+<% if @advanced %>
+
+<div id="advanced-search-tips">
+ <a name="show-tips"></a>
<h2><%= _("Advanced search tips")%></h2>
<ul>
<li><%= _("Enter words that you want to find separated by spaces, e.g. <strong>climbing lane</strong>") %></li>
@@ -172,28 +212,30 @@
<h2 id="statuses"><%= _('Table of statuses') %></h2>
<table class="status_table">
- <tr><td><strong><%=search_link('status:waiting_response')%></strong></td><td><%= _('Waiting for the public authority to reply') %></td></tr>
- <tr><td><strong><%=search_link('status:not_held')%></strong></td><td><%= _('The public authority does not have the information requested') %></td></tr>
- <tr><td><strong><%=search_link('status:rejected')%></strong></td><td><%= _('The request was refused by the public authority') %></td></tr>
- <tr><td><strong><%=search_link('status:partially_successful')%></strong></td><td><%= _('Some of the information requested has been received') %></td></tr>
- <tr><td><strong><%=search_link('status:successful')%></strong></td><td><%= _('All of the information requested has been received') %></td></tr>
- <tr><td><strong><%=search_link('status:waiting_clarification')%></strong></td><td><%= _('The public authority would like part of the request explained') %></td></tr>
- <tr><td><strong><%=search_link('status:gone_postal')%></strong></td><td><%= _('The public authority would like to / has responded by post') %></td></tr>
- <tr><td><strong><%=search_link('status:internal_review')%></strong></td><td><%= _('Waiting for the public authority to complete an internal review of their handling of the request') %></td></tr>
- <tr><td><strong><%=search_link('status:error_message')%></strong></td><td><%= _('Received an error message, such as delivery failure.') %></td></tr>
- <tr><td><strong><%=search_link('status:requires_admin')%></strong></td><td><%= _('A strange reponse, required attention by the {{site_name}} team', :site_name=>site_name) %></td></tr>
- <tr><td><strong><%=search_link('status:user_withdrawn')%></strong></td><td><%= _('The requester has abandoned this request for some reason') %></td></tr>
+ <tr><td><strong><%=search_link('status:waiting_response', nil, nil, true)%></strong></td><td><%= _('Waiting for the public authority to reply') %></td></tr>
+ <tr><td><strong><%=search_link('status:not_held', nil, nil, true)%></strong></td><td><%= _('The public authority does not have the information requested') %></td></tr>
+ <tr><td><strong><%=search_link('status:rejected', nil, nil, true)%></strong></td><td><%= _('The request was refused by the public authority') %></td></tr>
+ <tr><td><strong><%=search_link('status:partially_successful', nil, nil, true)%></strong></td><td><%= _('Some of the information requested has been received') %></td></tr>
+ <tr><td><strong><%=search_link('status:successful', nil, nil, true)%></strong></td><td><%= _('All of the information requested has been received') %></td></tr>
+ <tr><td><strong><%=search_link('status:waiting_clarification', nil, nil, true)%></strong></td><td><%= _('The public authority would like part of the request explained') %></td></tr>
+ <tr><td><strong><%=search_link('status:gone_postal', nil, nil, true)%></strong></td><td><%= _('The public authority would like to / has responded by post') %></td></tr>
+ <tr><td><strong><%=search_link('status:internal_review', nil, nil, true)%></strong></td><td><%= _('Waiting for the public authority to complete an internal review of their handling of the request') %></td></tr>
+ <tr><td><strong><%=search_link('status:error_message', nil, nil, true)%></strong></td><td><%= _('Received an error message, such as delivery failure.') %></td></tr>
+ <tr><td><strong><%=search_link('status:requires_admin', nil, nil, true)%></strong></td><td><%= _('A strange reponse, required attention by the {{site_name}} team', :site_name=>site_name) %></td></tr>
+ <tr><td><strong><%=search_link('status:user_withdrawn', nil, nil, true)%></strong></td><td><%= _('The requester has abandoned this request for some reason') %></td></tr>
</table>
<h2 id="varieties"><%= _('Table of varieties') %></h2>
<table class="status_table">
- <tr><td><strong><%=search_link('variety:sent')%></strong></td><td><%= _('Original request sent') %></td></tr>
- <tr><td><strong><%=search_link('variety:followup_sent')%></strong></td><td><%= _('Follow up message sent by requester') %></td></tr>
- <tr><td><strong><%=search_link('variety:response')%></strong></td><td><%= _('Response from a public authority') %></td></tr>
- <tr><td><strong><%=search_link('variety:comment')%></strong></td><td><%= _('Annotation added to request') %></td></tr>
- <tr><td><strong><%=search_link('variety:authority')%></strong></td><td><%= _('A public authority') %></td></tr>
- <tr><td><strong><%=search_link('variety:user')%></strong></td><td><%= _('A {{site_name}} user', :site_name=>site_name) %></td></tr>
+ <tr><td><strong><%=search_link('variety:sent', nil, nil, true)%></strong></td><td><%= _('Original request sent') %></td></tr>
+ <tr><td><strong><%=search_link('variety:followup_sent', nil, nil, true)%></strong></td><td><%= _('Follow up message sent by requester') %></td></tr>
+ <tr><td><strong><%=search_link('variety:response', nil, nil, true)%></strong></td><td><%= _('Response from a public authority') %></td></tr>
+ <tr><td><strong><%=search_link('variety:comment', nil, nil, true)%></strong></td><td><%= _('Annotation added to request') %></td></tr>
+ <tr><td><strong><%=search_link('variety:authority', nil, nil, true)%></strong></td><td><%= _('A public authority') %></td></tr>
+ <tr><td><strong><%=search_link('variety:user', nil, nil, true)%></strong></td><td><%= _('A {{site_name}} user', :site_name=>site_name) %></td></tr>
</table>
+</div>
+
<% end %>
diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml
index 9c36d076b..b3e945907 100644
--- a/app/views/public_body/list.rhtml
+++ b/app/views/public_body/list.rhtml
@@ -42,7 +42,6 @@
<%= label_tag(:public_body_query, _("Search:")) %>
<%= text_field_tag(:public_body_query, params[:public_body_query]) %>
<%= submit_tag(_("Search")) %>
- <%= submit_tag(_("Show all")) %>
<% end %>
<p class="subtitle">
diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml
index 92f07ef1c..1151b9966 100644
--- a/app/views/public_body/show.rhtml
+++ b/app/views/public_body/show.rhtml
@@ -91,7 +91,7 @@
<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @public_body.info_requests.size) %>
<% if @xapian_requests.results.empty? %>
- <p><% _('There were no requests matching your query.')</p>
+ <p><% _('There were no requests matching your query.') %></p>
<% else %>
<p> <%= _('Only requests made using {{site_name}} are shown.', :site_name => site_name) %></p>
<% end %>
diff --git a/app/views/request/_request_filter_form.rhtml b/app/views/request/_request_filter_form.rhtml
index e88ec2723..fd1fc5910 100644
--- a/app/views/request/_request_filter_form.rhtml
+++ b/app/views/request/_request_filter_form.rhtml
@@ -31,6 +31,7 @@
<%= label_tag(:query, _("Search for:")) %>
<%= text_field_tag(:query, params[:query]) %>
</div>
+<% if false # don't think we want this, but leaving as an example %>
<div class="list-filter-item">
<%= _("Search for words in:") %> <br/>
<% [["sent", _("messages from users")],
@@ -42,6 +43,7 @@
<%= label_tag("request_variety_#{index}", title) %> <br/>
<% end %>
</div>
+<% end %>
<div class="list-filter-item">
Search between dates:
<%= text_field_tag(:request_date_after, params[:request_date_after], {:class => "use-datepicker", :size => 10}) %> -
diff --git a/config/routes.rb b/config/routes.rb
index 87d20925c..48ad16fc2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -23,7 +23,8 @@ ActionController::Routing::Routes.draw do |map|
# Couldn't find a way to do this in routes which also picked up multiple other slashes
# and dots and other characters that can appear in search query. So we sort it all
# out in the controller.
- general.search_general '/search/*combined', :action => 'search'
+ general.search_general '/search/*combined', :action => 'search'
+ general.advanced_search '/advancedsearch', :action => 'search_redirect', :advanced => true
general.random_request '/random', :action => 'random_request'
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index 1ce35238d..fa7157b8a 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -1240,18 +1240,12 @@ div#user_locale_switcher {
margin: 5px;
}
-div#list-filter {
- clear: both;
- height: 7em;
-}
-div.list-filter-item {
- float:left;
- width: 200px;
+div#common-subfilters {
+ float: left;
+ width: 300px;
}
-div.list-search-item {
- clear:both
- width: auto;
- margin-bottom: 20px;
-} \ No newline at end of file
+div#requests-subfilters {
+ margin-left: 300px;
+}