aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/general/search.rhtml
blob: 71254a20885d655a7e8cf379f773782bf546a87d (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<% @show_tips = @xapian_requests.nil? || (@total_hits == 0) %>

<% if @query.nil? %>
    <% @title = "Search Freedom of Information requests, public authorities and users" %>
    <h1><%=@title%></h1>
<% elsif @total_hits == 0 %>
    <% @title = "Nothing found for '" + h(@query) + "'" %>
<% else %>
    <% @title = "Results page " + @page.to_s %>
<% end%>

<% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
   <p>
       <%= text_field_tag 'query', @query, { :size => 40 } %>
       <%= hidden_field_tag 'sortby', params[:sortby] %>
       <%= submit_tag "Search" %>
       <% if not @show_tips %>
           &nbsp;&nbsp;<a href="/search">Advanced tips</a>
       <% end %>
   </p>
<% end %>

<% if not @query.nil? %>
    <p>
    <%=link_to_unless @sortby.nil?, "Show most relevant results first", search_url(@query, nil) %>
    |
    <%=link_to_unless @sortby == 'newest', "Newest results first", search_url(@query, 'newest') %>
    <% if @sortby == 'described' %>
    | Recently described results first
    <% end %>
    </p>
<% end %>

<% if @total_hits == 0 %>
    <h1><%=@title %></h1>
<% end %>

<% if not @query.nil? %>
    <% if @spelling_correction %>
        <p id="did_you_mean">Did you mean: <%= link_to @spelling_correction, search_url(@spelling_correction, @sortby) %></p>
    <% end %>

    <% if @track_thing and (@xapian_bodies.results.size > 0 or @xapian_users.results.size > 0)%>
        <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %>
    <% end %>

    <% if @xapian_bodies.results.size > 0 %>
        <h1><%= "Public authorities " + ((@page-1)*@bodies_per_page+1).to_s + "-" + [@page*@bodies_per_page, @xapian_bodies.matches_estimated].min.to_s + " of " + @xapian_bodies.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1>

        <% for result in @xapian_bodies.results %>
            <%= render :partial => 'body/body_listing_single', :locals => { :public_body => result[:model] }  %>
        <% end %>

        <%= will_paginate WillPaginate::Collection.new(@page, @bodies_per_page, @xapian_bodies.matches_estimated) %>
    <% end %>

    <% if @xapian_users.results.size > 0 %>
        <h1><%= "People " + ((@page-1)*@users_per_page+1).to_s + "-" + [@page*@users_per_page, @xapian_users.matches_estimated].min.to_s + " of " + @xapian_users.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1>

        <% for result in @xapian_users.results %>
            <%= render :partial => 'user/user_listing_single', :locals => { :display_user => result[:model] } %>
        <% end %>

        <%= will_paginate WillPaginate::Collection.new(@page, @users_per_page, @xapian_users.matches_estimated) %>
    <% end %>

    <% if @xapian_requests.results.size > 0 %>
        <h1><%= "FOI requests " + ((@page-1)*@requests_per_page+1).to_s + "-" + [@page*@requests_per_page, @xapian_requests.matches_estimated].min.to_s + " of " + @xapian_requests.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1>

        <% if @track_thing %>
            <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %>
        <% end %>

        <% for result in @xapian_requests.results %>
            <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
        <% end %>

        <%= will_paginate WillPaginate::Collection.new(@page, @requests_per_page, @xapian_requests.matches_estimated) %>
        <% if @track_thing %>
            <p></p>
            <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %>
        <% end %>
    <% end %>
<% end %>

<% if @show_tips %>
    <h2>Search tips</h2>
    <ul>
    <li>Enter words that you want to find separated by spaces, e.g. <strong>climbing lane</strong></li>
    <li>Use OR (in capital letters) where you don't mind which word,  e.g. <strong>commons OR lords</strong>
    <li>Use quotes when you want to find an exact phrase, e.g. <strong>"Liverpool City Council"</strong>
    <li><strong>variety:</strong> with value sent, followup_sent, response, comment, authority or user to select type of thing to search for.
    <li>Type <strong>status:</strong> to select based on the status or historical status of the request, see table below.
    <li><strong>requested_from:home_office</strong> to restrict to requests from the <%= link_to "Home Office", show_public_body_url(:url_name => 'home_office') %>, typing the name as in the URL.
    <li><strong>requested_by:julian_todd</strong> to restrict to requests made by <%= link_to "Julian Todd", show_user_url(:url_name => 'julian_todd') %>, typing the name as in the URL.
    <li><strong>request:</strong> to restrict to a specific request, typing the title as in the URL.
    <li>Type <strong>01/01/2008..14/01/2008</strong> to only show things that happened in the first two weeks of January.
    <li>Read about <a href="http://www.xapian.org/docs/queryparser.html">advanced search operators</a>, such as proximity and wildcards.
    </ul>

    <table class="status_table">
        <tr><td><strong>status:waiting_response</strong></td><td> Waiting for the public authority to reply </td></tr>
        <tr><td><strong>status:not_held</strong></td><td> The public authority does not have the information requested </td></tr>
        <tr><td><strong>status:rejected</strong></td><td> The request was rejected by the public authority </td></tr>
        <tr><td><strong>status:partially_successful</strong></td><td> Some of the information requested has been received </td></tr>
        <tr><td><strong>status:successful</strong></td><td> All of the information requested has been received </td></tr>
        <tr><td><strong>status:waiting_clarification</strong></td><td> The public authority would like part of the request explained </td></tr>
        <tr><td><strong>status:waiting_classification</strong></td><td> A new response has arrived, but it hasn't been categorised yet </td></tr>
        <tr><td><strong>status:requires_admin</strong></td><td> A strange reponse, required attention by the WhatDoTheyKnow team </td></tr>
    </table>
<% end %>