blacklight 5.9.3 → 5.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -3
  3. data/Rakefile +1 -2
  4. data/VERSION +1 -1
  5. data/app/helpers/blacklight/blacklight_helper_behavior.rb +4 -2
  6. data/app/helpers/blacklight/configuration_helper_behavior.rb +5 -7
  7. data/app/models/bookmark.rb +4 -1
  8. data/app/models/search.rb +6 -3
  9. data/app/views/catalog/_home_text.html.erb +48 -8
  10. data/app/views/catalog/_sms_form.html.erb +1 -1
  11. data/blacklight.gemspec +1 -1
  12. data/config/jetty.yml +3 -0
  13. data/doc/Adding-new-document-actions.md +94 -0
  14. data/doc/Atom-Responses.md +90 -0
  15. data/doc/Blacklight-Add-ons.md +23 -0
  16. data/doc/Blacklight-configuration.md +411 -0
  17. data/doc/Blacklight-on-Heroku.md +100 -0
  18. data/doc/Blacklight-out-of-the-box.md +47 -0
  19. data/doc/Bookmarks.md +1 -0
  20. data/doc/Code4Lib-2014.md +94 -0
  21. data/doc/Configuration---Facet-Fields.md +130 -0
  22. data/doc/Configuration---Results-View.md +224 -0
  23. data/doc/Configuration---Solr-fields.md +106 -0
  24. data/doc/Configuring-and-Customizing-Blacklight.md +257 -0
  25. data/doc/Configuring-rails-routes.md +13 -0
  26. data/doc/Contributing-to-Blacklight.md +43 -0
  27. data/doc/Examples.md +120 -0
  28. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +141 -0
  29. data/doc/Home.md +100 -0
  30. data/doc/How-to-release-a-version.md +45 -0
  31. data/doc/Indexing-your-data-into-solr.md +36 -0
  32. data/doc/Internationalization.md +32 -0
  33. data/doc/JSON-API.md +83 -0
  34. data/doc/Pagination.md +52 -0
  35. data/doc/Providing-your-own-view-templates.md +69 -0
  36. data/doc/Quickstart.md +153 -0
  37. data/doc/README_SOLR.md +245 -0
  38. data/doc/Saved-Searches.md +5 -0
  39. data/doc/Solr-Configuration.md +154 -0
  40. data/doc/Sunspot-for-indexing.md +46 -0
  41. data/doc/Support.md +33 -0
  42. data/doc/Theming.md +62 -0
  43. data/doc/Understanding-Rails-and-Blacklight.md +75 -0
  44. data/doc/User-Authentication.md +60 -0
  45. data/doc/_Sidebar.md +9 -0
  46. data/doc/testing.md +58 -0
  47. data/lib/blacklight.rb +11 -3
  48. data/lib/blacklight/catalog.rb +16 -5
  49. data/lib/blacklight/catalog/search_context.rb +2 -0
  50. data/lib/blacklight/configuration/facet_field.rb +1 -1
  51. data/lib/blacklight/configuration/search_field.rb +1 -1
  52. data/lib/blacklight/routes.rb +3 -1
  53. data/lib/blacklight/solr/document.rb +24 -8
  54. data/lib/blacklight/solr_repository.rb +2 -2
  55. data/lib/blacklight/utils.rb +23 -0
  56. data/lib/generators/blacklight/install_generator.rb +1 -1
  57. data/lib/generators/blacklight/models_generator.rb +3 -1
  58. data/lib/generators/blacklight/templates/config/jetty.yml +3 -0
  59. data/spec/controllers/catalog_controller_spec.rb +9 -20
  60. data/spec/helpers/blacklight_helper_spec.rb +44 -0
  61. data/spec/helpers/configuration_helper_spec.rb +7 -0
  62. data/spec/lib/blacklight/configuration_spec.rb +33 -6
  63. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  64. data/tasks/blacklight.rake +6 -4
  65. metadata +38 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ea3fda913edc204db8dbc3b5a06ced2862324ad
4
- data.tar.gz: 0b1b41f89ccdfcd3dcd1b88857ccb0919a29afd9
3
+ metadata.gz: 8126f3ed502a69a91c6d18d78257a088da61315f
4
+ data.tar.gz: 09ba87bc46a31e4fc41a425378a28fe5aeee9bd4
5
5
  SHA512:
6
- metadata.gz: 57fbc7119ffaa221ff7e562ba6e1e27d0e4a8c10a44e1bde8ee95164cebd6f5ad40b5054466035aae35faf2f49da9f88f53c6dbc60e0d486f3abea5910b63479
7
- data.tar.gz: 29737da492197e076a19f36c103ae9277ea2bd063d036041b10ee1a6aae10589136a0243113c92a7716d929da51d59d5eb7f1e7438833336f1b45ee54161e1e0
6
+ metadata.gz: f7f98846b1ff0ce90bdf7c9b9e4012acfcad300ee7e59a8aa2b0fecba45c937440ec5bddc5c7ce56f463cc07b4385b6ffbaff72295c725611389a23d7eda038a
7
+ data.tar.gz: 885d1bcd43fea076f50fe2b7f4bc746799aaa7d6394a39b31594ea9d9c7fc28969e7708fefc4415236050c71484a83456bdd0fd16cafa049dc9f126e646fc92b
data/Gemfile CHANGED
@@ -8,10 +8,8 @@ gemspec path: File.expand_path('..', __FILE__)
8
8
  gem 'simplecov', '~> 0.7.1', require: false
9
9
  gem 'coveralls', require: false
10
10
 
11
- gem 'engine_cart', '~> 0.4'
12
-
13
11
  group :test do
14
- gem "blacklight-marc", "~> 5.0", github: "projectblacklight/blacklight_marc"
12
+ gem "blacklight-marc", "5.5.0"
15
13
  gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
16
14
  end
17
15
 
data/Rakefile CHANGED
@@ -11,5 +11,4 @@ Bundler::GemHelper.install_tasks
11
11
 
12
12
  load "tasks/blacklight.rake"
13
13
 
14
- task :default => [:ci]
15
- task :clean => ['blacklight:clean']
14
+ task :default => [:ci]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.9.3
1
+ 5.9.4
@@ -337,8 +337,10 @@ module Blacklight::BlacklightHelperBehavior
337
337
  # @param [Hash] the query parameters to check
338
338
  # @return [Symbol]
339
339
  def document_index_view_type query_params=params
340
- if query_params[:view] and blacklight_config.view.keys.include? query_params[:view].to_sym
341
- query_params[:view].to_sym
340
+ view_param = query_params[:view]
341
+ view_param ||= session[:preferred_view]
342
+ if view_param and document_index_views.keys.include? view_param.to_sym
343
+ view_param.to_sym
342
344
  else
343
345
  default_document_index_view_type
344
346
  end
@@ -85,13 +85,11 @@ module Blacklight::ConfigurationHelperBehavior
85
85
  # Look up the label for the facet field
86
86
  def facet_field_label field
87
87
  field_config = blacklight_config.facet_fields[field]
88
+ defaults = [:"blacklight.search.fields.facet.#{field}", :"blacklight.search.fields.#{field}"]
89
+ defaults << field_config.label if field_config
90
+ defaults << field.to_s.humanize
88
91
 
89
- solr_field_label(
90
- :"blacklight.search.fields.facet.#{field}",
91
- :"blacklight.search.fields.#{field}",
92
- (field_config.label if field_config),
93
- field.to_s.humanize
94
- )
92
+ solr_field_label *defaults
95
93
  end
96
94
 
97
95
  ##
@@ -107,7 +105,7 @@ module Blacklight::ConfigurationHelperBehavior
107
105
  # @param [Symbol] any number of additional keys
108
106
  # @param [Symbol] ...
109
107
  def solr_field_label *i18n_keys
110
- first, *rest = i18n_keys
108
+ first, *rest = i18n_keys.compact
111
109
 
112
110
  t(first, default: rest)
113
111
  end
@@ -5,7 +5,10 @@ class Bookmark < ActiveRecord::Base
5
5
  belongs_to :document, polymorphic: true
6
6
 
7
7
  validates_presence_of :user_id, :scope=>:document_id
8
- attr_accessible :id, :document_id, :document_type, :title if Rails::VERSION::MAJOR < 4
8
+
9
+ if Blacklight::Utils.needs_attr_accessible?
10
+ attr_accessible :id, :document_id, :document_type, :title
11
+ end
9
12
 
10
13
  def document
11
14
  document_type.new document_type.unique_key => document_id
data/app/models/search.rb CHANGED
@@ -5,10 +5,13 @@ class Search < ActiveRecord::Base
5
5
 
6
6
  serialize :query_params
7
7
 
8
- if Rails::VERSION::MAJOR < 4
8
+ if Blacklight::Utils.needs_attr_accessible?
9
9
  attr_accessible :query_params
10
-
11
- scope :none, where(:id => nil).where("id IS NOT ?", nil)
10
+ end
11
+
12
+ unless respond_to?(:none)
13
+ # polyfill
14
+ scope :none, where(id: nil).where("id IS NOT ?", nil)
12
15
  end
13
16
 
14
17
  # A Search instance is considered a saved search if it has a user_id.
@@ -1,9 +1,49 @@
1
- <h4><%= t('blacklight.welcome') %></h4>
2
- <p>&nbsp;</p>
3
- <p>To modify this text to your specifications, copy this file located in the blacklight plugin directory:<br/>
4
- &nbsp;&nbsp;&nbsp;<%= Blacklight.root %>/app/views/catalog/_home_text.html.erb</p>
5
- <p>to your top level rails app:<br/>
6
- &nbsp;&nbsp;&nbsp;<%= Rails.root %>/app/views/catalog/_home_text.html.erb</p>
7
- <p>Note that you will need to create the 'catalog' directory under views.</p>
8
- <% #Creates a bit space in the page -%>
1
+ <div class="page-header row">
2
+ <h1 class="col-md-8"><%= t('blacklight.welcome') %></h1>
3
+
4
+ <ul class="nav nav-pills col-md-4">
5
+ <li><a href="https://github.com/projectblacklight/blacklight/">Github</a></li>
6
+ <li><a href="https://github.com/projectblacklight/blacklight/wiki">Wiki</a></li>
7
+ <li><a href="https://github.com/projectblacklight/blacklight/releases/tag/v<%= Blacklight::VERSION %>">Release Notes</a></li>
8
+ </ul>
9
9
 
10
+
11
+ </div>
12
+
13
+ <div id="getting-started">
14
+ <h2>Here&rsquo;s how to get started:</h2>
15
+
16
+ <ol>
17
+ <li>To modify this text, you need to <a href="http://guides.rubyonrails.org/engines.html#improving-engine-functionality">override the Blacklight-provided view</a>.
18
+ You can copy this file, located in the blacklight gem: <br />
19
+ <%= Blacklight.root %>/app/views/catalog/_home_text.html.erb <br />
20
+ to your own application: <br />
21
+ <%= Rails.root %>/app/views/catalog/_home_text.html.erb
22
+ </li>
23
+ <li><a href="https://github.com/projectblacklight/blacklight/wiki/Indexing-your-data-into-solr">Index your own data</a> into Solr</li>
24
+ <li><a href="https://github.com/projectblacklight/blacklight/wiki#blacklight-configuration">Configure Blacklight</a> to match your data and user-experience needs</li>
25
+ <li><a href="https://github.com/projectblacklight/blacklight/wiki#support">Get in touch</a> with your comments, questions, and ideas</li>
26
+ </ol>
27
+ </div>
28
+
29
+ <%# This is the same panel shown in the Rails welcome template %>
30
+ <div id="about">
31
+ <h3><a href="/rails/info/properties">About your application&rsquo;s environment</a></h3>
32
+ <div id="about-content" class="well" style="display: none"></div>
33
+ </div>
34
+
35
+ <script>
36
+ $(function() {
37
+ $('#about a').on('click', function(e) {
38
+ e.preventDefault();
39
+
40
+ if ($('#about-content').html() == "") {
41
+ $('#about-content').load($(this).attr("href"), function() {
42
+ $('#about-content').show();
43
+ });
44
+ } else {
45
+ $('#about-content').toggle();
46
+ }
47
+ });
48
+ });
49
+ </script>
@@ -19,7 +19,7 @@
19
19
 
20
20
  </div>
21
21
  <% @documents.each do |doc| %>
22
- <%=hidden_field_tag "id[]", doc.get(:id)%>
22
+ <%=hidden_field_tag "id[]", doc.id %>
23
23
  <% end %>
24
24
  </div>
25
25
  <div class="modal-footer">
data/blacklight.gemspec CHANGED
@@ -31,6 +31,6 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency "rspec-collection_matchers", ">= 1.0"
32
32
  s.add_development_dependency "capybara"
33
33
  s.add_development_dependency "poltergeist"
34
- s.add_development_dependency 'engine_cart', ">= 0.1.0"
34
+ s.add_development_dependency 'engine_cart', ">= 0.6.0"
35
35
  s.add_development_dependency "equivalent-xml"
36
36
  end
data/config/jetty.yml CHANGED
@@ -1,10 +1,13 @@
1
1
  development:
2
2
  startup_wait: 15
3
3
  jetty_port: 8983
4
+ java_version: ">= 1.7"
4
5
  test:
5
6
  startup_wait: 60
6
7
  jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
7
8
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
9
+ java_version: ">= 1.7"
8
10
  production:
9
11
  startup_wait: 15
10
12
  jetty_port: 8983
13
+ java_version: ">= 1.7"
@@ -0,0 +1,94 @@
1
+ In your `CatalogController`, you can register document actions that display in various places within the default Blacklight UI:
2
+
3
+ - `add_show_tools_partial`: displays on the `catalog#show` page, using the `render_show_doc_actions` helper
4
+ - `add_results_document_tool`: displays on every search result, using the `render_index_doc_actions` helper
5
+ - `add_results_collection_tool`: displays at the top of a search result page, using the `render_results_collection_tools` helper
6
+ - `add_nav_action`: displays in the top application navbar, using the `render_nav_actions` helper
7
+
8
+ All types of actions take the same parameters, e.g.:
9
+
10
+ ```ruby
11
+ ##
12
+ # Add a partial to the tools for rendering a document
13
+ # @param partial [String] the name of the document partial
14
+ # @param opts [Hash]
15
+ # @option opts [String] :partial render this action using the provided partial
16
+ # @option opts [Symbol,Proc] :if render this action if the method identified by the symbol or the proc evaluates to true.
17
+ # The proc will receive the action configuration and the document or documents for the action.
18
+ # @option opts [Symbol,Proc] :unless render this action unless the method identified by the symbol or the proc evaluates to true
19
+ # The proc will receive the action configuration and the document or documents for the action.
20
+ def add_show_tools_partial name, opts = {}
21
+ ```
22
+
23
+ Examples:
24
+
25
+ ```
26
+ class CatalogController
27
+ ...
28
+
29
+ # only show patron information if a user is logged in. Note that `current_user?` has to be defined as a helper method
30
+ add_nav_action :patron_information, if: :current_user?
31
+
32
+ # In Rails 4+, this can also be defined using an inline proc:
33
+ add_nav_action :patron_information, if: Proc.new { |context, config, options| context.current_user? }
34
+
35
+ # Actions can also trigger based on properties of the document:
36
+ add_show_tools_partial :download_image_widget, if: Proc.new { |context, config, options| options[:document].image? }
37
+
38
+ ...
39
+ end
40
+ ```
41
+
42
+
43
+ ## Show Tools
44
+ You can register an action that displays on the document show page using the `add_show_tools_partial` controller method. In addition to the functionality offered by the other types of tools and actions, show tools also offer conventional defaults.
45
+
46
+ Here is a trivial example of registering a new type of action:
47
+
48
+ ```ruby
49
+ # app/controllers/catalog_controller.rb
50
+ class CatalogController
51
+ add_show_tools_partial :my_custom_action
52
+
53
+ ## OPTIONAL
54
+ # def my_custom_action
55
+ # # render some content..
56
+ # # by default, Blacklight will try to render the partial of the same name (i.e. `app/views/catalog/my_custom_action.html.erb`)
57
+ # end
58
+ end
59
+
60
+ # config/routes
61
+ Rails.application.routes.draw do
62
+ ...
63
+ get '/catalog/:id/my_custom_action' => 'catalog#my_custom_action', as: 'my_custom_action_catalog'
64
+ end
65
+ ```
66
+
67
+
68
+ If the action will receive form data from a `POST` request, you can also register a callback for handling that request. Optionally, the `POST` params can be validated using a helper method.
69
+
70
+ ```ruby
71
+ class CatalogController
72
+ include Blacklight::Catalog
73
+ ...
74
+
75
+ # Register a new action called "email".
76
+ # On a POST request, validate the params using the `#validate_email_params` method
77
+ # and process the request using `#email_action`.
78
+ add_show_tools_partial :email, callback: :email_action, validator: :validate_email_params
79
+
80
+ def validate_email_params
81
+ # validate that the posted params are suitable for the action
82
+ end
83
+
84
+ def email_action documents
85
+ # send an email with the attached documents
86
+ end
87
+
88
+ ...
89
+ end
90
+ ```
91
+
92
+ By convention, the action name is used to determine the route name for the action. For this email action, Blacklight will link to `email_catalog_path`.
93
+
94
+ The action will render the template [`catalog/email.html.erb`](https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/email.html.erb) template when the action is selected. This template provides a form, which, when submitted, will trigger the `email_action` method and will render the [`catalog/email_success.html.erb`](https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/email_success.html.erb) template.
@@ -0,0 +1,90 @@
1
+ Blacklight will provide atom responses for all catalog/index results. Just add ".atom" on to the end of your path component, `/catalog.atom`, or `/catalog/index.atom`.
2
+ ```xml
3
+ <?xml version="1.0" encoding="UTF-8"?>
4
+ <feed xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom">
5
+ <title>Blacklight Search Results</title>
6
+ <author>
7
+ <name>Blacklight</name>
8
+ </author>
9
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="self"/>
10
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=html&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="alternate" type="text/html"/>
11
+ <id>http://demo.projectblacklight.org/?commit=search&amp;amp;format=html&amp;amp;q=urdu&amp;amp;search_field=all_fields&amp;amp;type=text%2Fhtml</id>
12
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=2&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="next"/>
13
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=1&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="first"/>
14
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=15&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="last"/>
15
+ <link href="http://demo.projectblacklight.org/catalog/opensearch.xml" rel="search" type="application/opensearchdescription+xml"/>
16
+ <opensearch:totalResults>147</opensearch:totalResults>
17
+ <opensearch:startIndex>0</opensearch:startIndex>
18
+ <opensearch:itemsPerPage>10</opensearch:itemsPerPage>
19
+ <opensearch:Query searchTerms="urdu" startPage="1" role="request"/>
20
+ <updated>2011-05-11T17:46:58Z</updated>
21
+ <entry>
22
+ <title>Urdu&#772; d&#803;ra&#772;ma&#772;</title>
23
+ <updated>2011-05-11T17:46:58Z</updated>
24
+ <link href="http://demo.projectblacklight.org/catalog/2008306442" rel="alternate" type="text/html"/>
25
+ <link href="http://demo.projectblacklight.org/catalog/2008306442.dc_xml" rel="alternate" title="dc_xml" type="text/xml" />
26
+ <link href="http://demo.projectblacklight.org/catalog/2008306442.xml" rel="alternate" title="xml" type="application/xml" />
27
+ <id>http://demo.projectblacklight.org/catalog/2008306442</id>
28
+ <author>
29
+ <name>Farg&#818;h&#818;a&#772;nah, 1979-</name>
30
+ </author>
31
+ <summary type="html">
32
+ &lt;dl class="defList"&gt;
33
+
34
+
35
+ &lt;dt class="blacklight-title_display"&gt;Title:&lt;/dt&gt;
36
+ &lt;dd class="blacklight-title_display"&gt;Urdu&#772; d&#803;ra&#772;ma&#772;&lt;/dd&gt;
37
+
38
+ &lt;dt class="blacklight-author_display"&gt;Author:&lt;/dt&gt;
39
+ &lt;dd class="blacklight-author_display"&gt;Farg&#818;h&#818;a&#772;nah, 1979-&lt;/dd&gt;
40
+
41
+
42
+ <!-- [...] -->
43
+ &lt;/dl&gt;
44
+ </summary>
45
+ </entry>
46
+ <!-- [...] -->
47
+ </feed>
48
+ ```
49
+
50
+
51
+ The same HTML summary included in your HTML results pages are included as an `atom:summary` element -- the atom template uses the `[[#render_document_partial|https://github.com/projectblacklight/blacklight/blob/master/app/helpers/blacklight/blacklight_helper_behavior.rb#L203]]` helper method to generate this HTML summary, so if you've over-ridden that for your app, it will be used as the `atom:summary` content instead.
52
+
53
+ ## API Usage
54
+ The Atom response is intended to be pretty full of data, so it can fill many traditional API requests. It makes use of every relevant atom or [[OpenSearch|http://www.opensearch.org/Home]] element that could be conveniently included.
55
+
56
+ The Atom response also supports arbitrary format representations in the `atom:content` element. You can include `&content_format=some_format` in your request URL (e.g. `[[/catalog.atom?content_format=oai_dc_xml|http://demo.projectblacklight.org/catalog.atom?q=urdu&content_format=oai_dc_xml]]`). Any format a given document can be exported as using the [[Blacklight document framework|Extending-blacklight-with-the-document-extension-framework]] is available. Not every document can export in every format -- if a format is requested one or more of the items in your atom result can not export as, it will not have an `atom:content` element. Non-XML-based formats are supported, as the content is Base64-encoded (as per Atom spec, unless the format is `text/plain`).
57
+ ```xml
58
+ <?xml version="1.0" encoding="UTF-8"?>
59
+ <feed xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom">
60
+ <title>Blacklight Search Results</title>
61
+ <author>
62
+ <name>Blacklight</name>
63
+ </author>
64
+ <link href="http://demo.projectblacklight.org/?content_format=oai_dc_xml&amp;amp;format=atom&amp;amp;per_page=1" rel="self"/>
65
+ <!-- [...] -->
66
+ <entry>
67
+ <title>The book of the dance in the 20th century selections from the Jane Bourne Parton collection of books on the dance</title>
68
+ <updated>2011-05-11T17:59:32Z</updated>
69
+ <link href="http://demo.projectblacklight.org/catalog/u1" rel="alternate" type="text/html"/>
70
+ <link href="http://demo.projectblacklight.org/catalog/u1.dc_xml" rel="alternate" title="dc_xml" type="text/xml" />
71
+ <link href="http://demo.projectblacklight.org/catalog/u1.xml" rel="alternate" title="xml" type="application/xml" />
72
+ <id>http://demo.projectblacklight.org/catalog/u1</id>
73
+ <author>
74
+ <name>Roatcap, Adela Spindler</name>
75
+ </author>
76
+ <summary type="html">
77
+ <!-- [...] -->
78
+ </summary>
79
+ <!-- [ Here is the export format as OAI Dublin Core XML ] -->
80
+ <content type="text/xml">
81
+ <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:language>English</dc:language><dc:title>The book of the dance in the 20th century selections from the Jane Bourne Parton collection of books on the dance</dc:title><dc:format>Book</dc:format></oai_dc:dc> </content>
82
+ </entry>
83
+ </feed>
84
+ ```
85
+
86
+ This means that if you add on a document extension that provides more export formats for some or all of your documents, that will automatically be available in the atom response.
87
+
88
+ If you choose to use the [[Blacklight CQL add-on|https://github.com/projectblacklight/blacklight_cql]], the combination of [[CQL|http://www.loc.gov/standards/sru/specs/cql.html]] requests and Atom responses provides a pretty good more-or-less standards-based API to search results through Blacklight.
89
+
90
+ The Atom response generating template is at `app/views/catalog/index.builder.atom`.
@@ -0,0 +1,23 @@
1
+ ## Stable Add-ons
2
+
3
+ A few add-ons are are more or less 'officially supported', and all Blacklight developers have commit rights on them. (although some may not have received attention in a while if developers have been busy. Feel free to ask on the list for current status):
4
+
5
+ * [Advanced search](https://github.com/projectblacklight/blacklight_advanced_search)
6
+ * [CQL search](https://github.com/projectblacklight/blacklight_cql)
7
+ * [Date range limit](https://github.com/projectblacklight/blacklight_range_limit).
8
+
9
+ ## In development
10
+ * [Blacklight Gallery](https://github.com/projectblacklight/blacklight-gallery)
11
+ * [Blacklight Maps](https://github.com/sul-dlss/blacklight-maps)
12
+ * [Spotlight](https://github.com/sul-dlss/spotlight) Curated digital collections
13
+ * [blacklight-oembed](https://github.com/sul-dlss/blacklight-oembed) Embedding oEmbed resources in search results
14
+ * [GeoBlacklight](https://github.com/geoblacklight/geoblacklight) Discovery and access for geospatial data
15
+
16
+ ## Unstable/Experimental
17
+
18
+ * [[Blacklight Sitemap Generator|https://github.com/jronallo/blacklight-sitemap]]: Rake task for generating sitemaps.
19
+ * [[Blacklight OAI provider|https://github.com/cbeer/blacklight_oai_provider]]: Adds an [[OAI-PMH|http://www.openarchives.org/pmh/]] provider using the [[oai|http://rubygems.org/gems/oai]] gem for harvesting records within Blacklight.
20
+ * [[Blacklight unAPI|https://github.com/cbeer/blacklight_unapi]]: Adds an [[unAPI|http://unapi.info]] endpoint for records within Blacklight.
21
+ * [[Blacklight User Generated Content|https://github.com/cbeer/blacklight_user_generated_content]]: Adds user generated content to SolrDocument objects using acts_as_commentable, acts_as_taggable and acts_as_rateable directly against a SolrDocument object.
22
+ * [[Blacklight oEmbed|https://github.com/cbeer/blacklight_oembed]]: [[oEmbed|http://oembed.com]] endpoint that provides framework for allowing third-party sites (Wordpress, Facebook, etc) to embed content given a URL.
23
+ * [[Blacklight Google Analytics|https://github.com/jronallo/blacklight_google_analytics]]: Quick start for setting up Google Analytics for a Blacklight site, including Event Tracking of Blacklight-specific page elements like facets.
@@ -0,0 +1,411 @@
1
+ # Configuring Blacklight to work with your Solr index
2
+
3
+ In order to fully understand this section, you should be familiar with Solr, ways to index data into Solr, how to configure request handlers, and how to change a Solr schema. Those topics are covered in the official [Apache Solr Tutorial](http://lucene.apache.org/solr/tutorial.html).
4
+
5
+ The Blacklight example configuration is a (simplified) way to work with library data (in the MARC format), it is (hopefully) easy to reconfigure to work with your Solr index. In this section, we will describe most of the Blacklight configuration settings that determine how the Blacklight interface works with your data. Later sections demonstrate how to modify the Blacklight user experience and templates, etc.
6
+
7
+ > Note: In most of this section, we will show how to configure Blacklight to request data from Solr. While this works, and makes it easy to rapidly develop an application, we recommend eventually configuring your Apache Solr request handlers to do this instead.
8
+
9
+
10
+ ## Connecting to Solr: config/solr.yml
11
+
12
+ Your Blacklight-based application will interact with your Solr index. Although Blacklight does distribute a sample jetty-based Solr instance, you will likely want to connect Blacklight to your own Solr index. The Solr index to use is specified in a configuration file, ```config/solr.yml```. If you open this file in a recently generated Blacklight application, you’ll see a default solr configured to use a single-core Solr running under jetty:
13
+
14
+ ```yaml
15
+ development:
16
+ url: http://127.0.0.1:8983/solr
17
+
18
+ test:
19
+ url: http://127.0.0.1:8888/solr
20
+ ```
21
+
22
+ When you run your Rails application in the ```development``` environment, it will try to connect to Solr at ```http://127.0.0.1:8983/solr```, and, likewise, in ```test```, it will try to connect to Solr at ```http://127.0.0.1:8888/solr```.
23
+
24
+ This URL should point to the base path of your Solr application, and includes e.g. Solr core names (see below), but not request handler paths, etc.
25
+
26
+ Blacklight uses the RSolr gem to talk to Solr. The parameters are passed to [RSolr.connect](http://rubydoc.info/gems/rsolr/1.0.6/RSolr.connect).
27
+
28
+ ### Using Blacklight with a Multicore Solr
29
+
30
+ Here's an example of using a Multi-core Solr install with Blacklight:
31
+
32
+ ```yaml
33
+ development:
34
+ url: http://127.0.0.1:8983/solr/development-core
35
+ test:
36
+ url: http://127.0.0.1:8983/solr/test-core
37
+ ```
38
+
39
+ ### Running and Monitoring Solr with Foreman
40
+
41
+ You can use [foreman](http://blog.daviddollar.org/2011/05/06/introducing-foreman.html) to start up and monitor the blacklight rails app and the solr server. Here is an example Procfile:
42
+
43
+ web: bundle exec rails s -p $PORT
44
+ solr: bash -c "cd ./jetty; java -jar -Djetty.port=$PORT start.jar"
45
+
46
+ ## Blacklight Configuration
47
+
48
+ Now that you've connected to Solr, you probably want to configure Blacklight to display your Solr fields in the search results and facets, and also use your fields for search fields, sort options. This configuration goes in your CatalogController. By convention, this is in your Rails application, and is located at [```app/controllers/catalog_controller.rb```](https://github.com/projectblacklight/blacklight/blob/master/lib/generators/blacklight/templates/catalog_controller.rb).
49
+
50
+ The CatalogController includes functionality and templates for searching and displaying documents. The CatalogController needs to be configured so it knows about your Solr fields.
51
+
52
+ > NOTE: While most applications use only a single controller for search, it is possible to have multiple controllers with different configurations. This documentation will only discuss the simple case.
53
+
54
+ ### default_solr_params
55
+
56
+ The default_solr_params are parameters that will be sent to the Solr API on all search-like requests:
57
+
58
+ ```ruby
59
+ config.default_solr_params = {
60
+ :qt => 'search',
61
+ :rows => 10
62
+ }
63
+ ```
64
+
65
+ This configuration would send the following for any request to solr:
66
+
67
+ ```
68
+ http://localhost:8983/solr/select?qt=search&rows=10
69
+ ```
70
+
71
+ While the default_solr_params are useful for rapid development, they are often moved into the Solr request handler for production deployments.
72
+
73
+ A counter-part to default_solr_params is default_document_solr_params, which is sent when requesting only a single document from solr. In the Blacklight example solrconfig.xml, there is a `document` requestHandler to retrieve a single document at a time. We encourage you to adopt pattern as well, but with an existing Solr installation adding a single document requestHandler may not be an option. Instead, you can modify the `default_document_solr_params` to configure the appropriate defaults:
74
+
75
+ ```ruby
76
+ # See SolrHelper#solr_doc_params
77
+ config.default_document_solr_params = {
78
+ :qt => 'document',
79
+ ## These are hard-coded in the blacklight 'document' requestHandler
80
+ # :fl => '*',
81
+ # :rows => 1
82
+ # :q => '{!raw f=id v=$id}'
83
+ }
84
+ ```
85
+
86
+ Blacklight will add a query parameter called `id` containing the unique key for your document. It can be referenced as a Solr local parameter (as above) in your queries.
87
+
88
+
89
+ ### Results views (index and show)
90
+
91
+
92
+ You can configure the fields and labels that are display for search results on the search and document views.
93
+
94
+ > Note: these must be STORED fields in the Solr index, and must be returned in the solr response or they will not be displayed.
95
+
96
+ There's a set of configuration parameters for the title and Blacklight template handling (discussed elsewhere):
97
+
98
+ ```ruby
99
+ # solr field configuration for search results/index views
100
+ config.index.show_link = 'title_display'
101
+ config.index.record_display_type = 'format'
102
+
103
+ # solr field configuration for document/show views
104
+ config.show.html_title = 'title_display'
105
+ config.show.heading = 'title_display'
106
+ config.show.display_type = 'format'
107
+ ```
108
+
109
+ This configuration will use the ```title_display``` Solr field as the link text for each document.
110
+
111
+ There's a separate section for the additional fields to display:
112
+
113
+ ```ruby
114
+ # [from app/controllers/catalog_controller.rb]
115
+ # solr fields to be displayed in the index (search results) view
116
+ # The ordering of the field names is the order of the display
117
+ config.add_index_field 'title_display', :label => 'Title:'
118
+ config.add_index_field 'title_vern_display', :label => 'Title:'
119
+ config.add_index_field 'author_display', :label => 'Author:'
120
+ config.add_index_field 'author_vern_display', :label => 'Author:'
121
+
122
+ # ...
123
+ # And likewise for the show (single-document) view:
124
+
125
+ config.add_show_field 'title_display', :label => 'Title:'
126
+ config.add_show_field 'title_vern_display', :label => 'Title:'
127
+ config.add_show_field 'subtitle_display', :label => 'Subtitle:'
128
+ ```
129
+
130
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/index_fields.png|frame|alt=Index Fields]]
131
+
132
+ #### Linking a value to a facet search
133
+
134
+ When rendering the format value in the search results, link the value to a facet search for that value:
135
+
136
+ ```ruby
137
+ config.add_index_field 'format', :label => 'Format:', :link_to_search => true
138
+ ```
139
+
140
+ Or specify the field to facet against, explicitly:
141
+ ```ruby
142
+ config.add_index_field 'author_display', :label => 'Author:', :link_to_search => :author_facet
143
+ ```
144
+
145
+ More advanced configuration should use a custom helper method (see below) to render an appropriate value.
146
+
147
+ #### Using a helper method to render the value
148
+
149
+ You can use view helpers to render the Solr values, e.g.:
150
+
151
+ ```ruby
152
+ config.add_index_field 'title_vern_display', :label => 'Title:', :helper_method => :my_helper_method
153
+ ```
154
+
155
+ When Blacklight goes to display the 'title_vern_display' field, it will call ```my_helper_method``` to get the value to display. You can implement any logic you want to manipulate the solr document to return the value to display.
156
+
157
+ ```ruby
158
+ module ApplicationHelper
159
+ def my_helper_method args
160
+ args[:document][args[:field]].upcase
161
+ end
162
+ end
163
+ ```
164
+
165
+ Your helper method receives hash with (at least) two parameters:
166
+
167
+ - :document => the SolrDocument object
168
+ - :field => the solr field to display
169
+
170
+
171
+ #### Solr hit highlighting
172
+
173
+ You can trigger automatic Solr hit highlighting of results:
174
+
175
+ ```ruby
176
+ config.add_index_field 'title_vern_display', :label => 'Title:', :highlight => true
177
+ ```
178
+
179
+ This will cause Blacklight to look at the Solr highlight component response for the value of this field. This assumes you've configured the highlighting component elsewhere. The [Solr Highlighting Parameters](http://wiki.apache.org/solr/HighlightingParameters) documentation discusses the Solr parameters available to you. You could add these to your default_solr_params, request handler configuration, or elsewhere.
180
+
181
+ You can have Blacklight send the most basic highlighting parameters for you, if you set:
182
+
183
+ ```ruby
184
+ config.add_field_configuration_to_solr_request!
185
+ ```
186
+
187
+ This will enable the highlighting component and send 'hl.fl' parameters for the fields you wanted highlighted, but you will likely want to tweak this behavior further.
188
+
189
+ ### Facet fields
190
+
191
+ Faceted search allows users to constrain searches by controlled vocabulary items
192
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_facets.png|frame|alt=Search facets in action]]
193
+ Note that these must be INDEXED fields in the Solr index, and are generally a single token (e.g. a string).
194
+
195
+ ```ruby
196
+ # [from app/controllers/catalog_controller.rb]
197
+ # solr fields that will be treated as facets by the blacklight application
198
+ # The ordering of the field names is the order of the display
199
+ config.add_facet_field 'format', :label => 'Format'
200
+ config.add_facet_field 'pub_date', :label => 'Publication Year'
201
+ config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
202
+ config.add_facet_field 'language_facet', :label => 'Language', :limit => true
203
+ ```
204
+
205
+ ### Facet View Helpers [v.4.2.0+]
206
+
207
+ You can supply a :helper_method argument to configure what you would like displayed for the facet's text, e.g:
208
+
209
+ ```ruby
210
+ config.add_facet_field 'format', :label => 'Format', :helper_method => :my_helper_method
211
+ ```
212
+
213
+ With the above code Blacklight will pass the facet's value into the given helper method, with which you can do anything you'd like.
214
+
215
+ ```ruby
216
+ module ApplicationHelper
217
+ def my_helper_method value
218
+ value.upcase
219
+ end
220
+ end
221
+ ```
222
+ ### Facet Queries
223
+ Blacklight also supports Solr facet queries:
224
+
225
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/query_facets.png|frame|alt=Query facets in action]]
226
+
227
+ ```ruby
228
+ config.add_facet_field 'pub_date_query', :label => 'Publication Year', :query => {
229
+ :last_5_years => { :label => 'Last 5 Years', :fq => "[#{Time.now.year-5} TO *]"}
230
+ }
231
+ ```
232
+
233
+ The first argument (which maps to the facet field for plain facets) is used in the Blacklight URL when the facet is selected.
234
+
235
+ The :query hash maps a key to use in Blacklight URLs to a facet :label (used in the facet display) and an :fq to send to Solr as the `facet.query` and (if selected) the Solr `fq` parameter.
236
+
237
+ You can also tell Solr how to sort facets (either by [count or index](http://wiki.apache.org/solr/SimpleFacetParameters#facet.sort)):
238
+ If your data is strings, you can use this to perform an alphabetical sort of the facets.
239
+ ```ruby
240
+ config.add_facet_field :my_count_sorted_field, :sort => 'count'
241
+ config.add_facet_field :my_index_sorted_field, :sort => 'index'
242
+ ```
243
+
244
+
245
+ If you want Solr to add the configured facets and facet queries to the Solr query it sends, you should also add:
246
+
247
+ ```ruby
248
+ config.add_facet_fields_to_solr_request! # deprecated: use add_facet_field :include_in_request instead
249
+ ```
250
+
251
+ ### Date-based facets
252
+
253
+ If you have date facets in Solr, you should add a hint to the Blacklight configuration:
254
+
255
+ ```ruby
256
+ config.add_facet_field :my_date_field, :date => true
257
+ ```
258
+
259
+ This will trigger special date querying logic, and also use a localized date format when displaying the facet value. If you want to use a particular localization format, you can provide that as well:
260
+
261
+ ```ruby
262
+ config.add_facet_field :my_date_field, :date => { :format => :short }
263
+ ```
264
+
265
+ ### Tagging/Exclusion facets
266
+
267
+ From the solr docs:
268
+
269
+ > One can tag specific filters and exclude those filters when faceting. This is generally needed when doing multi-select faceting. [...]To implement a multi-select facet for doctype, a GUI may want to still display the other doctype values and their associated counts, as if the doctype:pdf constraint had not yet been applied.
270
+ >
271
+ > Example:
272
+ >
273
+ > === Document Type ===
274
+ >
275
+ > [ ] Word (42)
276
+ >
277
+ > [x] PDF (96)
278
+ >
279
+ > [ ] Excel(11)
280
+ >
281
+ > [ ] HTML (63)
282
+
283
+ To configure this behavior in Blacklight,
284
+
285
+ ```ruby
286
+ config.add_facet_field :document_type_facet, :tag => 'some-tag', :ex => 'some-tag'
287
+ ```
288
+
289
+ ### search fields
290
+
291
+ Search queries can be targeted at configurable fields (or sets of fields) to return precise search results. Advanced search capabilities are provided through the [[Advanced Search Add-On|https://github.com/projectblacklight/blacklight_advanced_search]]
292
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_fields.png|frame|alt=Search fields in action]]
293
+
294
+ ```ruby
295
+ # [from app/controllers/catalog_controller.rb]
296
+ # Now we see how to over-ride Solr request handler defaults, in this
297
+ # case for a BL "search field", which is really a dismax aggregate
298
+ # of Solr search fields.
299
+
300
+ config.add_search_field('title') do |field|
301
+ # solr_parameters hash are sent to Solr as ordinary url query params.
302
+ field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
303
+
304
+ # :solr_local_parameters will be sent using Solr LocalParams
305
+ # syntax, as eg {! qf=$title_qf }. This is neccesary to use
306
+ # Solr parameter de-referencing like $title_qf.
307
+ # See: http://wiki.apache.org/solr/LocalParams
308
+ field.solr_local_parameters = {
309
+ :qf => '$title_qf',
310
+ :pf => '$title_pf'
311
+ }
312
+ end
313
+ ```
314
+
315
+ ### sort fields
316
+
317
+ ```ruby
318
+ config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', :label => 'relevance'
319
+ config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
320
+ config.add_sort_field 'author_sort asc, title_sort asc', :label => 'author'
321
+ config.add_sort_field 'title_sort asc, pub_date_sort desc', :label => 'title'
322
+ ```
323
+
324
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/sort_fields.png|frame|alt=Sort fields in action]]
325
+
326
+ > TODO
327
+
328
+ ## Solr Document
329
+
330
+
331
+ By default, Blacklight assumes the unique key field in your solr index is called `id`. You can change this by editing `app/models/solr_document.rb`:
332
+
333
+ ```ruby
334
+ class SolrDocument
335
+ include Blacklight::Solr::Document
336
+
337
+ # self.unique_key = 'id'
338
+ ...
339
+ end
340
+ ```
341
+
342
+ If, for instance, your unique key field was 'uuid_s', this would read:
343
+
344
+ ```ruby
345
+ class SolrDocument
346
+ include Blacklight::Solr::Document
347
+
348
+ self.unique_key = 'uuid_s'
349
+ ...
350
+ end
351
+ ```
352
+
353
+ This will instruct Blacklight to use your ```uuid_s``` field any time it needs an identifier for the document, e.g. when constructing document URLs.
354
+
355
+ Also in SolrDocument is a set of "field semantics", which may be used in some basic metadata mapping:
356
+
357
+ ```ruby
358
+ class SolrDocument
359
+ ...
360
+
361
+ field_semantics.merge!(
362
+ :title => "title_display",
363
+ :author => "author_display",
364
+ :language => "language_facet",
365
+ :format => "format"
366
+ )
367
+ end
368
+ ```
369
+
370
+ ### Field Collapsing
371
+
372
+ Blacklight 4.4 adds support for Solr Field Collapsing (aka results grouping). The initial implementation requires you to explicitly configure your solr request handler (or default solr parameters) to enable grouping.
373
+
374
+ Here are some solr request parameters to enable grouping on our demo index:
375
+
376
+ ```
377
+ :group => true,
378
+ :'group.field' => 'pub_date_sort',
379
+ :'group.ngroups' => true, # group.ngroups is REQUIRED.
380
+ :'group.limit' => 3
381
+ ```
382
+
383
+ If you only define a single group.field, Blacklight will detect the grouped response and use it. If there are multiple fields defined, you have to configure Blacklight to detect the correct field, e.g.:
384
+
385
+ ```
386
+ config.index.group = "pub_date_sort"
387
+ ```
388
+
389
+ ### Thumbnails in results display
390
+
391
+ Blacklight 4.4+ can render a representative thumbnail with a result on the search index page.
392
+
393
+ Blacklight can pull a URL to the thumbnail from a field in Solr:
394
+
395
+ ```ruby
396
+ configure_blacklight do |config|
397
+ config.index.thumbnail_field = :some_field_in_the_document
398
+ end
399
+ ```
400
+
401
+ Or using custom logic in a helper method of your own creation:
402
+
403
+ ```ruby
404
+ configure_blacklight do |config|
405
+ config.index.thumbnail_method = :xyz
406
+ end
407
+ ```
408
+
409
+ With this configuration, the helper method `xyz` will be called with the `SolrDocument` document and a hash of caller-supplied image options.
410
+
411
+ Given that configuration, Blacklight will render a thumbnail (by default, right aligned, under the bookmark button) as a link to the document page. If no thumbnail is available (missing data in solr, the thumbnail method returned nil), the thumbnail block is not displayed at all.