blacklight-marc 6.3.0 → 7.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/{.solr_wrapper.yml → .solr_wrapper.yaml} +0 -0
  3. data/.travis.yml +3 -1
  4. data/Gemfile +7 -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 +2 -1
  8. data/app/models/concerns/blacklight/solr/document/marc.rb +13 -12
  9. data/app/models/concerns/blacklight/solr/document/marc_export.rb +53 -50
  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 +7 -5
  16. data/config/routes.rb +1 -1
  17. data/lib/blacklight/marc/catalog.rb +9 -15
  18. data/lib/blacklight/marc/indexer.rb +5 -41
  19. data/lib/blacklight/marc/indexer/formats.rb +1 -1
  20. data/lib/blacklight/marc/routes.rb +2 -39
  21. data/lib/blacklight/marc/routes/marc_viewable.rb +20 -0
  22. data/lib/blacklight/marc/version.rb +1 -1
  23. data/lib/generators/blacklight/marc/install_generator.rb +15 -8
  24. data/lib/generators/blacklight/marc/templates/app/models/marc_indexer.rb +57 -57
  25. data/lib/generators/blacklight/marc/templates/config/translation_maps/callnumber_map.properties +149 -11
  26. data/lib/railties/solr_marc.rake +33 -33
  27. data/solr/conf/schema.xml +321 -560
  28. data/solr/conf/solrconfig.xml +78 -294
  29. data/spec/controllers/catalog_controller_spec.rb +11 -6
  30. data/spec/features/bookmarks_spec.rb +2 -1
  31. data/spec/features/search_formats_spec.rb +3 -3
  32. data/spec/integration/solr_document_spec.rb +19 -19
  33. data/spec/lib/blacklight_solr_document_marc_spec.rb +7 -7
  34. data/spec/lib/indexer/dewey_spec.rb +4 -4
  35. data/spec/lib/indexer/formats_spec.rb +1 -1
  36. data/spec/lib/marc_export_spec.rb +46 -46
  37. data/spec/lib/tasks/solr_marc_task_spec.rb +7 -7
  38. data/spec/lib/traject_indexer_spec.rb +6 -2
  39. data/spec/routing/routes_spec.rb +0 -6
  40. data/spec/test_app_templates/Gemfile.extra +2 -0
  41. data/spec/test_app_templates/lib/generators/test_app_generator.rb +14 -13
  42. data/spec/views/bookmarks/_endnote.html.erb_spec.rb +16 -6
  43. data/spec/views/bookmarks/_refworks.html.erb_spec.rb +17 -7
  44. data/spec/views/catalog/index.atom.builder_spec.rb +12 -17
  45. data/test_support/config/translation_maps/test_formats.properties +3 -1
  46. metadata +23 -27
  47. data/app/helpers/blacklight_bookmarks_helper.rb +0 -3
  48. data/solr/sample_solr_documents.yml +0 -2692
@@ -1,4 +1,4 @@
1
- <% if @document_list.any? {|d| d.exports_as? :endnote } %>
1
+ <% if @response.documents.any? {|d| d.exports_as? :endnote } %>
2
2
  <li class="endnote">
3
3
  <%= link_to t('blacklight.tools.endnote'), bookmarks_path(:endnote, search_state.params_for_search), :class => "btn btn-default", :id => "endnoteLink" %>
4
4
  </li>
@@ -1,4 +1,4 @@
1
- <% if @document_list.any? {|d| d.exports_as? :refworks_marc_txt } %>
1
+ <% if @response.documents.any? {|d| d.exports_as? :refworks_marc_txt } %>
2
2
  <li class="refworks">
3
3
  <%= link_to t('blacklight.tools.refworks'), refworks_export_url(url: bookmarks_export_url(:refworks_marc_txt, search_state.params_for_search)), :class => "btn btn-default", :id => "refworksLink" %>
4
4
  </li>
@@ -1,6 +1,6 @@
1
1
  <div id="marc_view" class="modal-body">
2
- <% fields = @document.to_marc.find_all{|f| ('000'..'999') === f.tag } %>
3
- <div class="field"><%= t('blacklight.search.librarian_view.leader', :leader => @document.to_marc.leader) %></div>
2
+ <% fields = document.to_marc.find_all{|f| ('000'..'999') === f.tag } %>
3
+ <div class="field"><%= t('blacklight.search.librarian_view.leader', :leader => document.to_marc.leader) %></div>
4
4
  <%- fields.each do |field| -%>
