Sha256: 995d0e1dd6a8d2496b2415eb9b0d803e46b7cbe89d12b8eb8a90a01d64f74063

Contents?: true

Size: 1.54 KB

Versions: 8

Compression:

Stored size: 1.54 KB

Contents

module Sufia
  module SolrDocument
    module Export
      # MIME: 'application/x-endnote-refer'
      def export_as_endnote
        text = []
        text << "%0 #{human_readable_type}"
        end_note_format.each do |endnote_key, mapping|
          if mapping.is_a? String
            values = [mapping]
          else
            values = send(mapping[0]) if respond_to? mapping[0]
            values = mapping[1].call(values) if mapping.length == 2
            values = Array.wrap(values)
          end
          next if values.blank? || values.first.nil?
          spaced_values = values.join("; ")
          text << "#{endnote_key} #{spaced_values}"
        end
        text.join("\n")
      end

      def persistent_url
        "#{Sufia.config.persistent_hostpath}#{id}"
      end

      def end_note_format
        {
          '%T' => [:title],
          # '%Q' => [:title, ->(x) { x.drop(1) }], # subtitles
          '%A' => [:creator],
          '%C' => [:publication_place],
          '%D' => [:date_created],
          '%8' => [:date_uploaded],
          '%E' => [:contributor],
          '%I' => [:publisher],
          '%J' => [:series_title],
          '%@' => [:isbn],
          '%U' => [:related_url],
          '%7' => [:edition_statement],
          '%R' => [:persistent_url],
          '%X' => [:description],
          '%G' => [:language],
          '%[' => [:date_modified],
          '%9' => [:resource_type],
          '%~' => I18n.t('sufia.product_name'),
          '%W' => I18n.t('sufia.institution_name')
        }
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.1.0 app/models/concerns/sufia/solr_document/export.rb
sufia-7.0.0 app/models/concerns/sufia/solr_document/export.rb
sufia-7.0.0.rc2 app/models/concerns/sufia/solr_document/export.rb
sufia-7.0.0.rc1 app/models/concerns/sufia/solr_document/export.rb
sufia-7.0.0.beta4 app/models/concerns/sufia/solr_document/export.rb
sufia-7.0.0.beta3 app/models/concerns/sufia/solr_document/export.rb
sufia-7.0.0.beta2 app/models/concerns/sufia/solr_document/export.rb
sufia-7.0.0.beta1 app/models/concerns/sufia/solr_document/export.rb