Sha256: 17a6dd85db6eb1add8129d29ddbc2f7c22c0226783733888fc6931f10b81b2e8

Contents?: true

Size: 1009 Bytes

Versions: 21

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module Document
    # Render citations for the document
    class CitationComponent < Blacklight::Component
      DEFAULT_FORMATS = {
        'blacklight.citation.mla': :export_as_mla_citation_txt,
        'blacklight.citation.apa': :export_as_apa_citation_txt,
        'blacklight.citation.chicago': :export_as_chicago_citation_txt
      }.freeze

      with_collection_parameter :document

      # @param [Blacklight::Document] document
      # @param [Hash<String => Symbol>] formats map of citation format names (suspiciously, i18n keys
      #   for them) to document methods that return the formatted citation.
      def initialize(document:, formats: DEFAULT_FORMATS)
        @document = document
        @formats = formats.select { |_k, v| @document.respond_to?(v) }
      end

      # @return [String]
      def title
        presenter.heading
      end

      def presenter
        helpers.document_presenter(@document)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
blacklight-8.6.1 app/components/blacklight/document/citation_component.rb
blacklight-8.6.0 app/components/blacklight/document/citation_component.rb
blacklight-8.5.1 app/components/blacklight/document/citation_component.rb
blacklight-8.5.0 app/components/blacklight/document/citation_component.rb
blacklight-8.4.0 app/components/blacklight/document/citation_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/components/blacklight/document/citation_component.rb
blacklight-8.3.0 app/components/blacklight/document/citation_component.rb
blacklight-8.2.2 app/components/blacklight/document/citation_component.rb
blacklight-8.2.1 app/components/blacklight/document/citation_component.rb
blacklight-8.2.0 app/components/blacklight/document/citation_component.rb
blacklight-8.1.0 app/components/blacklight/document/citation_component.rb
blacklight-8.0.1 app/components/blacklight/document/citation_component.rb
blacklight-8.0.0 app/components/blacklight/document/citation_component.rb
blacklight-8.0.0.beta8 app/components/blacklight/document/citation_component.rb
blacklight-8.0.0.beta7 app/components/blacklight/document/citation_component.rb
blacklight-8.0.0.beta6 app/components/blacklight/document/citation_component.rb
blacklight-8.0.0.beta5 app/components/blacklight/document/citation_component.rb
blacklight-8.0.0.beta4 app/components/blacklight/document/citation_component.rb
blacklight-8.0.0.beta3 app/components/blacklight/document/citation_component.rb
blacklight-8.0.0.beta2 app/components/blacklight/document/citation_component.rb