5
5
  <%- unless field.tag.to_s == "940" -%>
6
6
  <div class="field">
@@ -14,10 +14,10 @@
14
14
  </span>
15
15
  <%- else -%>
16
16
  <div class="ind1">
17
- <%= !field.indicator1.blank? ? field.indicator1 : "&nbsp;&nbsp;".html_safe -%>
17
+ <%= !field.indicator1.blank? ? field.indicator1 : "&nbsp;".html_safe -%>
18
18
  </div>
19
19
  <div class="ind2">
20
- <%= !field.indicator2.blank? ? field.indicator2 : "&nbsp;&nbsp;".html_safe -%>
20
+ <%= !field.indicator2.blank? ? field.indicator2 : "&nbsp;".html_safe -%>
21
21
  </div>
22
22
  </div>
23
23
  <div class="subfields">
@@ -1 +1 @@
1
- <%= render_endnote_texts(@documents) %>
1
+ <%= render_endnote_texts(@response.documents) %>
@@ -1,10 +1,13 @@
1
1
 
2
2
  <div class="modal-header">
3
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
4
- <h3 class="modal-title"><%= t('blacklight.search.librarian_view.title') %></h3>
3
+ <h1 class="modal-title"><%= t('blacklight.search.librarian_view.title') %></h1>
4
+ <button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="Close">
5
+ <span aria-hidden="true">×</span>
6
+ </button>
5
7
  </div>
6
- <%- if @document.respond_to?(:to_marc) -%>
7
- <%= render "marc_view" %>
8
+ <%- if @response.documents.first.respond_to?(:to_marc) -%>
9
+ <%= render "marc_view", document: @response.documents.first %>
8
10
  <%- else %>
9
11
  <%= t('blacklight.search.librarian_view.empty') %>
10
12
  <%- end -%>
13
+
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = %q{MARC support for Blacklight}
11
11
  spec.summary = %q{MARC support for Blacklight}
12
12
  spec.homepage = "https://github.com/projectblacklight/blacklight-marc"
13
- spec.license = "Apache 2.0"
13
+ spec.license = "Apache-2.0"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
@@ -18,14 +18,16 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'blacklight', '> 6.1', '< 8.a'
21
+ spec.add_dependency 'blacklight', '> 7.0.0.a', '< 8.a'
22
22
  spec.add_dependency "library_stdnums"
23
23
  spec.add_dependency "rails"
24
- spec.add_dependency "marc", ">= 0.4.3", "< 2.0" # Marc record parser.
25
- spec.add_dependency "traject", ">= 2.1", "< 4"
24
+ # Let's allow future versions of marc, count on
25
+ # them to be backwards compat until 1.1
26
+ spec.add_dependency "marc", ">= 0.4.3", "< 1.1" # Marc record parser.
27
+ spec.add_dependency "traject", "~>3.0"
26
28
  spec.add_dependency 'marc-fastxmlwriter' # NO REXML
27
29
 
28
- spec.add_development_dependency "bundler"
30
+ spec.add_development_dependency "bundler", "~> 1.3"
29
31
  spec.add_development_dependency "rake"
30
32
  spec.add_development_dependency "rspec-rails", '~> 3.0'
31
33
  spec.add_development_dependency "rspec-activemodel-mocks"
data/config/routes.rb CHANGED
@@ -9,7 +9,7 @@ Rails.application.routes.draw do
9
9
  #
10
10
  # These routes can be injected into your Rails application by adding
11
11
  # Blacklight.add_routes(self)
12
- # to the application's ./config/routes.rb. The injected routes can be
12
+ # to the application's ./config/routes.rb. The injected routes can be
13
13
  # customized as well, e.g.:
14
14
  # Blacklight.add_routes(self, :only => [:bookmarks]) # will only look bookmark routes
15
15
  # Blacklight.add_routes(self, :except => [:catalog]) # will not load catalog routes
@@ -3,25 +3,19 @@ module Blacklight::Marc
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- add_show_tools_partial(:librarian_view, if: :render_librarian_view_control?, define_method: false)
7
- add_show_tools_partial(:refworks, if: :render_refworks_action?, modal: false)
8
- add_show_tools_partial(:endnote, if: :render_endnote_action?, modal: false, path: :single_endnote_catalog_path, define_method: false)
6
+ blacklight_config.add_show_tools_partial(:librarian_view, if: :render_librarian_view_control?, define_method: false)
7
+ blacklight_config.add_show_tools_partial(:refworks, if: :render_refworks_action?, modal: false)
8
+ blacklight_config.add_show_tools_partial(:endnote, if: :render_endnote_action?, modal: false, path: :single_endnote_catalog_path, define_method: false)
9
9
  end
