aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/general/search.rhtml
blob: e41294a1ffb7c672fcc081dd5f166f13d61eecf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<% if @query.nil? %>
    <% @title = "Search Freedom of Information requests, public bodies and users" %>
    <h1><%=@title%></h1>
<% elsif @search_hits == 0 %>
    <% @title = "Nothing found for '" + h(@query) + "'" %>

<% else %>
    <% @title = "Results " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@per_page, @search_hits].min.to_s + " of " + @search_hits.to_s + " for '" + h(@query) + "'" %>
<% end%>

<% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
   <p>
       <%= text_field_tag 'query', @query, { :size => 40 } %>
       <%= submit_tag "Search" %>
       <% if not @search_results.nil? and not @search_results.empty? %>
           &nbsp;&nbsp;<a href="/search">Advanced tips</a>
       <% end %>
   </p>
<% end %>

<% if not @search_results.nil? %>
    <%=link_to_unless @sortby.nil?, "Show most relevant results first", { :sortby => nil } %>
    |
    <%=link_to_unless @sortby == 'newest', "Newest results first", { :sortby => "newest" } %>

    <h1><%=@title%></h1>

    <% if @search_results.empty? %>
    <% else %>
        <% for search_result in @search_results %>
            <% if search_result.class.to_s == 'InfoRequest' %>
                <%= render :partial => 'request/request_listing_single', :locals => { :info_request => search_result } %>
            <% elsif search_result.class.to_s == 'OutgoingMessage' %>
                <%= render :partial => 'request/request_listing_via_outgoing', :locals => { :info_request => search_result.info_request, :outgoing_message => search_result } %>
            <% elsif search_result.class.to_s == 'IncomingMessage' %>
                <%= render :partial => 'request/request_listing_via_incoming', :locals => { :info_request => search_result.info_request, :incoming_message => search_result } %>
            <% elsif search_result.class.to_s == 'PublicBody' %>
                <%= render :partial => 'body/body_listing_single', :locals => { :public_body => search_result } %>
            <% elsif search_result.class.to_s == 'User' %>
                <%= render :partial => 'user/user_listing_single', :locals => { :display_user => search_result } %>
            <% else %>
                <p><strong>Unknown search result type <%=search_result.class.to_s%></strong></p>
            <% end %>
        <% end %>
    <% end %>

    <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @search_hits) %>
<% end %>

<% if @search_results.nil? or @search_results.empty? %>
    <h2>Search tips</h2>
    <ul>
    <li>Enter words that you want to find separated by spaces, e.g. climbing lane</li>
    <li>Use OR (in capital letters) where you don't mind which word,  e.g. commons OR lords
    <li>Use quotes when you want to find an exact phrase, e.g. "Liverpool City Council"
    <li>Type status: to select based on the status of the request.
        <table>
        <tr><td>status:waiting_response</td><td> Waiting for the public body to reply </td></tr>
        <tr><td>status:waiting_response_overdue</td><td> Waiting for the public body to reply, they are late </td></tr>
        <tr><td>status:not_held</td><td> The public body does not have the information requested </td></tr>
        <tr><td>status:rejected</td><td> The request was rejected by the public body </td></tr>
        <tr><td>status:partially_successful</td><td> Some of the information requested has been received </td></tr>
        <tr><td>status:successful</td><td> All of the information requested has been received </td></tr>
        <tr><td>status:waiting_clarification</td><td> The public body would like part of the request explained </td></tr>
        <tr><td>status:waiting_classification</td><td> A new response has arrived, but it hasn't been categorised yet </td></tr>
        <tr><td>status:requires_admin</td><td> A strange reponse, required attention by the WhatDoTheyKnow team </td></tr>
        </table>
    <li>Read about <a href="http://lucene.apache.org/java/docs/queryparsersyntax.html">advanced search operators</a>, such as fuzziness and proximity.
    </ul>
<% end %>