Module: CommonwealthVlrEngine::Controller
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/commonwealth-vlr-engine/controller.rb
Instance Method Summary collapse
- #after_sign_in_path_for(resource) ⇒ Object
- #create_img_sequence(image_files, current_img_pid) ⇒ Object
-
#search_action_path(*args) ⇒ Object
override of Blacklight::Controller#search_action_path for proper constraints linking in collections#index and institutions#index.
-
#store_location ⇒ Object
redirect after login to previous non-login page TODO figure out why it doesn’t work for Polaris or Facebook logins.
Instance Method Details
#after_sign_in_path_for(resource) ⇒ Object
36 37 38 |
# File 'lib/commonwealth-vlr-engine/controller.rb', line 36 def after_sign_in_path_for(resource) session[:previous_url] || root_path end |
#create_img_sequence(image_files, current_img_pid) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/commonwealth-vlr-engine/controller.rb', line 40 def create_img_sequence(image_files, current_img_pid) page_sequence = {} page_sequence[:current] = current_img_pid page_sequence[:index] = image_files.index(current_img_pid) + 1 page_sequence[:total] = image_files.length page_sequence[:prev] = page_sequence[:index]-2 > -1 ? image_files[page_sequence[:index]-2] : nil page_sequence[:next] = image_files[page_sequence[:index]].presence page_sequence end |
#search_action_path(*args) ⇒ Object
override of Blacklight::Controller#search_action_path for proper constraints linking in collections#index and institutions#index
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/commonwealth-vlr-engine/controller.rb', line 52 def search_action_path *args if args.first.is_a? Hash args.first[:only_path] = true # Rails 4.2 deprecated url helpers accepting string keys for 'controller' or 'action' args[0] = args.first.except(:controller, :action) end if params[:controller] == 'institutions' && params[:action] == 'index' institutions_url *args elsif params[:controller] == 'collections' && (params[:action] == 'index' || params[:action] == 'facet') collections_url *args else search_action_url *args end end |
#store_location ⇒ Object
redirect after login to previous non-login page TODO figure out why it doesn’t work for Polaris or Facebook logins
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/commonwealth-vlr-engine/controller.rb', line 21 def store_location # store last url - this is needed for post-login redirect to whatever the user last visited. if (request.path != "/users/sign_in" && request.path != "/users/sign_up" && request.path != "/users/password" && request.path != "/users/password/new" && request.path != "/users/password/edit" && request.path != "/users/confirmation" && request.path != "/users/sign_out" && !request.fullpath.match(/\/users\/auth\//) && !request.xhr?) # don't store ajax calls session[:previous_url] = request.fullpath end end |