blacklight-marc 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -2
  3. data/.solr_wrapper.yaml +5 -0
  4. data/.travis.yml +9 -11
  5. data/Gemfile +30 -14
  6. data/README.md +29 -8
  7. data/Rakefile +8 -20
  8. data/app/assets/stylesheets/blacklight_marc.scss +4 -6
  9. data/app/helpers/blacklight_marc_helper.rb +5 -4
  10. data/app/models/concerns/blacklight/solr/document/marc.rb +13 -12
  11. data/app/models/concerns/blacklight/solr/document/marc_export.rb +53 -50
  12. data/app/views/bookmarks/_endnote.html.erb +1 -1
  13. data/app/views/bookmarks/_refworks.html.erb +1 -1
  14. data/app/views/catalog/_marc_view.html.erb +4 -4
  15. data/app/views/catalog/endnote.endnote.erb +1 -1
  16. data/app/views/catalog/librarian_view.html.erb +7 -4
  17. data/blacklight-marc.gemspec +12 -12
  18. data/config/routes.rb +1 -1
  19. data/lib/blacklight/marc/catalog.rb +9 -15
  20. data/lib/blacklight/marc/engine.rb +2 -0
  21. data/lib/blacklight/marc/indexer.rb +9 -39
  22. data/lib/blacklight/marc/indexer/formats.rb +13 -15
  23. data/lib/blacklight/marc/routes.rb +2 -39
  24. data/lib/blacklight/marc/routes/marc_viewable.rb +20 -0
  25. data/lib/blacklight/marc/version.rb +1 -1
  26. data/lib/generators/blacklight/marc/install_generator.rb +16 -9
  27. data/lib/generators/blacklight/marc/templates/app/models/marc_indexer.rb +59 -59
  28. data/lib/generators/blacklight/marc/templates/config/translation_maps/callnumber_map.properties +149 -11
  29. data/lib/railties/solr_marc.rake +33 -33
  30. data/solr/conf/_rest_managed.json +3 -0
  31. data/solr/conf/admin-extra.html +31 -0
  32. data/solr/conf/elevate.xml +36 -0
  33. data/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  34. data/solr/conf/protwords.txt +21 -0
  35. data/solr/conf/schema.xml +388 -0
  36. data/solr/conf/scripts.conf +24 -0
  37. data/solr/conf/solrconfig.xml +195 -0
  38. data/solr/conf/spellings.txt +2 -0
  39. data/solr/conf/stopwords.txt +58 -0
  40. data/solr/conf/stopwords_en.txt +58 -0
  41. data/solr/conf/synonyms.txt +31 -0
  42. data/solr/conf/xslt/example.xsl +132 -0
  43. data/solr/conf/xslt/example_atom.xsl +67 -0
  44. data/solr/conf/xslt/example_rss.xsl +66 -0
  45. data/solr/conf/xslt/luke.xsl +337 -0
  46. data/spec/controllers/catalog_controller_spec.rb +11 -6
  47. data/spec/features/bookmarks_spec.rb +2 -1
  48. data/spec/features/search_formats_spec.rb +3 -3
  49. data/spec/integration/solr_document_spec.rb +19 -19
  50. data/spec/lib/blacklight_solr_document_marc_spec.rb +7 -7
  51. data/spec/lib/indexer/dewey_spec.rb +4 -4
  52. data/spec/lib/indexer/formats_spec.rb +9 -1
  53. data/spec/lib/marc_export_spec.rb +46 -46
  54. data/spec/lib/tasks/solr_marc_task_spec.rb +7 -7
  55. data/spec/lib/traject_indexer_spec.rb +6 -2
  56. data/spec/routing/routes_spec.rb +0 -6
  57. data/spec/spec_helper.rb +2 -2
  58. data/spec/test_app_templates/Gemfile.extra +2 -0
  59. data/spec/test_app_templates/lib/generators/test_app_generator.rb +15 -14
  60. data/spec/views/bookmarks/_endnote.html.erb_spec.rb +16 -6
  61. data/spec/views/bookmarks/_refworks.html.erb_spec.rb +17 -7
  62. data/spec/views/catalog/index.atom.builder_spec.rb +12 -17
  63. data/test_support/config/translation_maps/test_formats.properties +3 -1
  64. metadata +85 -60
  65. data/app/helpers/blacklight_bookmarks_helper.rb +0 -3
  66. data/config/jetty.yml +0 -4
