Module: Sufia::Controller

Extended by:
ActiveSupport::Concern
Included in:
GenericFilesController
Defined in:
lib/sufia/controller.rb

Instance Method Summary collapse

Instance Method Details

#current_abilityObject



11
12
13
# File 'lib/sufia/controller.rb', line 11

def current_ability
  user_signed_in? ? current_user.ability : super
end

#has_search_parameters?Boolean

This repeats has_search_parameters? method from Blacklight::CatalogHelperBehavior

Returns:

  • (Boolean)


49
50
51
# File 'lib/sufia/controller.rb', line 49

def has_search_parameters?
  !params[:q].blank? or !params[:f].blank? or !params[:search_field].blank?
end

#notifications_numberObject



30
31
32
33
34
35
36
37
38
# File 'lib/sufia/controller.rb', line 30

def notifications_number
  @notify_number=0
  @batches=[]
  return if action_name == "index" && controller_name == "mailbox"
  if user_signed_in? 
    @notify_number= current_user.mailbox.inbox(:unread => true).count
    @batches=current_user.mailbox.inbox.map {|msg| msg.last_message.body[/<span class="batchid ui-helper-hidden">(.*)<\/span>The file(.*)/,1]}.select{|val| !val.blank?}
  end
end

#render_404(exception) ⇒ Object



15
16
17
18
# File 'lib/sufia/controller.rb', line 15

def render_404(exception)
  logger.error("Rendering 404 page due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}")
  render :template => '/error/404', :layout => "error", :formats => [:html], :status => 404
end

#render_500(exception) ⇒ Object



20
21
22
23
# File 'lib/sufia/controller.rb', line 20

def render_500(exception)
  logger.error("Rendering 500 page due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}")
  render :template => '/error/500', :layout => "error", :formats => [:html], :status => 500
end

#render_single_use_error(exception) ⇒ Object



25
26
27
28
# File 'lib/sufia/controller.rb', line 25

def render_single_use_error(exception)
  logger.error("Rendering PAGE due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}")
  render :template => '/error/single_use_error', :layout => "error", :formats => [:html], :status => 404
end

#search_layoutObject



40
41
42
43
44
45
46
# File 'lib/sufia/controller.rb', line 40

def search_layout
  if has_search_parameters? 
    "sufia-two-column"
  else
    "homepage"
  end
end