10
10
 
11
11
  def librarian_view
12
- @response, @document = fetch params[:id]
13
-
14
- respond_to do |format|
15
- format.html
16
- format.js { render :layout => false }
17
- end
18
- end
19
-
20
- # grabs a bunch of documents to export to endnote
21
- def endnote
22
- @response, @documents = fetch(Array(params[:id]))
12
+ @response, deprecated_document = search_service.fetch params[:id]
13
+ @document = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_document, "The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0")
23
14
  respond_to do |format|
24
- format.endnote { render :layout => false }
15
+ format.html do
16
+ return render layout: false if request.xhr?
17
+ # Otherwise draw the full page
18
+ end
25
19
  end
26
20
  end
27
21
 
@@ -1,5 +1,6 @@
1
1
  require 'library_stdnums'
2
- require 'traject/null_writer'
2
+ require 'traject'
3
+ require 'traject/null_writer'
3
4
  require 'traject/macros/marc21_semantics'
4
5
 
5
6
  require 'traject/macros/marc_format_classifier'
@@ -8,12 +9,6 @@ require 'traject/solr_json_writer'
8
9
  require 'traject/marc_reader'
9
10
  require 'marc/fastxmlwriter'
10
11
 
11
- unless defined?(Traject::Indexer::MarcIndexer)
12
- # shim to get traject 2 to act like traject 3
13
- class Traject::Indexer::MarcIndexer < Traject::Indexer
14
- end
15
- end
16
-
17
12
  class Blacklight::Marc::Indexer < Traject::Indexer::MarcIndexer
18
13
  autoload :Dewey, 'blacklight/marc/indexer/dewey'
19
14
  autoload :Formats, 'blacklight/marc/indexer/formats'
@@ -40,44 +35,13 @@ class Blacklight::Marc::Indexer < Traject::Indexer::MarcIndexer
40
35
  provide "log.batch_size", 10_000
41
36
  end
42
37
  end
43
- def first_value block, options={}
44
- lambda do |record, accumulator|
45
- if block.arity == 3
46
- block.call(record,accumulator,options)
47
- else
48
- block.call(record,accumulator)
49
- end
50
- accumulator.replace Array(accumulator[0]) # just take the first
51
- end
52
- end
53
- def map_value block, options={}
54
- if translation_map_arg = options.delete(:translation_map)
55
- translation_map = Traject::TranslationMap.new(translation_map_arg)
56
- else
57
- translation_map = nil
58
- end
59
- lambda do |record, accumulator|
60
- if block.arity == 3
61
- block.call(record,accumulator,options)
62
- else
63
- block.call(record,accumulator)
64
- end
65
- if translation_map
66
- translation_map.translate_array! accumulator
67
- end
68
- end
69
- end
70
- def trim block, options={}
38
+
39
+ def trim
71
40
  lambda do |record, accumulator|
72
- vals = []
73
- if block.arity == 3
74
- block.call(record,accumulator,options)
75
- else
76
- block.call(record,accumulator)
77
- end
78
41
  accumulator.each {|x| x.strip!}
79
42
  end
80
43
  end
44
+
81
45
  def get_xml options={}
82
46
  lambda do |record, accumulator|
83
47
  accumulator << MARC::FastXMLWriter.encode(record)
@@ -137,7 +137,7 @@ module Blacklight::Marc::Indexer::Formats
137
137
  when (f_000.start_with? 'A')
138
138
  if f_000 == 'AM'
139
139
  vals << ((field007hasC) ? "eBook" : "Book")
140
- elsif f_000 == 'AS'
140
+ elsif f_000 == 'AS'
141
141
  # Look in 008 to determine what type of Continuing Resource
142
142
  format_code = Traject::Macros::Marc21.extract_marc_from(record, "008[21]", first: true, default: "").first.upcase
143
143
  if format_code == 'N'
