aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application.rb4
-rw-r--r--app/controllers/general_controller.rb13
-rw-r--r--app/helpers/link_to_helper.rb11
-rw-r--r--app/models/info_request.rb6
-rw-r--r--app/views/general/search.rhtml8
-rw-r--r--app/views/request/show.rhtml2
6 files changed, 29 insertions, 15 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 79521e240..7275e53a7 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application.rb,v 1.40 2008-04-24 23:52:59 francis Exp $
+# $Id: application.rb,v 1.41 2008-04-30 00:37:50 francis Exp $
class ApplicationController < ActionController::Base
@@ -127,7 +127,7 @@ class ApplicationController < ActionController::Base
@http_auth_user = admin_http_auth_user
end
- # Convert URL name for sort by order, to Lucene query
+ # Convert URL name for sort by order, to Xapian query
def order_to_sort_by(sortby)
if sortby.nil?
return [nil, true]
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 9e2dccc9a..6ac91c605 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.19 2008-04-24 23:52:59 francis Exp $
+# $Id: general_controller.rb,v 1.20 2008-04-30 00:37:50 francis Exp $
class GeneralController < ApplicationController
@@ -47,14 +47,19 @@ class GeneralController < ApplicationController
@query = nil
render :action => "search"
else
- redirect_to search_url(:query => @query, :sortby => @sortby)
+ redirect_to search_url(@query, @sortby)
end
end
# Actual search
def search
- query = params[:query]
- sortby = params[:sortby]
+ combined = params[:combined]
+ sortby = nil
+ if combined.size > 1 and combined[-1] == 'newest'
+ sortby = 'newest'
+ combined = combined[0..-2]
+ end
+ query = combined.join("/")
perform_search(query, sortby)
#render :controller => "help", :action => "about"
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index ab8915e5d..bc0bdbafe 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.25 2008-04-09 01:32:53 francis Exp $
+# $Id: link_to_helper.rb,v 1.26 2008-04-30 00:37:50 francis Exp $
module LinkToHelper
@@ -81,6 +81,15 @@ module LinkToHelper
link_to h(user.name), user_admin_url(user)
end
+ # General pages
+ def search_url(query, sortby = nil)
+ if sortby.nil?
+ combined = query
+ else
+ combined = query + "/" + sortby
+ end
+ search_general_url(:combined => combined)
+ end
# Admin pages
def admin_url(relative_path)
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 99312986d..e75127667 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -21,7 +21,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request.rb,v 1.98 2008-04-29 16:42:11 francis Exp $
+# $Id: info_request.rb,v 1.99 2008-04-30 00:37:50 francis Exp $
require 'digest/sha1'
require 'vendor/plugins/acts_as_xapian/lib/acts_as_xapian'
@@ -75,8 +75,8 @@ class InfoRequest < ActiveRecord::Base
[InfoRequestEvent, PublicBody, User], query,
:offset => offset, :limit => per_page,
:sort_by_prefix => order,
- :sort_by_ascending => ascending,
- :collapse_by_prefix => "request_collapse"
+ :sort_by_ascending => ascending
+# :collapse_by_prefix => "request_collapse" # XXX fix this so off for email/RSS, on for web
)
end
diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml
index a919bff45..929fa2871 100644
--- a/app/views/general/search.rhtml
+++ b/app/views/general/search.rhtml
@@ -20,14 +20,14 @@
<% end %>
<% if not @search_results.nil? %>
- <%=link_to_unless @sortby.nil?, "Show most relevant results first", { :sortby => nil } %>
+ <%=link_to_unless @sortby.nil?, "Show most relevant results first", search_url(@query, nil) %>
|
- <%=link_to_unless @sortby == 'newest', "Newest results first", { :sortby => "newest" } %>
+ <%=link_to_unless @sortby == 'newest', "Newest results first", search_url(@query, 'newest') %>
<h1><%=@title%></h1>
<% if @search_spelling %>
- <p id="did_you_mean">Did you mean: <%= link_to @search_spelling, search_url(:query => @search_spelling) %></p>
+ <p id="did_you_mean">Did you mean: <%= link_to @search_spelling, search_url(@search_spelling, @sortby) %></p>
<% end %>
<% if @search_results.empty? %>
@@ -59,7 +59,7 @@
<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>Read about <a href="http://lucene.apache.org/java/docs/queryparsersyntax.html">advanced search operators</a>, such as fuzziness and proximity.
+ <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">
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index ae9f2bda2..a13a129b5 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -51,7 +51,7 @@
<!-- <h2>Some other requests made by <%= user_link(@info_request.user) %> to <%= public_body_link(@info_request.public_body) %></h2> -->
<%= render :partial => 'sidebar_request_listing', :locals => { :info_requests => @info_requests_same_user_same_body } %>
<% if @info_requests_same_user_same_body_more %>
- <p><%= link_to "More such requests", search_url(:query => "variety:sent requested_from:" + @info_request.public_body.url_name + " requested_by:" + @info_request.user.url_name + " -request:" + @info_request.url_title, :sortby => "newest") %></p>
+ <p><%= link_to "More such requests", search_url("variety:sent requested_from:" + @info_request.public_body.url_name + " requested_by:" + @info_request.user.url_name + " -request:" + @info_request.url_title, "newest") %></p>
<% end %>
<% end %>