blacklight-marc 6.3.0 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +45 -0
  3. data/{.solr_wrapper.yml → .solr_wrapper.yaml} +0 -0
  4. data/Gemfile +12 -0
  5. data/README.md +28 -7
  6. data/app/assets/stylesheets/blacklight_marc.scss +4 -6
  7. data/app/helpers/blacklight_marc_helper.rb +5 -4
  8. data/app/models/concerns/blacklight/solr/document/marc.rb +13 -12
  9. data/app/models/concerns/blacklight/solr/document/marc_export.rb +53 -52
  10. data/app/views/bookmarks/_endnote.html.erb +1 -1
  11. data/app/views/bookmarks/_refworks.html.erb +1 -1
  12. data/app/views/catalog/_marc_view.html.erb +4 -4
  13. data/app/views/catalog/endnote.endnote.erb +1 -1
  14. data/app/views/catalog/librarian_view.html.erb +7 -4
  15. data/blacklight-marc.gemspec +4 -5
  16. data/config/routes.rb +1 -1
  17. data/lib/blacklight/marc/catalog.rb +9 -15
  18. data/lib/blacklight/marc/engine.rb +2 -0
  19. data/lib/blacklight/marc/indexer.rb +5 -41
  20. data/lib/blacklight/marc/indexer/formats.rb +1 -1
  21. data/lib/blacklight/marc/routes.rb +2 -39
  22. data/lib/blacklight/marc/routes/marc_viewable.rb +20 -0
  23. data/lib/blacklight/marc/version.rb +1 -1
  24. data/lib/generators/blacklight/marc/install_generator.rb +15 -8
  25. data/lib/generators/blacklight/marc/templates/app/models/marc_indexer.rb +57 -57
  26. data/lib/generators/blacklight/marc/templates/config/translation_maps/callnumber_map.properties +149 -11
  27. data/lib/railties/solr_marc.rake +33 -33
  28. data/solr/conf/schema.xml +322 -563
  29. data/solr/conf/solrconfig.xml +78 -294
  30. data/spec/controllers/catalog_controller_spec.rb +11 -6
  31. data/spec/features/bookmarks_spec.rb +2 -1
  32. data/spec/features/search_formats_spec.rb +3 -3
  33. data/spec/integration/solr_document_spec.rb +19 -19
  34. data/spec/lib/blacklight_solr_document_marc_spec.rb +7 -7
  35. data/spec/lib/indexer/dewey_spec.rb +4 -4
  36. data/spec/lib/indexer/formats_spec.rb +1 -1
  37. data/spec/lib/marc_export_spec.rb +46 -46
  38. data/spec/lib/tasks/solr_marc_task_spec.rb +7 -7
  39. data/spec/lib/traject_indexer_spec.rb +6 -2
  40. data/spec/routing/routes_spec.rb +0 -6
  41. data/spec/test_app_templates/Gemfile.extra +2 -0
  42. data/spec/test_app_templates/lib/generators/test_app_generator.rb +14 -13
  43. data/spec/views/bookmarks/_endnote.html.erb_spec.rb +16 -6
  44. data/spec/views/bookmarks/_refworks.html.erb_spec.rb +17 -7
  45. data/spec/views/catalog/index.atom.builder_spec.rb +12 -17
  46. data/test_support/config/translation_maps/test_formats.properties +3 -1
  47. metadata +18 -43
  48. data/.travis.yml +0 -21
  49. data/app/helpers/blacklight_bookmarks_helper.rb +0 -3
  50. data/solr/sample_solr_documents.yml +0 -2692
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e5b4577a4b98e98e1980bd542b762839999648a3bb630f74c91c0601d942930
4
- data.tar.gz: 6bfcd917cafe69f71d2585426e2dfff361321c87d832ac046a649a45e5800e7d
3
+ metadata.gz: 67e4c2b3e51422a3801fda3a61fe549e73889f43cdee3571c35368f44f10490e
4
+ data.tar.gz: dec3a61d6f54c91811d37afa6d9a4462255c224c33d1f7a0448d1de3028161ff
5
5
  SHA512:
