Sha256: 1d1a35b162d8cc4a347f1cd5c5fe1dbb35b1158575b642b63f3d689f41e6cc7d

Contents?: true

Size: 1.01 KB

Versions: 27

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Document
    # Render citations for the document
    class CitationComponent < ::ViewComponent::Base
      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>] 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
          @view_context.document_heading(@document)
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
blacklight-7.22.2 app/components/blacklight/document/citation_component.rb
blacklight-7.22.1 app/components/blacklight/document/citation_component.rb
blacklight-7.22.0 app/components/blacklight/document/citation_component.rb
blacklight-7.21.2 app/components/blacklight/document/citation_component.rb
blacklight-7.21.1 app/components/blacklight/document/citation_component.rb
blacklight-7.21.0 app/components/blacklight/document/citation_component.rb
blacklight-7.20.1 app/components/blacklight/document/citation_component.rb
blacklight-7.20.0 app/components/blacklight/document/citation_component.rb
blacklight-7.19.2 app/components/blacklight/document/citation_component.rb
blacklight-7.19.1 app/components/blacklight/document/citation_component.rb
blacklight-7.19.0 app/components/blacklight/document/citation_component.rb
blacklight-7.18.1 app/components/blacklight/document/citation_component.rb
blacklight-7.18.0 app/components/blacklight/document/citation_component.rb
blacklight-7.17.2 app/components/blacklight/document/citation_component.rb
blacklight-7.17.1 app/components/blacklight/document/citation_component.rb
blacklight-7.17.0 app/components/blacklight/document/citation_component.rb
blacklight-7.16.0 app/components/blacklight/document/citation_component.rb
blacklight-7.15.2 app/components/blacklight/document/citation_component.rb
blacklight-7.15.1 app/components/blacklight/document/citation_component.rb
blacklight-7.15.0 app/components/blacklight/document/citation_component.rb