@@ -1,43 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Blacklight::Marc
3
- class Routes
4
-
5
- def initialize(router, options)
6
- @router = router
7
- @options = options
8
- end
9
-
10
- def draw
11
- route_sets.each do |r|
12
- self.send(r)
13
- end
14
- end
15
-
16
- protected
17
-
18
- def add_routes &blk
19
- @router.instance_exec(@options, &blk)
20
- end
21
-
22
- def route_sets
23
- (@options[:only] || default_route_sets) - (@options[:except] || [])
24
- end
25
-
26
- def default_route_sets
27
- [:catalog]
28
- end
29
-
30
- module RouteSets
31
- def catalog
32
- add_routes do |options|
33
- # Catalog stuff.
34
- get 'catalog/:id/librarian_view', :to => "catalog#librarian_view", :as => "librarian_view_solr_document"
35
- get "catalog/endnote", :as => "endnote_solr_document"
36
-
37
- end
38
- end
39
- end
40
-
41
- include RouteSets
3
+ module Routes
4
+ require 'blacklight/marc/routes/marc_viewable'
42
5
  end
43
6
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module Blacklight
3
+ module Marc
4
+ module Routes
5
+ class MarcViewable
6
+ def initialize(defaults = {})
7
+ @defaults = defaults
8
+ end
9
+
10
+ def call(mapper, options = {})
11
+ options = @defaults.merge(options)
12
+
13
+ mapper.member do
14
+ mapper.match 'librarian_view', via: :get
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Marc
3
- VERSION = '6.3.0'
3
+ VERSION = '7.0.0.rc1'
4
4
  end
5
5
  end
@@ -36,18 +36,18 @@ EOF
36
36
  def add_marc_extension_to_solrdocument
37
37
 
38
38
  insert_into_file "app/models/solr_document.rb", :after => "include Blacklight::Solr::Document" do <<EOF
39
-
39
+
40
40
  # The following shows how to setup this blacklight document to display marc documents
41
- extension_parameters[:marc_source_field] = :marc_display
41
+ extension_parameters[:marc_source_field] = :marc_ss
42
42
  extension_parameters[:marc_format_type] = :marcxml
43
43
  use_extension( Blacklight::Solr::Document::Marc) do |document|
44
- document.key?( :marc_display )
44
+ document.key?( SolrDocument.extension_parameters[:marc_source_field] )
45
45
  end
46
46
 
47
47
  field_semantics.merge!(
48
- :title => "title_display",
49
- :author => "author_display",
50
- :language => "language_facet",
48
+ :title => "title_ssm",
49
+ :author => "author_ssm",
50
+ :language => "language_ssim",
51
51
  :format => "format"
52
52
  )
53
53
 
@@ -56,7 +56,7 @@ EOF
56
56
  end
57
57
 
58
58
  # Add MARC behaviors to the catalog controller
59
- def inject_blacklight_controller_behavior
59
+ def inject_blacklight_controller_behavior
60
60
  inject_into_file "app/controllers/catalog_controller.rb", after:"include Blacklight::Catalog" do
61
61
  "\n include Blacklight::Marc::Catalog\n"
62
62
  end
@@ -64,7 +64,14 @@ EOF
64
64
 
65
65
 
66
66
  def inject_blacklight_marc_routes
67
- route('Blacklight::Marc.add_routes(self)')
67
+ route <<-EOF
68
+ concern :marc_viewable, Blacklight::Marc::Routes::MarcViewable.new
69
+ EOF
70
+
71
+ inject_into_file "config/routes.rb", after: "resources :solr_documents, only: [:show], path: '/catalog', controller: 'catalog' do" do
72
+ "\n concerns [:exportable, :marc_viewable]\nINJECT_FLAG"
73
+ end
74
+ gsub_file "config/routes.rb", /[\n]INJECT_FLAG\s+concerns \:exportable/,""
68
75
  end
69
76
 
70
77
  end
@@ -13,39 +13,38 @@ class MarcIndexer < Blacklight::Marc::Indexer
13
13
  provide 'solr_writer.max_skipped', -1
14
14
  end
15
15
 
16
- to_field "id", trim(extract_marc("001"), :first => true)
17
- to_field 'marc_display', get_xml
18
- to_field "text", extract_all_marc_values do |r, acc|
16
+ to_field "id", extract_marc("001"), trim, first_only
17
+ to_field 'marc_ss', get_xml
18
+ to_field "all_text_timv", extract_all_marc_values do |r, acc|
19
19
  acc.replace [acc.join(' ')] # turn it into a single string
20
20
  end
21
-
22
- to_field "language_facet", marc_languages("008[35-37]:041a:041d:")
21
+
22
+ to_field "language_ssim", marc_languages("008[35-37]:041a:041d:")
23
23
  to_field "format", get_format
24
- to_field "isbn_t", extract_marc('020a', :separator=>nil) do |rec, acc|
24
+ to_field "isbn_tsim", extract_marc('020a', separator: nil) do |rec, acc|
25
25
  orig = acc.dup
26
26
  acc.map!{|x| StdNum::ISBN.allNormalizedValues(x)}
27
27
  acc << orig
28
28
  acc.flatten!
29
29
  acc.uniq!
30
30
  end
31
-
32
- to_field 'material_type_display', extract_marc('300a', :trim_punctuation => true)
33
-
31
+
32
+ to_field 'material_type_ssm', extract_marc('300a'), trim_punctuation
33
+
34
34
  # Title fields
35
35
  # primary title
36
-
37
- to_field 'title_t', extract_marc('245a')
38
- to_field 'title_display', extract_marc('245a', :trim_punctuation => true, :alternate_script=>false)
39
- to_field 'title_vern_display', extract_marc('245a', :trim_punctuation => true, :alternate_script=>:only)
40
-
36
+ to_field 'title_tsim', extract_marc('245a')
37
+ to_field 'title_ssm', extract_marc('245a', alternate_script: false), trim_punctuation
38
+ to_field 'title_vern_ssm', extract_marc('245a', alternate_script: :only), trim_punctuation
39
+
41
40
  # subtitle
42
-
43
- to_field 'subtitle_t', extract_marc('245b')
44
- to_field 'subtitle_display', extract_marc('245b', :trim_punctuation => true, :alternate_script=>false)
45
- to_field 'subtitle_vern_display', extract_marc('245b', :trim_punctuation => true, :alternate_script=>:only)
46
-
41
+
42
+ to_field 'subtitle_tsim', extract_marc('245b')
43
+ to_field 'subtitle_ssm', extract_marc('245b', alternate_script: false), trim_punctuation
44
+ to_field 'subtitle_vern_ssm', extract_marc('245b', alternate_script: :only), trim_punctuation
45
+
47
46
  # additional title fields
48
- to_field 'title_addl_t',
47
+ to_field 'title_addl_tsim',
49
48
  extract_marc(%W{
50
49
  245abnps
51
50
  130#{ATOZ}
@@ -57,31 +56,31 @@ class MarcIndexer < Blacklight::Marc::Indexer
57
56
  246abcdefgnp
58
57
  247abcdefgnp
59
58
  }.join(':'))
