Module: Blacklight::DocumentHelperBehavior
- Included in:
 - CatalogHelperBehavior
 
- Defined in:
 - app/helpers/blacklight/document_helper_behavior.rb
 
Overview
Helper methods for catalog-like controllers that work with documents
Instance Method Summary collapse
- 
  
    
      #bookmarked?(document)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Check if the document is in the user’s bookmarks.
 - 
  
    
      #document_class_prefix  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Return a prefix for the document classes infered from the document.
 - 
  
    
      #document_presenter(document)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a document presenter for the given document.
 - 
  
    
      #document_presenter_class(_document = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Override this method if you want to use a differnet presenter for your documents.
 - 
  
    
      #render_document_class(document = @document)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Get the classes to add to a document’s div.
 - 
  
    
      #render_document_sidebar_partial(document)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Render the sidebar partial for a document This is used as an integration point by downstream apps to add to the default sidebar.
 
Instance Method Details
#bookmarked?(document) ⇒ Boolean
Check if the document is in the user’s bookmarks
      55 56 57  | 
    
      # File 'app/helpers/blacklight/document_helper_behavior.rb', line 55 def bookmarked? document current_bookmarks.any? { |x| x.document_id == document.id && x.document_type == document.class } end  | 
  
#document_class_prefix ⇒ String
Return a prefix for the document classes infered from the document
      23 24 25  | 
    
      # File 'app/helpers/blacklight/document_helper_behavior.rb', line 23 def document_class_prefix 'blacklight-' end  | 
  
#document_presenter(document) ⇒ Object
Returns a document presenter for the given document
      61 62 63  | 
    
      # File 'app/helpers/blacklight/document_helper_behavior.rb', line 61 def document_presenter(document) document_presenter_class(document).new(document, self) end  | 
  
#document_presenter_class(_document = nil) ⇒ Object
Override this method if you want to use a differnet presenter for your documents
      68 69 70 71 72 73 74 75  | 
    
      # File 'app/helpers/blacklight/document_helper_behavior.rb', line 68 def document_presenter_class(_document = nil) case action_name when 'show', 'citation' blacklight_config.view_config(:show, action_name: action_name).document_presenter_class else blacklight_config.view_config(document_index_view_type, action_name: action_name).document_presenter_class end end  | 
  
#render_document_class(document = @document) ⇒ String
Get the classes to add to a document’s div
      10 11 12 13 14 15 16 17  | 
    
      # File 'app/helpers/blacklight/document_helper_behavior.rb', line 10 def render_document_class(document = @document) types = document_presenter(document).display_type return if types.blank? Array(types).compact.map do |t| "#{document_class_prefix}#{t.try(:parameterize) || t}" end.join(' ') end  | 
  
#render_document_sidebar_partial(document) ⇒ String
Render the sidebar partial for a document This is used as an integration point by downstream apps to add to the default sidebar. See: github.com/geoblacklight/geoblacklight/blob/7d3c31c7af3362879b97e2c1351a2496c728c59c/app/helpers/blacklight_helper.rb#L7
      35 36 37  | 
    
      # File 'app/helpers/blacklight/document_helper_behavior.rb', line 35 def (document) render 'show_sidebar', document: document end  |