diff options
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/general/frontpage.rhtml | 10 | ||||
-rw-r--r-- | app/views/general/search.rhtml | 66 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 4 | ||||
-rw-r--r-- | app/views/request/list.rhtml | 12 | ||||
-rw-r--r-- | app/views/track/atom_feed.atom.builder | 10 |
5 files changed, 58 insertions, 44 deletions
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index 9584b1608..bf6ccc6b9 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -58,14 +58,14 @@ <div id="find_information"> <h1>Explore government information that others received</h1> - <% if @search_results.empty? %> + <% if @xapian_object.results.empty? %> <p>None yet.</p> <% else %> - <% for search_result in @search_results %> - <% if search_result[:model].class.to_s == 'InfoRequestEvent' %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result[:model], :info_request => search_result[:model].info_request } %> + <% for result in @xapian_object.results %> + <% if result[:model].class.to_s == 'InfoRequestEvent' %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> <% else %> - <p><strong>Unexpected search result type <%=search_result[:model].class.to_s%></strong></p> + <p><strong>Unexpected search result type <%=result[:model].class.to_s%></strong></p> <% end %> <% end %> <% end %> diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml index a043e41c9..a31596463 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.rhtml @@ -1,11 +1,12 @@ +<% @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 @search_hits == 0 %> +<% elsif @total_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) + "'" %> + <% @title = "Results page " + @page.to_s %> <% end%> <% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %> @@ -13,42 +14,55 @@ <%= text_field_tag 'query', @query, { :size => 40 } %> <%= hidden_field_tag 'sortby', params[:sortby] %> <%= submit_tag "Search" %> - <% if not @search_results.nil? and not @search_results.empty? %> + <% if not @show_tips %> <a href="/search">Advanced tips</a> <% end %> </p> <% end %> -<% if not @search_results.nil? %> - <%=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') %> +<%=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') %> - <h1><%=@title%></h1> +<% if @total_hits == 0 %> + <h1><%=@title %></h1> +<% end %> - <% if @search_spelling %> - <p id="did_you_mean">Did you mean: <%= link_to @search_spelling, search_url(@search_spelling, @sortby) %></p> +<% if @spelling_correction %> + <p id="did_you_mean">Did you mean: <%= link_to @spelling_correction, search_url(@spelling_correction, @sortby) %></p> +<% end %> + +<% if @xapian_bodies.results.size > 0 %> + <h1><%= "Public authorities " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@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 %> - <% if @search_results.empty? %> - <% else %> - <% for search_result in @search_results %> - <% if search_result[:model].class.to_s == 'PublicBody' %> - <%= render :partial => 'body/body_listing_single', :locals => { :public_body => search_result[:model] } %> - <% elsif search_result[:model].class.to_s == 'User' %> - <%= render :partial => 'user/user_listing_single', :locals => { :display_user => search_result[:model] } %> - <% elsif search_result[:model].class.to_s == 'InfoRequestEvent' %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result[:model], :info_request => search_result[:model].info_request } %> - <% else %> - <p><strong>Unknown search result type <%=search_result[:model].class.to_s%></strong></p> - <% end %> - <% end %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_bodies.matches_estimated) %> +<% end %> + +<% if @xapian_users.results.size > 0 %> + <h1><%= "People " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@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, @per_page, @xapian_users.matches_estimated) %> +<% end %> + +<% if @xapian_requests.results.size > 0 %> + <h1><%= "FOI requests " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@per_page, @xapian_requests.matches_estimated].min.to_s + " of " + @xapian_requests.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> + + <% 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, @per_page, @search_hits) %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated) %> <% end %> -<% if @search_results.nil? or @search_results.empty? %> +<% 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> diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index e4877004b..9814a1b97 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -10,8 +10,8 @@ WhatDoTheyKnow - file and explore Freedom of Information (FOI) requests <% end %> </title> - <%= stylesheet_link_tag 'yucky-green', :rel => "alternate stylesheet", :title => "Yucky Green" %> - <%= stylesheet_link_tag 'main', :title => "Main" %> + <%= stylesheet_link_tag 'yucky-green', :title => "Yucky Green" %> + <%= stylesheet_link_tag 'main', :rel => "alternate stylesheet", :title => "Main" %> </head> <body> <div id="banner"> diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml index 3e84ca6e8..084f0577f 100644 --- a/app/views/request/list.rhtml +++ b/app/views/request/list.rhtml @@ -15,19 +15,19 @@ <%= render :partial => 'track/tracking_people_and_link', :locals => { :track_thing => @track_thing, :own_request => false, :list_people => false } %> <% end %> -<% if @search_results.empty? %> +<% if @xapian_object.results.empty? %> <p>No requests made yet.</p> <% else %> - <% for search_result in @search_results %> - <% if search_result[:model].class.to_s == 'InfoRequestEvent' %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result[:model], :info_request => search_result[:model].info_request } %> + <% for result in @xapian_object.results %> + <% if result[:model].class.to_s == 'InfoRequestEvent' %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> <% else %> - <p><strong>Unexpected search result type <%=search_result[:model].class.to_s%></strong></p> + <p><strong>Unexpected search result type <%=result[:model].class.to_s%></strong></p> <% end %> <% end %> <% end %> -<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @search_hits) %> +<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_object.matches_estimated) %> <% if @track_thing %> <%= render :partial => 'track/tracking_people_and_link', :locals => { :track_thing => @track_thing, :own_request => false, :list_people => false } %> diff --git a/app/views/track/atom_feed.atom.builder b/app/views/track/atom_feed.atom.builder index bc7a48de2..7fa2dda1a 100644 --- a/app/views/track/atom_feed.atom.builder +++ b/app/views/track/atom_feed.atom.builder @@ -1,14 +1,14 @@ atom_feed do |feed| feed.title(@track_thing.params[:title_in_rss]) - for search_result in @search_results - feed.entry(search_result[:model]) do |entry| + for result in @xapian_object.results + feed.entry(result[:model]) do |entry| # Get the HTML content from the same partial template as website search does content = '' - if search_result[:model].class.to_s == 'InfoRequestEvent' - content += render :partial => 'request/request_listing_via_event', :locals => { :event => search_result[:model], :info_request => search_result[:model].info_request } + if result[:model].class.to_s == 'InfoRequestEvent' + content += render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } else - content = "<p><strong>Unknown search result type " + search_result[:model].class.to_s + "</strong></p>" + content = "<p><strong>Unknown search result type " + result[:model].class.to_s + "</strong></p>" end # Pull out the heading as separate item, from the partial template content.match(/(<span class="head">\s+<a href="[^>]*">(.*)<\/a>\s+<\/span>)/) |