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