60
-
61
- to_field 'title_added_entry_t', extract_marc(%W{
59
+
60
+ to_field 'title_added_entry_tsim', extract_marc(%W{
62
61
  700gklmnoprst
63
62
  710fgklmnopqrst
64
63
  711fgklnpst
65
64
  730abcdefgklmnopqrst
66
65
  740anp
67
66
  }.join(':'))
68
-
69
- to_field 'title_series_t', extract_marc("440anpv:490av")
70
-
71
- to_field 'title_sort', marc_sortable_title
72
-
67
+
68
+ to_field 'title_series_tsim', extract_marc("440anpv:490av")
69
+
70
+ to_field 'title_si', marc_sortable_title
71
+
73
72
  # Author fields
74
-
75
- to_field 'author_t', extract_marc("100abcegqu:110abcdegnu:111acdegjnqu")
76
- to_field 'author_addl_t', extract_marc("700abcegqu:710abcdegnu:711acdegjnqu")
77
- to_field 'author_display', extract_marc("100abcdq:110#{ATOZ}:111#{ATOZ}", :alternate_script=>false)
78
- to_field 'author_vern_display', extract_marc("100abcdq:110#{ATOZ}:111#{ATOZ}", :alternate_script=>:only)
79
-
73
+
74
+ to_field 'author_tsim', extract_marc("100abcegqu:110abcdegnu:111acdegjnqu")
75
+ to_field 'author_addl_tsim', extract_marc("700abcegqu:710abcdegnu:711acdegjnqu")
76
+ to_field 'author_ssm', extract_marc("100abcdq:110#{ATOZ}:111#{ATOZ}", alternate_script: false)
77
+ to_field 'author_vern_ssm', extract_marc("100abcdq:110#{ATOZ}:111#{ATOZ}", alternate_script: :only)
78
+
80
79
  # JSTOR isn't an author. Try to not use it as one
81
- to_field 'author_sort', marc_sortable_author
82
-
80
+ to_field 'author_si', marc_sortable_author
81
+
83
82
  # Subject fields
84
- to_field 'subject_t', extract_marc(%W(
83
+ to_field 'subject_tsim', extract_marc(%W(
85
84
  600#{ATOU}
86
85
  610#{ATOU}
87
86
  611#{ATOU}
@@ -90,38 +89,39 @@ class MarcIndexer < Blacklight::Marc::Indexer
90
89
  651ae
91
90
  653a:654abcde:655abc
92
91
  ).join(':'))
93
- to_field 'subject_addl_t', extract_marc("600vwxyz:610vwxyz:611vwxyz:630vwxyz:650vwxyz:651vwxyz:654vwxyz:655vwxyz")
94
- to_field 'subject_topic_facet', extract_marc("600abcdq:610ab:611ab:630aa:650aa:653aa:654ab:655ab", :trim_punctuation => true)
95
- to_field 'subject_era_facet', extract_marc("650y:651y:654y:655y", :trim_punctuation => true)
96
- to_field 'subject_geo_facet', extract_marc("651a:650z",:trim_punctuation => true )
97
-
92
+ to_field 'subject_addl_tsim', extract_marc("600vwxyz:610vwxyz:611vwxyz:630vwxyz:650vwxyz:651vwxyz:654vwxyz:655vwxyz")
93
+ to_field 'subject_ssim', extract_marc("600abcdq:610ab:611ab:630aa:650aa:653aa:654ab:655ab"), trim_punctuation
94
+ to_field 'subject_era_ssim', extract_marc("650y:651y:654y:655y"), trim_punctuation
95
+ to_field 'subject_geo_ssim', extract_marc("651a:650z"), trim_punctuation
96
+
98
97
  # Publication fields
99
- to_field 'published_display', extract_marc('260a', :trim_punctuation => true, :alternate_script=>false)
100
- to_field 'published_vern_display', extract_marc('260a', :trim_punctuation => true, :alternate_script=>:only)
101
- to_field 'pub_date', marc_publication_date
102
-
98
+ to_field 'published_ssm', extract_marc('260a', alternate_script: false), trim_punctuation
99
+ to_field 'published_vern_ssm', extract_marc('260a', alternate_script: :only), trim_punctuation
100
+ to_field 'pub_date_si', marc_publication_date
101
+ to_field 'pub_date_ssim', marc_publication_date
102
+
103
103
  # Call Number fields
104
- to_field 'lc_callnum_display', extract_marc('050ab', :first => true)
105
- to_field 'lc_1letter_facet', extract_marc('050ab', :first=>true, :translation_map=>'callnumber_map') do |rec, acc|
106
- # Just get the first letter to send to the translation map
107
- acc.map!{|x| x[0]}
108
- end
104
+ to_field 'lc_callnum_ssm', extract_marc('050ab'), first_only
105
+
106
+ first_letter = lambda {|rec, acc| acc.map!{|x| x[0]} }
107
+ to_field 'lc_1letter_ssim', extract_marc('050ab'), first_only, first_letter, translation_map('callnumber_map')
109
108
 
110
109
  alpha_pat = /\A([A-Z]{1,3})\d.*\Z/
111
- to_field 'lc_alpha_facet', extract_marc('050a', :first=>true) do |rec, acc|
110
+ alpha_only = lambda do |rec, acc|
112
111
  acc.map! do |x|
113
112
  (m = alpha_pat.match(x)) ? m[1] : nil
114
113
  end
115
114
  acc.compact! # eliminate nils
116
115
  end
116
+ to_field 'lc_alpha_ssim', extract_marc('050a'), alpha_only, first_only
117
+
118
+ to_field 'lc_b4cutter_ssim', extract_marc('050a'), first_only
117
119
 
118
- to_field 'lc_b4cutter_facet', extract_marc('050a', :first=>true)
119
-
120
120
  # URL Fields
121
-
121
+
122
122
  notfulltext = /abstract|description|sample text|table of contents|/i
123
-
124
- to_field('url_fulltext_display') do |rec, acc|
123
+
124
+ to_field('url_fulltext_ssm') do |rec, acc|
125
125
  rec.fields('856').each do |f|
126
126
  case f.indicator2
127
127
  when '0'
@@ -140,7 +140,7 @@ class MarcIndexer < Blacklight::Marc::Indexer
140
140
  end
141
141
 
142
142
  # Very similar to url_fulltext_display. Should DRY up.
143
- to_field 'url_suppl_display' do |rec, acc|
143
+ to_field 'url_suppl_ssm' do |rec, acc|
144
144
  rec.fields('856').each do |f|
145
145
  case f.indicator2
146
146
  when '2'