diff options
author | Robin Houston <robin@lenny.robin> | 2011-09-08 00:56:59 +0100 |
---|---|---|
committer | Robin Houston <robin@lenny.robin> | 2011-09-08 00:56:59 +0100 |
commit | 6e0e5e5bed89ff2093e1cca3fa50310f678565fd (patch) | |
tree | ae9a198a8134e90ab2a140d699ed6f3248f467cc /app/controllers/services_controller.rb | |
parent | e286a5a91e449ef01b5ce5f23654d1316bffaf53 (diff) | |
parent | a9002cc8e749df6f5961acab8e3e61fd21987fc1 (diff) |
Merge branch 'develop' of git@github.com:sebbacon/alaveteli into develop
Conflicts:
app/models/request_mailer.rb
Diffstat (limited to 'app/controllers/services_controller.rb')
-rw-r--r-- | app/controllers/services_controller.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb new file mode 100644 index 000000000..6fb20336e --- /dev/null +++ b/app/controllers/services_controller.rb @@ -0,0 +1,32 @@ +# controllers/application.rb: +# Parent class of all controllers in FOI site. Filters added to this controller +# apply to all controllers in the application. Likewise, all the methods added +# will be available for all controllers. +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: application.rb,v 1.59 2009-09-17 13:01:56 francis Exp $ + +require 'open-uri' + +class ServicesController < ApplicationController + def other_country_message + text = "" + iso_country_code = MySociety::Config.get('ISO_COUNTRY_CODE').downcase + if country_from_ip.downcase != iso_country_code + found_country = WorldFOIWebsites.by_code(country_from_ip) + found_country_name = !found_country.nil? && found_country[:country_name] + if found_country_name + text = _("Hello! You can make Freedom of Information requests within {{country_name}} at {{link_to_website}}", :country_name => found_country_name, :link_to_website => "<a href=\"#{found_country[:url]}\">#{found_country[:name]}</a>") + else + current_country = WorldFOIWebsites.by_code(iso_country_code)[:country_name] + text = _("Hello! We have an <a href=\"/help/alaveteli?country_name=#{CGI.escape(current_country)}\">important message</a> for visitors outside {{country_name}}", :country_name => current_country) + end + end + if !text.empty? + text += ' <span class="close-button">X</span>' + end + render :text => text, :content_type => "text/plain" # XXX workaround the HTML validation in test suite + end +end |