Module: Sufia::Controller
- Extended by:
- ActiveSupport::Concern
- Included in:
- GenericFilesController
- Defined in:
- lib/sufia/controller.rb
Overview
Copyright © 2012 The Pennsylvania State University
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Method Summary collapse
- #current_ability ⇒ Object
- #groups ⇒ Object
-
#has_search_parameters? ⇒ Boolean
This repeats has_search_parameters? method from Blacklight::CatalogHelperBehavior.
- #notifications_number ⇒ Object
- #render_404(exception) ⇒ Object
- #render_500(exception) ⇒ Object
- #render_single_use_error(exception) ⇒ Object
- #search_layout ⇒ Object
Instance Method Details
#current_ability ⇒ Object
27 28 29 |
# File 'lib/sufia/controller.rb', line 27 def current_ability user_signed_in? ? current_user.ability : super end |
#groups ⇒ Object
31 32 33 |
# File 'lib/sufia/controller.rb', line 31 def groups @groups ||= user_signed_in? ? current_user.groups : [] end |
#has_search_parameters? ⇒ Boolean
This repeats has_search_parameters? method from Blacklight::CatalogHelperBehavior
69 70 71 |
# File 'lib/sufia/controller.rb', line 69 def has_search_parameters? !params[:q].blank? or !params[:f].blank? or !params[:search_field].blank? end |
#notifications_number ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/sufia/controller.rb', line 50 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(:id, :distinct => true) @batches=current_user.mailbox.inbox.map {|msg| msg..body[/<a class="batchid ui-helper-hidden">(.*)<\/a>The file(.*)/,1]}.select{|val| !val.blank?} end end |
#render_404(exception) ⇒ Object
35 36 37 38 |
# File 'lib/sufia/controller.rb', line 35 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
40 41 42 43 |
# File 'lib/sufia/controller.rb', line 40 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
45 46 47 48 |
# File 'lib/sufia/controller.rb', line 45 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_layout ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/sufia/controller.rb', line 60 def search_layout if has_search_parameters? "sufia-two-column" else "homepage" end end |