diff options
Diffstat (limited to 'app/views/general/search.html.erb')
-rw-r--r-- | app/views/general/search.html.erb | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/app/views/general/search.html.erb b/app/views/general/search.html.erb new file mode 100644 index 000000000..de42d3937 --- /dev/null +++ b/app/views/general/search.html.erb @@ -0,0 +1,210 @@ +<% @show_tips = @xapian_requests.nil? || (@total_hits == 0) %> + +<% @include_request_link_in_authority_listing = true %> + +<%= render :partial => 'localised_datepicker' %> + +<% if @query.nil? %> + <% @title = _("Search Freedom of Information requests, public authorities and users") %> +<% elsif @total_hits == 0 %> + <% @title = _('There were no results matching your query.') %> +<% else %> + <% @title = _("Results page {{page_number}}", :page_number => @page.to_s) %> +<% end%> + +<div id="header_left"> + <% if @query.nil? %> + <h1><%= _("Search") %></h1> + <% else %> + <h1><%= _("Search results") %></h1> + <% end%> + + <% if @advanced %> + <div id="advanced-search"> + <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 %> + <p> + <%= text_field_tag :query, @query, { :size => 60 } %> + <%= hidden_field_tag 'sortby', @inputted_sortby %> + <% if @bodies %> + <%= hidden_field_tag 'bodies', 1 %> + <% end %> + <%= submit_tag _("Search") %> + <%= link_to _('Simple search'), search_redirect_path %> + </p> + <% end %> + </div> + <% else %> + <%= form_tag(request.url, {:method => "get", :id => "search_form"}) do %> + <p> + <%= text_field_tag 'query', params[:query], { :size => 40 } %> + <%= hidden_field_tag 'sortby', @inputted_sortby %> + <% if @bodies %> + <%= hidden_field_tag 'bodies', 1 %> + <% end %> + <%= submit_tag _("Search") %> + <%= link_to(_("Advanced search"), advanced_search_url) %> + </p> + + <div id="common-subfilters"> + <div id="variety-filter"> + <h3 class="title"><%= _("Showing") %></h3> + <% labels = [ + ["requests", _("requests")], + ["users", _("users")], + ["bodies", _("authorities")], + ["all", _("everything")]]%> + <% for variety, label in labels %> + <% if @variety_postfix != variety %> + <%= link_to label, search_url([params[:query], variety, @sort_postfix]) %> + <% else %> + <%= label %> + <% end %> + <%= "|" unless variety == labels.last[0]%> + <% end %> + </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> + <h3 class="title"><%= _("Restrict to") %></h3> + <% [["successful", _("successful requests")], + ["unsuccessful", _("unsuccessful requests")], + ["awaiting", _("unresolved requests")], + ["internal_review", _("internal reviews")]].each_with_index do |item, index| + status, title = item %> + + <%= check_box_tag "latest_status[]", status, params[:latest_status].nil? ? false : params[:latest_status].include?(status), :id => "latest_status_#{index}" %> + <%= label_tag("latest_status_#{index}", title) %> <br/> + <% end %> + </div> + + <div> + <h3 class="title"><%= _("Search in") %></h3> + <% [["sent", _("messages from users")], + ["response", _("messages from authorities")], + ["comment", _("comments")]].each_with_index do |item, index| + variety, title = item %> + + <%= check_box_tag "request_variety[]", variety, params[:request_variety].nil? ? true : params[:request_variety].include?(variety), :id => "request_variety_#{index}" %> + <%= label_tag("request_variety_#{index}", title) %> <br/> + <% end %> + </div> + + <div id="date_range"> + <label class="form_label title" for="query"><%= _("Made between") %></label> + <%= text_field_tag(:request_date_after, params[:request_date_after], {:class => "use-datepicker", :size => 10}) %> + <label class="form_label" for="query"> <%= _("and") %></label> + <%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %> + </div> + </div> + <% end %> + + <div> + <%= submit_tag _("Filter") if @variety_postfix == "requests"%> + </div> + <% end # Search form%> + + <% end # if @advanced %> + + <% if !@query.nil? %> + <p id="search_controls"> + <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url([params[:query], @variety_postfix, 'relevant'], params) %> + | + <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url([params[:query], @variety_postfix, 'newest'], params) %> + <% if @sortby == 'described' %> + | <%= _('Recently described results first') %> + <% end %> + </p> + <% end %> +</div> <!-- header left --> +<% if !@track_thing.nil? %> + <div id="header_right"> + <h2><%= _('Track this search')%></h2> + <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %> + </div> +<% end %> + +<div style="clear:both;"></div> + +<% if @total_hits == 0 %> + <h2><%=@title %></h2> +<% end %> + +<% if not @query.nil? %> + <div class="results_section"> + <% if @xapian_bodies_hits > 0 %> + <% if @xapian_bodies_hits == 1 && @page == 1 %> + <h2 class="publicbody_results"><%= _('One public authority found') %></h2> + <% else %> + <h2 class="publicbody_results"><%= _('Public authorities {{start_count}} to {{end_count}} of {{total_count}}', :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) %></h2> + <% end %> + + <div class="results_block"> + <% for result in @xapian_bodies.results %> + <%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %> + <% end %> + </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, @postfix)) %></p> + <% end %> + <p><%= raw(_('<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 %> + </div> + + <div class="results_section"> + <% if @xapian_users_hits > 0 %> + <% if @xapian_users_hits == 1 && @page == 1 %> + <h2 class="person_results"><%= _("One person found") %></h2> + <% else %> + <h2 class="person_results"><%= _("People {{start_count}} to {{end_count}} of {{total_count}}", :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) %></h2> + <% end %> + + <div class="results_block"> + <% for result in @xapian_users.results %> + <%= render :partial => 'user/user_listing_single', :locals => { :display_user => result[:model] } %> + <% end %> + </div> + <%= will_paginate WillPaginate::Collection.new(@page, @users_per_page, @xapian_users.matches_estimated) %> + + <% end %> + </div> + + <div class="results_section"> + <% if @xapian_requests_hits > 0 %> + <% if @xapian_requests_hits == 1 && @page == 1 %> + <h2 class="foi_results"><%= _("One FOI request found") %></h2> + <% else %> + <h2 class="foi_results"><%= _("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) %></h2> + <% end %> + + <div class="results_block"> + <% for result in @xapian_requests.results %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> + <% end %> + </div> + + <%= will_paginate WillPaginate::Collection.new(@page, @requests_per_page, @xapian_requests.matches_estimated) %> + <% end %> + </div> +<% end %> + +<% if @advanced %> + <%= render :partial => 'general/advanced_search_tips' %> +<% end %> |