Sha256: 358618fb74fc91abce3dde53c70e67b0ae8cd69e187f8de6513d1e7a6b606707

Contents?: true

Size: 1.01 KB

Versions: 25

Compression:

Stored size: 1.01 KB

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
        Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
          helpers.document_heading(@document)
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/components/blacklight/document/citation_component.rb
blacklight-7.39.0 app/components/blacklight/document/citation_component.rb
blacklight-7.38.0 app/components/blacklight/document/citation_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/components/blacklight/document/citation_component.rb
blacklight-7.37.0 app/components/blacklight/document/citation_component.rb
blacklight-7.36.2 app/components/blacklight/document/citation_component.rb
blacklight-7.36.1 app/components/blacklight/document/citation_component.rb
blacklight-7.36.0 app/components/blacklight/document/citation_component.rb
blacklight-7.35.0 app/components/blacklight/document/citation_component.rb
blacklight-7.34.0 app/components/blacklight/document/citation_component.rb
blacklight-7.33.1 app/components/blacklight/document/citation_component.rb
blacklight-7.33.0 app/components/blacklight/document/citation_component.rb
blacklight-7.32.0 app/components/blacklight/document/citation_component.rb
blacklight-7.31.0 app/components/blacklight/document/citation_component.rb
blacklight-7.30.0 app/components/blacklight/document/citation_component.rb
blacklight-7.29.0 app/components/blacklight/document/citation_component.rb
blacklight-7.28.0 app/components/blacklight/document/citation_component.rb
blacklight-7.27.1 app/components/blacklight/document/citation_component.rb
blacklight-7.27.0 app/components/blacklight/document/citation_component.rb
blacklight-7.26.1 app/components/blacklight/document/citation_component.rb