Sha256: 48ed73ccdaea81913b9b08d161e3c0a78f0eace0c57643588c32609076fe8df2

Contents?: true

Size: 1.18 KB

Versions: 48

Compression:

Stored size: 1.18 KB

Contents

module Hyrax
  module CitationsBehaviors
    module Formatters
      class OpenUrlFormatter < BaseFormatter
        def format(work)
          export_text = []
          export_text << "url_ver=Z39.88-2004&ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator"
          FIELD_MAP.each do |element, kev|
            next unless work.respond_to?(element)
            values = work.send(element)
            Array.wrap(values).each do |value|
              next if value.blank?
              export_text << "rft.#{kev}=#{CGI.escape(value.to_s)}"
            end
          end
          export_text.join('&') if export_text.present?
        end

        FIELD_MAP = {
          title: 'title',
          creator: 'creator',
          subject: 'subject',
          description: 'description',
          publisher: 'publisher',
          contributor: 'contributor',
          date_created: 'date',
          resource_type: 'format',
          identifier: 'identifier',
          language: 'language',
          keyword: 'relation',
          based_near: 'coverage',
          license: 'license'
        }.freeze
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.9.5 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.9.4 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.9.3 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.9.2 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.9.1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.9.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.8.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.7.2 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.7.1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.7.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.6.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.0.0.pre.rc1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.0.0.pre.beta3 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.5.1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.5.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.0.0.pre.beta2 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.4.1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.0.0.pre.beta1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-2.4.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb