Module: Hyrax::SolrDocument::Export

Included in:
Hyrax::SolrDocumentBehavior
Defined in:
app/models/concerns/hyrax/solr_document/export.rb

Instance Method Summary collapse

Instance Method Details

#end_note_formatObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/models/concerns/hyrax/solr_document/export.rb', line 33

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('hyrax.product_name'),
    '%W' => Institution.name
  }
end

#endnote_filenameObject

Name of the downloaded endnote file Override this if you want to use a different name



25
26
27
# File 'app/models/concerns/hyrax/solr_document/export.rb', line 25

def endnote_filename
  "#{id}.endnote"
end

#export_as_endnoteObject

MIME: ‘application/x-endnote-refer’



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/concerns/hyrax/solr_document/export.rb', line 5

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

#persistent_urlObject



29
30
31
# File 'app/models/concerns/hyrax/solr_document/export.rb', line 29

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