diff options
author | Francis Irving <francis@mysociety.org> | 2009-12-03 13:18:53 +0000 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2009-12-03 13:18:53 +0000 |
commit | 1053556b7c12d757f2e654266a855609658b2964 (patch) | |
tree | 6f258882491a6815bd97aec861e670236eb98681 | |
parent | bcf0dc3226866264d1da4bcd208f4df69f9f02c8 (diff) |
Move WillPaginate hack into its own file
-rw-r--r-- | config/environment.rb | 18 | ||||
-rw-r--r-- | lib/willpaginate_hack.rb | 14 |
2 files changed, 15 insertions, 17 deletions
diff --git a/config/environment.rb b/config/environment.rb index 4250cf5fe..00508dacc 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -90,23 +90,6 @@ if (MySociety::Config.get("DOMAIN", "") != "") ActionController::Base.asset_host = MySociety::Config.get("DOMAIN", 'localhost:3000') end -# 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 - -# XXX all the monkey patches above should be moved into their own files in -# lib/, and required below - # Load monkey patches from lib/ require 'tmail_extensions.rb' require 'activesupport_cache_extensions.rb' @@ -116,6 +99,7 @@ require 'fcgi_fixes.rb' require 'use_spans_for_errors.rb' require 'make_html_4_compliant.rb' require 'activerecord_errors_extensions.rb' +require 'willpaginate_hack.rb' # XXX temp debug for SQL logging production sites #ActiveRecord::Base.logger = Logger.new(STDOUT) diff --git a/lib/willpaginate_hack.rb b/lib/willpaginate_hack.rb new file mode 100644 index 000000000..084329e82 --- /dev/null +++ b/lib/willpaginate_hack.rb @@ -0,0 +1,14 @@ +# 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 + |