diff options
Diffstat (limited to 'app')
25 files changed, 363 insertions, 174 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a2a628f10..3794043fb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -211,7 +211,9 @@ class ApplicationController < ActionController::Base post_redirect = PostRedirect.new(:uri => request.request_uri, :post_params => params, :reason_params => reason_params) post_redirect.save! - redirect_to signin_url(:token => post_redirect.token) + # 'modal' controls whether the sign-in form will be displayed in the typical full-blown + # page or on its own, useful for pop-ups + redirect_to signin_url(:token => post_redirect.token, :modal => params[:modal]) return false end return true diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 378dd58e3..0e58b7055 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -176,5 +176,17 @@ class PublicBodyController < ApplicationController :filename => 'all-authorities.csv', :disposition =>'attachment', :encoding => 'utf8') end + + # Type ahead search + def search_typeahead + # Since acts_as_xapian doesn't support the Partial match flag, we work around it + # by making the last work a wildcard, which is quite the same + query = params[:q] + '*' + + query = query.split(' ').join(' OR ') # XXX: HACK for OR instead of default AND! + @xapian_requests = perform_search([PublicBody], query, 'relevant', 'request_collapse', 5) + + render :partial => "public_body/search_ahead" + end end diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 10c0917c8..12b5247b5 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -22,6 +22,21 @@ class RequestController < ApplicationController rescue MissingSourceFile, NameError end + def select_authority + # Check whether we force the user to sign in right at the start, or we allow her + # to start filling the request anonymously + if force_registration_on_new_request && !authenticated?( + :web => _("To send your FOI request"), + :email => _("Then you'll be allowed to send FOI requests."), + :email_subject => _("Confirm your email address") + ) + # do nothing - as "authenticated?" has done the redirect to signin page for us + return + end + + medium_cache + end + def show medium_cache @locale = self.locale_from_params() @@ -66,7 +81,7 @@ class RequestController < ApplicationController @last_info_request_event_id = @info_request.last_event_id_needing_description @new_responses_count = @info_request.events_needing_description.select {|i| i.event_type == 'response'}.size -1 + # Sidebar stuff # ... requests that have similar imporant terms behavior_cache :tag => ['similar', @info_request.id] do @@ -131,7 +146,7 @@ class RequestController < ApplicationController @view = params[:view] params[:latest_status] = @view query = make_query_from_params - @title = "View and search requests" + @title = _("View and search requests") sortby = "newest" @page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect behavior_cache :tag => [@view, @page] do @@ -727,5 +742,17 @@ class RequestController < ApplicationController return end end + + # Type ahead search + def search_typeahead + # Since acts_as_xapian doesn't support the Partial match flag, we work around it + # by making the last work a wildcard, which is quite the same + query = params[:q] + '*' + + query = query.split(' ').join(' OR ') # XXX: HACK for OR instead of default AND! + @xapian_requests = perform_search([InfoRequestEvent], query, 'relevant', 'request_collapse', 5) + + render :partial => "request/search_ahead.rhtml" + end end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 47a133135..96dbfba74 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -8,6 +8,8 @@ class UserController < ApplicationController + layout :select_layout + protect_from_forgery :only => [ :contact, :set_profile_photo, :signchangeemail, @@ -113,7 +115,12 @@ class UserController < ApplicationController session[:user_id] = @user_signin.id session[:user_circumstance] = nil session[:remember_me] = params[:remember_me] ? true : false - do_post_redirect @post_redirect + + if is_modal_dialog + render :action => 'signin_successful' + else + do_post_redirect @post_redirect + end else send_confirmation_mail @user_signin end @@ -511,6 +518,15 @@ class UserController < ApplicationController private + def is_modal_dialog + (params[:modal].to_i != 0) + end + + # when logging in through a modal iframe, don't display chrome around the content + def select_layout + is_modal_dialog ? 'no_chrome' : 'default' + end + # Decide where we are going to redirect back to after signin/signup, and record that def work_out_post_redirect # Redirect to front page later if nothing else specified diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb index 80f2deed2..b0381a2f5 100644 --- a/app/helpers/config_helper.rb +++ b/app/helpers/config_helper.rb @@ -2,4 +2,8 @@ module ConfigHelper def site_name MySociety::Config.get('SITE_NAME', 'Alaveteli') end + + def force_registration_on_new_request + MySociety::Config.get('FORCE_REGISTRATION_ON_NEW_REQUEST', false) + end end
\ No newline at end of file diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 9b0f1047b..88a02cc2c 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -117,13 +117,13 @@ class InfoRequest < ActiveRecord::Base # only check on create, so existing models with mixed case are allowed def validate_on_create if !self.title.nil? && !MySociety::Validate.uses_mixed_capitals(self.title, 10) - errors.add(:title, N_('Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.')) + errors.add(:title, _('Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.')) end if !self.title.nil? && title.size > 200 - errors.add(:title, N_('Please keep the summary short, like in the subject of an email. You can use a phrase, rather than a full sentence.')) + errors.add(:title, _('Please keep the summary short, like in the subject of an email. You can use a phrase, rather than a full sentence.')) end if !self.title.nil? && self.title =~ /^(FOI|Freedom of Information)\s*requests?$/i - errors.add(:title, N_('Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.')) + errors.add(:title, _('Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.')) end end @@ -780,8 +780,7 @@ public # Display version of status - def display_status - status = self.calculate_status + def InfoRequest.get_status_description(status) if status == 'waiting_classification' _("Awaiting classification.") elsif status == 'waiting_response' @@ -819,6 +818,10 @@ public end end + def display_status + InfoRequest.get_status_description(self.calculate_status) + end + # Completely delete this request and all objects depending on it def fully_destroy self.track_things.each do |track_thing| diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 4003217b0..4ea89bf81 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -303,37 +303,7 @@ class InfoRequestEvent < ActiveRecord::Base def display_status if is_incoming_message? status = self.calculated_state - if !status.nil? - if status == 'waiting_response' - return _("Acknowledgement") - elsif status == 'waiting_clarification' - return _("Clarification required") - elsif status == 'gone_postal' - return _("Handled by post") - elsif status == 'deadline_extended' - return _("Deadline Extended") - elsif status == 'wrong_response' - return _("Wrong Response") - elsif status == 'not_held' - return _("Information not held") - elsif status == 'rejected' - return _("Refused") - elsif status == 'partially_successful' - return _("Some information sent") - elsif status == 'successful' - return _("All information sent") - elsif status == 'internal_review' - return _("Internal review acknowledgement") - elsif status == 'user_withdrawn' - return _("Withdrawn by requester") - elsif status == 'error_message' - return _("Delivery error") - elsif status == 'requires_admin' - return _("Unusual response") - end - raise "unknown status " + status - end - return "Response" + return status.nil? ? _("Response") : InfoRequest.get_status_description(status) end if is_outgoing_message? diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index e244aaac9..f46ce33c5 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -61,7 +61,8 @@ class RequestMailer < ApplicationMailer @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834 + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = "New response to your FOI request - " + info_request.title @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url } @@ -79,7 +80,8 @@ class RequestMailer < ApplicationMailer @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834 + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF' @recipients = user.name_and_email @subject = "Delayed response to your FOI request - " + info_request.title @body = { :info_request => info_request, :url => url } @@ -97,7 +99,8 @@ class RequestMailer < ApplicationMailer @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834 + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF' @recipients = user.name_and_email @subject = "You're long overdue a response to your FOI request - " + info_request.title @body = { :info_request => info_request, :url => url } @@ -116,7 +119,8 @@ class RequestMailer < ApplicationMailer @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834 + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = "Was the response you got to your FOI request any good?" @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url } @@ -126,7 +130,8 @@ class RequestMailer < ApplicationMailer def old_unclassified_updated(info_request) @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834 + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = "Someone has updated the status of your request" url = main_url(request_url(info_request)) @@ -146,7 +151,8 @@ class RequestMailer < ApplicationMailer @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834 + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = "Clarify your FOI request - " + info_request.title @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url } @@ -156,7 +162,8 @@ class RequestMailer < ApplicationMailer def comment_on_alert(info_request, comment) @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834 + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = "Somebody added a note to your FOI request - " + info_request.title @body = { :comment => comment, :info_request => info_request, :url => main_url(comment_url(comment)) } @@ -164,7 +171,8 @@ class RequestMailer < ApplicationMailer def comment_on_alert_plural(info_request, count, earliest_unalerted_comment) @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken - 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834 + 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 + 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email @subject = "Some notes have been added to your FOI request - " + info_request.title @body = { :count => count, :info_request => info_request, :url => main_url(comment_url(earliest_unalerted_comment)) } diff --git a/app/views/general/_orglink.rhtml b/app/views/general/_orglink.rhtml index 20d0d6ce4..7d74dbaac 100644 --- a/app/views/general/_orglink.rhtml +++ b/app/views/general/_orglink.rhtml @@ -1,2 +1,2 @@ <%-# Put the link to your organisation here, or leave blank -%> -<a href="http://www.alaveteli.org">an Alaveteli site</a> +<%= link_to image_tag('logo.png'), frontpage_url, :id=>'logo' %> diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index 3b1088411..55b00b753 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -7,7 +7,7 @@ Information<br/> request</strong>") %> </h1> - <a class="link_button_green_large" href="/en/new/tgq"><%= _("Start now »") %></a> + <a class="link_button_green_large" href="/select_authority"><%= _("Start now »") %></a> </div> <div id="right_column"> <div id="frontpage_search_box"> diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index c82d75ebe..c802e7d45 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -1,8 +1,8 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="<%= I18n.locale %>"> <head> + <script type="text/javascript" src="/javascripts/jquery.js"></script> <% if @profile_photo_javascript %> - <script type="text/javascript" src="/javascripts/jquery.js"></script> <script type="text/javascript" src="/javascripts/jquery.Jcrop.js"></script> <script type="text/javascript" src="/javascripts/profile_photo.js"></script> <link rel="stylesheet" href="/stylesheets/jquery.Jcrop.css" type="text/css" > @@ -32,6 +32,8 @@ <style type="text/css">@import url("/stylesheets/ie7.css");</style> <![endif]--> <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %> + <!-- XXX: add conditional include --> + <%= stylesheet_link_tag 'jquery.fancybox-1.3.4', :rel => "stylesheet" %> <% if @feed_autodetect %> <% for feed in @feed_autodetect %> @@ -53,6 +55,28 @@ </head> <body <%= "class='front'" if params[:action] == 'frontpage' %>> + <!-- XXX: move to a separate file --> + <% if force_registration_on_new_request && !@user %> + <%= javascript_include_tag 'jquery.fancybox-1.3.4.pack' %> + <script> + $(document).ready(function() { + $("#make-request-link").fancybox({ + 'modal': false, + 'width': 800, + 'height': 500, + 'type': 'iframe', + 'href': '/en/profile/sign_in?modal=1', + 'onClosed': function() { + // modal_signin_successful variable set by modal dialog box + if (typeof modal_signin_successful != 'undefined' ) { + window.location.href = '<%= select_authority_url %>'; + } + } + }); + }); + </script> + <% end %> + <% # code for popup advert for a campaign etc. =begin <div id="everypage" class="jshide"> @@ -93,12 +117,13 @@ <% end %> </div> - <%= link_to image_tag('logo.png'), frontpage_url, :id=>'logo' %> + <%= render :partial => 'general/orglink' %> <div id="topnav"> <ul id="navigation"> - <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] != 'blog' %>"><%= link_to _("Make a request"), frontpage_url %></li> - <li class="<%= 'selected' if params[:controller] == 'request' %>"><%= link_to _("View requests"), request_list_successful_url %></li> + <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] != 'blog' %>"><%= link_to _("Home"), frontpage_url %></li> + <li class="<%= 'selected' if params[:controller] == 'request' and ['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("Make a request"), select_authority_url, :id => 'make-request-link' %></li> + <li class="<%= 'selected' if params[:controller] == 'request' and !['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("View requests"), request_list_successful_url %></li> <li class="<%= 'selected' if params[:controller] == 'public_body' %>"><%= link_to _("View authorities"), list_public_bodies_default %></li> <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] == 'blog' %>"><%= link_to _("Read blog"), blog_url %></li> <li class="<%= 'selected' if params[:controller] == 'help' %>"><%= link_to _("Help"), help_about_url %></li> diff --git a/app/views/layouts/no_chrome.rhtml b/app/views/layouts/no_chrome.rhtml new file mode 100644 index 000000000..c314dfbd3 --- /dev/null +++ b/app/views/layouts/no_chrome.rhtml @@ -0,0 +1,39 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang="<%= I18n.locale %>"> + <head> + <title> + <% if @title %> + <%=@title%> - <%= site_name %> + <% else %> + <%= site_name %> - <%= _('Make and browse Freedom of Information (FOI) requests') %> + <% end %> + </title> + + <script type="text/javascript" src="/javascripts/jquery.js"></script> + + <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %> + <!--[if LT IE 7]> + <style type="text/css">@import url("/stylesheets/ie6.css");</style> + <![endif]--> + <!--[if LT IE 7]> + <style type="text/css">@import url("/stylesheets/ie6-custom.css");</style> + <![endif]--> + <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %> + </head> + <body> + <div class="entirebody"> + <div id="content"> + <% if flash[:notice] %> + <div id="notice"><%= flash[:notice] %></div> + <% end %> + <% if flash[:error] %> + <div id="error"><%= flash[:error] %></div> + <% end %> + + <div id="<%= controller.controller_name + "_" + controller.action_name %>" class="controller_<%= controller.controller_name %>"> + <%= yield :layout %> + </div> + </div> + </div> + </body> +</html>
\ No newline at end of file diff --git a/app/views/public_body/_search_ahead.rhtml b/app/views/public_body/_search_ahead.rhtml new file mode 100644 index 000000000..19c7eb4e8 --- /dev/null +++ b/app/views/public_body/_search_ahead.rhtml @@ -0,0 +1,18 @@ +<p> + <% if @xapian_requests.results.size > 0 %> + <h3><%= _('Top search results:') %></h3> + <p> + <%= _('Select one to see more information about the authority.')%> + </p> + <% else %> + <h3><%= _('No results found.') %></h3> + <% end %> + <div id="authority_search_ahead_results"> + <% for result in @xapian_requests.results %> + <%= render :partial => 'body_listing_single', :locals => { :public_body => result[:model] } %> + <% end %> + </div> +</p> + + + diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml index 06c7d3be9..bb17b544f 100644 --- a/app/views/public_body/list.rhtml +++ b/app/views/public_body/list.rhtml @@ -34,7 +34,7 @@ <% @title = _("Public authorities - {{description}}", :description => @description) %> <div id="left_column"> -<h1>Public authorities</h1> +<h1><%= _('Public authorities') %></h1> <% form_tag(list_public_bodies_default_url, :method => "get", :id=>"search_form") do %> <div> diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml index b6e0c68b2..7091e2eec 100644 --- a/app/views/public_body/show.rhtml +++ b/app/views/public_body/show.rhtml @@ -1,4 +1,5 @@ <% @title = h(@public_body.name) + " - view and make Freedom of Information requests" %> +<div id="main_content"> <div> <div id="header_right"> <h2><%= _('Follow this authority')%></h2> @@ -50,9 +51,9 @@ <div id="stepwise_make_request"> <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %> <% if @public_body.eir_only? %> - Make a new <strong>Environmental Information</strong> request + <%= _('Make a new <strong>Environmental Information</strong> request')%> <% else %> - Make a new <strong>Freedom of Information</strong> request to <%=h(@public_body.name)%> + <%= _('Make a new <strong>Freedom of Information</strong> request to {{public_body}}', :public_body => h(@public_body.name))%> <% end %> <%= _('<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? %> @@ -119,4 +120,5 @@ <% end %> <p> <%= _('The search index is currently offline, so we can\'t show the Freedom of Information requests that have been made to this authority.')%></p> <% end %> - +</div> +</div> diff --git a/app/views/request/_request_filter_form.rhtml b/app/views/request/_request_filter_form.rhtml index 9264540dc..ac133889d 100644 --- a/app/views/request/_request_filter_form.rhtml +++ b/app/views/request/_request_filter_form.rhtml @@ -46,7 +46,7 @@ </div> <div class="list-filter-item"> - <%= submit_tag("Search") %> + <%= submit_tag(_("Search")) %> </div> <% end %> </div> diff --git a/app/views/request/_search_ahead.rhtml b/app/views/request/_search_ahead.rhtml new file mode 100644 index 000000000..b8ef7437e --- /dev/null +++ b/app/views/request/_search_ahead.rhtml @@ -0,0 +1,13 @@ +<p> + <div id="request_search_ahead_results"> + <% if @xapian_requests.results.size > 0 %> + <h3><%= _("Possibly related requests:") %></h3> + <% end %> + <% for result in @xapian_requests.results %> + <%= render :partial => 'request/request_listing_short_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> + <% end %> + </div> +</p> + + + diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml index 44c53ca1d..0137cb6dd 100644 --- a/app/views/request/list.rhtml +++ b/app/views/request/list.rhtml @@ -5,7 +5,7 @@ </div> <div id="header_right"> - <h2>Follow 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/request/new.rhtml b/app/views/request/new.rhtml index f58cbdd94..cd748b6c2 100644 --- a/app/views/request/new.rhtml +++ b/app/views/request/new.rhtml @@ -1,3 +1,14 @@ +<script type="text/javascript" src="/javascripts/ba-throttle-debounce.js"></script> +<script> + $(document).ready(function(){ + // Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin: + // http://benalman.com/projects/jquery-throttle-debounce-plugin/ + $("#typeahead_search").keypress($.debounce( 300, function() { + $("#typeahead_response").load("<%=search_ahead_url%>?q="+encodeURI(this.value)); + })); + }); +</script> + <% @title = _("Make an {{law_used_short}} request to '{{public_body_name}}'",:law_used_short=>h(@info_request.law_used_short),:public_body_name=>h(@info_request.public_body.name)) %> <% if @existing_request %> @@ -10,109 +21,89 @@ </ul></div> <% end %> -<h1>Make a new request</h1> + <%= foi_error_messages_for :info_request, :outgoing_message %> -<%= foi_error_messages_for :info_request, :outgoing_message %> + <h1><%= _('2. Ask for Information') %></h1> -<div id="request_advice"> - <h2><%= _('Read this before writing your {{info_request_law_used_full}} request', :info_request_law_used_full=>h(@info_request.law_used_full)) %></h2> - <ol> - <li> - <% form_tag("http://www.google.co.uk/search", {:id => "search_body_website_form", :method => "get"} ) do %> - <p> - <%= _('First,') %> - <% if !@info_request.public_body.publication_scheme.empty? %> - <%= _('<strong>browse</strong> the authority\'s <a href="%s">publication scheme</a> or <strong>search</strong> their web site ...') % [@info_request.public_body.publication_scheme] %> + <% form_for(:info_request, @info_request, :html => { :id => 'write_form' } ) do |f| %> + + <div id="request_header"> + <p> + <label class="form_label" for="info_request_public_body_id"><%= _('To:') %></label> + <span id="to_public_body"><%=h(@info_request.public_body.name)%></span> + <div class="form_item_note"> + <% if @info_request.public_body.info_requests.size > 0 %> + <%= _("Browse <a href='{{url}}'>other requests</a> to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_url(@info_request.public_body)) %> <% else %> - <%= _('<strong>search</strong> the authority\'s web site ...') %> + <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_url) %> <% end %> - </p> - <% if !@info_request.public_body.calculated_home_page.nil? %> - <p> - <%= text_field_tag 'q', params[:q], { :size => 20 } %> - <%= hidden_field_tag 'as_sitesearch', @info_request.public_body.calculated_home_page %> - <%= submit_tag _("Search") %> - </p> - <% end %> - <p> - ... <%= _('to check that the info isn\'t already published.') %> - </p> - <% end %> - </li> + </div> + </p> - <li> - <% if @info_request.public_body.info_requests.size > 0 %> - <%= _("Browse <a href='{{url}}'>other requests</a> to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_url(@info_request.public_body)) %> - <% else %> - <%= _('Browse <a href="%s">other requests</a> for examples of how to word your request.') % [request_list_url] %> + <div id="request_header_text"> + <% if @info_request.public_body.has_notes? %> + <h3><%= _('Special note for this authority!') %></h3> + <p><%= @info_request.public_body.notes_as_html %></p> <% end %> - </li> - <li><%= _('Write your request in <strong>simple, precise language</strong>.') %></li> - <li><%= _('Ask for <strong>specific</strong> documents or information, this site is not suitable for general enquiries.') %></li> - <li><%= _('Keep it <strong>focused</strong>, you\'ll be more likely to get what you want (<a href="%s">why?</a>).') % [help_requesting_path + '#focused'] %></li> - <li><%= _('This site is <strong>public</strong>. Everything you type and any response will be published.') %></li> - </ol> - - <% if @info_request.public_body.has_notes? %> - <h1><%= _('Special note for this authority!') %></h1> - <ul> - <li><p><%= @info_request.public_body.notes_as_html %></p></li> - </ul> - <% end %> - <% if @info_request.public_body.eir_only? %> - <h1><%= _('Please ask for environmental information only') %></h1> - - <p><%= _('The Freedom of Information Act <strong>does not apply</strong> to') %> <%=h(@info_request.public_body.name)%>. - <%= _('However, you have the right to request environmental - information under a different law') %> (<a href="/help/requesting#eir">explanation</a>). - <%= _('This covers a very wide spectrum of information about the state of - the <strong>natural and built environment</strong>, such as:') %> + <% if @info_request.public_body.eir_only? %> + <h3><%= _('Please ask for environmental information only') %></h3> + + <p><%= _('The Freedom of Information Act <strong>does not apply</strong> to') %> <%=h(@info_request.public_body.name)%>. + <%= _('However, you have the right to request environmental + information under a different law') %> (<a href="/help/requesting#eir">explanation</a>). + <%= _('This covers a very wide spectrum of information about the state of + the <strong>natural and built environment</strong>, such as:') %> + <ul> + <li><%= _('Air, water, soil, land, flora and fauna (including how these effect + human beings)') %></li> + <li><%= _('Information on emissions and discharges (e.g. noise, energy, + radiation, waste materials)') %></li> + <li><%= _('Human health and safety') %></li> + <li><%= _('Cultural sites and built structures (as they may be affected by the + environmental factors listed above)') %></li> + <li><%= _('Plans and administrative measures that affect these matters') %></li> + </ul> + + <p><%= _('Please only request information that comes under those categories, <strong>do not waste your + time</strong> or the time of the public authority by requesting unrelated information.') %></p> + <% end %> + </div> + + <p> + <label class="form_label" for="info_request_title"><%= _('Summary:') %></label> + <%= f.text_field :title, :size => 50, :id =>"typeahead_search" %> + </p> + <div class="form_item_note"> + (<%= _("a one line summary of the information you are requesting, \n\t\t\te.g.") %> + <% if @info_request.law_used == 'eir' %> + <%= _("'Pollution levels over time for the River Tyne'") %> + <% else %> + <%= _("'Crime statistics by ward level for Wales'") %> + <% end %> + ) + </div> + <div id="typeahead_response"> + </div> + </div> + + <div id="request_advice"> <ul> - <li><%= _('Air, water, soil, land, flora and fauna (including how these effect - human beings)') %></li> - <li><%= _('Information on emissions and discharges (e.g. noise, energy, - radiation, waste materials)') %></li> - <li><%= _('Human health and safety') %></li> - <li><%= _('Cultural sites and built structures (as they may be affected by the - environmental factors listed above)') %></li> - <li><%= _('Plans and administrative measures that affect these matters') %></li> + <li><%= _('Write your request in <strong>simple, precise language</strong>.') %></li> + <li><%= _('Ask for <strong>specific</strong> documents or information, this site is not suitable for general enquiries.') %></li> + <li><%= _('Keep it <strong>focused</strong>, you\'ll be more likely to get what you want (<a href="%s">why?</a>).') % [help_requesting_path + '#focused'] %></li> </ul> + </div> - <p><%= _('Please only request information that comes under those categories, <strong>do not waste your - time</strong> or the time of the public authority by requesting unrelated information.') %></p> - <% end %> -</div> - -<% form_for(:info_request, @info_request, :html => { :id => 'write_form' } ) do |f| %> - - <div id="request_form"> - <label class="form_label" for="info_request_public_body_id"><%= _('To:') %></label> - <span id="to_public_body"><%=h(@info_request.public_body.name)%></span> - - <p> - <label class="form_label" for="info_request_title"><%= _('Summary:') %></label> - <%= f.text_field :title, :size => 50 %> - </p> - <div class="form_item_note"> - (<%= _('a one line summary of the information you are requesting, - e.g.') %> - <% if @info_request.law_used == 'eir' %> - <%= _("'Pollution levels over time for the River Tyne'") %> - <% else %> - <%= _("'Crime statistics by ward level for Wales'") %> - <% end %> - ) - </div> - - <% fields_for :outgoing_message do |o| %> - <p> - <label class="form_label" for="outgoing_message_body"><%= _('Your request:') %></label> - <%= o.text_area :body, :rows => 20, :cols => 60 %> - </p> - <% end %> - + <div id="request_form"> + <% fields_for :outgoing_message do |o| %> + <p> + <label class="form_label" for="outgoing_message_body"><%= _('Your request:') %></label> + <%= o.text_area :body, :rows => 20, :cols => 60 %> + </p> + <% end %> + <% if !@user %> <p class="form_note"> <%= _('Everything that you enter on this page, including <strong>your name</strong>, @@ -128,18 +119,18 @@ this website forever (<a href="%s">why?</a>).') % [help_privacy_path+"#public_request"] %> </p> <% end %> - - <p class="form_note"> - <%= _('<strong> Can I request information about myself?</strong> - <a href="%s">No! (Click here for details)</a>') % [help_requesting_path+"#data_protection"] %> - </p> - - <div class="form_button"> - <%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %> - <%= hidden_field_tag(:submitted_new_request, 1 ) %> - <%= hidden_field_tag(:preview, 1 ) %> - <%= submit_tag _("Preview your public request") %> - </div> + + <p class="form_note"> + <%= _("<strong> Can I request information about myself?</strong>\n" + + "\t\t\t<a href=\"%s\">No! (Click here for details)</a>") % [help_requesting_path+"#data_protection"] %> + </p> + + <div class="form_button"> + <%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %> + <%= hidden_field_tag(:submitted_new_request, 1 ) %> + <%= hidden_field_tag(:preview, 1 ) %> + <%= submit_tag _("Preview your public request") %> + </div> <% if !@info_request.tag_string.empty? %> <p class="form_note"> @@ -150,8 +141,8 @@ <strong>Tags:</strong> <%=h @info_request.tag_string %> </p> <% end %> - - </div> + + </div> <% end %> diff --git a/app/views/request/preview.rhtml b/app/views/request/preview.rhtml index 6f6ecb2f9..45b6a3dc1 100644 --- a/app/views/request/preview.rhtml +++ b/app/views/request/preview.rhtml @@ -2,7 +2,7 @@ <% form_for(:info_request, @info_request, :html => { :id => 'preview_form' } ) do |f| %> - <h1><%= _('Now preview your request') %></h1> + <h1><%= _('3. Now check your request') %></h1> <ul> <li><%= _('Check you haven\'t included any <strong>personal information</strong>.') %></li> <li><%= _('Your name, request and any responses will appear in <strong>search engines</strong> @@ -37,14 +37,12 @@ <%= f.hidden_field(:tag_string) %> <%= hidden_field_tag(:submitted_new_request, 1) %> <%= hidden_field_tag(:preview, 0 ) %> - <%= submit_tag _("Re-edit this request"), :name => 'reedit' %> - <%= submit_tag _("Send public ") + h(@info_request.law_used_full) + " request", :name => 'submit' %> + <%= submit_tag _("Edit this request"), :name => 'reedit', :id => 'reedit_button' %> + <%= submit_tag _("Send request"), :name => 'submit', :id => 'submit_button' %> </p> <% if !@info_request.tag_string.empty? %> <p><strong><%= _('Tags:') %></strong> <%=h @info_request.tag_string %></p> <% end %> -<% end %> - - +<% end %>
\ No newline at end of file diff --git a/app/views/request/select_authority.rhtml b/app/views/request/select_authority.rhtml new file mode 100644 index 000000000..802fefec6 --- /dev/null +++ b/app/views/request/select_authority.rhtml @@ -0,0 +1,50 @@ +<script type="text/javascript" src="/javascripts/ba-throttle-debounce.js"></script> +<script> + $(document).ready(function(){ + $("#authority_preview").hide(); + + // Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin: + // http://benalman.com/projects/jquery-throttle-debounce-plugin/ + $("#query").keypress($.debounce( 300, function() { + // Do a type ahead search and display results + $("#typeahead_response").load("<%=search_ahead_bodies_url%>?q="+encodeURI(this.value), function() { + $("#authority_preview").hide(); // Hide the preview, since results have changed + + // We're using the existing body list: we intercept the clicks on the titles to + // display a preview on the right hand side of the screen + $("#typeahead_response a").click(function() { + $("#authority_preview").load(this.href+" #main_content", function() { + $("#authority_preview").show(); + $("#authority_preview #header_right").hide(); + }); + return false; + }); + }); + })); + }); +</script> + +<% @title = _("Select the authority to write to") %> + + <h1 style="clear: left"><%= _('1. Select an authority') %></h1> + + <div id="authority_selection"> + <% form_tag({:controller => "general", :action => "search_redirect"}, {:id => "search_form"}) do %> + <p> + <p> + <%= _('First, type in the <strong>name of the UK public authority</strong> you\'d + <br>like information from. <strong>By law, they have to respond</strong> + (<a href="%s">why?</a>).') % help_about_url %> + </p> + <%= text_field_tag 'query', params[:query], { :size => 30 } %> + <%= hidden_field_tag 'bodies', 1 %> + <%= submit_tag _('Search') %> + </p> + <% end %> + <div id="typeahead_response"> + </div> + </div> + + <div id="authority_preview"> + </div> +
\ No newline at end of file diff --git a/app/views/track/_tracking_links.rhtml b/app/views/track/_tracking_links.rhtml index 09206528c..f50a8bbbf 100644 --- a/app/views/track/_tracking_links.rhtml +++ b/app/views/track/_tracking_links.rhtml @@ -18,12 +18,12 @@ <% 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 "Follow 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%>"> <%= link_to '<img src="/images/feed-16.png" alt="">', do_track_url(track_thing, 'feed') %> - <%= link_to (location == 'sidebar' ? 'RSS feed of updates' : 'RSS feed'), do_track_url(track_thing, 'feed') %> + <%= link_to (location == 'sidebar' ? _('RSS feed of updates') : _('RSS feed')), do_track_url(track_thing, 'feed') %> </div> <% end %> diff --git a/app/views/user/_signin.rhtml b/app/views/user/_signin.rhtml index 6baed3c25..a7cfdf28a 100644 --- a/app/views/user/_signin.rhtml +++ b/app/views/user/_signin.rhtml @@ -28,6 +28,7 @@ <div class="form_button"> <%= hidden_field_tag 'token', params[:token], { :id => 'signin_token' } %> + <%= hidden_field_tag :modal, params[:modal] %> <%= submit_tag _('Sign in') %> </div> <% end %> diff --git a/app/views/user/_signup.rhtml b/app/views/user/_signup.rhtml index f183ac1f1..791226586 100644 --- a/app/views/user/_signup.rhtml +++ b/app/views/user/_signup.rhtml @@ -42,6 +42,7 @@ <div class="form_button"> <%= hidden_field_tag 'token', params[:token], { :id => 'signup_token' } %> + <%= hidden_field_tag :modal, params[:modal] %> <%= submit_tag _('Sign up') %> </div> diff --git a/app/views/user/signin_successful.rhtml b/app/views/user/signin_successful.rhtml new file mode 100644 index 000000000..762bfa763 --- /dev/null +++ b/app/views/user/signin_successful.rhtml @@ -0,0 +1,9 @@ +<%= _("You're in. <a href=\"#\" id=\"send-request\">Continue sending your request</a>") %> + +<script> + parent.modal_signin_successful = true; + + $("#send-request").click(function() { + parent.$.fancybox.close(); return false; + }); +</script>
\ No newline at end of file |