blacklight_marc 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (18) hide show
  1. checksums.yaml +4 -4
  2. data/lib/blacklight_marc.rb +0 -1
  3. data/lib/blacklight_marc/version.rb +1 -1
  4. data/lib/generators/blacklight_marc/marc_generator.rb +66 -0
  5. data/lib/generators/blacklight_marc/templates/catalog_controller.rb +180 -0
  6. data/lib/generators/blacklight_marc/templates/config/SolrMarc/config-test.properties +37 -0
  7. data/lib/generators/blacklight_marc/templates/config/SolrMarc/config.properties +37 -0
  8. data/lib/generators/blacklight_marc/templates/config/SolrMarc/index.properties +97 -0
  9. data/lib/generators/blacklight_marc/templates/config/SolrMarc/index_scripts/dewey.bsh +47 -0
  10. data/lib/generators/blacklight_marc/templates/config/SolrMarc/index_scripts/format.bsh +126 -0
  11. data/lib/generators/blacklight_marc/templates/config/SolrMarc/translation_maps/README_MAPS +1 -0
  12. data/lib/generators/blacklight_marc/templates/config/SolrMarc/translation_maps/callnumber_map.properties +407 -0
  13. data/lib/generators/blacklight_marc/templates/config/SolrMarc/translation_maps/composition_era_map.properties +56 -0
  14. data/lib/generators/blacklight_marc/templates/config/SolrMarc/translation_maps/country_map.properties +379 -0
  15. data/lib/generators/blacklight_marc/templates/config/SolrMarc/translation_maps/format_map.properties +50 -0
  16. data/lib/generators/blacklight_marc/templates/config/SolrMarc/translation_maps/instrument_map.properties +101 -0
  17. data/lib/generators/blacklight_marc/templates/config/SolrMarc/translation_maps/language_map.properties +490 -0
  18. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1171cfeb002f676e5d9968eb3f14add4c283f9c2
4
- data.tar.gz: 10bc0cc3965242b2a567bd7d0fd6b766ef8700b7
3
+ metadata.gz: a60af104e098faf23df159fc6b40d969930e1dcf
4
+ data.tar.gz: 282afc9c475de163651aec56541ca89dca089a10
5
5
  SHA512:
6
- metadata.gz: f2635c66af2756dd4c1e0d29c464a8e22f0517fe319d325ab33d34082fb84b43867e92e74d9e4dc8f2de6c1a46f8060f25ce738117eec7126bc4df73c502a273
7
- data.tar.gz: 13e52192af75956a56136db04552a008394a8a7ae714a2643e672dcaa699c88d9c916e3452d29bd4e9d5e52c9d4811790b7981bfeec22394f9b66e206cdbbbec
6
+ metadata.gz: 7f4efd8d66bbd5c9943fda14bc4269b93cc807dde946ce3a2442bf69f306c1ba633dd004fc5407651ba3cdab60f562f1c8f8ffe396cf48765ff26350bc63fc4e
7
+ data.tar.gz: deededf0ded38297e41e159c2b8c4eece7acf741991ebc839869d84f408be3b5cf0b54e982a55b66375297ffb5e3584af8e378fc82f32ca52920b7ac9114fd4e
@@ -6,5 +6,4 @@ module BlacklightMarc
6
6
  load "railties/solr_marc.rake"
7
7
  end
8
8
  end
9
-
10
9
  end
@@ -1,3 +1,3 @@
1
1
  module BlacklightMarc
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,66 @@
1
+ require 'rails/generators'
2
+
3
+ module BlacklightMarc
4
+ class MarcGenerator < Rails::Generators::Base
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ desc """
9
+ 1. Adds additional mime types to you application in the file '/config/initializers/mime_types.rb'
10
+ 2. Creates config/SolrMarc/... with settings for SolrMarc
11
+ 3. Creates a CatalogController with some some demo fields for MARC-like data
12
+ 4. Injects MARC-specific behaviors into the SolrDocument
13
+ """
14
+
15
+ # Content types used by Marc Document extension, possibly among others.
16
+ # Registering a unique content type with 'register' (rather than
17
+ # register_alias) will allow content-negotiation for the format.
18
+ def add_mime_types
19
+ puts "Updating Mime Types"
20
+ insert_into_file "config/initializers/mime_types.rb", :after => "# Be sure to restart your server when you modify this file." do <<EOF
21
+ Mime::Type.register_alias "text/plain", :refworks_marc_txt
22
+ Mime::Type.register_alias "text/plain", :openurl_kev
23
+ Mime::Type.register "application/x-endnote-refer", :endnote
24
+ Mime::Type.register "application/marc", :marc
25
+ Mime::Type.register "application/marcxml+xml", :marcxml,
26
+ ["application/x-marc+xml", "application/x-marcxml+xml",
27
+ "application/marc+xml"]
28
+ EOF
29
+ end
30
+ end
31
+
32
+ # Copy all files in templates/config directory to host config
33
+ def create_configuration_files
34
+ directory("config/SolrMarc")
35
+ end
36
+
37
+ # Generate blacklight catalog controller
38
+ def create_blacklight_catalog
39
+ copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
40
+ end
41
+
42
+ # add MARC-specific extensions to the solr document
43
+ def add_marc_extension_to_solrdocument
44
+
45
+ insert_into_file "app/models/solr_document.rb", :after => "include Blacklight::Solr::Document" do <<EOF
46
+
47
+ # The following shows how to setup this blacklight document to display marc documents
48
+ extension_parameters[:marc_source_field] = :marc_display
49
+ extension_parameters[:marc_format_type] = :marcxml
50
+ use_extension( Blacklight::Solr::Document::Marc) do |document|
51
+ document.key?( :marc_display )
52
+ end
53
+
54
+ field_semantics.merge!(
55
+ :title => "title_display",
56
+ :author => "author_display",
57
+ :language => "language_facet",
58
+ :format => "format"
59
+ )
60
+
61
+ EOF
62
+ end
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,180 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'blacklight/catalog'
3
+
4
+ class CatalogController < ApplicationController
5
+
6
+ include Blacklight::Catalog
7
+
8
+ configure_blacklight do |config|
9
+ ## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
10
+ config.default_solr_params = {
11
+ :qt => 'search',
12
+ :rows => 10
13
+ }
14
+
15
+ ## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SolrHelper#solr_doc_params) or
16
+ ## parameters included in the Blacklight-jetty document requestHandler.
17
+ #
18
+ #config.default_document_solr_params = {
19
+ # :qt => 'document',
20
+ # ## These are hard-coded in the blacklight 'document' requestHandler
21
+ # # :fl => '*',
22
+ # # :rows => 1
23
+ # # :q => '{!raw f=id v=$id}'
24
+ #}
25
+
26
+ # solr field configuration for search results/index views
27
+ config.index.show_link = 'title_display'
28
+ config.index.record_display_type = 'format'
29
+
30
+ # solr field configuration for document/show views
31
+ config.show.html_title = 'title_display'
32
+ config.show.heading = 'title_display'
33
+ config.show.display_type = 'format'
34
+
35
+ # solr fields that will be treated as facets by the blacklight application
36
+ # The ordering of the field names is the order of the display
37
+ #
38
+ # Setting a limit will trigger Blacklight's 'more' facet values link.
39
+ # * If left unset, then all facet values returned by solr will be displayed.
40
+ # * If set to an integer, then "f.somefield.facet.limit" will be added to
41
+ # solr request, with actual solr request being +1 your configured limit --
42
+ # you configure the number of items you actually want _displayed_ in a page.
43
+ # * If set to 'true', then no additional parameters will be sent to solr,
44
+ # but any 'sniffed' request limit parameters will be used for paging, with
45
+ # paging at requested limit -1. Can sniff from facet.limit or
46
+ # f.specific_field.facet.limit solr request params. This 'true' config
47
+ # can be used if you set limits in :default_solr_params, or as defaults
48
+ # on the solr side in the request handler itself. Request handler defaults
49
+ # sniffing requires solr requests to be made with "echoParams=all", for
50
+ # app code to actually have it echo'd back to see it.
51
+ #
52
+ # :show may be set to false if you don't want the facet to be drawn in the
53
+ # facet bar
54
+ config.add_facet_field 'format', :label => 'Format'
55
+ config.add_facet_field 'pub_date', :label => 'Publication Year', :single => true
56
+ config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
57
+ config.add_facet_field 'language_facet', :label => 'Language', :limit => true
58
+ config.add_facet_field 'lc_1letter_facet', :label => 'Call Number'
59
+ config.add_facet_field 'subject_geo_facet', :label => 'Region'
60
+ config.add_facet_field 'subject_era_facet', :label => 'Era'
61
+
62
+ config.add_facet_field 'example_pivot_field', :label => 'Pivot Field', :pivot => ['format', 'language_facet']
63
+
64
+ config.add_facet_field 'example_query_facet_field', :label => 'Publish Date', :query => {
65
+ :years_5 => { :label => 'within 5 Years', :fq => "pub_date:[#{Time.now.year - 5 } TO *]" },
66
+ :years_10 => { :label => 'within 10 Years', :fq => "pub_date:[#{Time.now.year - 10 } TO *]" },
67
+ :years_25 => { :label => 'within 25 Years', :fq => "pub_date:[#{Time.now.year - 25 } TO *]" }
68
+ }
69
+
70
+
71
+ # Have BL send all facet field names to Solr, which has been the default
72
+ # previously. Simply remove these lines if you'd rather use Solr request
73
+ # handler defaults, or have no facets.
74
+ config.add_facet_fields_to_solr_request!
75
+
76
+ # solr fields to be displayed in the index (search results) view
77
+ # The ordering of the field names is the order of the display
78
+ config.add_index_field 'title_display', :label => 'Title:'
79
+ config.add_index_field 'title_vern_display', :label => 'Title:'
80
+ config.add_index_field 'author_display', :label => 'Author:'
81
+ config.add_index_field 'author_vern_display', :label => 'Author:'
82
+ config.add_index_field 'format', :label => 'Format:'
83
+ config.add_index_field 'language_facet', :label => 'Language:'
84
+ config.add_index_field 'published_display', :label => 'Published:'
85
+ config.add_index_field 'published_vern_display', :label => 'Published:'
86
+ config.add_index_field 'lc_callnum_display', :label => 'Call number:'
87
+
88
+ # solr fields to be displayed in the show (single result) view
89
+ # The ordering of the field names is the order of the display
90
+ config.add_show_field 'title_display', :label => 'Title:'
91
+ config.add_show_field 'title_vern_display', :label => 'Title:'
92
+ config.add_show_field 'subtitle_display', :label => 'Subtitle:'
93
+ config.add_show_field 'subtitle_vern_display', :label => 'Subtitle:'
94
+ config.add_show_field 'author_display', :label => 'Author:'
95
+ config.add_show_field 'author_vern_display', :label => 'Author:'
96
+ config.add_show_field 'format', :label => 'Format:'
97
+ config.add_show_field 'url_fulltext_display', :label => 'URL:'
98
+ config.add_show_field 'url_suppl_display', :label => 'More Information:'
99
+ config.add_show_field 'language_facet', :label => 'Language:'
100
+ config.add_show_field 'published_display', :label => 'Published:'
101
+ config.add_show_field 'published_vern_display', :label => 'Published:'
102
+ config.add_show_field 'lc_callnum_display', :label => 'Call number:'
103
+ config.add_show_field 'isbn_t', :label => 'ISBN:'
104
+
105
+ # "fielded" search configuration. Used by pulldown among other places.
106
+ # For supported keys in hash, see rdoc for Blacklight::SearchFields
107
+ #
108
+ # Search fields will inherit the :qt solr request handler from
109
+ # config[:default_solr_parameters], OR can specify a different one
110
+ # with a :qt key/value. Below examples inherit, except for subject
111
+ # that specifies the same :qt as default for our own internal
112
+ # testing purposes.
113
+ #
114
+ # The :key is what will be used to identify this BL search field internally,
115
+ # as well as in URLs -- so changing it after deployment may break bookmarked
116
+ # urls. A display label will be automatically calculated from the :key,
117
+ # or can be specified manually to be different.
118
+
119
+ # This one uses all the defaults set by the solr request handler. Which
120
+ # solr request handler? The one set in config[:default_solr_parameters][:qt],
121
+ # since we aren't specifying it otherwise.
122
+
123
+ config.add_search_field 'all_fields', :label => 'All Fields'
124
+
125
+
126
+ # Now we see how to over-ride Solr request handler defaults, in this
127
+ # case for a BL "search field", which is really a dismax aggregate
128
+ # of Solr search fields.
129
+
130
+ config.add_search_field('title') do |field|
131
+ # solr_parameters hash are sent to Solr as ordinary url query params.
132
+ field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
133
+
134
+ # :solr_local_parameters will be sent using Solr LocalParams
135
+ # syntax, as eg {! qf=$title_qf }. This is neccesary to use
136
+ # Solr parameter de-referencing like $title_qf.
137
+ # See: http://wiki.apache.org/solr/LocalParams
138
+ field.solr_local_parameters = {
139
+ :qf => '$title_qf',
140
+ :pf => '$title_pf'
141
+ }
142
+ end
143
+
144
+ config.add_search_field('author') do |field|
145
+ field.solr_parameters = { :'spellcheck.dictionary' => 'author' }
146
+ field.solr_local_parameters = {
147
+ :qf => '$author_qf',
148
+ :pf => '$author_pf'
149
+ }
150
+ end
151
+
152
+ # Specifying a :qt only to show it's possible, and so our internal automated
153
+ # tests can test it. In this case it's the same as
154
+ # config[:default_solr_parameters][:qt], so isn't actually neccesary.
155
+ config.add_search_field('subject') do |field|
156
+ field.solr_parameters = { :'spellcheck.dictionary' => 'subject' }
157
+ field.qt = 'search'
158
+ field.solr_local_parameters = {
159
+ :qf => '$subject_qf',
160
+ :pf => '$subject_pf'
161
+ }
162
+ end
163
+
164
+ # "sort results by" select (pulldown)
165
+ # label in pulldown is followed by the name of the SOLR field to sort by and
166
+ # whether the sort is ascending or descending (it must be asc or desc
167
+ # except in the relevancy case).
168
+ config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', :label => 'relevance'
169
+ config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
170
+ config.add_sort_field 'author_sort asc, title_sort asc', :label => 'author'
171
+ config.add_sort_field 'title_sort asc, pub_date_sort desc', :label => 'title'
172
+
173
+ # If there are more than this many search results, no spelling ("did you
174
+ # mean") suggestion is offered.
175
+ config.spell_max = 5
176
+ end
177
+
178
+
179
+
180
+ end
@@ -0,0 +1,37 @@
1
+ # If using the solr:marc:index task, you can define environment-specific
2
+ # config files that will be used instead of 'config.properties' for
3
+ # a specific environment. config-development.properties,
4
+ # config-production.properties, etc.
5
+
6
+ # Relative paths for solrmarc.solr.war.path and solr.path are relative
7
+ # to the location of SolrMarc.jar, which for blacklight is by default
8
+ # in blacklight/config/solr_marc.
9
+
10
+ # solrmarc.solr.war.path - must point to either a war file for the version of
11
+ # Solr that you want to use, or to a directory of jar files extracted from a
12
+ # Solr war files. If this is not provided, SolrMarc can only work by
13
+ # communicating with a running Solr server.
14
+ #solrmarc.solr.war.path=../jetty/webapps/solr.war
15
+ # Path to your solr instance
16
+ #solr.path = ../jetty/solr
17
+
18
+ # Relative paths for solr.indexer can be relative to the location of
19
+ # this config.properties file.
20
+ solr.indexer = org.solrmarc.index.SolrIndexer
21
+ solr.indexer.properties = index.properties
22
+
23
+ # URL of running solr search engine to cause updates to be recognized.
24
+ # * When solr.path and solrmarc.solr.war.path are defined, this is optional,
25
+ # but if defined SolrMarc will issue a 'commit' after it's done indexing.
26
+ # * Alternately, do not define solr.path or solrmarc.solr.war.path to have
27
+ # SolrMarc use HTTP Post to add documents.
28
+ # NOTE:
29
+ # When using the solr:marc:index rake task, this value will be automatically
30
+ # looked up from your solr.yml, and the value here will NOT be used.
31
+ solr.hosturl = http://localhost:8888/solr/update
32
+
33
+ # MARC handling parameters
34
+ marc.to_utf_8 = true
35
+ marc.permissive = true
36
+ marc.default_encoding = MARC8
37
+ marc.include_errors = false
@@ -0,0 +1,37 @@
1
+ # If using the solr:marc:index task, you can define environment-specific
2
+ # config files that will be used instead of 'config.properties' for
3
+ # a specific environment. config-development.properties,
4
+ # config-production.properties, etc.
5
+
6
+ # Relative paths for solrmarc.solr.war.path and solr.path are relative
7
+ # to the location of SolrMarc.jar, which for blacklight is by default
8
+ # in blacklight/config/solr_marc.
9
+
10
+ # solrmarc.solr.war.path - must point to either a war file for the version of
11
+ # Solr that you want to use, or to a directory of jar files extracted from a
12
+ # Solr war files. If this is not provided, SolrMarc can only work by
13
+ # communicating with a running Solr server.
14
+ # solrmarc.solr.war.path= ../../../../jetty/webapps/solr.war
15
+ # Path to your solr instance
16
+ # solr.path = ../../../../jetty/solr
17
+
18
+ # Relative paths for solr.indexer can be relative to the location of
19
+ # this config.properties file.
20
+ solr.indexer = org.solrmarc.index.SolrIndexer
21
+ solr.indexer.properties = index.properties
22
+
23
+ # URL of running solr search engine to cause updates to be recognized.
24
+ # * When solr.path and solrmarc.solr.war.path are defined, this is optional,
25
+ # but if defined SolrMarc will issue a 'commit' after it's done indexing.
26
+ # * Alternately, do not define solr.path or solrmarc.solr.war.path to have
27
+ # SolrMarc use HTTP Post to add documents.
28
+ # NOTE:
29
+ # When using the solr:marc:index rake task, this value will be automatically
30
+ # looked up from your solr.yml, and the value here will NOT be used.
31
+ solr.hosturl = http://localhost:8983/solr/update
32
+
33
+ # MARC handling parameters
34
+ marc.to_utf_8 = true
35
+ marc.permissive = true
36
+ marc.default_encoding = MARC8
37
+ marc.include_errors = false
@@ -0,0 +1,97 @@
1
+ # for more information on solrmarc mappings,
2
+ # see http://code.google.com/p/solrmarc/w/list
3
+ #
4
+ # GenericBlacklight uses these conventions, mostly.
5
+ # _t for indexed fields (for searching)
6
+ # _display for stored fields (for display in UI)
7
+ # _facet for facet fields
8
+ # _sort for sorting fields (fields used to sort results)
9
+ #
10
+ # see jetty/solr/conf/schema.xml in Blacklight demo project
11
+ # see http://blacklight.rubyforge.org/ DEMO_README file
12
+
13
+ id = 001, first
14
+ marc_display = FullRecordAsXML
15
+ text = custom, getAllSearchableFields(100, 900)
16
+
17
+ language_facet = 008[35-37]:041a:041d, language_map.properties
18
+ # format is for facet, display, and selecting partial for display in show view
19
+ format = 007[0-1]:000[6-7]:000[6], (map.format), first
20
+ isbn_t = 020a, (pattern_map.isbn_clean)
21
+ material_type_display = custom, removeTrailingPunct(300aa)
22
+
23
+ # Title fields
24
+ # primary title
25
+ title_t = custom, getLinkedFieldCombined(245a)
26
+ title_display = custom, removeTrailingPunct(245a)
27
+ title_vern_display = custom, getLinkedField(245a)
28
+ # subtitle
29
+ subtitle_t = custom, getLinkedFieldCombined(245b)
30
+ subtitle_display = custom, removeTrailingPunct(245b)
31
+ subtitle_vern_display = custom, getLinkedField(245b)
32
+ # additional title fields
33
+ title_addl_t = custom, getLinkedFieldCombined(245abnps:130[a-z]:240[a-gk-s]:210ab:222ab:242abnp:243[a-gk-s]:246[a-gnp]:247[a-gnp])
34
+ title_added_entry_t = custom, getLinkedFieldCombined(700[gk-pr-t]:710[fgk-t]:711fgklnpst:730[a-gk-t]:740anp)
35
+ title_series_t = custom, getLinkedFieldCombined(440anpv:490av)
36
+ title_sort = custom, getSortableTitle
37
+
38
+ # Author fields
39
+ author_t = custom, getLinkedFieldCombined(100abcegqu:110abcdegnu:111acdegjnqu)
40
+ author_addl_t = custom, getLinkedFieldCombined(700abcegqu:710abcdegnu:711acdegjnqu)
41
+ author_display = custom, removeTrailingPunct(100abcdq:110[a-z]:111[a-z])
42
+ author_vern_display = custom, getLinkedField(100abcdq:110[a-z]:111[a-z])
43
+ author_sort = custom, getSortableAuthor
44
+
45
+ # Subject fields
46
+ subject_t = custom, getLinkedFieldCombined(600[a-u]:610[a-u]:611[a-u]:630[a-t]:650[a-e]:651ae:653aa:654[a-e]:655[a-c])
47
+ subject_addl_t = custom, getLinkedFieldCombined(600[v-z]:610[v-z]:611[v-z]:630[v-z]:650[v-z]:651[v-z]:654[v-z]:655[v-z])
48
+ subject_topic_facet = custom, removeTrailingPunct(600abcdq:610ab:611ab:630aa:650aa:653aa:654ab:655ab)
49
+ subject_era_facet = custom, removeTrailingPunct(650y:651y:654y:655y)
50
+ subject_geo_facet = custom, removeTrailingPunct(651a:650z)
51
+
52
+ # Publication fields
53
+ published_display = custom, removeTrailingPunct(260a)
54
+ published_vern_display = custom, getLinkedField(260a)
55
+ # used for facet and display, and copied for sort
56
+ pub_date = custom, getDate
57
+
58
+ # Call Number fields
59
+ lc_callnum_display = 050ab, first
60
+ lc_1letter_facet = 050a[0], callnumber_map.properties, first
61
+ lc_alpha_facet = 050a, (pattern_map.lc_alpha), first
62
+ lc_b4cutter_facet = 050a, first
63
+
64
+ # URL Fields
65
+ url_fulltext_display = custom, getFullTextUrls
66
+ url_suppl_display = custom, getSupplUrls
67
+
68
+
69
+ # MAPPINGS
70
+
71
+ # format mapping
72
+ # leader 06-07
73
+ map.format.aa = Book
74
+ map.format.ab = Serial
75
+ map.format.am = Book
76
+ map.format.as = Serial
77
+ map.format.ta = Book
78
+ map.format.tm = Book
79
+ # leader 06
80
+ map.format.c = Musical Score
81
+ map.format.d = Musical Score
82
+ map.format.e = Map or Globe
83
+ map.format.f = Map or Globe
84
+ map.format.i = Non-musical Recording
85
+ map.format.j = Musical Recording
86
+ map.format.k = Image
87
+ map.format.m = Computer File
88
+ # 007[0] when it doesn't clash with above
89
+ map.format.h = Microform
90
+ map.format.q = Musical Score
91
+ map.format.v = Video
92
+ # none of the above
93
+ map.format = Unknown
94
+
95
+ pattern_map.lc_alpha.pattern_0 = ^([A-Z]{1,3})\\d+.*=>$1
96
+
97
+ pattern_map.isbn_clean.pattern_0 = ([- 0-9]*[0-9]).*=>$1