diff options
-rw-r--r-- | app/views/request/select_authority.rhtml | 4 | ||||
-rw-r--r-- | config/environment.rb | 5 | ||||
-rw-r--r-- | lib/willpaginate_extension.rb | 54 | ||||
-rw-r--r-- | lib/willpaginate_hack.rb | 14 | ||||
-rw-r--r-- | public/stylesheets/main.css | 1 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb | 2 |
6 files changed, 63 insertions, 17 deletions
diff --git a/app/views/request/select_authority.rhtml b/app/views/request/select_authority.rhtml index bf616ad89..1e78168e9 100644 --- a/app/views/request/select_authority.rhtml +++ b/app/views/request/select_authority.rhtml @@ -14,7 +14,7 @@ })); // We're using the existing body list: we intercept the clicks on the titles to // display a preview on the right hand side of the screen - $("#typeahead_response a").live('click', function() { + $("#typeahead_response .head a").live('click', function() { $("#authority_preview").load(this.href+" #public_body_show", function() { $("#authority_preview").show(); $("#authority_preview #header_right").hide(); @@ -56,6 +56,8 @@ <%= 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/config/environment.rb b/config/environment.rb index d15ee9a0e..17ded987e 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -131,6 +131,9 @@ I18n.locale = default_locale I18n.available_locales = available_locales.map {|locale_name| locale_name.to_sym} I18n.default_locale = default_locale +# Customise will_paginate URL generation +WillPaginate::ViewHelpers.pagination_options[:renderer] = 'WillPaginateExtension::LinkRenderer' + # Load monkey patches and other things from lib/ require 'ruby19.rb' require 'tmail_extensions.rb' @@ -139,7 +142,7 @@ require 'timezone_fixes.rb' require 'use_spans_for_errors.rb' require 'make_html_4_compliant.rb' require 'activerecord_errors_extensions.rb' -require 'willpaginate_hack.rb' +require 'willpaginate_extension.rb' require 'sendmail_return_path.rb' require 'tnef.rb' require 'i18n_fixes.rb' diff --git a/lib/willpaginate_extension.rb b/lib/willpaginate_extension.rb new file mode 100644 index 000000000..98ca8d763 --- /dev/null +++ b/lib/willpaginate_extension.rb @@ -0,0 +1,54 @@ +# this extension is loaded in environment.rb +module WillPaginateExtension + class LinkRenderer < WillPaginate::LinkRenderer + def page_link(page, text, attributes = {}) + # Hack for admin pages, when proxied via https on mySociety servers, they + # need a relative URL. + url = url_for(page) + if url.match(/^\/admin.*(\?.*)/) + url = $1 + end + @template.link_to text, url, attributes + end + + # Returns URL params for +page_link_or_span+, taking the current GET params + # and <tt>:params</tt> option into account. + def url_for(page) + page_one = page == 1 + unless @url_string and !page_one + # the following line makes pagination work on our specially munged search page + @url_params = @template.request.symbolized_path_parameters + # page links should preserve GET parameters + stringified_merge @url_params, @template.params if @template.request.get? + stringified_merge @url_params, @options[:params] if @options[:params] + @request_method=:get, @symbolized_path_parameters={:locale=>"en", :action=>"search", :combined=>["school", "all"], :controller=>"general"} + if complex = param_name.index(/[^\w-]/) + page_param = parse_query_parameters("#{param_name}=#{page}") + + stringified_merge @url_params, page_param + else + @url_params[param_name] = page_one ? 1 : 2 + end + url = @template.url_for(@url_params) + return url if page_one + + if complex + @url_string = url.sub(%r!((?:\?|&)#{CGI.escape param_name}=)#{page}!, "\\1\0") + return url + else + @url_string = url + @url_params[param_name] = 3 + @template.url_for(@url_params).split(//).each_with_index do |char, i| + if char == '3' and url[i, 1] == '2' + @url_string[i] = "\0" + break + end + end + end + end + # finally! + @url_string.sub "\0", page.to_s + end + + end +end diff --git a/lib/willpaginate_hack.rb b/lib/willpaginate_hack.rb deleted file mode 100644 index 084329e82..000000000 --- a/lib/willpaginate_hack.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Monkeypatch! Hack for admin pages, when proxied via https on mySociety servers, they -# need a relative URL. -module WillPaginate - class LinkRenderer - def page_link(page, text, attributes = {}) - url = url_for(page) - if url.match(/^\/admin.*(\?.*)/) - url = $1 - end - @template.link_to text, url, attributes - end - end -end - diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index ab29d3ffd..1db05486b 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -1502,6 +1502,7 @@ p.public-body-name-prefix { color:#888; margin-top:15px; margin-bottom:-15px; +font-size: 16px; } #other-country-notice a { 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 512f59f97..33ad70d5f 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -525,6 +525,7 @@ module ActsAsXapian # If there are no models in the queue, then nothing to do return if model_classes.size == 0 + ActsAsXapian.writable_init # Abort if full rebuild is going on new_path = ActsAsXapian.db_path + ".new" if File.exist?(new_path) @@ -532,7 +533,6 @@ module ActsAsXapian end ids_to_refresh = ActsAsXapianJob.find(:all).map() { |i| i.id } - ActsAsXapian.writable_init for id in ids_to_refresh job = nil begin |