diff options
-rw-r--r-- | app/controllers/application_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 7 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 20 | ||||
-rw-r--r-- | app/views/request/select_authority.rhtml | 1 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb | 3 |
5 files changed, 37 insertions, 17 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1c73f06a7..73ba74f30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -388,11 +388,24 @@ class ApplicationController < ActionController::Base ActsAsXapian.readable_init old_default_op = ActsAsXapian.query_parser.default_op ActsAsXapian.query_parser.default_op = Xapian::Query::OP_OR - user_query = ActsAsXapian.query_parser.parse_query( - query, - Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_PARTIAL | - Xapian::QueryParser::FLAG_SPELLING_CORRECTION) - xapian_requests = ActsAsXapian::Search.new([model], query, options, user_query) + begin + user_query = ActsAsXapian.query_parser.parse_query( + query.strip + '*', + Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_WILDCARD | + Xapian::QueryParser::FLAG_SPELLING_CORRECTION) + xapian_requests = ActsAsXapian::Search.new([model], query, options, user_query) + rescue RuntimeError => e + if e.message =~ /^QueryParserError: Wildcard/ + # Wildcard expands to too many terms + logger.info "Wildcard query '#{query.strip + '*'}' caused: #{e.message}" + + user_query = ActsAsXapian.query_parser.parse_query( + query, + Xapian::QueryParser::FLAG_LOVEHATE | + Xapian::QueryParser::FLAG_SPELLING_CORRECTION) + xapian_requests = ActsAsXapian::Search.new([model], query, options, user_query) + end + end ActsAsXapian.query_parser.default_op = old_default_op end return xapian_requests diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 33ea7d5a6..aeb6d31fe 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -155,6 +155,13 @@ class RequestController < ApplicationController if @view == "recent" return redirect_to request_list_all_path(:action => "list", :view => "all", :page => @page), :status => :moved_permanently end + + # Temporary patch + # Later pages are very expensive to load + if @page > 100 + raise "Sorry. No pages after 100 today." + end + params[:latest_status] = @view query = make_query_from_params @title = _("View and search requests") diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index ad0560baa..f439b27d2 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -10,13 +10,13 @@ </title> <link rel="shortcut icon" href="/favicon.ico"> - <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet", :media => "all" %> - <%= stylesheet_link_tag 'fonts', :rel => "stylesheet", :media => "all" %> - <%= stylesheet_link_tag 'print', :rel => "stylesheet", :media => "print" %> - <% if !params[:print_stylesheet].nil? %> + <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet", :media => "all" %> + <%= stylesheet_link_tag 'fonts', :rel => "stylesheet", :media => "all" %> + <%= stylesheet_link_tag 'print', :rel => "stylesheet", :media => "print" %> + <% if !params[:print_stylesheet].nil? %> <%= stylesheet_link_tag 'print', :rel => "stylesheet", :media => "all" %> - <% end %> - <%= javascript_include_tag 'jquery.js', 'jquery-ui.min','jquery.cookie.js', 'general.js' %> + <% end %> + <%= javascript_include_tag 'jquery.js', 'jquery-ui.min','jquery.cookie.js', 'general.js' %> <% if @profile_photo_javascript %> <script type="text/javascript" src="/javascripts/jquery.Jcrop.js"></script> @@ -24,7 +24,7 @@ <link rel="stylesheet" href="/stylesheets/jquery.Jcrop.css" type="text/css" > <% end %> - <%= stylesheet_link_tag 'admin-theme/jquery-ui-1.8.15.custom.css', :rel => 'stylesheet'%> + <%= stylesheet_link_tag 'admin-theme/jquery-ui-1.8.15.custom.css', :rel => 'stylesheet'%> <!--[if LT IE 7]> <style type="text/css">@import url("/stylesheets/ie6.css");</style> <![endif]--> @@ -34,8 +34,8 @@ <!--[if LT IE 8]> <style type="text/css">@import url("/stylesheets/ie7.css");</style> <![endif]--> - <!-- the following method for customising CSS is deprecated; see `doc/THEMES.md` for detail --> - <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %> + <!-- the following method for customising CSS is deprecated; see `doc/THEMES.md` for detail --> + <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %> <% if force_registration_on_new_request %> <%= stylesheet_link_tag 'jquery.fancybox-1.3.4', :rel => "stylesheet" %> <% end %> @@ -56,7 +56,7 @@ <meta name="robots" content="noindex, nofollow"> <% end %> - <%= render :partial => 'general/before_head_end' %> + <%= render :partial => 'general/before_head_end' %> </head> <body <%= "class='front'" if params[:action] == 'frontpage' %>> diff --git a/app/views/request/select_authority.rhtml b/app/views/request/select_authority.rhtml index 0e8df872d..521136f8e 100644 --- a/app/views/request/select_authority.rhtml +++ b/app/views/request/select_authority.rhtml @@ -57,7 +57,6 @@ <%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %> <% end %> </div> - <%= will_paginate WillPaginate::Collection.new(@page, 10, @xapian_requests.matches_estimated) %> <% end %> diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb index 38bfb7c98..656b722f6 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -143,6 +143,7 @@ module ActsAsXapian @@query_parser.stemming_strategy = Xapian::QueryParser::STEM_SOME @@query_parser.database = @@db @@query_parser.default_op = Xapian::Query::OP_AND + @@query_parser.set_max_wildcard_expansion(1000) @@stopper = Xapian::SimpleStopper.new @@stopper.add("and") @@ -443,7 +444,7 @@ module ActsAsXapian user_query = ActsAsXapian.query_parser.parse_query( self.query_string, Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_PHRASE | - Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_WILDCARD | + Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_SPELLING_CORRECTION) end self.query = Xapian::Query.new(Xapian::Query::OP_AND, model_query, user_query) |