@@ -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,21 +18,21 @@ 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.0.0.pre3', '< 7'
22
-
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec-rails", '~> 3.0'
26
- spec.add_development_dependency "rspec-activemodel-mocks"
27
- spec.add_development_dependency "jettywrapper"
28
- spec.add_development_dependency "capybara"
29
- spec.add_development_dependency "engine_cart", "~> 0.8"
30
-
21
+ spec.add_dependency 'blacklight', '~> 7.0'
31
22
  spec.add_dependency "library_stdnums"
32
23
  spec.add_dependency "rails"
33
24
  # Let's allow future versions of marc, count on
34
25
  # them to be backwards compat until 1.1
35
26
  spec.add_dependency "marc", ">= 0.4.3", "< 1.1" # Marc record parser.
36
- spec.add_dependency "traject", "~>2.1"
27
+ spec.add_dependency "traject", "~>3.0"
37
28
  spec.add_dependency 'marc-fastxmlwriter' # NO REXML
29
+
30
+ spec.add_development_dependency "bundler"
31
+ spec.add_development_dependency "rake"
32
+ spec.add_development_dependency "rspec-rails", '~> 4.0'
33
+ spec.add_development_dependency "rspec-activemodel-mocks"
34
+ spec.add_development_dependency "solr_wrapper"
35
+ spec.add_development_dependency "capybara"
36
+ spec.add_development_dependency "simplecov"
37
+ spec.add_development_dependency "engine_cart", "~> 2.0"
38
38
  end
@@ -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
 
@@ -14,6 +14,8 @@ module Blacklight::Marc
14
14
  end
15
15
 
16
16
  initializer 'blacklight_marc.initialize' do |app|
17
+ require 'blacklight/solr/document'
18
+
17
19
  Mime::Type.register_alias "text/plain", :refworks_marc_txt
18
20
  Mime::Type.register_alias "text/plain", :openurl_kev
19
21
  Mime::Type.register "application/x-endnote-refer", :endnote
@@ -1,14 +1,15 @@
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'
6
-
7
+
7
8
  require 'traject/solr_json_writer'
8
9
  require 'traject/marc_reader'
9
10
  require 'marc/fastxmlwriter'
10
11
 
11
- class Blacklight::Marc::Indexer < Traject::Indexer
12
+ class Blacklight::Marc::Indexer < Traject::Indexer::MarcIndexer
12
13
  autoload :Dewey, 'blacklight/marc/indexer/dewey'
13
14
  autoload :Formats, 'blacklight/marc/indexer/formats'
14
15
 
@@ -34,47 +35,16 @@ class Blacklight::Marc::Indexer < Traject::Indexer
34
35
  provide "log.batch_size", 10_000
35
36
  end
36
37
  end
37
- def first_value block, options={}
38
- lambda do |record, accumulator|
39
- if block.arity == 3
40
- block.call(record,accumulator,options)
41
- else
42
- block.call(record,accumulator)
43
- end
44
- accumulator.replace Array(accumulator[0]) # just take the first
45
- end
46
- end
47
- def map_value block, options={}
48
- if translation_map_arg = options.delete(:translation_map)
49
- translation_map = Traject::TranslationMap.new(translation_map_arg)
50
- else
51
- translation_map = nil
52
- end
53
- lambda do |record, accumulator|
54
- if block.arity == 3
55
- block.call(record,accumulator,options)
56
- else
57
- block.call(record,accumulator)
58
- end
59
- if translation_map
60
- translation_map.translate_array! accumulator
61
- end
62
- end
63
- end
64
- def trim block, options={}
38
+
39
+ def trim
65
40
  lambda do |record, accumulator|
66
- vals = []
67
- if block.arity == 3
68
- block.call(record,accumulator,options)
69
- else
70
- block.call(record,accumulator)
71
- end
72
41
  accumulator.each {|x| x.strip!}
73
42
  end
74
43
  end
44
+
75
45
  def get_xml options={}
76
46
  lambda do |record, accumulator|
77
47
  accumulator << MARC::FastXMLWriter.encode(record)
78
48
  end
79
49
  end
80
- end
50
+ end
@@ -5,7 +5,7 @@ module Blacklight::Marc::Indexer::Formats
5
5
  v = v.upcase
6
6
  case
7
7
  when (v.start_with? 'A')
8
- vals << (v == 'AD') ? 'Atlas' : 'Map'
8
+ vals << (v == 'AD' ? 'Atlas' : 'Map')
9
9
  when (v.start_with? 'C')
10
10
  case
11
11
  when (v == "CA")
@@ -107,7 +107,7 @@ module Blacklight::Marc::Indexer::Formats
107
107
  field007hasC
108
108
  end
109
109
 
110
- def self.map_leader(f_000,field007hasC,vals)
110
+ def self.map_leader(f_000,field007hasC,vals,record)
111
111
  f_000 = f_000.upcase
112
112
  case
113
113
  when (f_000.start_with? 'C')
@@ -137,17 +137,15 @@ 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
- formatCode = extract_marc("008[21]", first: true) do |r,a|
143
- format_code = a.upcase
144
- if format_code == 'N'
145
- vals << 'Newspaper'
146
- elsif format_code == 'P'
147
- vals << 'Journal'
148
- else
149
- vals << 'Serial'
150
- end
142
+ format_code = Traject::Macros::Marc21.extract_marc_from(record, "008[21]", first: true, default: "").first.upcase
143
+ if format_code == 'N'
144
+ vals << 'Newspaper'
145
+ elsif format_code == 'P'
146
+ vals << 'Journal'
147
+ else
148
+ vals << 'Serial'
151
149
  end
152
150
  end
153
151
  end
@@ -174,12 +172,12 @@ module Blacklight::Marc::Indexer::Formats
174
172
  else
175
173
  # check the Leader - this is NOT a repeating field
176
174
  # if we find a matching value there, grab it and return.
177
- FormatMap.map_leader(record.leader[6,2],field007hasC,vals)
175
+ FormatMap.map_leader(record.leader[6,2],field007hasC,vals,record)
178
176
  unless vals.empty?
179
177
  vals.uniq!
180
178
  accumulator.concat vals
181
179
  else
182
- FormatMap.map_leader(record.leader[6],field007hasC,vals)
180
+ FormatMap.map_leader(record.leader[6],field007hasC,vals,record)
183
181
  if vals.empty?
184
182
  accumulator.concat ['Unknown']
185
183
  else
@@ -191,4 +189,4 @@ module Blacklight::Marc::Indexer::Formats
191
189
  end
192
190
  end
193
191
  end
194
- end
192
+ end
@@ -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.0.0'
3
+ VERSION = '7.0.0'
4
4
  end
5
5
  end
@@ -16,7 +16,7 @@ module Blacklight::Marc
16
16
  source_root File.expand_path('../templates', __FILE__)
17
17
 
18
18
  def assets
19
- insert_into_file "app/assets/stylesheets/blacklight.css.scss", after: "@import 'blacklight/blacklight';" do
19
+ insert_into_file "app/assets/stylesheets/blacklight.scss", after: "@import 'blacklight/blacklight';" do
20
20
  <<-EOF
21
21
 
22
22
  @import 'blacklight_marc';
@@ -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
@@ -1,6 +1,6 @@
1
1
  $:.unshift './config'
2
2
  class MarcIndexer < Blacklight::Marc::Indexer
3
- # this mixin defines lambda facotry method get_format for legacy marc formats
3
+ # this mixin defines lambda factory method get_format for legacy marc formats
4
4
  include Blacklight::Marc::Indexer::Formats
5
5
 
6
6
  def initialize
@@ -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'
@@ -158,4 +158,4 @@ class MarcIndexer < Blacklight::Marc::Indexer
158
158
  end
159
159
  end
160
160
  end
161
- end
161
+ end