aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb16
-rw-r--r--app/controllers/general_controller.rb26
-rw-r--r--app/controllers/public_body_controller.rb1
-rw-r--r--app/controllers/user_controller.rb13
-rw-r--r--app/helpers/application_helper.rb15
-rw-r--r--app/models/track_mailer.rb4
-rw-r--r--app/models/track_thing.rb76
-rw-r--r--app/models/user.rb9
-rw-r--r--app/models/user_mailer.rb2
-rw-r--r--app/views/admin_public_body/_form.rhtml20
-rw-r--r--app/views/general/_credits.rhtml2
-rw-r--r--app/views/general/_frontpage_intro_sentence.rhtml7
-rw-r--r--app/views/general/blog.rhtml2
-rw-r--r--app/views/general/frontpage.rhtml70
-rw-r--r--app/views/general/search.rhtml21
-rw-r--r--app/views/layouts/default.rhtml4
-rw-r--r--app/views/request/_next_actions.rhtml1
-rw-r--r--app/views/request/_sidebar.rhtml23
-rw-r--r--app/views/track_mailer/event_digest.rhtml12
-rw-r--r--app/views/user/show.rhtml28
-rw-r--r--app/views/user/sign.rhtml2
-rw-r--r--config/routes.rb2
-rw-r--r--db/migrate/102_add_locale_to_users.rb11
-rw-r--r--public/images/button-gradient-large.pngbin0 -> 266 bytes
-rw-r--r--public/images/flying-computer.pngbin0 -> 10357 bytes
-rw-r--r--public/images/home-grad.pngbin0 -> 306 bytes
-rw-r--r--public/stylesheets/main.css4
-rw-r--r--public/stylesheets/theme.css109
-rw-r--r--spec/controllers/general_controller_spec.rb2
-rw-r--r--spec/controllers/public_body_controller_spec.rb6
-rw-r--r--spec/controllers/request_controller_spec.rb1
-rw-r--r--spec/controllers/track_controller_spec.rb15
-rw-r--r--spec/controllers/user_controller_spec.rb20
-rw-r--r--spec/fixtures/users.yml3
-rw-r--r--spec/integration/search_request_spec.rb11
-rw-r--r--spec/models/track_mailer_spec.rb3
-rw-r--r--spec/models/track_thing_spec.rb10
-rw-r--r--vendor/plugins/action_mailer_layouts/CHANGELOG21
-rw-r--r--vendor/plugins/action_mailer_layouts/README35
-rw-r--r--vendor/plugins/action_mailer_layouts/init.rb7
-rw-r--r--vendor/plugins/action_mailer_layouts/plugin.rb48
41 files changed, 419 insertions, 243 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 9133f701b..3794043fb 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,8 +14,14 @@ class ApplicationController < ActionController::Base
# Standard headers, footers and navigation for whole site
layout "default"
include FastGettext::Translation # make functions like _, n_, N_ etc available)
+
+ # Note: a filter stops the chain if it redirects or renders something
+ before_filter :authentication_check
before_filter :set_gettext_locale
+ before_filter :check_in_post_redirect
+ before_filter :session_remember_me
before_filter :set_vary_header
+
# scrub sensitive parameters from the logs
filter_parameter_logging :password
@@ -48,7 +54,14 @@ class ApplicationController < ActionController::Base
else
requested_locale = params[:locale] || session[:locale] || cookies[:locale] || I18n.default_locale
end
+ requested_locale = FastGettext.best_locale_in(requested_locale)
session[:locale] = FastGettext.set_locale(requested_locale)
+ if !@user.nil?
+ if @user.locale != requested_locale
+ @user.locale = session[:locale]
+ @user.save!
+ end
+ end
end
# scrub sensitive parameters from the logs
@@ -85,7 +98,6 @@ class ApplicationController < ActionController::Base
# Set cookie expiry according to "remember me" checkbox, as per "An easier
# and more flexible hack" on this page:
# http://wiki.rubyonrails.org/rails/pages/HowtoChangeSessionOptions
- before_filter :session_remember_me
def session_remember_me
# Reset the "sliding window" session expiry time.
if request.env['rack.session.options']
@@ -265,7 +277,6 @@ class ApplicationController < ActionController::Base
end
# If we are in a faked redirect to POST request, then set post params.
- before_filter :check_in_post_redirect
def check_in_post_redirect
if params[:post_redirect] and session[:post_redirect_token]
post_redirect = PostRedirect.find_by_token(session[:post_redirect_token])
@@ -274,7 +285,6 @@ class ApplicationController < ActionController::Base
end
# Default layout shows user in corner, so needs access to it
- before_filter :authentication_check
def authentication_check
if session[:user_id]
@user = authenticated_user
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 1ddf3acff..ada891ce9 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -50,11 +50,18 @@ class GeneralController < ApplicationController
query = 'variety:response (status:successful OR status:partially_successful)'
# query = 'variety:response' # XXX debug
sortby = "described"
- xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', 8)
- @successful_request_events = xapian_object.results.map { |r| r[:model] }
- @successful_request_events = @successful_request_events.sort_by { |e| e.described_at }.reverse
+ max_count = 5
+ xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count)
+ @request_events = xapian_object.results.map { |r| r[:model] }
+ @request_events = @request_events.sort_by { |e| e.described_at }.reverse
+ if @request_events.count < max_count
+ query = 'variety:sent'
+ xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count-@request_events.count)
+ more_events = xapian_object.results.map { |r| r[:model] }
+ @request_events += more_events.sort_by { |e| e.described_at }.reverse
+ end
rescue
- @successful_request_events = []
+ @request_events = []
end
end
end
@@ -92,7 +99,7 @@ class GeneralController < ApplicationController
@variety_postfix = path.pop
end
@variety_postfix = params[:bodies] if @variety_postfix.nil? && !params[:bodies].nil?
- @variety_postfix = "all" if @variety_postfix.nil?
+ @variety_postfix = "requests" if @variety_postfix.nil?
if @variety_postfix != "users"
@common_query = get_tags_from_params
end
@@ -135,7 +142,9 @@ class GeneralController < ApplicationController
@sort_postfix = combined.pop
@sortby = @sort_postfix
end
-
+ if !params[:view].nil?
+ combined += [params[:view]]
+ end
if combined.size > 0 && (['bodies', 'requests', 'users', 'all'].include?(combined[-1]))
@variety_postfix = combined.pop
case @variety_postfix
@@ -152,8 +161,13 @@ class GeneralController < ApplicationController
@requests = false
@users = true
end
+ else
+ @variety_postfix = "all"
end
@query = combined.join("/")
+ if params[:query].nil?
+ params[:query] = @query
+ end
@inputted_sortby = @sortby
@common_query = get_tags_from_params
if @sortby.nil?
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 77cede36b..0e58b7055 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -90,6 +90,7 @@ class PublicBodyController < ApplicationController
@query = "%#{params[:public_body_query].nil? ? "" : params[:public_body_query]}%"
@tag = params[:tag]
@locale = self.locale_from_params()
+
locale_condition = "(upper(public_body_translations.name) LIKE upper(?) OR upper(public_body_translations.notes) LIKE upper (?)) AND public_body_translations.locale = ?"
if @tag.nil? or @tag == "all"
@tag = "all"
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index c53529bc3..96dbfba74 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -35,9 +35,16 @@ class UserController < ApplicationController
# Use search query for this so can collapse and paginate easily
# XXX really should just use SQL query here rather than Xapian.
begin
- @xapian_requests = perform_search([InfoRequestEvent], 'requested_by:' + @display_user.url_name, 'newest', 'request_collapse')
- @xapian_comments = perform_search([InfoRequestEvent], 'commented_by:' + @display_user.url_name, 'newest', nil)
-
+ requests_query = 'requested_by:' + @display_user.url_name
+ comments_query = 'commented_by:' + @display_user.url_name
+ if !params[:user_query].nil?
+ requests_query += " " + params[:user_query]
+ comments_query += " " + params[:user_query]
+ @match_phrase = _("{{search_results}} matching '{{query}}'", :search_results => "", :query => params[:user_query])
+ end
+ @xapian_requests = perform_search([InfoRequestEvent], requests_query, 'newest', 'request_collapse')
+ @xapian_comments = perform_search([InfoRequestEvent], comments_query, 'newest', nil)
+
if (@page > 1)
@page_desc = " (page " + @page.to_s + ")"
else
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ec56566a9..d12238582 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -94,5 +94,20 @@ module ApplicationHelper
block.call
end
end
+ # (unfortunately) ugly way of getting id of generated form element
+ # ids
+ # see http://chrisblunt.com/2009/10/12/rails-getting-the-id-of-form-fields-inside-a-fields_for-block/
+ def sanitized_object_name(object_name)
+ object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/,"_").sub(/_$/,"")
+ end
+
+ def sanitized_method_name(method_name)
+ method_name.sub(/\?$/, "")
+ end
+
+ def form_tag_id(object_name, method_name)
+ return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}"
+ end
+
end
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb
index 4b7c603a7..f8bef4d61 100644
--- a/app/models/track_mailer.rb
+++ b/app/models/track_mailer.rb
@@ -85,7 +85,11 @@ class TrackMailer < ApplicationMailer
# If we have anything to send, then send everything for the user in one mail
if email_about_things.size > 0
# Send the email
+
+ previous_locale = I18n.locale
+ I18n.locale = user.get_locale
TrackMailer.deliver_event_digest(user, email_about_things)
+ I18n.locale = previous_locale
end
# Record that we've now sent those alerts to that user
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index 82848341d..b74f7dad5 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -22,6 +22,7 @@
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
# $Id: track_thing.rb,v 1.53 2009-09-17 21:10:05 francis Exp $
+require 'set'
class TrackThing < ActiveRecord::Base
belongs_to :tracking_user, :class_name => 'User'
@@ -67,6 +68,63 @@ class TrackThing < ActiveRecord::Base
TrackThing.track_type_description(self.track_type)
end
+ def track_query_description
+ # XXX this is very brittle... we should probably ask users
+ # simply to name their tracks when they make them?
+ self.track_query = self.track_query.gsub(/([()]|OR)/, "")
+ filters = self.track_query.scan /\b\S+:\S+\b/
+ text = self.track_query
+ varieties = Set.new
+ date = ""
+ statuses = Set.new
+ for filter in filters
+ text = text.sub(filter, "")
+ if filter =~ /variety:user/
+ varieties << _("users")
+ end
+ if filter =~ /variety:comment/
+ varieties << _("comments")
+ end
+ if filter =~ /variety:authority/
+ varieties << _("authorities")
+ end
+ if filter =~ /(variety:(sent|followup_sent|response)|latest_status)/
+ varieties << _("requests")
+ end
+ if filter =~ /[0-9\/]+\.\.[0-9\/]+/
+ date = _("between two dates")
+ end
+ if filter =~ /(rejected|not_held)/
+ statuses << _("unsuccessful")
+ end
+ if filter =~ /(:successful|:partially_successful)/
+ statuses << _("successful")
+ end
+ if filter =~ /waiting/
+ statuses << _("awaiting a response")
+ end
+ end
+ if filters.empty?
+ text = self.track_query
+ end
+ descriptions = []
+ if varieties.include? _("requests")
+ descriptions << _("requests which are {{list_of_statuses}}", :list_of_statuses => Array(statuses).join(_(' or ')))
+ varieties -= [_("requests")]
+ end
+ if descriptions.empty? and varieties.empty?
+ varieties << _("anything")
+ end
+ descriptions += Array(varieties)
+ text = text.strip
+ descriptions = descriptions.join(_(" or "))
+ if !text.empty?
+ descriptions += _("{{list_of_things}} matching text '{{search_query}}'", :list_of_things => "", :search_query => text)
+ end
+ return descriptions
+ end
+
+
def TrackThing.create_track_for_request(info_request)
track_thing = TrackThing.new
track_thing.track_type = 'request_updates'
@@ -134,16 +192,16 @@ class TrackThing < ActiveRecord::Base
if self.track_type == 'request_updates'
@params = {
# Website
- :list_description => "'<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>', a request", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+ :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Track this request by email"),
:verb_on_page_already => _("You are already tracking this request by email"),
# Email
- :title_in_email => "New updates for the request '" + self.info_request.title + "'",
- :title_in_rss => "New updates for the request '" + self.info_request.title + "'",
+ :title_in_email => _("New updates for the request '{{request_title}}'", :request_title => self.info_request.title),
+ :title_in_rss => _("New updates for the request '{{request_title}}'", :request_title => self.info_request.title),
# Authentication
- :web => "To follow updates to the request '" + CGI.escapeHTML(self.info_request.title) + "'",
- :email => "Then you will be emailed whenever the request '" + CGI.escapeHTML(self.info_request.title) + "' is updated.",
- :email_subject => "Confirm you want to follow updates to the request '" + self.info_request.title + "'",
+ :web => _("To follow updates to the request '{{request_title}}'", :request_title => CGI.escapeHTML(self.info_request.title)),
+ :email => _("Then you will be emailed whenever the request '{{request_title}}' is updated.", :request_title => CGI.escapeHTML(self.info_request.title)),
+ :email_subject => _("Confirm you want to follow updates to the request '{{request_title}}'", :request_title => self.info_request.title),
# RSS sorting
:feed_sortby => 'newest'
}
@@ -185,7 +243,7 @@ class TrackThing < ActiveRecord::Base
elsif self.track_type == 'public_body_updates'
@params = {
# Website
- :list_description => "'<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>', a public authority", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+ :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Track requests to {{public_body_name}} by email",:public_body_name=>CGI.escapeHTML(self.public_body.name)),
:verb_on_page_already => _("You are already tracking requests to {{public_body_name}} by email", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
# Email
@@ -201,7 +259,7 @@ class TrackThing < ActiveRecord::Base
elsif self.track_type == 'user_updates'
@params = {
# Website
- :list_description => "'<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>', a person", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+ :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Track this person by email"),
:verb_on_page_already => _("You are already tracking this person by email"),
# Email
@@ -217,7 +275,7 @@ class TrackThing < ActiveRecord::Base
elsif self.track_type == 'search_query'
@params = {
# Website
- :list_description => "'<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest\">" + CGI.escapeHTML(self.track_query) + "</a>' in new requests/responses", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+ :list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Track things matching this search by email"),
:verb_on_page_already => _("You are already tracking things matching this search by email"),
# Email
diff --git a/app/models/user.rb b/app/models/user.rb
index fddb6b035..c3c3da6f7 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -96,6 +96,15 @@ class User < ActiveRecord::Base
end
end
end
+
+ def get_locale
+ if !self.locale.nil?
+ locale = self.locale
+ else
+ locale = I18n.locale
+ end
+ return locale.to_s
+ end
def visible_comments
self.comments.find(:all, :conditions => 'visible')
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
index 0972e167d..7adf5b63c 100644
--- a/app/models/user_mailer.rb
+++ b/app/models/user_mailer.rb
@@ -46,7 +46,5 @@ class UserMailer < ApplicationMailer
@body[:old_email] = old_email
@body[:new_email] = new_email
end
-
-
end
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
index 191b29e89..6a9013071 100644
--- a/app/views/admin_public_body/_form.rhtml
+++ b/app/views/admin_public_body/_form.rhtml
@@ -26,20 +26,20 @@
<div id="div-locale-<%=locale.to_s%>">
<%= t.hidden_field :locale, :value => locale.to_s %>
- <p><label for="public_body_name">Name</label><br/>
- <%= t.text_field :name, :size => 60 %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :name) %>">Name</label><br/>
+ <%= t.text_field :name, :size => 60, :id => form_tag_id(t.object_name, :name) %></p>
- <p><label for="public_body_short_name">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/>
- <%= t.text_field :short_name, :size => 60 %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :short_name) %>">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/>
+ <%= t.text_field :short_name, :size => 60, :id => form_tag_id(t.object_name, :short_name) %></p>
- <p><label for="public_body_request_email">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/>
- <%= t.text_field :request_email, :size => 40 %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :request_email) %>">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/>
+ <%= t.text_field :request_email, :size => 40, :id => form_tag_id(t.object_name, :request_email) %></p>
- <p><label for="public_body_publication_scheme">Publication scheme URL</label><br/>
- <%= t.text_field :publication_scheme, :size => 60 %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :publication_scheme) %>">Publication scheme URL</label><br/>
+ <%= t.text_field :publication_scheme, :size => 60, :id => form_tag_id(t.object_name, :publication_scheme) %></p>
- <p><label for="public_body_notes">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/>
- <%= t.text_area :notes, :rows => 3, :cols => 60 %></p>
+ <p><label for="<%= form_tag_id(t.object_name, :notes) %>">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/>
+ <%= t.text_area :notes, :rows => 3, :cols => 60, :id => form_tag_id(t.object_name, :notes) %></p>
</div>
<%
end
diff --git a/app/views/general/_credits.rhtml b/app/views/general/_credits.rhtml
index 8c519ce7e..b1a9ce05e 100644
--- a/app/views/general/_credits.rhtml
+++ b/app/views/general/_credits.rhtml
@@ -1 +1 @@
-| <%= _('Powered by <a href="http://www.alaveteli.org/">Alaveteli</a>.') %>
+| <%= _('Powered by <a href="http://www.alaveteli.org/">Alaveteli</a>') %>
diff --git a/app/views/general/_frontpage_intro_sentence.rhtml b/app/views/general/_frontpage_intro_sentence.rhtml
index 4e6dbecb3..70b47ad06 100644
--- a/app/views/general/_frontpage_intro_sentence.rhtml
+++ b/app/views/general/_frontpage_intro_sentence.rhtml
@@ -1,3 +1,4 @@
-<h3>Use your Right to Know</h3>
-
-Every citizen has the right to access information held by public authorities. <strong>By law, they have to respond</strong>. <a href="<%= help_about_url %>">Find out more about freedom of information.</a>
+<h2>
+ Your <strong>Right to Know</strong>
+</h2>
+<p>Every citizen has the right to access information held by public authorities. <strong>By law, they have to respond</strong>. <a href="<%= help_about_url %>">Find out more about freedom of information.</a></p>
diff --git a/app/views/general/blog.rhtml b/app/views/general/blog.rhtml
index 4bc23832d..4ff408e52 100644
--- a/app/views/general/blog.rhtml
+++ b/app/views/general/blog.rhtml
@@ -4,7 +4,7 @@
<div id="right_column">
<div class="act_link">
<h2>Stay up to date</h2>
- <img src="/images/twitter-16.png" alt="twitter icon" valign="middle"> <a href="http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>">Follow us on twitter</a><br/><br/>
+ <img src="/images/twitter-16.png" alt="twitter icon" class="twitter-icon"> <a href="http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>">Follow us on twitter</a><br/><br/>
<img src="/images/feed-16.png" alt="RSS icon" valign="middle"> <a href="<%= MySociety::Config.get('BLOG_FEED') %>">Subscribe to blog</a>
</div>
<div id="twitter">
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml
index e1cdaa52e..55b00b753 100644
--- a/app/views/general/frontpage.rhtml
+++ b/app/views/general/frontpage.rhtml
@@ -1,37 +1,43 @@
<% view_cache :ttl => 5.minutes, :tag => I18n.locale do %>
-
-
- <div class="frontpage-box" id="frontpage-box-1">
- <%= render :partial => 'frontpage_intro_sentence' %>
- </div>
-
- <div class="frontpage-box" id="frontpage-box-2">
- <div id="bighand">
- Make a new <strong>Freedom of Information</strong> request
- <br />
- <a href="/select_authority"><img alt="Start-button" src="/images/start-button.png"></a>
- </div>
- </div>
-
- <div class="frontpage-box" id="frontpage-box-3">
- <div id="littlehand">
- Search over <strong><%= InfoRequest.count %> requests</strong> and <strong><%= PublicBody.count %> authorities</strong>:
- <% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
- <%= text_field_tag 'query', params[:query], { :size => 30 } %>
- <%= hidden_field_tag 'bodies', 1 %>
- <%= image_submit_tag 'button-search.png', :title => 'Search' %>
- <br>
- <%= render :partial => 'frontpage_search_examples' %>
- <% end %>
+ <div id="frontpage_splash">
+ <div id="left_column">
+ <h1>
+ <%= _("Make a new<br/>
+ <strong>Freedom <span>of</span><br/>
+ Information<br/>
+ request</strong>") %>
+ </h1>
+ <a class="link_button_green_large" href="/select_authority"><%= _("Start now &raquo;") %></a>
+ </div>
+ <div id="right_column">
+ <div id="frontpage_search_box">
+ <h2>
+ <%= _("Search over<br/>
+ <strong>{{number_of_requests}} requests</strong> <span>and</span><br/>
+ <strong>{{number_of_authorities}} authorities</strong>",
+ :number_of_requests => InfoRequest.count, :number_of_authorities => PublicBody.count) %>
+ </h2>
+ <% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
+ <div>
+ <%= text_field_tag 'query', params[:query], { :size => 30 } %>
+ <%= hidden_field_tag 'bodies', 1 %>
+ <%= submit_tag _('Search') %>
+ </div>
+ <% end %>
+ </div>
+ <div id="frontpage_right_to_know">
+ <%= render :partial => 'frontpage_intro_sentence' %>
+ </div>
</div>
+ <div style="clear:both"></div>
</div>
-
<div id="frontpage_examples">
<% if @popular_bodies.size > 0 %>
<div id="examples_0">
- <h3>Who has the information?</h3>
- <%= site_name %> covers requests to <%= PublicBody.count %> authorities, including:
+ <h3><%= _("Who can I request information from?") %></h3>
+ <%= _("{{site_name}} covers requests to {{number_of_authorities}} authorities, including:",
+ :site_name => site_name, :number_of_authorities => PublicBody.count) %>
<ul>
<% for popular_body in @popular_bodies %>
<li><%=public_body_link(popular_body)%>
@@ -46,13 +52,13 @@
<% end %>
<div id="examples_1">
- <h3>What are people asking?</h3>
- <%= site_name %> users have asked <%= InfoRequest.count %> questions.
+ <h3><%= _("What information has been released?") %></h3>
+ <%= _("{{site_name}} users have made {{number_of_requests}} requests, including:",
+ :site_name => site_name, :number_of_requests => InfoRequest.count) %>
<ul>
-
- <% for event in @successful_request_events %>
+ <% for event in @request_events %>
<li>
- <%= public_body_link(event.info_request.public_body) %> answered a question about
+ <%= public_body_link(event.info_request.public_body) %> answered a request about
<%=link_to h(event.info_request.title), request_url(event.info_request)%>
<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %>
<p class="excerpt" onclick="document.location.href='<%=request_url(event.info_request)%>'"><%= excerpt(event.info_request.title, "", 200) %></p>
diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml
index f0c5f1576..ba060d33c 100644
--- a/app/views/general/search.rhtml
+++ b/app/views/general/search.rhtml
@@ -20,10 +20,11 @@
<% end%>
<% if @advanced %>
+ <div id="advanced-search">
<p><%= _('To use the advanced search, combine phrases and labels as described in the search tips below.') %></p>
<% form_tag(advanced_search_url, :method => "get") do %>
<p>
- <%= text_field_tag :query, params[:query], { :size => 40 } %>
+ <%= text_field_tag :query, @query, { :size => 60 } %>
<%= hidden_field_tag 'sortby', @inputted_sortby %>
<% if @bodies %>
<%= hidden_field_tag 'bodies', 1 %>
@@ -32,6 +33,7 @@
&nbsp;&nbsp;<%= link_to _('Simple search'), search_redirect_path %>
</p>
<% end %>
+ </div>
<% else %>
<% form_tag(request.url, {:method => "get", :id => "search_form"}) do %>
<p>
@@ -41,15 +43,18 @@
<%= hidden_field_tag 'bodies', 1 %>
<% end %>
<%= submit_tag _("Search") %>
+ <%= link_to(_("Advanced search"), advanced_search_url) %>
+
+
</p>
<div id="common-subfilters">
<div id="variety-filter">
<h3 class="title"><%= _("Showing") %></h3>
<% labels = [
- ["all", _("everything")],
["requests", _("requests")],
["users", _("users")],
- ["bodies", _("authorities")]]%>
+ ["bodies", _("authorities")],
+ ["all", _("everything")]]%>
<% for variety, label in labels %>
<% if @variety_postfix != variety %>
<% if variety != "users" %>
@@ -109,20 +114,20 @@
<%= text_field_tag(:request_date_before, params[:request_date_before], {:class => "use-datepicker", :size => 10}) %>
</div>
</div>
-<br/>
<% end %>
+<div>
<%= submit_tag("Filter") if @variety_postfix == "requests"%>
+</div>
<% end %>
- <p><%= link_to(_("Advanced search"), advanced_search_url) %></p>
<% end %>
<% if !@query.nil? %>
<p id="search_controls">
- <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url(@query, 'relevant') %>
+ <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url(@query, @variety_postfix, 'relevant') %>
|
- <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url(@query, 'newest') %>
+ <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url(@query, @variety_postfix, 'newest') %>
<% if @sortby == 'described' %>
| <%= _('Recently described results first') %>
<% end %>
@@ -191,7 +196,7 @@
<% if @xapian_requests_hits == 1 && @page == 1 %>
<h2 class="foi_results"><%= _("One FOI request found") %></h2>
<% else %>
- <h2 class="foi_results"><%= _("FOI requests {{start_count}} to {{end_count}} of {{total_count}}", :start_count => ((@page-1)*@requests_per_page+1).to_s, :end_count => [@page*@requests_per_page, @xapian_requests.matches_estimated].min.to_s, :total_count => @xapian_requests.matches_estimated.to_s) %></h2>
+ <h2 class="foi_results"><%= _("FOI requests {{start_count}} to {{end_count}} of {{total_count}}", :start_count => ((@page-1)*@requests_per_page+1).to_s, :end_count => [@page*@requests_per_page, @xapian_requests.matches_estimated].min.to_s, :total_count => @xapian_requests.matches_estimated.to_s) %></h2>
<% end %>
<div class="results_block">
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index 6ff52a3a7..75ba167e8 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.rhtml
@@ -53,7 +53,7 @@
<%= render :partial => 'general/before_head_end' %>
</head>
- <body>
+ <body <%= "class='front'" if params[:action] == 'frontpage' %>>
<!-- XXX: move to a separate file -->
<% if force_registration_on_new_request && !@user %>
@@ -150,6 +150,7 @@
<div id="footer">
<%= link_to _("Contact {{site_name}}", :site_name => site_name), help_contact_url %>
+ | <img src="/images/twitter-16.png" alt="twitter icon" class="twitter-icon"> <a href="http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>"><%= _("Follow us on twitter") %></a>
<%= render :partial => 'general/credits' %>
</div>
<div class="after-footer">&nbsp;</div>
@@ -158,3 +159,4 @@
</div>
</body>
</html>
+
diff --git a/app/views/request/_next_actions.rhtml b/app/views/request/_next_actions.rhtml
new file mode 100644
index 000000000..f318df6e4
--- /dev/null
+++ b/app/views/request/_next_actions.rhtml
@@ -0,0 +1 @@
+<!-- Consider listing websites that users might find useful here (in your theme) -->
diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.rhtml
index 4dce18e76..e562c4f6a 100644
--- a/app/views/request/_sidebar.rhtml
+++ b/app/views/request/_sidebar.rhtml
@@ -3,31 +3,22 @@
<%= 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>
+
<div class="act_link">
- <%= link_to '<img src="/images/helpmeinvestigate.png" alt="" class="rss">', "http://helpmeinvestigate.com/"%>
- <%= link_to 'Get help investigating', "http://helpmeinvestigate.com/"%>
- </div>
- <div class="act_link">
- <%= link_to '<img src="/images/writetothem.png" alt="" class="rss">', "http://www.writetothem.com"%>
- <%= link_to 'Write to your politician', "http://www.writetothem.com"%>
- </div>
- <div class="act_link">
- <%= link_to '<img src="/images/pledgebank.png" alt="" class="rss">', "http://www.pledgebank.com"%>
- <%= link_to 'Pledge with others', "http://www.pledgebank.com"%>
+ <% tweet_link = "http://twitter.com/share?url=#{h(request.url)}&via=#{h(MySociety::Config.get('TWITTER_USERNAME', ''))}&text='#{h(@info_request.title)}'&related=#{_('alaveteli_foi:The software that runs {{site_name}}', :site_name => h(site_name))}" %>
+ <%= link_to '<img src="/images/twitter-16.png" alt="twitter icon">', tweet_link %>
+ <%= link_to _("Tweet this request"), tweet_link %>
</div>
- <!-- <div class="act_link">
- <%= link_to '<img src="/images/petitions.png" alt="" class="rss">', "http://petitions.number10.gov.uk"%>
- <%= link_to 'Petition the PM', "http://petitions.number10.gov.uk"%>
- </div> -->
<div class="act_link">
<%= link_to '<img src="/images/wordpress.png" alt="" class="rss">', "http://wordpress.com/"%>
- <%= link_to 'Start your own blog', "http://wordpress.com/"%>
+ <%= link_to _("Start your own blog"), "http://wordpress.com/"%>
</div>
+ <%= render :partial => 'request/next_actions' %>
<% view_cache :ttl => 1.day, :tag => ['similar', @info_request.id, I18n.locale] do %>
<% if !@xapian_similar.nil? && @xapian_similar.results.size > 0 %>
- <h2><% _('Similar requests')%></h2>
+ <h2><%= _('Similar requests')%></h2>
<% for result in @xapian_similar.results %>
<%= render :partial => 'request/request_listing_short_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
<% end %>
diff --git a/app/views/track_mailer/event_digest.rhtml b/app/views/track_mailer/event_digest.rhtml
index 46f230da1..089b778f8 100644
--- a/app/views/track_mailer/event_digest.rhtml
+++ b/app/views/track_mailer/event_digest.rhtml
@@ -18,17 +18,17 @@
# e.g. Julian Burgess sent a request to Royal Mail Group (15 May 2008)
if event.event_type == 'response'
url = main_url(incoming_message_url(event.incoming_message))
- main_text += event.info_request.public_body.name + " sent a response to " + event.info_request.user.name
+ main_text += _("{{public_body}} sent a response to {{user_name}}", :public_body => event.info_request.public_body.name, :user_name => event.info_request.user.name)
elsif event.event_type == 'followup_sent'
url = main_url(outgoing_message_url(event.outgoing_message))
- main_text += event.info_request.user.name + " sent a follow up message to " + event.info_request.public_body.name
+ main_text += _("{{user_name}} sent a follow up message to {{public_body}}", :user_name => event.info_request.user.name, :public_body => event.info_request.public_body.name)
elsif event.event_type == 'sent'
# this is unlikely to happen in real life, but happens in the test code
url = main_url(outgoing_message_url(event.outgoing_message))
- main_text += event.info_request.user.name + " sent a request to " + event.info_request.public_body.name
+ main_text += _("{{user_name}} sent a request to {{public_body}}", :user_name => event.info_request.user.name, :public_body => event.info_request.public_body.name)
elsif event.event_type == 'comment'
url = main_url(comment_url(event.comment))
- main_text += event.comment.user.name + " added an annotation"
+ main_text += _("{{user_name}} added an annotation", :user_name => event.comment.user.name)
else
raise "unknown type in event_digest " + event.event_type
end
@@ -57,10 +57,10 @@
main_text += "\n"
end
-%><%=main_text%>Alter your subscription
+%><%=main_text%><%= _("Alter your subscription")%>
=======================
-Please click on the link below to cancel or alter these emails.
+<% _("Please click on the link below to cancel or alter these emails.") %>
<%=@unsubscribe_url%>
-- <%= _('the {{site_name}} team', :site_name=>site_name) %>
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 17fc0c46d..63f9fe3a0 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -116,19 +116,34 @@
</div>
</div>
<div style="clear:both"></div>
+ <% form_tag(show_user_url, :method => "get", :id=>"search_form") do %>
+ <div>
+ <%= text_field_tag(:user_query, params[:user_query]) %>
+ <% if @is_you %>
+ <%= submit_tag(_("Search your contributions")) %>
+ <% else %>
+ <%= submit_tag(_("Search contributions by this person")) %>
+ <% end %>
+ </div>
+ <% end %>
+
<% if !@xapian_requests.nil? %>
<% if @xapian_requests.results.empty? %>
<% if @page == 1 %>
- <h2 class="foi_results" id="foi_requests"><%= @is_you ? 'Freedom of Information requests made by you' : 'Freedom of Information requests made by this person' %> </h2>
+ <h2 class="foi_results" id="foi_requests"><%= @is_you ? 'Freedom of Information requests made by you' : 'Freedom of Information requests made by this person' %> <%= @match_phrase %>
+</h2>
<p><%= @is_you ? _('You have made no Freedom of Information requests using this site.') : _('This person has made no Freedom of Information requests using this site.') %>
+ <%= @page_desc %>
<% end %>
<% else %>
<h2 class="foi_results" id="foi_requests">
- <%= @is_you ? n_('Your %d Freedom of Information request', 'Your %d Freedom of Information requests', @display_user.info_requests.size) % @display_user.info_requests.size : n_('This person\'s %d Freedom of Information request', 'This person\'s %d Freedom of Information requests', @display_user.info_requests.size) % @display_user.info_requests.size %>
+ <%= @is_you ? n_('Your %d Freedom of Information request', 'Your %d Freedom of Information requests', @xapian_requests.results.size) % @xapian_requests.results.size : n_('This person\'s %d Freedom of Information request', 'This person\'s %d Freedom of Information requests', @xapian_requests.results.size) % @xapian_requests.results.size %>
<!-- matches_estimated <%=@xapian_requests.matches_estimated%> -->
- <%= @page_desc %>
+ <%= @match_phrase %>
+ <%= @page_desc %>
</h2>
+
<% for result in @xapian_requests.results %>
<%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
@@ -144,7 +159,9 @@
<% if !@xapian_comments.nil? %>
<% if @xapian_comments.results.empty? %>
<% if @page == 1 %>
- <h2><%= @is_you ? _('Your annotations') : _('This person\'s annotations') %></h2>
+ <h2><%= @is_you ? _('Your annotations') : _('This person\'s annotations') %>
+ <%= @match_phrase %>
+ </h2>
<p><%= _('None made.')%></p>
<% end %>
<% else %>
@@ -213,6 +230,3 @@
<% end %>
<% end %>
<% end %>
-
-</div>
-
diff --git a/app/views/user/sign.rhtml b/app/views/user/sign.rhtml
index 1140d961a..76732c09a 100644
--- a/app/views/user/sign.rhtml
+++ b/app/views/user/sign.rhtml
@@ -37,7 +37,7 @@
- or -
</div>
<div id="right_half">
- <h1>Sign up</h2>
+ <h1>Sign up</h1>
<%= render :partial => 'signup' %>
</div>
<div style="clear:both"></div>
diff --git a/config/routes.rb b/config/routes.rb
index f46a75afe..6f13c7bc3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -23,7 +23,7 @@ ActionController::Routing::Routes.draw do |map|
# Couldn't find a way to do this in routes which also picked up multiple other slashes
# and dots and other characters that can appear in search query. So we sort it all
# out in the controller.
- general.search_general '/search/*combined/all', :action => 'search', :view => 'all'
+ general.search_general '/search/*combined/requests', :action => 'search', :view => 'requests'
general.search_general '/search/*combined', :action => 'search'
general.advanced_search '/advancedsearch', :action => 'search_redirect', :advanced => true
diff --git a/db/migrate/102_add_locale_to_users.rb b/db/migrate/102_add_locale_to_users.rb
new file mode 100644
index 000000000..a299a8561
--- /dev/null
+++ b/db/migrate/102_add_locale_to_users.rb
@@ -0,0 +1,11 @@
+class AddLocaleToUsers < ActiveRecord::Migration
+ def self.up
+ add_column :users, :locale, :string
+ end
+ def self.down
+ remove_column :users, :locale
+ end
+end
+
+
+
diff --git a/public/images/button-gradient-large.png b/public/images/button-gradient-large.png
new file mode 100644
index 000000000..93ebc6cbc
--- /dev/null
+++ b/public/images/button-gradient-large.png
Binary files differ
diff --git a/public/images/flying-computer.png b/public/images/flying-computer.png
new file mode 100644
index 000000000..b1e1d59bb
--- /dev/null
+++ b/public/images/flying-computer.png
Binary files differ
diff --git a/public/images/home-grad.png b/public/images/home-grad.png
new file mode 100644
index 000000000..ff9887a11
--- /dev/null
+++ b/public/images/home-grad.png
Binary files differ
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index dd37bcf79..d9bdd25a8 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -415,6 +415,10 @@ div#twitter
margin: 0 0 1em 1em;
}
+img.twitter-icon {
+ vertical-align: middle;
+}
+
.blog_post {
margin-bottom: 2em;
}
diff --git a/public/stylesheets/theme.css b/public/stylesheets/theme.css
index f4c258a0f..43042fa75 100644
--- a/public/stylesheets/theme.css
+++ b/public/stylesheets/theme.css
@@ -56,6 +56,10 @@ body {
font-size: 12px;
}
+body.front {
+ background: url(/images/home-grad.png) repeat-x 0px 160px;
+}
+
#wrapper {
padding-top:160px;
}
@@ -363,17 +367,8 @@ p.subtitle {
margin:0px -6px 20px 0px;
}
-#search_form input[type=text] {
- margin-right:-6px;
- font-size: 17px;
- color: #555;
- border-radius: 3px 0px 0px 3px;
- -moz-border-radius: 3px 0px 0px 3px;
- border-style: solid;
- border-color: #BBB;
- border-width: 1px;
- width: 250px;
- height: 18px;
+#advanced-search input[type=text] {
+ width: auto;
}
#search_form input[type=submit] {
@@ -437,7 +432,6 @@ h2.publicbody_results {
border-bottom:1px solid #B3B3B3;
padding-bottom:15px;
margin-bottom:0px;
- padding-top: 15px;
margin-top: 0px;
}
@@ -594,7 +588,8 @@ form input.use-datepicker[type=text] {
}
form input[type=submit],
-a.link_button_green {
+a.link_button_green,
+a.link_button_green_large {
background: url(/images/button-gradient.png);
color: white;
text-decoration: none;
@@ -609,6 +604,13 @@ a.link_button_green {
cursor: pointer;
}
+a.link_button_green_large {
+ background: url(/images/button-gradient-large.png);
+ font-size: 22px;
+ line-height: 22px;
+ padding-bottom: 7px;
+}
+
@-moz-document url-prefix() {
form input[type=submit],
a.link_button_green {
@@ -735,6 +737,87 @@ div.correspondence {
font-size: 13px;
}
+/* ---------- Frontpage ----------- */
+
+#frontpage_splash {
+ height: 375px;
+ margin-top: -12px;
+ margin-bottom: 20px;
+ width: 100%;
+ background: url(/images/flying-computer.png) no-repeat 175px bottom;
+}
+
+#frontpage_splash #left_column {
+ line-height: 40px;
+ margin-top: 66px;
+}
+
+#frontpage_splash h1 {
+ margin: 0px 0px 20px 0px;
+ font-family: 'DeliciousRoman', Arial, sans-serif;
+ font-size: 39px;
+ color: #6B3C6A;
+ font-weight:normal;
+}
+
+#frontpage_splash h1 strong {
+ font-family: 'DeliciousHeavyRegular', Arial, sans-serif;
+ font-size: 54px;
+ color: #93278F;
+ font-weight: normal;
+}
+
+#frontpage_splash h1 span {
+ font-family: Georgia;
+ font-style: italic;
+ font-weight:normal;
+ font-size: 25px;
+ color: #6B3C6A;
+}
+
+#frontpage_splash #right_column {
+ width: 265px;
+}
+
+#frontpage_splash h2 {
+ font-size: 26px;
+ font-weight:normal;
+ color: #6B3C6A;
+ font-family:'DeliciousRoman', Arial, sans-serif;
+ margin-bottom: 10px;
+ line-height: 28px;
+}
+
+#frontpage_splash h2 strong {
+ font-size: 31px;
+ color: #93278F;
+ font-family:'DeliciousBold', Arial, sans-serif;
+}
+
+#frontpage_splash h2 span {
+ color: #6B3C6A;
+ font-style: italic;
+ font-size: 19px;
+ font-family: Georgia;
+}
+
+#frontpage_splash #right_column input[type=text] {
+ width: 180px;
+}
+
+#frontpage_splash #frontpage_search_box {
+ margin-bottom: 30px;
+ margin-top: -10px;
+}
+
+#frontpage_splash #frontpage_right_to_know p {
+ line-height: 20px;
+}
+
+body.front h3 {
+ font-size: 28px;
+}
+
/* ---------- Calendar theme ----------- */
#ui-datepicker-div.ui-widget {
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index 4d7f1831d..1ffbda90d 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -64,7 +64,7 @@ describe GeneralController, "when searching" do
it "should redirect from search query URL to pretty URL" do
post :search_redirect, :query => "mouse" # query hidden in POST parameters
- response.should redirect_to(:action => 'search', :combined => "mouse", :view => "all") # URL /search/:query/all
+ response.should redirect_to(:action => 'search', :combined => "mouse", :view => "requests") # URL /search/:query/all
end
describe "when using different locale settings" do
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 8e35b4a8d..c5c9d60e1 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -75,7 +75,7 @@ describe PublicBodyController, "when listing bodies" do
assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), public_bodies(:geraldine_public_body) ]
assigns[:tag].should == "all"
- assigns[:description].should == "all"
+ assigns[:description].should == ""
end
it "should support simple searching of bodies by title" do
@@ -94,7 +94,7 @@ describe PublicBodyController, "when listing bodies" do
response.should render_template('list')
assigns[:public_bodies].should == [ public_bodies(:geraldine_public_body), public_bodies(:humpadink_public_body) ]
assigns[:tag].should == "all"
- assigns[:description].should == "all"
+ assigns[:description].should == ""
I18n.default_locale = :en
end
@@ -113,7 +113,7 @@ describe PublicBodyController, "when listing bodies" do
get :list
response.should render_template('list')
- assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), public_bodies(:geraldine_public_body) ]
+ assigns[:public_bodies].count.should == 2
end
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index d8fe6cc1d..63e86b525 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -451,6 +451,7 @@ describe RequestController, "when making a new request" do
@user.stub!(:get_undescribed_requests).and_return([])
@user.stub!(:can_leave_requests_undescribed?).and_return(false)
@user.stub!(:can_file_requests?).and_return(true)
+ @user.stub!(:locale).and_return("en")
User.stub!(:find).and_return(@user)
@body = mock_model(PublicBody, :id => 314, :eir_only? => false, :is_requestable? => true, :name => "Test Quango")
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 2f3f903f9..c3dc98a67 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -16,6 +16,7 @@ describe TrackController, "when making a new track on a request" do
@user = mock_model(User)
User.stub!(:find).and_return(@user)
+ @user.stub!(:locale).and_return("en")
end
it "should require login when making new track" do
@@ -69,7 +70,6 @@ describe TrackController, "when sending alerts for a track" do
mail.body.should include('added an annotation') # comment included
mail.body.should =~ /This a the daftest comment the world has ever seen/ # comment text included
-
# Check subscription managing link
# XXX We can't do this, as it is redirecting to another controller. I'm
# apparently meant to be writing controller unit tests here, not functional
@@ -93,6 +93,19 @@ describe TrackController, "when sending alerts for a track" do
deliveries.size.should == 0
end
+ it "should send localised alerts" do
+ # set the time the comment event happened at to within the last week
+ ire = info_request_events(:silly_comment_event)
+ ire.created_at = Time.now - 3.days
+ ire.save!
+ user = users(:silly_name_user)
+ user.locale = "es"
+ user.save!
+ TrackMailer.alert_tracks
+ deliveries = ActionMailer::Base.deliveries
+ mail = deliveries[0]
+ mail.body.should include('el equipo de Alaveteli')
+ end
end
describe TrackController, "when viewing RSS feed for a track" do
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 438fb8c0c..0ba542630 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -32,6 +32,13 @@ describe UserController, "when showing a user" do
assigns[:display_user].should == users(:bob_smith_user)
end
+ it "should search the user's contributions" do
+ get :show, :url_name => "bob_smith"
+ assigns[:xapian_requests].results.count.should == 2
+ get :show, :url_name => "bob_smith", :user_query => "money"
+ assigns[:xapian_requests].results.count.should == 1
+ end
+
# Error handling not quite good enough for this yet
# it "should not show unconfirmed users" do
# get :show, :url_name => "silly_emnameem"
@@ -171,6 +178,19 @@ describe UserController, "when signing up" do
deliveries[0].body.should include("not reveal your email")
end
+ it "should send confirmation mail in other languages or different locales" do
+ session[:locale] = "es"
+ post :signup, {:user_signup => { :email => 'new@localhost', :name => 'New Person',
+ :password => 'sillypassword', :password_confirmation => 'sillypassword',
+ }
+ }
+ response.should render_template('confirm')
+
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 1
+ deliveries[0].body.should include("No revelaremos su dirección de correo")
+ end
+
it "should send special 'already signed up' mail if you fill the form in with existing registered email " do
post :signup, { :user_signup => { :email => 'silly@localhost', :name => 'New Person',
:password => 'sillypassword', :password_confirmation => 'sillypassword' }
diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml
index 2485c95a0..c54ac0985 100644
--- a/spec/fixtures/users.yml
+++ b/spec/fixtures/users.yml
@@ -10,6 +10,7 @@ bob_smith_user:
email_confirmed: true
admin_level: 'none'
ban_text: ''
+ locale: 'en'
about_me: 'I like making requests about fancy dogs and naughty chickens and stuff.'
silly_name_user:
id: "2"
@@ -23,6 +24,7 @@ silly_name_user:
email_confirmed: false
admin_level: 'none'
ban_text: ''
+ locale: 'en'
about_me: ''
admin_user:
id: "3"
@@ -36,4 +38,5 @@ admin_user:
email_confirmed: false
admin_level: 'super'
ban_text: ''
+ locale: ''
about_me: ''
diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb
index 84239f7a3..25c091111 100644
--- a/spec/integration/search_request_spec.rb
+++ b/spec/integration/search_request_spec.rb
@@ -25,14 +25,19 @@ describe "When searching" do
request_via_redirect("post", "/search",
:query => 'bob'
)
- response.body.should include("One person matching")
+ response.body.should include("FOI requests")
end
it "should correctly filter searches for requests" do
request_via_redirect("post", "/search/bob/requests")
- response.body.should_not include("One person matching")
+ response.body.should_not include("One person found")
response.body.should include("FOI requests 1 to 2 of 2")
end
+ it "should correctly filter searches for users" do
+ request_via_redirect("post", "/search/bob/users")
+ response.body.should include("One person found")
+ response.body.should_not include("FOI requests 1 to 2 of 2")
+ end
it "should correctly filter searches for successful requests" do
request_via_redirect("post", "/search",
@@ -45,7 +50,7 @@ describe "When searching" do
request_via_redirect("post", "/search",
:query => "daftest",
:request_variety => ['comments'])
- response.body.should include("One FOI request matching your search")
+ response.body.should include("One FOI request found")
request_via_redirect("post", "/search",
:query => "daftest",
diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb
index 828904d02..b90ca7e52 100644
--- a/spec/models/track_mailer_spec.rb
+++ b/spec/models/track_mailer_spec.rb
@@ -21,7 +21,8 @@ describe TrackMailer do
@user = mock_model(User, :no_xapian_reindex= => false,
:last_daily_track_email= => true,
:save! => true,
- :url_name => 'test-name')
+ :url_name => 'test-name',
+ :get_locale => 'en')
User.stub!(:find).and_return([@user])
@user.stub!(:no_xapian_reindex=)
end
diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb
index 6b9cd6d4a..1a0324a78 100644
--- a/spec/models/track_thing_spec.rb
+++ b/spec/models/track_thing_spec.rb
@@ -28,5 +28,15 @@ describe TrackThing, "when tracking changes" do
found_track.should == @track_thing
end
+ it "will make some sane descriptions of search-based tracks" do
+ tests = [['bob variety:user', "users matching text 'bob'"],
+ ['bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)', "requests which are successful or unsuccessful or comments matching text 'bob'"],
+ ['(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)', 'requests which are awaiting a response']]
+ for query, description in tests
+ track_thing = TrackThing.create_track_for_search_query(query)
+ track_thing.track_query_description.should == description
+ end
+ end
+
end
diff --git a/vendor/plugins/action_mailer_layouts/CHANGELOG b/vendor/plugins/action_mailer_layouts/CHANGELOG
deleted file mode 100644
index 0b3f47667..000000000
--- a/vendor/plugins/action_mailer_layouts/CHANGELOG
+++ /dev/null
@@ -1,21 +0,0 @@
-2008-06-03
-* Added support for Rails 2.0 and 2.1. Thanks to Scott Windsor.
-
-2008-02-08
-* Added support for *.<format>.erb layouts and templates. Thanks to Eric Wollensen.
-
-2007-12-20
-* Fixed a bug present when specifying the layout with a string (eg: layout 'subdir/layout_template') in a multipart mail, which caused the plugin to only render one part and not the other. Thanks to Andres Koetsier.
-
-2007-12-12
-* Now works with Rails 2.0.
-
-2007-11-27
-* Now supports helpers defined in the mailer class. Thanks to Marshall Roch.
-
-2007-24-07
-* Now requires actionmailer-1.3.3.
-
-2007-05-07
-* No longer have to specify a :layout. The layout name is now inferred from the mailer class name. Thanks to Peter Boctor.
-* Helper methods are now available to action mailer layouts. Thanks to Peter Boctor. \ No newline at end of file
diff --git a/vendor/plugins/action_mailer_layouts/README b/vendor/plugins/action_mailer_layouts/README
deleted file mode 100644
index 92b19a69d..000000000
--- a/vendor/plugins/action_mailer_layouts/README
+++ /dev/null
@@ -1,35 +0,0 @@
-== Action Mailer Layouts
-
-Original Homepage: http://cardboardrocket.com/pages/action_mailer_layouts
-Original svn: http://svn.cardboardrocket.com/action_mailer_layouts
-
-A plugin to enable layouts for ActionMailer templates.
-
-Adds a new 'layout' property to the ActionMailer::Base class. Specify the name
-of the layout you want to use. The plugin will look in app/views/layouts for your
-layout. If no layout is specified, the plugin will look for a layout that matches
-the name of your mailer class.
-
-For example:
-
-If your mailer class is called UserNotifier and you are rendering the activation.rhtml
-template, then the plugin will attempt to load the user_notifier.rhtml layout. If you are
-rendering the activation.text.html.rhtml template, the plugin will look for the
-user_notifier.text.html.rhtml layout. In other words, the plugin attempts to load the
-layout named after the your ActionMailer class.
-
-You can overload this behavior by setting the layout property of your mailer:
-
-class UserNotfier < ActionMailer::Base
- def activation(user)
- @recipients = user.email
- @from = 'you@domain.com'
- @sent_on = Time.now
- @subject = 'Activate your account!'
- @layout = :email
- end
-end
-
-This arrangement will cause the plugin to render the content in
-views/user_notifier/activation.text.html.rhtml in the views/layouts/email.text.html.rhtml
-layout. \ No newline at end of file
diff --git a/vendor/plugins/action_mailer_layouts/init.rb b/vendor/plugins/action_mailer_layouts/init.rb
deleted file mode 100644
index 8289c4eb9..000000000
--- a/vendor/plugins/action_mailer_layouts/init.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-begin
- require File.join(File.dirname(__FILE__), 'plugin.rb')
- ActionController::Base.logger.fatal '** Loaded layouts plugin for ActionMailer'
-rescue Exception => e
- puts e.inspect
- ActionController::Base.logger.fatal e if ActionController::Base.logger
-end \ No newline at end of file
diff --git a/vendor/plugins/action_mailer_layouts/plugin.rb b/vendor/plugins/action_mailer_layouts/plugin.rb
deleted file mode 100644
index ef0cbc37c..000000000
--- a/vendor/plugins/action_mailer_layouts/plugin.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-module ActionMailer
- class Base
-
- # Specify the layout name
- adv_attr_accessor :layout
-
- alias_method :render_message_without_layouts, :render_message
-
- def render_message(method_name, body)
- layout = @layout ? @layout.to_s.clone : self.class.to_s.underscore
-
- filename = if method_name.respond_to?(:filename)
- method_name.filename
- else
- method_name
- end
-
- md = /([^\.]+)\.([^\.]+\.[^\.]+)\.(erb|rhtml|rxml)$/.match(filename)
-
- layout << ".#{md.captures[1]}" if md && md.captures[1]
- layout << ".#{md.captures[2]}" if md && md.captures[2]
-
- if File.exists?(File.join(layouts_path, layout))
- body[:content_for_layout] = render_message_without_layouts(method_name, body)
-
- # TODO: extract content_for blocks and somehow put them in body[:content_for_...]
-
- initialize_layout_template_class(body).render(:file => "/#{layout}")
- else
- render_message_without_layouts(method_name, body)
- end
- end
-
- def initialize_layout_template_class(assigns)
- # for Rails 2.1 (and greater), we have to process view paths first!
- ActionView::TemplateFinder.process_view_paths(layouts_path) if defined?(ActionView::TemplateFinder)
-
- returning(template = ActionView::Base.new(layouts_path, assigns, self)) do
- template.extend self.class.master_helper_module
- template.extend ActionView::Helpers::CaptureHelper
- end
- end
-
- def layouts_path
- File.join(template_root, 'layouts')
- end
- end
-end \ No newline at end of file