aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/general_controller.rb39
-rw-r--r--app/helpers/link_to_helper.rb16
-rw-r--r--app/views/general/new_frontpage.rhtml9
-rw-r--r--app/views/general/search.rhtml31
-rw-r--r--app/views/layouts/default.rhtml2
-rw-r--r--config/routes.rb6
-rw-r--r--public/stylesheets/main.css12
-rw-r--r--todo.txt14
8 files changed, 91 insertions, 38 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 9e197d8e8..d0b6f8999 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: general_controller.rb,v 1.36 2008-09-04 17:59:08 francis Exp $
+# $Id: general_controller.rb,v 1.37 2008-09-05 09:05:05 francis Exp $
class GeneralController < ApplicationController
@@ -48,11 +48,17 @@ class GeneralController < ApplicationController
def search_redirect
@query = params[:query]
@sortby = params[:sortby]
- if @query.nil? or @query.empty?
+ @bodies = params[:bodies]
+ if @query.nil? || @query.empty?
@query = nil
render :action => "search"
else
- redirect_to search_url(@query, @sortby)
+ if (@bodies == '1') && (@sortby.nil? || @sortby.empty?)
+ @postfix = 'bodies'
+ else
+ @postfix = @sortby
+ end
+ redirect_to search_url(@query, @postfix)
end
end
@@ -61,23 +67,29 @@ class GeneralController < ApplicationController
# XXX Why is this so complicated with arrays and stuff? Look at the route
# in config/routes.rb for comments.
combined = params[:combined]
- sortby = nil
+ @sortby = nil
+ @bodies = false # searching from front page, largely for a public authority
# 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 and (combined[-1] == 'newest' or combined[-1] == 'described')
- sortby = combined[-1]
+ if combined.size > 1 && (['newest', 'described', 'bodies'].include?(combined[-1]))
+ @postfix = combined[-1]
combined = combined[0..-2]
+ if @postfix == 'bodies'
+ @bodies = true
+ else
+ @sortby = @postfix
+ end
end
- query = combined.join("/")
+ @query = combined.join("/")
# Query each type separately for separate display (XXX we are calling
# perform_search multiple times and it clobbers per_page for each one,
# so set as separate var)
- @xapian_requests = perform_search([InfoRequestEvent], query, sortby, 'request_collapse', 25)
+ @xapian_requests = perform_search([InfoRequestEvent], @query, @sortby, 'request_collapse', 25)
@requests_per_page = @per_page
- @xapian_bodies = perform_search([PublicBody], query, sortby, nil, 5)
+ @xapian_bodies = perform_search([PublicBody], @query, @sortby, nil, 5)
@bodies_per_page = @per_page
- @xapian_users = perform_search([User], query, sortby, nil, 5)
+ @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
@@ -87,11 +99,16 @@ class GeneralController < ApplicationController
@spelling_correction = @xapian_requests.spelling_correction
@highlight_words = @xapian_requests.words_to_highlight
- @track_thing = TrackThing.create_track_for_search_query(query)
+ @track_thing = TrackThing.create_track_for_search_query(@query)
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss] } ]
# No point bots crawling all the pages of search results.
@no_crawl = true
+
+ # If we came from the front page (@bodies is true) and found no bodies
+ #if @bodies && @xapian_bodies.results.size == 0
+ # flash[:notice] = 'No authorities found with that name. <a href="/body/list/other">Browse all</a> or <a href="/help/about#missing_body">ask us to add one</a>.'
+ #end
end
# For debugging
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 294390f5f..33276168e 100644
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: link_to_helper.rb,v 1.38 2008-08-29 12:52:25 francis Exp $
+# $Id: link_to_helper.rb,v 1.39 2008-09-05 09:05:05 francis Exp $
module LinkToHelper
@@ -106,14 +106,14 @@ module LinkToHelper
end
end
- # General pages
- def search_url(query, sortby = nil)
- if sortby.nil?
- combined = query
- else
- combined = query + "/" + sortby
+ # 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)
+ url = search_general_url(:combined => query)
+ if !postfix.nil? && !postfix.empty?
+ url = url + "/" + postfix
end
- search_general_url(:combined => combined)
+ return url
end
# Admin pages
diff --git a/app/views/general/new_frontpage.rhtml b/app/views/general/new_frontpage.rhtml
index e69346dd0..ef317ec57 100644
--- a/app/views/general/new_frontpage.rhtml
+++ b/app/views/general/new_frontpage.rhtml
@@ -7,9 +7,10 @@
<br>or anything to search for</strong>
<br>
<%= text_field_tag 'query', params[:query], { :size => 30 } %>
+ <%= hidden_field_tag 'bodies', 1 %>
<%= submit_tag "Search" %>
<br>
- e.g. <%=link_to 'Liverpool', search_url('liverpool')%>, <%=link_to 'MRSA', search_url('mrsa')%>, <%=link_to 'Treasury', search_url('treasury')%>
+ e.g. <%=link_to 'Liverpool', search_url('liverpool', 'bodies')%>, <%=link_to 'MRSA', search_url('mrsa', 'bodies')%>, <%=link_to 'Treasury', search_url('treasury', 'bodies')%>
</p>
<% end %>
</div>
@@ -25,11 +26,11 @@
</div>
<div id="examples_1">
- <ul
+ <ul>
<% for request in @random_requests %>
<li><%=link_to h(excerpt(request.title, "", 35)), request_url(request)%> </li>
- <% end%>
- </ul
+ <% end %>
+ </ul>
<p><strong><a href="/list/successful">More successful requests...</a></strong></p>
</div>
</div>
diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml
index 950bb109a..2d8b24039 100644
--- a/app/views/general/search.rhtml
+++ b/app/views/general/search.rhtml
@@ -9,10 +9,21 @@
<% @title = "Results page " + @page.to_s %>
<% end%>
+<% if @bodies %>
+ <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="/body/list/other">Browse all</a> or <a href="/help/about#missing_body">ask us to add it</a>.</p>
+ <p>
+ </div>
+<% end %>
+
<% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
<p>
<%= text_field_tag 'query', @query, { :size => 40 } %>
- <%= hidden_field_tag 'sortby', params[:sortby] %>
+ <%= hidden_field_tag 'sortby', @sortby %>
+ <% if @bodies %>
+ <%= hidden_field_tag 'bodies', 1 %>
+ <% end %>
<%= submit_tag "Search" %>
<% if not @show_tips %>
&nbsp;&nbsp;<a href="/search">Advanced tips</a>
@@ -31,16 +42,24 @@
</p>
<% end %>
+<% if @bodies && !@query.nil? && @xapian_bodies.results.size == 0 %>
+ <h1>No public authorities found</h1>
+ <% if @spelling_correction %>
+ <p id="did_you_mean">Did you mean: <%= link_to @spelling_correction, search_url(@spelling_correction, @postfix) %></p>
+ <% end %>
+ <p><a href="/body/list/other">Browse all</a> or <a href="/help/about#missing_body">ask us to add one</a>.</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>
+ <p id="did_you_mean">Did you mean: <%= link_to @spelling_correction, search_url(@spelling_correction, @postfix) %></p>
<% end %>
- <% if @track_thing and (@xapian_bodies.results.size > 0 or @xapian_users.results.size > 0 or @total_hits == 0)%>
+ <% if (!@bodies || @xapian_requests.results.size == 0) && @track_thing && (@xapian_bodies.results.size > 0 || @xapian_users.results.size > 0 || @total_hits == 0)%>
<%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %>
<% end %>
@@ -90,9 +109,9 @@
<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>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 search 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 search requests made by <%= link_to "Julian Todd", show_user_url(:url_name => 'julian_todd') %>, typing the name as in the URL.
<li><strong>commented_by:tony_bowden</strong> to search annotations made by <%= link_to "Tony Bowden", show_user_url(:url_name => 'tony_bowden') %>, 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><strong>filetype:pdf</strong> to find all responses with PDF attachments. Or try these: <%= IncomingMessage.get_all_file_extentions%>.
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index aafc8e57a..d61245f1c 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.rhtml
@@ -55,7 +55,7 @@
<% if @user %>
<li><%=link_to "My requests", user_url(@user) %></li>
<% end %>
- <li><%= link_to "About", about_url %></li>
+ <li><%= link_to "Help", about_url %></li>
</ul>
<% if not (controller.action_name == 'signin' or controller.action_name == 'signup') %>
<div id="logged_in_bar">
diff --git a/config/routes.rb b/config/routes.rb
index d97285f23..bb82d50cb 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: routes.rb,v 1.69 2008-09-03 00:48:55 francis Exp $
+# $Id: routes.rb,v 1.70 2008-09-05 09:05:06 francis Exp $
ActionController::Routing::Routes.draw do |map|
@@ -15,8 +15,8 @@ ActionController::Routing::Routes.draw do |map|
# Keep in mind you can assign values other than :controller and :action
map.with_options :controller => 'general' do |general|
- general.frontpage '/', :action => 'frontpage'
- general.new_frontpage '/new_frontpage', :action => 'new_frontpage'
+ general.frontpage '/old_frontpage', :action => 'frontpage'
+ general.new_frontpage '/', :action => 'new_frontpage'
general.auto_complete_for_public_body_query 'auto_complete_for_public_body_query', :action => 'auto_complete_for_public_body_query'
general.search_redirect '/search', :action => 'search_redirect'
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index 2bea5af11..048a8b401 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -277,6 +277,18 @@ dd { margin: 0.6em 0 2em 4em; width: 33em; }
padding: 1em;
background-color: #e0e0e0;
}
+#stepwise_instructions
+{
+ text-align: center;
+ margin: 0em 0em 0em 0em;
+ padding: 0.2em 0em 0.2em 0em;
+ background-color: #e0e0e0;
+}
+#stepwise_instructions p
+{
+ margin: 0.5em 0em 0em 0em;
+ padding: 0em 0em 0em 0em;
+}
#frontpage_examples div#examples_0 {
float: left;
margin-left: 0%;
diff --git a/todo.txt b/todo.txt
index e790e523a..3d0505a5d 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,5 +1,7 @@
Test data for Tony
+Check tracks still work with URL routing changes
+
Site move:
Install PostgresSQL 8.3
Move database
@@ -85,17 +87,19 @@ Google search within website of authority.
Show similar requests after you have filed yours - maybe on preview too.
Use spelling correction for public bodies search (in addition to substring?)
-frontpage things:
- - browse public authorities gone
- - telling us public authority not found gone
- - doesn't have successful requests
-turning it off
+Turning off frontpage
- Remove javascript from default :)
Add count of comments to admin summary page
Flag bad comments, delete comments from admin interface
- perhaps via contact form, and form sending refering URL?
+Add "I have a large file" to FOI office FAQ
+Add "Who should I make my request to?"
+Add "I want to file squillions of requests"
+
+Simple initial bulk request prevention (see Tony's mail on this)
+
Later
=====