Sha256: e19a930260abef0f93289783ffd4bd0c6d66e217e6c88924b05e3363db006bdb

Contents?: true

Size: 1.21 KB

Versions: 25

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true
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

25 entries across 25 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-5.0.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-5.0.0.rc3 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-5.0.0.rc2 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-5.0.0.rc1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.6.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-4.0.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-4.0.0.rc3 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-4.0.0.rc2 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-4.0.0.rc1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.5.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-4.0.0.beta2 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.4.2 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-4.0.0.beta1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.4.1 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.4.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.3.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.2.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.1.0 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
hyrax-3.0.2 app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb