aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/services_controller.rb32
-rw-r--r--app/views/help/_sidebar.rhtml1
-rw-r--r--app/views/help/alaveteli.rhtml30
-rw-r--r--app/views/layouts/default.rhtml6
-rw-r--r--app/views/public_body/show.rhtml29
-rw-r--r--app/views/request/_request_filter_form.rhtml38
-rw-r--r--app/views/request/_sidebar.rhtml5
-rw-r--r--app/views/request/list.rhtml2
-rw-r--r--app/views/track/_tracking_links.rhtml5
-rw-r--r--app/views/user/show.rhtml6
-rw-r--r--config/environment.rb1
-rw-r--r--config/routes.rb5
-rw-r--r--lib/world_foi_websites.rb40
-rw-r--r--public/javascripts/general.js22
-rw-r--r--public/javascripts/jquery.cookie.js111
-rw-r--r--public/stylesheets/theme.css39
-rw-r--r--spec/controllers/services_controller_spec.rb31
17 files changed, 281 insertions, 122 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
diff --git a/app/views/help/_sidebar.rhtml b/app/views/help/_sidebar.rhtml
index b6d26271e..db69f283b 100644
--- a/app/views/help/_sidebar.rhtml
+++ b/app/views/help/_sidebar.rhtml
@@ -5,6 +5,7 @@
<li><%= link_to_unless_current "Making requests", "/help/requesting" %></li>
<li><%= link_to_unless_current "Your privacy", "/help/privacy" %></li>
<li><%= link_to_unless_current "FOI officers", "/help/officers" %></li>
+ <li><%= link_to_unless_current "About the software", "/help/alaveteli" %></li>
<li><%= link_to_unless_current "Credits", "/help/credits" %></li>
<li><%= link_to_unless_current "Programmers API", "/help/api" %></li>
<li><%= link_to_unless_current "Advanced search", "/search" %></li>
diff --git a/app/views/help/alaveteli.rhtml b/app/views/help/alaveteli.rhtml
new file mode 100644
index 000000000..f7accdd11
--- /dev/null
+++ b/app/views/help/alaveteli.rhtml
@@ -0,0 +1,30 @@
+<% @title = "Making requests" %>
+
+<%= render :partial => 'sidebar' %>
+<div id="left_column">
+ <% if params[:country_name] %>
+ <h1><%= _("Would you like to see a website like this in your country?") %></h1>
+ <% else %>
+ <h1>Powered by Alaveteli</h1>
+ <% end %>
+ <p>This website is powered by Alaveteli. Alaveteli is free software
+ for making Freedom of Information requests. It can easily be
+ translated into any language, and customised for variations of FOI
+ law.</p>
+
+ <p>The development of Alaveteli is sponsored and supported by a
+ number of foundataions and charities who are interested in
+ transparency across the world.</p>
+
+ <p>If you would like to set up an Alaveteli website in your own
+ country, we can help. You will need a few days to get the site
+ configured and ready to use, and will then have to spend at least an
+ hour a week moderating and managing the site (more for busy
+ websites).</p>
+
+ <p>Read more on the <a href="http://alaveteli.org">Alaveteli
+ website</a>, or <a href="mailto:hello@alaveteli.org">drop us an
+ email</a>.</p>
+
+ <div id="hash_link_padding"></div>
+</div>
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index 75ba167e8..c802e7d45 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.rhtml
@@ -20,7 +20,7 @@
<%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %>
<%= stylesheet_link_tag 'fonts', :rel => "stylesheet" %>
<%= stylesheet_link_tag 'theme', :rel => "stylesheet" %>
- <%= javascript_include_tag 'jquery.js', 'jquery-ui.min' %>
+ <%= javascript_include_tag 'jquery.js', 'jquery-ui.min','jquery.cookie.js', 'general.js' %>
<%= 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>
@@ -132,7 +132,7 @@
</div>
</div>
<div id="wrapper">
-
+
<div id="content">
<% if flash[:notice] %>
@@ -143,6 +143,8 @@
<% end %>
<div id="<%= controller.controller_name + "_" + controller.action_name %>" class="controller_<%= controller.controller_name %>">
+
+ <div id="other-country-notice"></div>
<%= yield :layout %>
</div>
</div>
diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml
index f7583614c..7091e2eec 100644
--- a/app/views/public_body/show.rhtml
+++ b/app/views/public_body/show.rhtml
@@ -2,7 +2,11 @@
<div id="main_content">
<div>
<div id="header_right">
- <h2><%= _('Track this authority')%></h2>
+ <h2><%= _('Follow this authority')%></h2>
+
+ <% follower_count = TrackThing.count(:all, :conditions => ["public_body_id = ?", @public_body.id]) %>
+ <p><%= n_("There is %d person following this authority", "There are %d people following this authority", follower_count) % follower_count %></p>
+
<%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %>
<h2><%= _('More about this authority')%></h2>
<% if !@public_body.calculated_home_page.nil? %>
@@ -24,6 +28,7 @@
</div>
<div id="header_left">
+ <p class="public-body-name-prefix">Freedom of information requests to</p>
<h1><%=h(@public_body.name)%></h1>
<p class="subtitle">
@@ -48,7 +53,7 @@
<% if @public_body.eir_only? %>
<%= _('Make a new <strong>Environmental Information</strong> request')%>
<% else %>
- <%= _('Make a new <strong>Freedom of Information</strong> request')%>
+ <%= _('Make a new <strong>Freedom of Information</strong> request to {{public_body}}', :public_body => h(@public_body.name))%>
<% end %>
&nbsp;<%= _('<a class="link_button_green" href="{{url}}">{{text}}</a>', :url=>new_request_to_body_url(:url_name => @public_body.url_name), :text=>_("Start"))%>
<% elsif @public_body.has_notes? %>
@@ -63,9 +68,7 @@
<% end %>
</div>
</div>
-</div>
-<div style="clear:both">&nbsp;</div>
-<% if !@xapian_requests.nil? %>
+
<% if @public_body.info_requests.size == 0 %>
<% if @public_body.eir_only? %>
<h2><%= _('Environmental Information Regulations requests made using this site') %></h2>
@@ -76,15 +79,26 @@
<% end %>
<% else %>
<h2 class="foi_results">
+
<% if @public_body.eir_only? %>
<%= pluralize(@public_body.info_requests.size, "Environmental Information Regulations request made using this site") %>
<% else %>
- <%= n_('%d Freedom of Information request made using this site', '%d Freedom of Information requests made using this site', @public_body.info_requests.size) % @public_body.info_requests.size %>
+ <% if @public_body.info_requests.size > 1 %>
+ <%= n_('Search within the %d Freedom of Information requests to %s', 'Search within the %d Freedom of Information requests made to %s', @public_body.info_requests.size) % [@public_body.info_requests.size, @public_body.name] %>
+ <% else %>
+ <%= n_('%d Freedom of Information request to %s', '%d Freedom of Information requests to %s', @public_body.info_requests.size) % [@public_body.info_requests.size, @public_body.name] %>
+ <% end %>
<% end %>
<%= @page_desc %>
</h2>
+ <% if @public_body.info_requests.size > 1 %>
+ <%= render :partial => 'request/request_filter_form' %>
+ <% end %>
+ <% end %>
- <%= render :partial => 'request/request_filter_form' %>
+</div>
+<div style="clear:both">&nbsp;</div>
+<% if !@xapian_requests.nil? %>
<% for result in @xapian_requests.results %>
<%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
@@ -98,7 +112,6 @@
<p> <%= _('Only requests made using {{site_name}} are shown.', :site_name => site_name) %></p>
<% end %>
- <% end %>
<% else %>
<% if @public_body.eir_only? %>
<h2><%= _('Environmental Information Regulations requests made') %></h2>
diff --git a/app/views/request/_request_filter_form.rhtml b/app/views/request/_request_filter_form.rhtml
index c1848c59a..ac133889d 100644
--- a/app/views/request/_request_filter_form.rhtml
+++ b/app/views/request/_request_filter_form.rhtml
@@ -1,25 +1,6 @@
<%= render :partial => 'general/localised_datepicker' %>
<div id="list-filter">
- <div class="list-filter-item">
- <h3 class="title"><%= _("Showing") %></h3>
- <% statuses = [["all", _("all requests")],
- ["successful", _("successful requests")],
- ["unsuccessful", _("unsuccessful requests")],
- ["awaiting", _("unresolved requests")]] %>
- <% for status, label in statuses %>
- <% if params[:view] != status %>
- <% if params[:controller] == "public_body" %>
- <%= link_to label, url_for(:controller => "public_body", :action => "show", :view => status, :url_name => @public_body.url_name) + "?" + request.query_string %>
- <% else %>
- <%= link_to label, url_for(:controller => "request", :action => "list", :view => status) + "?" + request.query_string %>
- <% end %>
- <% else %>
- <%= label %>
- <% end %>
- <%= "|" unless statuses.last[0] == status %>
- <% end %>
- </div>
<% form_tag(request.path, :method => "get", :id=>"filter_requests_form") do %>
<div class="list-filter-item">
<%= label_tag(:query, _("Keywords"), :class=>"form_label title") %>
@@ -44,6 +25,25 @@
<%= label_tag(:query, _("and"), :class=>"form_label") %>
<%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %>
</div>
+ <div class="list-filter-item">
+ <h3 class="title">Showing</h3>
+ <% statuses = [["all", _("all requests")],
+ ["successful", _("successful requests")],
+ ["unsuccessful", _("unsuccessful requests")],
+ ["awaiting", _("unresolved requests")]] %>
+ <% for status, label in statuses %>
+ <% if params[:view] != status %>
+ <% if params[:controller] == "public_body" %>
+ <%= link_to label, url_for(:controller => "public_body", :action => "show", :view => status, :url_name => @public_body.url_name) + "?" + request.query_string %>
+ <% else %>
+ <%= link_to label, url_for(:controller => "request", :action => "list", :view => status) + "?" + request.query_string %>
+ <% end %>
+ <% else %>
+ <%= label %>
+ <% end %>
+ <%= "|" unless statuses.last[0] == status %>
+ <% end %>
+ </div>
<div class="list-filter-item">
<%= submit_tag(_("Search")) %>
diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.rhtml
index e562c4f6a..62ece4821 100644
--- a/app/views/request/_sidebar.rhtml
+++ b/app/views/request/_sidebar.rhtml
@@ -1,5 +1,8 @@
<div id="right_column">
- <h2><%= _('Track this request') %></h2>
+ <h2><%= _('Follow this request') %></h2>
+
+ <% follower_count = TrackThing.count(:all, :conditions => ["info_request_id = ?", @info_request.id]) + 1 %>
+ <p><%= n_("There is %d person following this request", "There are %d people following this request", follower_count) % follower_count %></p>
<%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user == @user, :location => 'sidebar' } %>
<h2><%= _("Act on what you've learnt") %></h2>
diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml
index 88d4279e1..0137cb6dd 100644
--- a/app/views/request/list.rhtml
+++ b/app/views/request/list.rhtml
@@ -5,7 +5,7 @@
</div>
<div id="header_right">
- <h2><%= _("Track these requests") %></h2>
+ <h2><%= _("Follow these requests") %></h2>
<% if @track_thing %>
<%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %>
<% end %>
diff --git a/app/views/track/_tracking_links.rhtml b/app/views/track/_tracking_links.rhtml
index 53688867c..f50a8bbbf 100644
--- a/app/views/track/_tracking_links.rhtml
+++ b/app/views/track/_tracking_links.rhtml
@@ -4,11 +4,10 @@
end
%>
-
<% if own_request %>
<p><%= _('This is your own request, so you will be automatically emailed when new responses arrive.')%></p>
<% elsif existing_track %>
- <% form_tag({:controller => 'track', :action => 'update', :track_id => existing_track.id}, :class => "feed_form_" + location) do %>
+ <% form_tag({:controller => 'track', :action => 'update', :track_id => existing_track.id}, :class => "feed_form feed_form_" + location) do %>
<p>
<%= track_thing.params[:verb_on_page_already] %>
<%= hidden_field_tag 'track_medium', "delete" %>
@@ -19,7 +18,7 @@
<% elsif track_thing %>
<div class="feed_link feed_link_<%=location%>">
<%= link_to '<img src="/images/email-16.png" alt="">', do_track_url(track_thing) %>
- <%= link_to _("Track by email"), do_track_url(track_thing) %>
+ <%= link_to _("Follow by email"), do_track_url(track_thing) %>
</div>
<div class="feed_link feed_link_<%=location%>">
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 63f9fe3a0..4c7635c5e 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -186,7 +186,7 @@
<% else %>
<h2 id="email_subscriptions"> Your <%=pluralize(@track_things.size, _('email subscription')) %> </h2>
<% if @track_things_grouped.size == 1 %>
- <% form_tag :controller => 'track', :action => 'delete_all_type' do %>
+ <% form_tag ({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
<h3>
<%=TrackThing.track_type_description(@track_things[0].track_type)%>
<%= hidden_field_tag 'track_type', @track_things[0].track_type %>
@@ -200,7 +200,7 @@
<% end %>
<% for track_type, track_things in @track_things_grouped %>
<% if @track_things_grouped.size > 1 %>
- <% form_tag :controller => 'track', :action => 'delete_all_type' do %>
+ <% form_tag ({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
<h3>
<%=TrackThing.track_type_description(track_type)%>
<%= hidden_field_tag 'track_type', track_type %>
@@ -216,7 +216,7 @@
<ul>
<% for track_thing in track_things %>
<li>
- <% form_tag :controller => 'track', :action => 'update', :track_id => track_thing.id do %>
+ <% form_tag ({:controller => 'track', :action => 'update', :track_id => track_thing.id}, :class => "feed_form") do %>
<div>
<%= track_thing.params[:list_description] %>
<%= hidden_field_tag 'track_medium', "delete", { :id => 'track_medium_' + track_thing.id.to_s } %>
diff --git a/config/environment.rb b/config/environment.rb
index 0c49e5e3c..2f7967cdc 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -145,3 +145,4 @@ require 'sendmail_return_path.rb'
require 'tnef.rb'
require 'i18n_fixes.rb'
require 'rack_quote_monkeypatch.rb'
+require 'world_foi_websites.rb'
diff --git a/config/routes.rb b/config/routes.rb
index 6f13c7bc3..1fa2f8aa0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -109,6 +109,10 @@ ActionController::Routing::Routes.draw do |map|
comment.new_comment "/annotate/request/:url_title", :action => 'new', :type => 'request'
end
+ map.with_options :controller => 'services' do |service|
+ service.other_country_message "/country_message", :action => 'other_country_message'
+ end
+
map.with_options :controller => 'track' do |track|
# /track/ is for setting up an email alert for the item
# /feed/ is a direct RSS feed of the item
@@ -128,6 +132,7 @@ ActionController::Routing::Routes.draw do |map|
map.with_options :controller => 'help' do |help|
help.help_unhappy '/help/unhappy/:url_title', :action => 'unhappy'
help.help_about '/help/about', :action => 'about'
+ help.help_about '/help/alaveteli', :action => 'alaveteli'
help.help_contact '/help/contact', :action => 'contact'
help.help_officers '/help/officers', :action => 'officers'
help.help_requesting '/help/requesting', :action => 'requesting'
diff --git a/lib/world_foi_websites.rb b/lib/world_foi_websites.rb
new file mode 100644
index 000000000..24845437a
--- /dev/null
+++ b/lib/world_foi_websites.rb
@@ -0,0 +1,40 @@
+class WorldFOIWebsites
+ def self.world_foi_websites
+ world_foi_websites = [
+ {:name => "WhatDoTheyKnow?",
+ :country_name => _("United Kingdom"),
+ :country_iso_code => "GB",
+ :url => "http://www.whatdotheyknow.com"},
+ {:name => "Informata Zyrtare",
+ :country_name => _("Kosovo"),
+ :country_iso_code => "XK",
+ :url => "http://informatazyrtare.org"},
+ {:name => "Ask The EU",
+ :country_name => _("European Union"),
+ :country_iso_code => "",
+ :url => "http://asktheu.org"},
+ {:name => "MuckRock.com",
+ :country_name => _("United States of America"),
+ :country_iso_code => "US",
+ :url => "http://www.muckrock.com"},
+ {:name => "FYI",
+ :country_name => _("New Zealand"),
+ :country_iso_code => "NZ",
+ :url => "http://fyi.org.nz"},
+ {:name => "Frag den Staat",
+ :country_name => _("Germany"),
+ :country_iso_code => "DE",
+ :url => "http://fragdenstaat.de"},
+ {:name => "Acceso Intelligente",
+ :country_name => _("Chile"),
+ :country_iso_code => "CL",
+ :url => "accesointeligente.org"}]
+ return world_foi_websites
+ end
+
+ def self.by_code(code)
+ result = self.world_foi_websites.find{|x| x[:country_iso_code].downcase == code.downcase}
+ return result
+ end
+end
+
diff --git a/public/javascripts/general.js b/public/javascripts/general.js
new file mode 100644
index 000000000..ed5095f82
--- /dev/null
+++ b/public/javascripts/general.js
@@ -0,0 +1,22 @@
+$(document).ready(function() {
+ if(window.location.search.substring(1).search("country_name") == -1) {
+ if (!$.cookie('has_seen_country_message')) {
+ $.ajax({
+ url: "/country_message",
+ dataType: 'html',
+ success: function(country_message){
+ if (country_message != ''){
+ $('#other-country-notice').html(country_message);
+ $('body:not(.front) #other-country-notice').show()
+ }
+ }
+ })
+
+ }
+ }
+
+ $('#other-country-notice').click(function() {
+ $('#other-country-notice').hide();
+ $.cookie('has_seen_country_message', 1, {expires: 365, path: '/'});
+ })
+}) \ No newline at end of file
diff --git a/public/javascripts/jquery.cookie.js b/public/javascripts/jquery.cookie.js
index 6df1faca2..6a3e394b4 100644
--- a/public/javascripts/jquery.cookie.js
+++ b/public/javascripts/jquery.cookie.js
@@ -1,96 +1,41 @@
/**
- * Cookie plugin
+ * jQuery Cookie plugin
*
- * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
+ * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
+jQuery.cookie = function (key, value, options) {
-/**
- * Create a cookie with the given name and value and other optional parameters.
- *
- * @example $.cookie('the_cookie', 'the_value');
- * @desc Set the value of a cookie.
- * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
- * @desc Create a cookie with all available options.
- * @example $.cookie('the_cookie', 'the_value');
- * @desc Create a session cookie.
- * @example $.cookie('the_cookie', null);
- * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
- * used when the cookie was set.
- *
- * @param String name The name of the cookie.
- * @param String value The value of the cookie.
- * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
- * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
- * If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
- * If set to null or omitted, the cookie will be a session cookie and will not be retained
- * when the the browser exits.
- * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
- * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
- * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
- * require a secure protocol (like HTTPS).
- * @type undefined
- *
- * @name $.cookie
- * @cat Plugins/Cookie
- * @author Klaus Hartl/klaus.hartl@stilbuero.de
- */
+ // key and at least value given, set cookie...
+ if (arguments.length > 1 && String(value) !== "[object Object]") {
+ options = jQuery.extend({}, options);
-/**
- * Get the value of a cookie with the given name.
- *
- * @example $.cookie('the_cookie');
- * @desc Get the value of a cookie.
- *
- * @param String name The name of the cookie.
- * @return The value of the cookie.
- * @type String
- *
- * @name $.cookie
- * @cat Plugins/Cookie
- * @author Klaus Hartl/klaus.hartl@stilbuero.de
- */
-jQuery.cookie = function(name, value, options) {
- if (typeof value != 'undefined') { // name and value given, set cookie
- options = options || {};
- if (value === null) {
- value = '';
+ if (value === null || value === undefined) {
options.expires = -1;
}
- var expires = '';
- if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
- var date;
- if (typeof options.expires == 'number') {
- date = new Date();
- date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
- } else {
- date = options.expires;
- }
- expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
- }
- // CAUTION: Needed to parenthesize options.path and options.domain
- // in the following expressions, otherwise they evaluate to undefined
- // in the packed version for some reason...
- var path = options.path ? '; path=' + (options.path) : '';
- var domain = options.domain ? '; domain=' + (options.domain) : '';
- var secure = options.secure ? '; secure' : '';
- document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
- } else { // only name given, get cookie
- var cookieValue = null;
- if (document.cookie && document.cookie != '') {
- var cookies = document.cookie.split(';');
- for (var i = 0; i < cookies.length; i++) {
- var cookie = jQuery.trim(cookies[i]);
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) == (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
+
+ if (typeof options.expires === 'number') {
+ var days = options.expires, t = options.expires = new Date();
+ t.setDate(t.getDate() + days);
}
- return cookieValue;
+
+ value = String(value);
+
+ return (document.cookie = [
+ encodeURIComponent(key), '=',
+ options.raw ? value : encodeURIComponent(value),
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
+ options.path ? '; path=' + options.path : '',
+ options.domain ? '; domain=' + options.domain : '',
+ options.secure ? '; secure' : ''
+ ].join(''));
}
-}; \ No newline at end of file
+
+ // key and possibly options given, get cookie...
+ options = value || {};
+ var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
+ return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
+};
diff --git a/public/stylesheets/theme.css b/public/stylesheets/theme.css
index 43042fa75..964974321 100644
--- a/public/stylesheets/theme.css
+++ b/public/stylesheets/theme.css
@@ -3,6 +3,7 @@ h1 {
font-size: 42px;
font-family: 'DeliciousBold', Arial, sans-serif;
margin-bottom:15px;
+ margin-top:10px;
}
h2 a {
@@ -193,6 +194,7 @@ div.lang {
p.subtitle {
margin-top:10px;
margin-bottom:20px;
+ font-style: italic;
}
.results_section {
@@ -411,6 +413,12 @@ p.subtitle {
padding-right:2px;
}
+form.feed_form input[type="submit"] {
+ font-size: 12px;
+ line-height: 12px;
+ padding: 2px 4px;
+}
+
#header_right > br {
line-height:200%;
}
@@ -429,12 +437,15 @@ h2.foi_results,
h2.person_results,
h2.publicbody_results {
padding-top:0px;
- border-bottom:1px solid #B3B3B3;
padding-bottom:15px;
margin-bottom:0px;
margin-top: 0px;
}
+h2.foi_results {
+ width: 600px;
+}
+
.list_toggle_controls {
padding-bottom:20px;
}
@@ -589,7 +600,8 @@ form input.use-datepicker[type=text] {
form input[type=submit],
a.link_button_green,
-a.link_button_green_large {
+a.link_button_green_large,
+span.close-button {
background: url(/images/button-gradient.png);
color: white;
text-decoration: none;
@@ -602,6 +614,7 @@ a.link_button_green_large {
font-family: 'DeliciousRoman', Arial, sans-serif;
font-size: 18px;
cursor: pointer;
+ cursor: hand;
}
a.link_button_green_large {
@@ -884,3 +897,25 @@ body.front h3 {
cursor:pointer;
opacity: 1;
}
+
+#other-country-notice {
+ position: absolute;
+}
+
+span.close-button {
+ cursor: pointer;
+ font-size: 1em;
+ padding: 0 1px 0 1px;
+ line-height: 1.1em;
+ font-family: Arial;
+}
+body.front #other-country-notice,
+#other-country-notice {
+ display: none;
+}
+
+p.public-body-name-prefix {
+ color: #DEB4D8;
+ margin-top: 15px;
+ margin-bottom: -15px;
+}
diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb
new file mode 100644
index 000000000..1bafd0c8f
--- /dev/null
+++ b/spec/controllers/services_controller_spec.rb
@@ -0,0 +1,31 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe ServicesController, "when using web services" do
+ integrate_views
+
+ it "should show no alaveteli message when in the deployed country" do
+ config = MySociety::Config.load_default()
+ config['ISO_COUNTRY_CODE'] = "DE"
+ controller.stub!(:country_from_ip).and_return('DE')
+ get :other_country_message
+ response.body.should == ""
+ end
+
+ it "should show an alaveteli message when not in the deployed country and in a country with no FOI website" do
+ config = MySociety::Config.load_default()
+ config['ISO_COUNTRY_CODE'] = "DE"
+ controller.stub!(:country_from_ip).and_return('ZZ')
+ get :other_country_message
+ response.body.should match(/outside Germany/)
+ end
+
+ it "should show link to other FOI website when not in the deployed country" do
+ config = MySociety::Config.load_default()
+ config['ISO_COUNTRY_CODE'] = "ZZ"
+ controller.stub!(:country_from_ip).and_return('DE')
+ get :other_country_message
+ response.body.should match(/within Germany/)
+ end
+
+
+end