diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/public_body_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 18 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 23 |
3 files changed, 47 insertions, 6 deletions
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 e446854ab..d39b78f36 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -22,6 +22,10 @@ class RequestController < ApplicationController rescue MissingSourceFile, NameError end + def select_authority + medium_cache + end + def show medium_cache @locale = self.locale_from_params() @@ -66,7 +70,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 @@ -736,5 +740,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..7b99be393 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -72,6 +72,10 @@ class UserController < ApplicationController def signin work_out_post_redirect + # when logging in through a modal iframe, don't display chrome around the content + @is_modal_dialog = (params[:modal].to_i != 0) + layout = @is_modal_dialog ? 'no_chrome' : 'default' + # make sure we have cookies if session.instance_variable_get(:@dbman) if not session.instance_variable_get(:@dbman).instance_variable_get(:@original) @@ -80,7 +84,7 @@ class UserController < ApplicationController redirect_to signin_url(:r => params[:r], :again => 1) return end - render :action => 'no_cookies' + render :action => 'no_cookies', :layout => layout return end end @@ -92,13 +96,13 @@ class UserController < ApplicationController if not params[:user_signin] # First time page is shown - render :action => 'sign' + render :action => 'sign', :layout => layout return else @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name] ? true : false) if @user_signin.errors.size > 0 # Failed to authenticate - render :action => 'sign' + render :action => 'sign', :layout => layout return else # Successful login @@ -106,7 +110,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', :layout => layout + else + do_post_redirect @post_redirect + end else send_confirmation_mail @user_signin end @@ -119,11 +128,15 @@ class UserController < ApplicationController def signup work_out_post_redirect + # when logging in through a modal iframe, don't display chrome around the content + @is_modal_dialog = (params[:modal].to_i != 0) + layout = @is_modal_dialog ? 'no_chrome' : 'default' + # Make the user and try to save it @user_signup = User.new(params[:user_signup]) if !@user_signup.valid? # Show the form - render :action => 'sign' + render :action => 'sign', :layout => layout else user_alreadyexists = User.find_user_by_email(params[:user_signup][:email]) if user_alreadyexists |