blacklight 4.6.3 → 4.7.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/controllers/bookmarks_controller.rb +4 -0
  4. data/app/helpers/blacklight/blacklight_helper_behavior.rb +76 -21
  5. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +8 -1
  6. data/app/views/catalog/_citation.html.erb +1 -1
  7. data/app/views/catalog/_did_you_mean.html.erb +1 -1
  8. data/app/views/catalog/_search_form.html.erb +1 -1
  9. data/blacklight.gemspec +1 -1
  10. data/config/locales/blacklight.en.yml +3 -0
  11. data/config/locales/blacklight.fr.yml +3 -0
  12. data/doc/Atom-Responses.md +90 -0
  13. data/doc/Blacklight-3.0-Release-Notes-And-Upgrade-Guide.md +107 -0
  14. data/doc/Blacklight-3.2-Release-Notes-and-Upgrade-Guide.md +191 -0
  15. data/doc/Blacklight-3.3-release-notes-and-upgrade-guide.md +37 -0
  16. data/doc/Blacklight-3.4-release-notes-and-upgrade-guide.md +27 -0
  17. data/doc/Blacklight-3.5-release-notes-and-upgrade-guide.md +44 -0
  18. data/doc/Blacklight-3.6-release-notes-and-upgrade-guide.md +25 -0
  19. data/doc/Blacklight-3.7-release-notes-and-upgrade-guide.md +80 -0
  20. data/doc/Blacklight-3.8-release-notes-and-upgrade-guide.md +11 -0
  21. data/doc/Blacklight-4.0-release-notes-and-upgrade-guide.md +135 -0
  22. data/doc/Blacklight-4.1-release-notes-and-upgrade-guide.md +17 -0
  23. data/doc/Blacklight-4.2-release-notes-and-upgrade-guide.md +25 -0
  24. data/doc/Blacklight-4.3-release-notes-and-upgrade-guide.md +21 -0
  25. data/doc/Blacklight-4.4-release-notes-and-upgrade-guide.md +41 -0
  26. data/doc/Blacklight-Add-ons.md +28 -0
  27. data/doc/Blacklight-configuration.md +411 -0
  28. data/doc/Blacklight-on-Heroku.md +135 -0
  29. data/doc/Code4Lib-2014.md +48 -0
  30. data/doc/Community-principles.md +44 -0
  31. data/doc/Configuring-and-Customizing-Blacklight.md +271 -0
  32. data/doc/Configuring-rails-routes.md +13 -0
  33. data/doc/Contributing-to-Blacklight.md +25 -0
  34. data/doc/Examples.md +94 -0
  35. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +141 -0
  36. data/doc/FAQs.md +1 -0
  37. data/doc/Home.md +80 -0
  38. data/doc/How-to-release-a-version.md +29 -0
  39. data/doc/Indexing-your-data-into-solr.md +32 -0
  40. data/doc/Integration-with-Rails-Footnotes.md +20 -0
  41. data/doc/Internationalization.md +32 -0
  42. data/doc/JSON-API.md +17 -0
  43. data/doc/Pagination.md +51 -0
  44. data/doc/Providing-your-own-view-templates.md +109 -0
  45. data/doc/Quickstart.md +115 -0
  46. data/doc/README_SOLR.md +245 -0
  47. data/doc/Release-Notes-And-Upgrade-Guides.md +20 -0
  48. data/doc/Roadmap.md +43 -0
  49. data/doc/Sunspot-for-indexing.md +46 -0
  50. data/doc/Theming.md +64 -0
  51. data/doc/User-Authentication.md +60 -0
  52. data/doc/testing.md +57 -0
  53. data/lib/blacklight.rb +6 -0
  54. data/lib/blacklight/base.rb +2 -0
  55. data/lib/blacklight/catalog.rb +4 -3
  56. data/lib/blacklight/catalog/search_context.rb +8 -1
  57. data/lib/blacklight/configurable.rb +1 -2
  58. data/lib/blacklight/solr/document.rb +2 -1
  59. data/lib/blacklight/solr_helper.rb +8 -0
  60. data/lib/blacklight/user.rb +7 -2
  61. data/lib/blacklight/utils.rb +9 -1
  62. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -4
  63. data/spec/helpers/blacklight_helper_spec.rb +84 -9
  64. data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -1
  65. data/spec/lib/blacklight_spec.rb +6 -0
  66. data/spec/lib/blacklight_user_spec.rb +4 -0
  67. data/spec/lib/solr_helper_spec.rb +8 -6
  68. data/spec/lib/utils_spec.rb +35 -5
  69. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -1
  70. metadata +49 -8
