aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-05-29 16:26:45 +0100
committerLouise Crow <louise.crow@gmail.com>2013-05-29 16:26:45 +0100
commitb97e1af431ca491132cbc56d3bc570639482fffc (patch)
tree16ab6ac5425d465395e123dc0c698306cf9c8a6d
parentccd924b2626d7c9f84190f106c0508768effef99 (diff)
parentedbce1f569c997b8d5c10cdf95e301e0a15e9393 (diff)
Merge branch 'rails-3-develop' of ssh://git.mysociety.org/data/git/public/alaveteli into rails-3-develop
-rw-r--r--config/initializers/alaveteli.rb4
-rw-r--r--lib/willpaginate_extension.rb59
2 files changed, 0 insertions, 63 deletions
diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb
index a9e9d498d..263e5cf7b 100644
--- a/config/initializers/alaveteli.rb
+++ b/config/initializers/alaveteli.rb
@@ -43,15 +43,11 @@ 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 'activesupport_cache_extensions.rb'
require 'use_spans_for_errors.rb'
require 'activerecord_errors_extensions.rb'
-require 'willpaginate_extension.rb'
require 'i18n_fixes.rb'
require 'world_foi_websites.rb'
require 'alaveteli_external_command.rb'
diff --git a/lib/willpaginate_extension.rb b/lib/willpaginate_extension.rb
deleted file mode 100644
index fa58bd9f0..000000000
--- a/lib/willpaginate_extension.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# this extension is loaded in environment.rb
-module WillPaginateExtension
- class LinkRenderer < WillPaginate::ActionView::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
- # Hack around our type-ahead search magic
- if url.match(/\/body\/search_ahead/)
- url.sub!("/body/search_ahead", "/select_authority")
- 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
- @url_params = {}
- # 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]
- 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
- # the following line makes pagination work on our specially munged search page
- combined = @template.request.path_parameters["combined"]
- @url_params["combined"] = combined if !combined.nil?
- url = @template.url_for(@url_params)
- return url if page_one
-
- if complex
- @url_string = url.sub(%r!((?:\?|&amp;)#{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