6
- metadata.gz: f43a53f1aeea6010586d31d3a11412cbcbd66e6f209734fde7501cfca444c894154b9d226d276331d7f8d91c06b9a49253bc35a7f118b25d79d869161114241f
7
- data.tar.gz: 63794ad1115771f67c7e4d736e7e5991987add27ddaa59c250afe2352a64259a4132a374f2acbed700d6439daf6db826b9872d0e91dd61fd5ef268af4aa641a1
6
+ metadata.gz: 57f8a9949505a58970bae0a8aaf9f25a0d46c1d7d80272cf19c8a5ff43aa2833c3676e9f5246dd88c8954d33d6699601ddf463429ae30cb916a762616b7014eb
7
+ data.tar.gz: 959d4dae4de2e8f5378cd7379b3863a1ca70408f9d6e0ba95bed151651ec6bc5b4f052167782caf53f3d1c351e6747f68be5841825888a4be724ee3c02ad1330
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ rails_version: [6.1.1]
15
+ ruby: [2.7, 3.0]
16
+ env:
17
+ RAILS_VERSION: ${{ matrix.rails_version }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby ${{ matrix.ruby }}
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ - name: Install dependencies with Rails ${{ matrix.rails_version }}
25
+ run: bundle install
26
+ - name: Run tests
27
+ run: bundle exec rake
28
+ test_rails52:
29
+ runs-on: ubuntu-latest
30
+ strategy:
31
+ matrix:
32
+ rails_version: [5.2.4.4, 6.0.3.4]
33
+ ruby: [2.7]
34
+ env:
35
+ RAILS_VERSION: ${{ matrix.rails_version }}
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+ - name: Set up Ruby ${{ matrix.ruby }}
39
+ uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: ${{ matrix.ruby }}
42
+ - name: Install dependencies with Rails ${{ matrix.rails_version }}
43
+ run: bundle install
44
+ - name: Run tests
45
+ run: bundle exec rake
File without changes
data/Gemfile CHANGED
@@ -1,5 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
3
8
  # Please see blacklight_marc.gemspec for dependency information.
4
9
  gemspec path: File.expand_path('..', __FILE__)
5
10
 
@@ -28,6 +33,11 @@ else
28
33
  end
29
34
 
30
35
  case ENV['RAILS_VERSION']
36
+ when /^6.0/
37
+ gem 'sass-rails', '>= 6'
38
+ gem 'webpacker', '~> 4.0'
39
+ when /^5.[12]/
40
+ gem 'sass-rails', '~> 5.0'
31
41
  when /^4.2/
32
42
  gem 'responders', '~> 2.0'
33
43
  gem 'sass-rails', '>= 5.0'
@@ -37,3 +47,5 @@ else
37
47
  end
38
48
  end
39
49
  # END ENGINE_CART BLOCK
50
+
51
+ eval_gemfile File.expand_path("spec/test_app_templates/Gemfile.extra", File.dirname(__FILE__))
data/README.md CHANGED
@@ -1,9 +1,15 @@
1
- [![Build Status](https://travis-ci.org/projectblacklight/blacklight_marc.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight_marc)
1
+ [![Build Status](https://travis-ci.org/projectblacklight/blacklight-marc.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight-marc)
2
2
 
3
3
  # Blacklight::Marc
4
4
 
5
5
  MARC-specific enhancements for [Blacklight](https://github.com/projectblacklight/blacklight)
6
6
 
7
+ ## Features
8
+ * Rake task `solr:marc:index` to import .mrc files using Traject and app/models/marc_indexer
9
+ * "Librarian View" at `catalog/:id/librarian_view`
10
+ * Export records to refworks and endnote
11
+ * Blacklight::Solr::Document mixins for exporting and transforming MARC data from a stored Solr field
12
+
7
13
  ## Installation
8
14
 
9
15
  Add this line to your application's Gemfile:
@@ -18,6 +24,27 @@ After running the blacklight generator, run the blacklight_marc generator:
18
24
 
19
25
  $ rails generate blacklight:marc:install
20
26
 
27
+
28
+ ## How does it work?
29
+ This generator injects an include into CatalogController (parent class of BookmarksController):
30
+
31
+ ```ruby
32
+ include Blacklight::Marc::Catalog
33
+ ```
34
+
35
+ and the following code is generated into SolrDocument:
36
+
37
+ ```ruby
38
+ use_extension( Blacklight::Solr::Document::Marc) do |document|
39
+ document.key?( :marc_display )
40
+ end
41
+ ```
42
+
43
+ This means, the extension will be applied on the instance if the backing hash
44
+ has a field called `marc_display`.
45
+
46
+
47
+ ## Indexing
21
48
  The generator will create a model called MarcIndexer. This model can be customized by modifying
22
49
  the field configurations in its initializer as a Traject 2 indexer; new indexing behaviors can
23
50
  be added to it via mixins or inline methods. Two example mixins are provided:
@@ -35,12 +62,6 @@ MarcIndexer
35
62
  end
36
63
  end
37
64
  ```
38
- ## Features
39
- * Rake task `solr:marc:index` to import .mrc files using Traject and app/models/marc_indexer
40
- * Librarian view at `catalog/:id/librarian_view`
41
- * Export records to refworks and endnote
42
- * Blacklight::Solr::Document mixins for exporting and transforming MARC data from a stored Solr field
43
-
44
65
 
45
66
  ## Documentation, Information and Support
46
67
 
@@ -12,6 +12,9 @@ $marc_item_separator: 1px solid $text-muted !default;
12
12
  #marc_view
13
13
  {
14
14
  text-align:left;
15
+ /* https://meyerweb.com/eric/thoughts/2010/02/12/fixed-monospace-sizing/ */
16
+ font-family: "Courier New", monospace, serif;
17
+ font-size: 1em;
15
18
 
16
19
  .field
17
20
  {
@@ -22,7 +25,7 @@ $marc_item_separator: 1px solid $text-muted !default;
22
25
  .ind1, .ind2
23
26
  {
24
27
  display:inline;
25
- padding:0 $padding-xs-horizontal;
28
+ padding: 0 ($spacer / 2);
26
29
  }
27
30
 
28
31
  .subfields
@@ -35,8 +38,3 @@ $marc_item_separator: 1px solid $text-muted !default;
35
38
  float:left;
36
39
  }
37
40
  }
38
-
39
- /* refworks uses a form; we need to give it some additional padding to make it look like a link */
40
- #refworks-form .btn {
41
- padding: $nav-link-padding;
42
- }
@@ -1,18 +1,18 @@
1
1
  module BlacklightMarcHelper
2
2
 
3
3
  # This method should move to BlacklightMarc in Blacklight 6.x
4
- def refworks_export_url params = {}
4
+ def refworks_export_url params = {}, *_
5
5
  "http://www.refworks.com/express/expressimport.asp?vendor=#{CGI.escape(params[:vendor] || application_name)}&filter=#{CGI.escape(params[:filter] || "MARC Format")}&encoding=65001" + (("&url=#{CGI.escape(params[:url])}" if params[:url]) || "")
6
6
  end
7
7
 
8
- def refworks_solr_document_path opts = {}
8
+ def refworks_solr_document_path opts = {}, *_
9
9
  if opts[:id]
10
10
  refworks_export_url(url: solr_document_url(opts[:id], format: :refworks_marc_txt))
11
11
  end
12
12
  end
13
13
 
14
14
  # For exporting a single endnote document. (endnote_catalog_path is defined by blacklight-marc and it is used for multiple document export)
15
- def single_endnote_catalog_path opts = {}
15
+ def single_endnote_catalog_path opts = {}, *_
16
16
  solr_document_path(opts.merge(format: 'endnote'))
17
17
  end
18
18
 
@@ -33,7 +33,8 @@ module BlacklightMarcHelper
33
33
  val = ''
34
34
  documents.each do |doc|
35
35
  if doc.exports_as? :endnote
36
- val += doc.export_as(:endnote) + "\n"
36
+ endnote = doc.export_as(:endnote)
37
+ val += "#{endnote}\n" if endnote
37
38
  end
38
39
  end
39
40
  val
@@ -6,7 +6,7 @@
6
6
  # then provides various transformations/exports of that Marc via the included
7
7
  # Blacklight::Solr::Document::MarcExport module.
8
8
  #
9
- # This extension would normally be registered using
9
+ # This extension would normally be registered using
10
10
  # Blacklight::Solr::Document#use_extension. eg:
11
11
  #
12
12
  # SolrDocument.use_extension( Blacklight::Solr::Document::Marc ) { |document| my_logic_for_document_has_marc?( document ) }
@@ -20,15 +20,15 @@ require 'marc'
20
20
 
21
21
  module Blacklight::Solr::Document::Marc
22
22
 
23
- include Blacklight::Solr::Document::MarcExport # All our export_as stuff based on to_marc.
24
-
23
+ include Blacklight::Solr::Document::MarcExport # All our export_as stuff based on to_marc.
24
+
25
25
  class UnsupportedMarcFormatType < RuntimeError; end
26
-
26
+
27
27
  def self.extended(document)
28
- # Register our exportable formats, we inherit these from MarcExport
28
+ # Register our exportable formats, we inherit these from MarcExport
29
29
  Blacklight::Solr::Document::MarcExport.register_export_formats( document )
30
30
  end
31
-
31
+
32
32
  # ruby-marc object
33
33
  def to_marc
34
34
  @_ruby_marc_obj ||= load_marc
@@ -50,29 +50,30 @@ module Blacklight::Solr::Document::Marc
50
50
  return MARC::Record.new_from_hash( JSON.parse( fetch(_marc_source_field) ) )
51
51
  else
52
52
  raise UnsupportedMarcFormatType.new("Only marcxml, marc21, and json are supported, this documents format is #{_marc_format_type} and the current extension parameters are #{self.class.extension_parameters.inspect}")
53
- end
53
+ end
54
54
  rescue Exception => e
55
55
  raise e if e.is_a? UnsupportedMarcFormatType
56
56
 
57
57
  Rails.logger.error("Blacklight failed to parse MARC record. Exception was: #{e}")
58
+ nil
58
59
  end
59
-
60
+
60
61
  def marc_record_from_marcxml
61
62
  MARC::XMLReader.new(StringIO.new( fetch(_marc_source_field) )).to_a.first
62
63
  end
63
-
64
+
64
65
  def _marc_helper
65
66
  @_marc_helper ||= (
66
67
  Blacklight::Marc::Document.new fetch(_marc_source_field), _marc_format_type )
67
68
  end
68
69
 
69
- def _marc_source_field
70
+ def _marc_source_field
70
71
  self.class.extension_parameters[:marc_source_field]
71
72
  end
72
73
 
73
74
  def _marc_format_type
74
75
  #TODO: Raise if not present
75
- self.class.extension_parameters[:marc_format_type]
76
+ self.class.extension_parameters[:marc_format_type]
76
77
  end
77
-
78
+
78
79
  end
@@ -4,13 +4,13 @@
4
4
  # it for your own custom Blacklight document Marc extension too -- just
5
5
  # include this module in any document extension (or any other class)
6
6
  # that provides a #to_marc returning a ruby-marc object. This module will add
7
- # in export_as translation methods for a variety of formats.
7
+ # in export_as translation methods for a variety of formats.
8
8
  module Blacklight::Solr::Document::MarcExport
9
-
9
+
10
10
  def self.register_export_formats(document)
11
11
  document.will_export_as(:xml)
12
12
  document.will_export_as(:marc, "application/marc")
13
- # marcxml content type:
13
+ # marcxml content type:
14
14
  # http://tools.ietf.org/html/draft-denenberg-mods-etc-media-types-00
15
15
  document.will_export_as(:marcxml, "application/marcxml+xml")
16
16
  document.will_export_as(:openurl_ctx_kev, "application/x-openurl-ctx-kev")
@@ -27,20 +27,20 @@ module Blacklight::Solr::Document::MarcExport
27
27
  to_marc.to_xml.to_s
28
28
  end
29
29
  alias_method :export_as_xml, :export_as_marcxml
30
-
31
-
30
+
31
+
32
32
  # TODO This exporting as formatted citation thing should be re-thought
33
33
  # redesigned at some point to be more general purpose, but this
34
34
  # is in-line with what we had before, but at least now attached
35
- # to the document extension where it belongs.
35
+ # to the document extension where it belongs.
36
36
  def export_as_apa_citation_txt
37
37
  apa_citation( to_marc )
38
38
  end
39
-
39
+
40
40
  def export_as_mla_citation_txt
41
41
  mla_citation( to_marc )
42
42
  end
43
-
43
+
44
44
  def export_as_chicago_citation_txt
45
45
  chicago_citation( to_marc )
46
46
  end
@@ -52,8 +52,8 @@ module Blacklight::Solr::Document::MarcExport
52
52
  # more sensibly. The "format" argument was in the old marc.marc.to_zotero
53
53
  # call, but didn't neccesarily do what it thought it did anyway. Left in
54
54
  # for now for backwards compatibilty, but should be replaced by
55
- # just ruby OpenURL.
56
- def export_as_openurl_ctx_kev(format = nil)
55
+ # just ruby OpenURL.
56
+ def export_as_openurl_ctx_kev(format = nil)
57
57
  title = to_marc.find{|field| field.tag == '245'}
58
58
  author = to_marc.find{|field| field.tag == '100'}
59
59
  corp_author = to_marc.find{|field| field.tag == '110'}
@@ -100,11 +100,13 @@ module Blacklight::Solr::Document::MarcExport
100
100
 
101
101
  # This format used to be called 'refworks', which wasn't really
102
102
  # accurate, sounds more like 'refworks tagged format'. Which this
103
- # is not, it's instead some weird under-documented Refworks
103
+ # is not, it's instead some weird under-documented Refworks
104
104
  # proprietary marc-ish in text/plain format. See
105
- # http://robotlibrarian.billdueber.com/sending-marcish-data-to-refworks/
105
+ # http://robotlibrarian.billdueber.com/2009/05/sending-marcish-data-to-refworks/
106
106
  def export_as_refworks_marc_txt
107
- fields = to_marc.find_all { |f| ('000'..'999') === f.tag }
107
+ marc_obj = to_marc
108
+ return unless marc_obj
109
+ fields = marc_obj.find_all { |f| ('000'..'999') === f.tag }
108
110
  text = "LEADER #{to_marc.leader}"
109
111
  fields.each do |field|
110
112
  unless ["940","999"].include?(field.tag)
@@ -124,10 +126,8 @@ module Blacklight::Solr::Document::MarcExport
124
126
  # As of 11 May 2010, Refworks has a problem with UTF-8 if it's decomposed,
125
127
  # it seems to want C form normalization, although RefWorks support
126
128
  # couldn't tell me that. -jrochkind
127
- text = ActiveSupport::Multibyte::Unicode.normalize(text, :c)
128
-
129
- return text
130
- end
129
+ text.unicode_normalize(:nfc)
130
+ end
131
131
 
132
132
  # Endnote Import Format. See the EndNote User Guide at:
133
133
  # http://www.endnote.com/support/enx3man-terms-win.asp
@@ -138,7 +138,7 @@ module Blacklight::Solr::Document::MarcExport
138
138
  # endnote import format; the %0 is likely to be entirely illegal, the
139
139
  # rest of the data is barely correct but messy. TODO, a new version of this,
140
140
  # or better yet just an export_as_ris instead, which will be more general
141
- # purpose.
141
+ # purpose.
142
142
  def export_as_endnote()
143
143
  end_note_format = {
144
144
  "%A" => "100.a",
@@ -154,10 +154,12 @@ module Blacklight::Solr::Document::MarcExport
154
154
  "%7" => "250.a"
155
155
  }
156
156
  marc_obj = to_marc
157
+ return unless marc_obj
158
+
157
159
  # TODO. This should be rewritten to guess
158
160
  # from actual Marc instead, probably.
159
161
  format_str = 'Generic'
160
-
162
+
161
163
  text = ''
162
164
  text << "%0 #{ format_str }\n"
163
165
  # If there is some reliable way of getting the language of a record we can add it here
@@ -170,7 +172,7 @@ module Blacklight::Solr::Document::MarcExport
170
172
  else
171
173
  second_value = []
172
174
  end
173
-
175
+
174
176
  if marc_obj[first_value[0].to_s]
175
177
  marc_obj.find_all{|f| (first_value[0].to_s) === f.tag}.each do |field|
176
178
  if field[first_value[1]].to_s or field[second_value[1]].to_s
@@ -190,11 +192,11 @@ module Blacklight::Solr::Document::MarcExport
190
192
  end
191
193
 
192
194
  protected
193
-
195
+
194
196
  # Main method for defining chicago style citation. If we don't end up converting to using a citation formatting service
195
197
  # we should make this receive a semantic document and not MARC so we can use this with other formats.
196
198
  def chicago_citation(marc)
197
- authors = get_all_authors(marc)
199
+ authors = get_all_authors(marc)
198
200
  author_text = ""
199
201
  unless authors[:primary_authors].blank?
200
202
  if authors[:primary_authors].length > 10
@@ -226,7 +228,7 @@ module Blacklight::Solr::Document::MarcExport
226
228
  author_text << "and #{name_reverse(author)}."
227
229
  else
228
230
  author_text << "#{name_reverse(author)}, "
229
- end
231
+ end
230
232
  end
231
233
  else
232
234
  author_text << authors[:primary_authors].first
@@ -242,7 +244,7 @@ module Blacklight::Solr::Document::MarcExport
242
244
  authors[:compilers].each do |compiler|
243
245
  temp_authors << [compiler, "comp."]
244
246
  end
245
-
247
+
246
248
  unless temp_authors.blank?
247
249
  if temp_authors.length > 10
248
250
  temp_authors.each_with_index do |author,index|
@@ -281,18 +283,18 @@ module Blacklight::Solr::Document::MarcExport
281
283
  section_title << "."
282
284
  end
283
285
  end
284
-
286
+
285
287
  if !authors[:primary_authors].blank? and (!authors[:translators].blank? or !authors[:editors].blank? or !authors[:compilers].blank?)
286
288
  additional_title << "Translated by #{authors[:translators].collect{|name| name_reverse(name)}.join(" and ")}. " unless authors[:translators].blank?
287
289
  additional_title << "Edited by #{authors[:editors].collect{|name| name_reverse(name)}.join(" and ")}. " unless authors[:editors].blank?
288
290
  additional_title << "Compiled by #{authors[:compilers].collect{|name| name_reverse(name)}.join(" and ")}. " unless authors[:compilers].blank?
289
291
  end
290
-
292
+
291
293
  edition = ""
292
294
  edition << setup_edition(marc) unless setup_edition(marc).nil?
293
-
295
+
294
296
  pub_info = ""
295
- if marc["260"] and (marc["260"]["a"] or marc["260"]["b"])
297
+ if marc["260"] and (marc["260"]["a"] or marc["260"]["b"])
296
298
  pub_info << clean_end_punctuation(marc["260"]["a"]).strip if marc["260"]["a"]
297
299
  pub_info << ": #{clean_end_punctuation(marc["260"]["b"]).strip}" if marc["260"]["b"]
298
300
  pub_info << ", #{setup_pub_date(marc)}" if marc["260"]["c"]
@@ -301,7 +303,7 @@ module Blacklight::Solr::Document::MarcExport
301
303
  elsif marc["502"] and (marc["502"]["b"] or marc["502"]["c"] or marc["502"]["d"]) #sometimes the dissertation note is encoded in pieces in the $b $c and $d sub fields instead of lumped into the $a
302
304
  pub_info << "#{marc["502"]["b"]}, #{marc["502"]["c"]}, #{clean_end_punctuation(marc["502"]["d"])}"
303
305
  end
304
-
306
+
305
307
  citation = ""
306
308
  citation << "#{author_text} " unless author_text.blank?
307
309
  citation << "<i>#{title}.</i> " unless title.blank?
@@ -311,13 +313,13 @@ module Blacklight::Solr::Document::MarcExport
311
313
  citation << "#{pub_info}." unless pub_info.blank?
312
314
  citation
313
315
  end
314
-
315
-
316
-
316
+
317
+
318
+
317
319
  def mla_citation(record)
318
320
  text = ''
319
321
  authors_final = []
320
-
322
+
321
323
  #setup formatted author list
322
324
  authors = get_author_list(record)
323
325
 
@@ -351,10 +353,10 @@ module Blacklight::Solr::Document::MarcExport
351
353
  # Edition
352
354
  edition_data = setup_edition(record)
353
355
  text += edition_data + " " unless edition_data.nil?
354
-
356
+
355
357
  # Publication
356
358
  text += setup_pub_info(record) + ", " unless setup_pub_info(record).nil?
357
-
359
+
358
360
  # Get Pub Date
359
361
  text += setup_pub_date(record) unless setup_pub_date(record).nil?
360
362
  if text[-1,1] != "."
@@ -367,7 +369,7 @@ module Blacklight::Solr::Document::MarcExport
367
369
  text = ''
368
370
  authors_list = []
369
371
  authors_list_final = []
370
-
372
+
371
373
  #setup formatted author list
372
374
  authors = get_author_list(record)
373
375
  authors.each do |l|
@@ -392,15 +394,15 @@ module Blacklight::Solr::Document::MarcExport
392
394
  end
393
395
  # Get Pub Date
394
396
  text += "(" + setup_pub_date(record) + "). " unless setup_pub_date(record).nil?
395
-
397
+
396
398
  # setup title info
397
399
  title = setup_title_info(record)
398
400
  text += "<i>" + title + "</i> " unless title.nil?
399
-
401
+
400
402
  # Edition
401
403
  edition_data = setup_edition(record)
402
404
  text += edition_data + " " unless edition_data.nil?
403
-
405
+
404
406
  # Publisher info
405
407
  text += setup_pub_info(record) unless setup_pub_info(record).nil?
406
408
  unless text.blank?
@@ -451,7 +453,7 @@ module Blacklight::Solr::Document::MarcExport
451
453
  end
452
454
  new_text.join(" ")
453
455
  end
454
-
456
+
455
457
  # This will replace the mla_citation_title method with a better understanding of how MLA and Chicago citation titles are formatted.
456
458
  # This method will take in a string and capitalize all of the non-prepositions.
457
459
  def citation_title(title_text)
@@ -482,18 +484,18 @@ module Blacklight::Solr::Document::MarcExport
482
484
  end
483
485
  text += b_title_info unless b_title_info.nil?
484
486
  end
485
-
487
+
486
488
  return nil if text.strip.blank?
487
489
  clean_end_punctuation(text.strip) + "."
488
-
490
+
489
491
  end
490
-
492
+
491
493
  def clean_end_punctuation(text)
492
494
  if [".",",",":",";","/"].include? text[-1,1]
493
495
  return text[0,text.length-1]
494
496
  end
495
497
  text
496
- end
498
+ end
497
499
 
498
500
  def setup_edition(record)
499
501
  edition_field = record.find{|f| f.tag == '250'}
@@ -503,9 +505,9 @@ module Blacklight::Solr::Document::MarcExport
503
505
  return nil
504
506
  else
505
507
  return edition_data
506
- end
508
+ end
507
509
  end
508
-
510
+
509
511
  def get_author_list(record)
510
512
  author_list = []
511
513
  authors_primary = record.find{|f| f.tag == '100'}
@@ -517,11 +519,11 @@ module Blacklight::Solr::Document::MarcExport
517
519
  author_list.push(clean_end_punctuation(l.find{|s| s.code == 'a'}.value)) unless l.find{|s| s.code == 'a'}.value.nil?
518
520
  end
519
521
  end
520
-
522
+
521
523
  author_list.uniq!
522
524
  author_list
523
525
  end
524
-
526
+
525
527
  # This is a replacement method for the get_author_list method. This new method will break authors out into primary authors, translators, editors, and compilers
526
528
  def get_all_authors(record)
527
529
  translator_code = "trl"; editor_code = "edt"; compiler_code = "com"
@@ -547,7 +549,7 @@ module Blacklight::Solr::Document::MarcExport
547
549
  end
548
550
  {:primary_authors => primary_authors, :translators => translators, :editors => editors, :compilers => compilers}
549
551
  end
550
-
552
+
551
553
  def abbreviate_name(name)
552
554
  name_parts = name.split(", ")
553
555
  first_name_parts = name_parts.last.split(" ")
@@ -562,6 +564,5 @@ module Blacklight::Solr::Document::MarcExport
562
564
  return name unless name =~ /,/
563
565
  temp_name = name.split(", ")
564
566
  return temp_name.last + " " + temp_name.first
565
- end
566
-
567
- end
567
+ end
568
+ end