@@ -0,0 +1,17 @@
1
+ ## Release Notes
2
+ Bug fixes include:
3
+
4
+ - #529 Responsive facet collapsing is not JS degradable
5
+ - #528 Reset "page" param on "per_page" change
6
+
7
+ And some minor feature enhancements, highlights include:
8
+ - #523 Pass the document object into helper methods so local overrides can make rendering decisions based on the current document
9
+ - #522 Make it easier to add custom SolrField fields in the Blacklight config
10
+ - add a #blacklight_solr accessor (intended to replace the global Blacklight.solr)
11
+ - a French locale translation for Blacklight (thanks @biblimathieu!)
12
+
13
+ There's a handful of Rails 4 deprecation warnings and improvements that still need to happen, but this release fixed all major blockers and relaxes the Rails version dependency.
14
+
15
+ ## Upgrade Guide
16
+
17
+ No known issues.
@@ -0,0 +1,25 @@
1
+ ## Release Notes
2
+ ### 4.2.0
3
+ Bug fixes include:
4
+
5
+ - jQuery 1.9 compatibility (#545 and others)
6
+ - #548 remove duplicate favicon link tag
7
+ - #546 more straightforward testing (deprecating the test_support/bin/* scripts in favor of just 'rake')
8
+ - #549 add :helper_method to add_facet_field (similar to add_index/show_field) documented in [1]
9
+
10
+ ### 4.2.1
11
+ Bug fixes include:
12
+
13
+ - Rails 4 support
14
+ - #554 enable users to update bootstrap-sass to the latest version
15
+ - #557 add the post route for sending email
16
+ - #559 Remove unnecessary require of 'mash' which was causing "uninitialized constant HashWithIndifferentAccess"
17
+ - Fixed issue with refworks exports [156e76](https://github.com/projectblacklight/blacklight/commit/156e7680630fcbae2defa4d07f1e1c0aabc67944)
18
+
19
+ ### 4.2.2
20
+
21
+ Minor fixes for Rails 4.0 final release.
22
+
23
+ ## Upgrade Guide
24
+
25
+ No known issues.
@@ -0,0 +1,21 @@
1
+ ## Release Notes
2
+ ### 4.3.0
3
+ Bug fixes include:
4
+
5
+ - #556 check that a highlight field exists before trying to render it.
6
+ - #561 Redirect to home page on a missing document
7
+ - #569 Applies header style to `#header-navbar-fixed-top .brand` in order to avoid trumping other Bootstrap navbars.
8
+ - use `#facet_configuration_for_field` to render search history constraints for consistency and configuration-independence
9
+
10
+ Other changes:
11
+ - deprecate `#sidebar_items`, and stop populating it with content.
12
+ - provide a `SOLR_URL` ENV variable to set the location of the development solr core
13
+ - fix Rails 4-related deprecation warnings
14
+
15
+ [[Changes|https://github.com/projectblacklight/blacklight/compare/v4.2.2...v4.3.0]]
16
+
17
+ ## Upgrade Guide
18
+
19
+ Application overrides that used the CSS selector `.navbar .brand` to change the navbar styling should use `#header-navbar-fixed-top .brand` instead.
20
+
21
+ Applications that used content from `#sidebar_items` must populate that content themselves (by rendering it directly in their partial, or in some other application-specific way).
@@ -0,0 +1,41 @@
1
+ ## Release Notes
2
+ ### 4.4.0
3
+
4
+
5
+ Features
6
+ - [#598](https://github.com/projectblacklight/blacklight/issues/598) Show thumbnails (if available) for documents in search results
7
+ - [#594](https://github.com/projectblacklight/blacklight/issues/594) Provide Blacklight configuration support for linking field values to facets
8
+ - [#589](https://github.com/projectblacklight/blacklight/issues/589) Support Rails 4.x-style turbolinks (Blacklight-provided javascript should be loaded on document ready or the page:load event)
9
+ - [#588](https://github.com/projectblacklight/blacklight/issues/588) Provide an (experimental) JSON API for search and show
10
+ - [#577](https://github.com/projectblacklight/blacklight/issues/477) Add Solr Field Collapsing feature, if the Solr response includes a grouped element.
11
+
12
+ Bug Fixes
13
+ - [#640](https://github.com/projectblacklight/blacklight/issues/640) Fix the solr query Blacklight generates when the query contains Solr "local parameters" containing digits (e.g. $pf2_value)
14
+ - [#590](https://github.com/projectblacklight/blacklight/issues/590) Fix transferring unregistered guest user bookmarks to a newly registered user
15
+ - [#587](https://github.com/projectblacklight/blacklight/issues/587) Fix Zotero support, where ampersands in the context object were being double escaped
16
+ - [#534](https://github.com/projectblacklight/blacklight/issues/534) Blacklight::CatalogHelperBehavior#paginate_params values of first_page? and last_page? incorrectly set?
17
+ - [#525](https://github.com/projectblacklight/blacklight/issues/525) Add i18n support to Bookmarks javascript replacement
18
+ - [#585](https://github.com/projectblacklight/blacklight/issues/585) Add keyboard accessibility to the facet expanders
19
+ - [#563](https://github.com/projectblacklight/blacklight/issues/563) Login page should have focus in the email field, not the search field.
20
+
21
+ Other Improvements
22
+ - [#600](https://github.com/projectblacklight/blacklight/issues/600) Decomposing blacklight generator
23
+ - [#599](https://github.com/projectblacklight/blacklight/issues/599) Improving speed of blacklight generator
24
+ - [#597](https://github.com/projectblacklight/blacklight/issues/597) Rewrite document_counter logic in header
25
+ - [#596](https://github.com/projectblacklight/blacklight/issues/596) Don't generate devise views by default
26
+ - [#595](https://github.com/projectblacklight/blacklight/issues/595) Support kaminari pagination helpers in Blacklight::SolrResponse (kaminari can now work with our SolrResponse objects natively).
27
+ - [#591](https://github.com/projectblacklight/blacklight/issues/591) Remove cucumber. All features have been ported to rspec feature tests.
28
+ - [#584](https://github.com/projectblacklight/blacklight/issues/584) Move onload_text out of layouts/blacklight.html.erb
29
+ - [#515](https://github.com/projectblacklight/blacklight/issues/515) Ensure we run bundle install after generating bootstrap-sass into the Gemfile
30
+ - Update lightbox_dialog.js - Adding an event for DOM change when modal is already shown
31
+ - [#607](https://github.com/projectblacklight/blacklight/issues/607) Refactor catalog#email and catalog#sms methods
32
+ - [#609](https://github.com/projectblacklight/blacklight/issues/609) The solr facet :ex local parameter should work with pivot and facet
33
+ field configurations.
34
+ - Convert some bare strings to i18n strings
35
+ - [#608](https://github.com/projectblacklight/blacklight/issues/608) Use ActiveRecord query methods in Blacklight::User mixin
36
+
37
+ [[Changes|https://github.com/projectblacklight/blacklight/compare/v4.3.0...v4.4.0]]
38
+
39
+ ## Upgrade Guide
40
+
41
+ If you've overridden the `catalog/sms.html.erb` template or `RecordMailer#sms` action (e.g. to add custom SMS provider mappings), you should look at the changes in [this patch](https://github.com/projectblacklight/blacklight/pull/607), which moved the mappings and validation into the controller.
@@ -0,0 +1,28 @@
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) plugin
6
+ * [CQL search](https://github.com/projectblacklight/blacklight_cql) plugin
7
+ * a fancy GUI [date range limit](https://github.com/projectblacklight/blacklight_range_limit) plugin.
8
+
9
+
10
+
11
+ [RSolr Footnotes](https://github.com/cbeer/rsolr-footnotes) is useful for debugging, to see the request/response sent to Solr via RSolr: [[Integration with Rails Footnotes]]
12
+
13
+ (Not all 'stable' add-ons neccesarily need to be in Blacklight github areas; if others come to exist that the community deems stable, feel free to add them here.)
14
+
15
+
16
+ ## Unstable/Experimental
17
+
18
+ * [[Blacklight Sitemap Generator|https://github.com/jronallo/blacklight-sitemap]]: Rake task for generating sitemaps.
19
+ * [[Blacklight Highlight|https://github.com/cbeer/blacklight_highlight]]: Expose Solr fulltext highlighting.
20
+ * [[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.
21
+ * [[Blacklight unAPI|https://github.com/cbeer/blacklight_unapi]]: Adds an [[unAPI|http://unapi.info]] endpoint for records within Blacklight.
22
+ * [[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.
23
+ * [[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.
24
+ * [[Blacklight More Like This|https://github.com/cbeer/blacklight_mlt]]: Solr more like this results
25
+ * [[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.
26
+
27
+ # Deprecated
28
+ * [[Blacklight Facet Extras|https://github.com/cbeer/blacklight_facet_extras]]: Exposes new faceting features present in Solr 3.1 and 3.4, such as facet queries, facet range requests, pivot facets, and tagged/excluded 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
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!
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.