aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_public_body_controller.rb26
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/controllers/public_body_controller.rb12
-rw-r--r--app/controllers/request_controller.rb29
-rw-r--r--app/controllers/user_controller.rb18
-rw-r--r--app/helpers/config_helper.rb4
-rwxr-xr-xapp/helpers/link_to_helper.rb2
-rw-r--r--app/models/info_request.rb7
-rw-r--r--app/models/info_request_event.rb55
-rw-r--r--app/models/public_body.rb60
-rw-r--r--app/models/request_mailer.rb10
-rw-r--r--app/views/admin_public_body/_form.rhtml72
-rw-r--r--app/views/admin_public_body/edit.rhtml14
-rw-r--r--app/views/admin_public_body/new.rhtml15
-rw-r--r--app/views/admin_public_body/show.rhtml11
-rw-r--r--app/views/general/_orglink.rhtml2
-rw-r--r--app/views/general/frontpage.rhtml2
-rw-r--r--app/views/layouts/admin.rhtml6
-rw-r--r--app/views/layouts/default.rhtml33
-rw-r--r--app/views/layouts/no_chrome.rhtml39
-rw-r--r--app/views/public_body/_search_ahead.rhtml18
-rw-r--r--app/views/public_body/show.rhtml4
-rw-r--r--app/views/request/_search_ahead.rhtml13
-rw-r--r--app/views/request/new.rhtml201
-rw-r--r--app/views/request/preview.rhtml10
-rw-r--r--app/views/request/select_authority.rhtml50
-rw-r--r--app/views/user/_signin.rhtml1
-rw-r--r--app/views/user/_signup.rhtml1
-rw-r--r--app/views/user/signin_successful.rhtml9
29 files changed, 496 insertions, 232 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index 021122734..60cb324a1 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -82,16 +82,12 @@ class AdminPublicBodyController < AdminController
end
def new
- @locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
- @public_body = PublicBody.new
- render
- end
+ @public_body = PublicBody.new
+ render
end
-
+
def create
- @locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ PublicBody.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_http_auth_user()
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
@@ -104,17 +100,13 @@ class AdminPublicBodyController < AdminController
end
def edit
- @locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
- @public_body = PublicBody.find(params[:id])
- @public_body.last_edit_comment = ""
- render
- end
+ @public_body = PublicBody.find(params[:id])
+ @public_body.last_edit_comment = ""
+ render
end
def update
- @locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ PublicBody.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_http_auth_user()
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
@@ -157,7 +149,7 @@ class AdminPublicBodyController < AdminController
# Try with dry run first
csv_contents = params[:csv_file].read
- en = PublicBody.import_csv(csv_contents, params[:tag], true, admin_http_auth_user(), I18n.available_locales)
+ en = PublicBody.import_csv(csv_contents, params[:tag], true, admin_http_auth_user(), available_locales)
errors = en[0]
notes = en[1]
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 0df3e22da..8ef23f49d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -192,7 +192,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 05acf4868..ea1ffb619 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -168,5 +168,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 c1a13273a..e13291c2d 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
@@ -743,5 +758,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 d3c42c7f1..3e3913fae 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,
@@ -106,7 +108,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
@@ -500,6 +507,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/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 444129052..558479c26 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -61,7 +61,7 @@ module LinkToHelper
# Public bodies
def public_body_url(public_body)
- return show_public_body_url(:url_name => public_body.url_name, :only_path => true)
+ public_body.url_name.nil? ? '' : show_public_body_url(:url_name => public_body.url_name, :only_path => true)
end
def public_body_link_short(public_body)
link_to h(public_body.short_or_long_name), public_body_url(public_body)
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index c667e1499..67ebd01b0 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -779,8 +779,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'
@@ -818,6 +817,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 d79647c98..5ae1f5b2d 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -57,22 +57,7 @@ class InfoRequestEvent < ActiveRecord::Base
]
# user described state (also update in info_request)
- validates_inclusion_of :described_state, :in => [
- nil,
- 'waiting_response',
- 'waiting_clarification',
- 'gone_postal',
- 'deadline_extended',
- 'wrong_response',
- 'not_held',
- 'rejected',
- 'successful',
- 'partially_successful',
- 'internal_review',
- 'error_message',
- 'requires_admin',
- 'user_withdrawn'
- ]
+ validate :must_be_valid_state
# whether event is publicly visible
validates_inclusion_of :prominence, :in => [
@@ -81,6 +66,12 @@ class InfoRequestEvent < ActiveRecord::Base
'requester_only'
]
+ def must_be_valid_state
+ if !described_state.nil? and !InfoRequest.enumerate_states.include?(described_state)
+ errors.add(described_state, "is not a valid state")
+ end
+ end
+
def user_can_view?(user)
if !self.info_request.user_can_view?(user)
raise "internal error, called user_can_view? on event when there is not permission to view entire request"
@@ -288,37 +279,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/public_body.rb b/app/models/public_body.rb
index b75da4331..b4d1b6704 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -38,7 +38,7 @@ class PublicBody < ActiveRecord::Base
validates_uniqueness_of :short_name, :message => N_("Short name is already taken"), :if => Proc.new { |pb| pb.short_name != "" }
validates_uniqueness_of :name, :message => N_("Name is already taken")
-
+
has_many :info_requests, :order => 'created_at desc'
has_many :track_things, :order => 'created_at desc'
@@ -46,6 +46,40 @@ class PublicBody < ActiveRecord::Base
translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme
+ # Convenience methods for creating/editing translations via forms
+ def translation(locale)
+ self.translations.find_by_locale(locale)
+ end
+
+ # XXX - Don't like repeating this!
+ def calculate_cached_fields(t)
+ t.first_letter = t.name.scan(/^./mu)[0].upcase unless t.name.nil? or t.name.empty?
+ short_long_name = t.name
+ short_long_name = t.short_name if t.short_name and !t.short_name.empty?
+ t.url_name = MySociety::Format.simplify_url_part(short_long_name, 'body')
+ end
+
+ def translated_versions
+ translations
+ end
+
+ def translated_versions=(translation_attrs)
+ if translation_attrs.respond_to? :each_value # Hash => updating
+ translation_attrs.each_value do |attrs|
+ t = translation(attrs[:locale]) || PublicBody::Translation.new
+ t.attributes = attrs
+ calculate_cached_fields(t)
+ t.save!
+ end
+ else # Array => creating
+ translation_attrs.each do |attrs|
+ new_translation = PublicBody::Translation.new(attrs)
+ calculate_cached_fields(new_translation)
+ translations << new_translation
+ end
+ end
+ end
+
# Make sure publication_scheme gets the correct default value.
# (This would work automatically, were publication_scheme not a translated attribute)
def after_initialize
@@ -191,7 +225,6 @@ class PublicBody < ActiveRecord::Base
# When name or short name is changed, also change the url name
def short_name=(short_name)
-
globalize.write(self.class.locale || I18n.locale, :short_name, short_name)
self[:short_name] = short_name
self.update_url_name
@@ -204,15 +237,15 @@ class PublicBody < ActiveRecord::Base
end
def update_url_name
- url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body')
- self.url_name = url_name
+ self.url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body')
end
+
# Return the short name if present, or else long name
def short_or_long_name
- if self.short_name.nil? # can happen during construction
+ if self.short_name.nil? || self.short_name.empty? # 'nil' can happen during construction
self.name
else
- self.short_name.empty? ? self.name : self.short_name
+ self.short_name
end
end
@@ -341,9 +374,12 @@ class PublicBody < ActiveRecord::Base
row.each_with_index {|field, i| field_names[field] = i}
next
end
+
+ fields = {}
+ field_names.each{|name, i| fields[name] = row[i]}
- name = row[field_names['name']]
- email = row[field_names['email']]
+ name = fields['name']
+ email = fields['email']
next if name.nil?
if email.nil?
email = '' # unknown/bad contact is empty string
@@ -356,7 +392,7 @@ class PublicBody < ActiveRecord::Base
errors.push "error: line " + line.to_s + ": invalid email " + email + " for authority '" + name + "'"
next
end
-
+
if bodies_by_name[name]
# Already have the public body, just update email
public_body = bodies_by_name[name]
@@ -367,9 +403,9 @@ class PublicBody < ActiveRecord::Base
public_body.last_edit_comment = 'Updated from spreadsheet'
public_body.save!
end
-
+
additional_locales.each do |locale|
- localized_name = field_names["name.#{locale}"] && row[field_names["name.#{locale}"]]
+ localized_name = fields["name.#{locale}"]
PublicBody.with_locale(locale) do
if !localized_name.nil? and public_body.name != localized_name
notes.push "line " + line.to_s + ": updating name for '#{name}' from '#{public_body.name}' to '#{localized_name}' (locale: #{locale})."
@@ -386,7 +422,7 @@ class PublicBody < ActiveRecord::Base
public_body.save!
additional_locales.each do |locale|
- localized_name = field_names["name.#{locale}"] && row[field_names["name.#{locale}"]]
+ localized_name = fields["name.#{locale}"]
if !localized_name.nil?
PublicBody.with_locale(locale) do
notes.push "line " + line.to_s + ": (aka '#{localized_name}' in locale #{locale})"
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb
index fc317d20d..e244aaac9 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -266,12 +266,12 @@ class RequestMailer < ApplicationMailer
end
end
- # Send email alerts for new responses which haven't been classified. Goes
- # out 3 days after last update of event, then after 7, then after 24.
+ # Send email alerts for new responses which haven't been classified. By default,
+ # it goes out 3 days after last update of event, then after 10, then after 24.
def self.alert_new_response_reminders
- self.alert_new_response_reminders_internal(3, 'new_response_reminder_1')
- self.alert_new_response_reminders_internal(10, 'new_response_reminder_2')
- self.alert_new_response_reminders_internal(24, 'new_response_reminder_3')
+ MySociety::Config.get("NEW_RESPONSE_REMINDER_AFTER_DAYS", [3, 10, 24]).each_with_index do |days, i|
+ self.alert_new_response_reminders_internal(days, "new_response_reminder_#{i+1}")
+ end
end
def self.alert_new_response_reminders_internal(days_since, type_code)
info_requests = InfoRequest.find_old_unclassified(:order => 'info_requests.id',
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
index b1516be2e..15313bbdd 100644
--- a/app/views/admin_public_body/_form.rhtml
+++ b/app/views/admin_public_body/_form.rhtml
@@ -2,7 +2,10 @@
<!--[form:public_body]-->
-<div id="tag_help">
+<!--
+ XXX: disabled temporarily while testing jQuery tabs
+
+ <div id="tag_help">
<h2>List of tags</h2>
<% first_row = true %>
<% for row in PublicBodyCategories::CATEGORIES_WITH_HEADINGS %>
@@ -19,31 +22,66 @@
<h3><%=h row%></h3>
<% end %>
<% end %>
-</div>
+</div> -->
-<p><label for="public_body_name">Name</label><br/>
-<%= text_field 'public_body', 'name', :size => 60 %></p>
+<h3>Localized Fields</h3>
+<div id="div-locales">
-<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/>
-<%= text_field 'public_body', 'short_name', :size => 60 %></p>
+ <ul>
+ <% for locale in I18n.available_locales do %>
+ <li><a href="#div-locale-<%=locale.to_s%>"><%=locale_name(locale.to_s)%></a></li>
+ <% end %>
+ </ul>
-<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/>
-<%= text_field 'public_body', 'request_email', :size => 40 %></p>
-<p><label for="public_body_tag_string">Tags <small>(space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity)</small></label><br/>
-<%= text_field 'public_body', 'tag_string', :size => 60 %></p>
+<%
+ for locale in I18n.available_locales do
+ if locale==I18n.default_locale # The default locale is submitted as part of the bigger object...
+ prefix = 'public_body'
+ object = @public_body
+ else # ...but additional locales go "on the side"
+ prefix = "public_body[translated_versions][]"
+ object = @public_body.new_record? ?
+ PublicBody::Translation.new :
+ @public_body.translation(locale.to_s) || PublicBody::Translation.new
+ end
-<p><label for="public_body_home_page">Home page <small>(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</small></label><br/>
-<%= text_field 'public_body', 'home_page', :size => 60 %></p>
+ fields_for prefix, object do |t|
+%>
+ <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="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="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="public_body_publication_scheme">Publication scheme URL</label><br/>
-<%= text_field 'public_body', 'publication_scheme', :size => 60 %></p>
+ <p><label for="public_body_publication_scheme">Publication scheme URL</label><br/>
+ <%= t.text_field :publication_scheme, :size => 60 %></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/>
-<%= text_area 'public_body', 'notes', :rows => 3, :cols => 60 %></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>
+ </div>
+<%
+ end
+ end
+%>
+</div>
+
+<h3>Common Fields</h3>
+
+<p><label for="public_body_tag_string">Tags <small>(space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity)</small></label><br/>
+<%= f.text_field :tag_string, :size => 60 %></p>
+
+<p><label for="public_body_home_page">Home page <small>(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</small></label><br/>
+<%= f.text_field :home_page, :size => 60 %></p>
<p><label for="public_body_last_edit_comment"><strong>Comment</strong> for this edit</label> <small>(put URL or other source of new info)</small><br/>
-<%= text_area 'public_body', 'last_edit_comment', :rows => 3, :cols => 60 %></p>
+<%= f.text_area :last_edit_comment, :rows => 3, :cols => 60 %></p>
<!--[eoform:public_body]-->
diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml
index 005ec93ce..b895fbd70 100644
--- a/app/views/admin_public_body/edit.rhtml
+++ b/app/views/admin_public_body/edit.rhtml
@@ -1,10 +1,14 @@
-
-
<h1><%=@title%></h1>
-<% form_tag '../update/' + @public_body.id.to_s do %>
- <%= render :partial => 'form' %>
- <p><%= submit_tag 'Save', :accesskey => 's' %></p>
+<script>
+ $(function() {
+ $("#div-locales").tabs();
+ });
+</script>
+
+<% form_for @public_body, :url => {:action => 'update'} do |f| %>
+ <%= render :partial => 'form', :locals => {:f => f} %>
+ <p><%= f.submit 'Save', :accesskey => 's' %></p>
<% end %>
<p>
diff --git a/app/views/admin_public_body/new.rhtml b/app/views/admin_public_body/new.rhtml
index 95208b5b3..dcef8ae9f 100644
--- a/app/views/admin_public_body/new.rhtml
+++ b/app/views/admin_public_body/new.rhtml
@@ -2,11 +2,18 @@
<h1><%=@title%></h1>
-<% form_tag 'create' do %>
- <%= render :partial => 'form' %>
- <p><%= submit_tag "Create" %></p>
+<script>
+ $(function() {
+ $("#div-locales").tabs();
+ });
+</script>
+
+
+<% form_for :public_body, @public_body, :url => {:action => "create"} do |f| %>
+ <%= render :partial => 'form', :locals => {:f => f} %>
+ <p><%= f.submit "Create" %></p>
<% end %>
<p>
<%= link_to 'List all', 'list' %>
-</p>
+</p> \ No newline at end of file
diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml
index c1292c63a..643ccf5e8 100644
--- a/app/views/admin_public_body/show.rhtml
+++ b/app/views/admin_public_body/show.rhtml
@@ -12,7 +12,7 @@
<% if column.name == 'home_page' and !column.name.empty? %>
<%= link_to(h(@public_body.send(column.name)), @public_body.send(column.name)) %>
<% elsif column.name == 'request_email' and !column.name.empty? %>
- <%= link_to(h(@public_body.send(column.name)), "mailto:" + @public_body.send(column.name)) %>
+ <%= link_to(h(@public_body.send(column.name)), "mailto:#{@public_body.send(column.name)}") %>
<% if !@public_body.is_requestable? %>
(not requestable due to: <%=h @public_body.not_requestable_reason %><% if @public_body.is_followupable? %>; but followupable<% end %>)
<% end %>
@@ -32,7 +32,14 @@
</p>
<p>
- <%= link_to 'Public page', main_url(public_body_url(@public_body)) %>
+ <%=
+ # url_name can be missing if the name hasn't been set for this locale
+ if !@public_body.url_name.nil?
+ link_to 'Public page', main_url(public_body_url(@public_body))
+ else
+ 'Public page not available'
+ end
+ %>
| <%= link_to 'Edit', '../edit/' + @public_body.id.to_s %>
</p>
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 959ccd8c6..a188e7359 100644
--- a/app/views/general/frontpage.rhtml
+++ b/app/views/general/frontpage.rhtml
@@ -9,7 +9,7 @@
<div id="bighand">
Make a new <strong>Freedom of Information</strong> request
<br />
- <a href="/en/new/tgq"><%= image_tag('start-button.png') %></a>
+ <a href="/select_authority"><img alt="Start-button" src="/images/start-button.png?1314013338"></a>
</div>
</div>
diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml
index f0e9a7019..c81ac889f 100644
--- a/app/views/layouts/admin.rhtml
+++ b/app/views/layouts/admin.rhtml
@@ -3,7 +3,13 @@
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" >
<title><%= site_name %> admin<%= @title ? ":" : "" %> <%=@title%></title>
+
+ <!-- XXX: use local versions once we agree on tabs -->
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js"></script>
+
<%= stylesheet_link_tag 'admin', :title => "Main", :rel => "stylesheet" %>
+ <%= stylesheet_link_tag 'ui-lightness/jquery-ui-1.8.15.custom.css', :rel => 'stylesheet'%>
</head>
<body>
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index b603c5676..cc12fb53c 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" >
@@ -28,6 +28,8 @@
<style type="text/css">@import url("/stylesheets/ie6-custom.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 %>
@@ -49,6 +51,28 @@
</head>
<body>
+ <!-- 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">
@@ -89,12 +113,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/show.rhtml b/app/views/public_body/show.rhtml
index 6215d7a0c..0783e91b9 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><%= _('Track this authority')%></h2>
@@ -100,4 +101,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> \ No newline at end of file
diff --git a/app/views/request/_search_ahead.rhtml b/app/views/request/_search_ahead.rhtml
new file mode 100644
index 000000000..053b10146
--- /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/new.rhtml b/app/views/request/new.rhtml
index ddb9bd046..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,107 +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 %>
- <% if !@info_request.public_body.calculated_home_page.nil? %>
- <br>
- &nbsp; &nbsp; &nbsp; &nbsp; <%= text_field_tag 'q', params[:q], { :size => 20 } %>
- <%= hidden_field_tag 'as_sitesearch', @info_request.public_body.calculated_home_page %>
- <%= submit_tag _("Search"), :class=>"small" %>
- <% end %>
- <br>
- ... <%= _('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>,
@@ -126,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">
@@ -148,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/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 9c228d684..6c34dcac6 100644
--- a/app/views/user/_signup.rhtml
+++ b/app/views/user/_signup.rhtml
@@ -38,6 +38,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