blacklight 5.9.4 → 5.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +11 -10
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -14
- data/app/helpers/blacklight/configuration_helper_behavior.rb +16 -10
- data/app/helpers/blacklight/facets_helper_behavior.rb +15 -14
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/bookmark.rb +1 -4
- data/app/models/search.rb +3 -6
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_facet_limit.html.erb +5 -3
- data/app/views/catalog/_facet_pivot.html.erb +4 -4
- data/app/views/catalog/_home_text.html.erb +8 -48
- data/app/views/catalog/_index_default.html.erb +3 -3
- data/app/views/catalog/_show_default.html.erb +3 -3
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/jetty.yml +0 -3
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +2 -0
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/lib/blacklight.rb +70 -26
- data/lib/blacklight/abstract_repository.rb +29 -0
- data/lib/blacklight/base.rb +7 -7
- data/lib/blacklight/bookmarks.rb +5 -5
- data/lib/blacklight/catalog.rb +34 -19
- data/lib/blacklight/catalog/search_context.rb +1 -1
- data/lib/blacklight/configuration.rb +112 -46
- data/lib/blacklight/configuration/facet_field.rb +9 -7
- data/lib/blacklight/configuration/field.rb +27 -0
- data/lib/blacklight/configuration/fields.rb +25 -20
- data/lib/blacklight/configuration/search_field.rb +6 -8
- data/lib/blacklight/configuration/solr_field.rb +3 -18
- data/lib/blacklight/configuration/sort_field.rb +6 -7
- data/lib/blacklight/document.rb +156 -0
- data/lib/blacklight/document/dublin_core.rb +41 -0
- data/lib/blacklight/document/email.rb +16 -0
- data/lib/blacklight/document/export.rb +107 -0
- data/lib/blacklight/document/extensions.rb +56 -0
- data/lib/blacklight/document/schema_org.rb +7 -0
- data/lib/blacklight/document/semantic_fields.rb +51 -0
- data/lib/blacklight/document/sms.rb +14 -0
- data/lib/blacklight/document_presenter.rb +3 -3
- data/lib/blacklight/exceptions.rb +9 -2
- data/lib/blacklight/facet.rb +21 -16
- data/lib/blacklight/request_builders.rb +60 -284
- data/lib/blacklight/routes.rb +1 -1
- data/lib/blacklight/search_builder.rb +130 -0
- data/lib/blacklight/search_helper.rb +316 -0
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/document.rb +4 -187
- data/lib/blacklight/solr/document/dublin_core.rb +3 -37
- data/lib/blacklight/solr/document/email.rb +4 -13
- data/lib/blacklight/solr/document/export.rb +3 -103
- data/lib/blacklight/solr/document/extensions.rb +4 -52
- data/lib/blacklight/solr/document/more_like_this.rb +1 -1
- data/lib/blacklight/solr/document/schema_org.rb +4 -4
- data/lib/blacklight/solr/document/sms.rb +4 -11
- data/lib/blacklight/solr/facet_paginator.rb +2 -2
- data/lib/blacklight/solr/search_builder.rb +264 -0
- data/lib/blacklight/solr_helper.rb +6 -261
- data/lib/blacklight/solr_repository.rb +30 -24
- data/lib/blacklight/solr_response.rb +3 -3
- data/lib/blacklight/user.rb +1 -2
- data/lib/blacklight/utils.rb +0 -23
- data/lib/generators/blacklight/controller_generator.rb +38 -0
- data/lib/generators/blacklight/document_generator.rb +20 -0
- data/lib/generators/blacklight/install_generator.rb +38 -39
- data/lib/generators/blacklight/models_generator.rb +2 -62
- data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
- data/lib/generators/blacklight/templates/config/{solr.yml → blacklight.yml} +3 -0
- data/lib/generators/blacklight/templates/config/jetty.yml +0 -3
- data/lib/generators/blacklight/templates/solr_document.rb +6 -6
- data/lib/generators/blacklight/test_support_generator.rb +1 -6
- data/lib/generators/blacklight/user_generator.rb +59 -0
- data/lib/railties/blacklight.rake +16 -7
- data/spec/controllers/catalog_controller_spec.rb +9 -15
- data/spec/features/facets_spec.rb +8 -0
- data/spec/helpers/configuration_helper_spec.rb +6 -13
- data/spec/helpers/facets_helper_spec.rb +3 -2
- data/spec/lib/blacklight/configuration_spec.rb +11 -38
- data/spec/lib/blacklight/{solr/document → document}/dublin_core_spec.rb +4 -4
- data/spec/lib/blacklight/{solr/document → document}/email_spec.rb +2 -2
- data/spec/lib/blacklight/{solr/document → document}/sms_spec.rb +2 -2
- data/spec/lib/blacklight/search_builder_spec.rb +145 -0
- data/spec/lib/blacklight/search_helper_spec.rb +775 -0
- data/spec/lib/blacklight/solr/document/more_like_this_spec.rb +1 -1
- data/spec/lib/blacklight/solr/search_builder_spec.rb +561 -0
- data/spec/lib/blacklight/solr_helper_spec.rb +5 -1291
- data/spec/lib/blacklight/solr_repository_spec.rb +13 -13
- data/spec/models/record_mailer_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- data/tasks/blacklight.rake +1 -1
- data/template.demo.rb +1 -1
- metadata +33 -45
- data/doc/Adding-new-document-actions.md +0 -94
- data/doc/Atom-Responses.md +0 -90
- data/doc/Blacklight-Add-ons.md +0 -23
- data/doc/Blacklight-configuration.md +0 -411
- data/doc/Blacklight-on-Heroku.md +0 -100
- data/doc/Blacklight-out-of-the-box.md +0 -47
- data/doc/Bookmarks.md +0 -1
- data/doc/Code4Lib-2014.md +0 -94
- data/doc/Configuration---Facet-Fields.md +0 -130
- data/doc/Configuration---Results-View.md +0 -224
- data/doc/Configuration---Solr-fields.md +0 -106
- data/doc/Configuring-and-Customizing-Blacklight.md +0 -257
- data/doc/Configuring-rails-routes.md +0 -13
- data/doc/Contributing-to-Blacklight.md +0 -43
- data/doc/Examples.md +0 -120
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
- data/doc/Home.md +0 -100
- data/doc/How-to-release-a-version.md +0 -45
- data/doc/Indexing-your-data-into-solr.md +0 -36
- data/doc/Internationalization.md +0 -32
- data/doc/JSON-API.md +0 -83
- data/doc/Pagination.md +0 -52
- data/doc/Providing-your-own-view-templates.md +0 -69
- data/doc/Quickstart.md +0 -153
- data/doc/README_SOLR.md +0 -245
- data/doc/Saved-Searches.md +0 -5
- data/doc/Solr-Configuration.md +0 -154
- data/doc/Sunspot-for-indexing.md +0 -46
- data/doc/Support.md +0 -33
- data/doc/Theming.md +0 -62
- data/doc/Understanding-Rails-and-Blacklight.md +0 -75
- data/doc/User-Authentication.md +0 -60
- data/doc/_Sidebar.md +0 -9
- data/doc/testing.md +0 -58
data/doc/Blacklight-on-Heroku.md
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
> As of March 2014, the directions from the Heroku [Getting Started with Rails](https://devcenter.heroku.com/articles/getting-started-with-rails4) guide can be followed as-is with an existing Blacklight application.
|
2
|
-
|
3
|
-
<hr />
|
4
|
-
|
5
|
-
Blacklight can be deployed on [Heroku](http://heroku.com/), a Platform-as-a-Service (PaaS) provider that supports Ruby. This walkthrough assumes some familiarity with Heroku, that you have a Solr server running somewhere, and that you already have a Heroku account. For more information on working with Heroku, please see [Getting Started with Heroku](https://devcenter.heroku.com/articles/quickstart).
|
6
|
-
|
7
|
-
## Create a new Blacklight app
|
8
|
-
|
9
|
-
* Use the Blacklight [[Quickstart]] to create a new Rails application:
|
10
|
-
|
11
|
-
```bash
|
12
|
-
$ rails new blheroku
|
13
|
-
# create
|
14
|
-
# create README
|
15
|
-
# create Rakefile
|
16
|
-
# create config.ru
|
17
|
-
# create .gitignore
|
18
|
-
# create Gemfile
|
19
|
-
# [...]
|
20
|
-
|
21
|
-
$ cd blheroku
|
22
|
-
$ rm public/index.html
|
23
|
-
|
24
|
-
* Append this line to your application's `Gemfile`:
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
gem 'blacklight'
|
28
|
-
```
|
29
|
-
|
30
|
-
* Install the gems using Bundler:
|
31
|
-
|
32
|
-
```bash
|
33
|
-
$ bundle install
|
34
|
-
```
|
35
|
-
|
36
|
-
* Call the Blacklight generator (in this case, without Devise for authentication):
|
37
|
-
|
38
|
-
```bash
|
39
|
-
$ rails generate blacklight
|
40
|
-
```
|
41
|
-
|
42
|
-
## Change Gem dependencies for Heroku deployment
|
43
|
-
|
44
|
-
* Change the database-related gems in your `Gemfile` from:
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
gem 'sqlite3'
|
48
|
-
```
|
49
|
-
|
50
|
-
* to the following:
|
51
|
-
|
52
|
-
```ruby
|
53
|
-
gem 'sqlite3', :groups => [:development, :test]
|
54
|
-
gem 'pg', :group => :production
|
55
|
-
```
|
56
|
-
|
57
|
-
* Move all gems in the asset block of `Gemfile` to the main block [see here for more info](http://stackoverflow.com/questions/9629620) (still needed? - 2/1/2014).
|
58
|
-
|
59
|
-
## Configure Solr for your application
|
60
|
-
|
61
|
-
* While untested, you may want to look at [Websolr](http://websolr.com/), which provides Solr as a Service.
|
62
|
-
* Add a line `config/solr.yml` to point to your production instance of Solr:
|
63
|
-
|
64
|
-
```yaml
|
65
|
-
production:
|
66
|
-
url: http://my.solr.host:8983/path/to/solr
|
67
|
-
```
|
68
|
-
|
69
|
-
## Index some test records
|
70
|
-
|
71
|
-
```bash
|
72
|
-
$ RAILS_ENV=production rake solr:marc:index_test_data
|
73
|
-
```
|
74
|
-
## Set up Heroku
|
75
|
-
|
76
|
-
```bash
|
77
|
-
$ git init
|
78
|
-
$ heroku create --stack cedar
|
79
|
-
Creating vivid-winter-2427... done, stack is cedar
|
80
|
-
http://vivid-winter-2427.herokuapp.com/ | git@heroku.com:vivid-winter-2427.git
|
81
|
-
Git remote heroku added
|
82
|
-
$ git add .
|
83
|
-
$ git commit -m"Initial import"
|
84
|
-
```
|
85
|
-
|
86
|
-
* Take note of the URL reported back by Heroku (in this case, http://vivid-winter-2427.herokuapp.com/)
|
87
|
-
|
88
|
-
## Deploy to Heroku
|
89
|
-
|
90
|
-
```bash
|
91
|
-
$ git push heroku master
|
92
|
-
[...]
|
93
|
-
$ heroku run rake db:migrate
|
94
|
-
[...]
|
95
|
-
```
|
96
|
-
|
97
|
-
## Try opening up your app
|
98
|
-
|
99
|
-
* Go to URL reported by Heroku above (in this example, http://vivid-winter-2427.herokuapp.com/).
|
100
|
-
* Does it work? If it doesn't, try running `heroku logs` to see where problems are cropping up.
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# Bootstrap 3 / Responsive Design
|
2
|
-
![Responsive Design](https://f.cloud.github.com/assets/111218/2058435/e31f4314-8b71-11e3-9cac-dd4feff588d9.png)
|
3
|
-
|
4
|
-
# Search
|
5
|
-
#### Global Search Bar
|
6
|
-
![Global Search](https://f.cloud.github.com/assets/111218/2058442/e336ebb8-8b71-11e3-8995-27c85b33a1f1.png)
|
7
|
-
#### Sortable Results
|
8
|
-
![Sorting](https://f.cloud.github.com/assets/111218/2058444/e33f6234-8b71-11e3-83a6-b3c65a96d6c2.png)
|
9
|
-
#### Fielded Search
|
10
|
-
![Fielded Search](https://f.cloud.github.com/assets/111218/2058437/e327c084-8b71-11e3-8438-cdc7f2263158.png)
|
11
|
-
|
12
|
-
## Pagination
|
13
|
-
#### Sorting options
|
14
|
-
![Sort and Per Page](https://f.cloud.github.com/assets/111218/2058433/e2ee32c4-8b71-11e3-929c-76eb693723e4.png)
|
15
|
-
|
16
|
-
#### Deep pagination
|
17
|
-
![Pagination](https://f.cloud.github.com/assets/111218/2058438/e32a5c22-8b71-11e3-8979-e3afd961daed.png)
|
18
|
-
|
19
|
-
## History
|
20
|
-
![Search History](https://f.cloud.github.com/assets/111218/2058439/e32c8312-8b71-11e3-9e67-424e586e15dd.png)
|
21
|
-
|
22
|
-
# Facets
|
23
|
-
#### Facets
|
24
|
-
![Facets](https://f.cloud.github.com/assets/111218/2058447/e34cc12c-8b71-11e3-940e-3eba736a0577.png)
|
25
|
-
|
26
|
-
#### Selected Facet
|
27
|
-
![Facets](https://f.cloud.github.com/assets/111218/2058443/e33a7634-8b71-11e3-9f46-6861325b19a3.png)
|
28
|
-
|
29
|
-
#### Constraints
|
30
|
-
![Constraints](https://f.cloud.github.com/assets/111218/2058446/e34504a0-8b71-11e3-9188-7cd87d08efdb.png)
|
31
|
-
|
32
|
-
#### Query Facets
|
33
|
-
![Query Facets](https://f.cloud.github.com/assets/111218/2058448/e34e61c6-8b71-11e3-8905-f72ff12a95d0.png)
|
34
|
-
|
35
|
-
#### Constraints
|
36
|
-
![Query Constraints](https://f.cloud.github.com/assets/111218/2058434/e305c146-8b71-11e3-8d2b-8e5b7760dfcb.png)
|
37
|
-
|
38
|
-
# Results
|
39
|
-
|
40
|
-
#### Index view
|
41
|
-
![Index View](https://f.cloud.github.com/assets/111218/2058445/e341d4f6-8b71-11e3-97f1-4e21e5ed1034.png)
|
42
|
-
|
43
|
-
#### Show view
|
44
|
-
![Show View](https://f.cloud.github.com/assets/111218/2058436/e322543c-8b71-11e3-90a3-6744cb6628c7.png)
|
45
|
-
|
46
|
-
#### Tools
|
47
|
-
![Tools](https://f.cloud.github.com/assets/111218/2058441/e33395d0-8b71-11e3-98e4-fe794e2ba63b.png)
|
data/doc/Bookmarks.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
If a User implementation is provided, Blacklight can provide a "bookmarks" or "selected items" feature. Blacklight ships with a devise-based example, but it should be portable across authentication framework.
|
data/doc/Code4Lib-2014.md
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# Preconference Planning
|
2
|
-
|
3
|
-
## "Half-Day [Morning]" (3 hours)
|
4
|
-
Contact: Chris Beer, Stanford University, cabeer@stanford.edu
|
5
|
-
TA: Bess Sadler, Stanford University, bess@stanford.edu
|
6
|
-
This session will be walk-through of the architecture of Blacklight, the community, and an introduction to building a Blacklight-based application. Each participant will have the opportunity to build a simple Blacklight application, and make basic customizations, while using a test-driven approach.
|
7
|
-
For more information about Blacklight see our wiki ( http://projectblacklight.org/ ) and our GitHub repo ( https://github.com/projectblacklight/blacklight ). We will also send out some brief instructions beforehand for those that would like to setup their environments to follow along and get Blacklight up and running on their local machines.
|
8
|
-
|
9
|
-
### Welcome and Introductions (15m)
|
10
|
-
|
11
|
-
### Intro to Blacklight (25m)
|
12
|
-
|
13
|
-
* History
|
14
|
-
* Development methodology (github, mailing list, irc)
|
15
|
-
* Roadmap (?)
|
16
|
-
* Demos: searchworks, frda, spotlight, uohull, cornell, https://scholarsphere.psu.edu/ ? (some of these may show up below in the configuration section..)
|
17
|
-
|
18
|
-
### Installfest (40m)
|
19
|
-
|
20
|
-
* Vagrant with everything pre-installed
|
21
|
-
* Rails Application Template
|
22
|
-
|
23
|
-
-- break (10m) --
|
24
|
-
|
25
|
-
### Indexing (30m; hopefully less)
|
26
|
-
|
27
|
-
* MARC data
|
28
|
-
* digital collections data (github.com/tategallery/collection ?)
|
29
|
-
|
30
|
-
### Configuration (1h)
|
31
|
-
|
32
|
-
* Index fields
|
33
|
-
* Thumbnails
|
34
|
-
* Facet configuration
|
35
|
-
* Search fields
|
36
|
-
* other search options (sort, per page, etc)
|
37
|
-
* Show fields
|
38
|
-
|
39
|
-
* Custom partials
|
40
|
-
* CSS + Bootstrap
|
41
|
-
|
42
|
-
### Q & A
|
43
|
-
|
44
|
-
|
45
|
-
## "Half-Day [Afternoon]" (3 hours)
|
46
|
-
This afternoon hackfest is both a follow-on to the Intro to Blacklight morning session to continue building Blacklight-based applications, and also an opportunity for existing Blacklight contributors and members of the Blacklight community to exchange common patterns and approaches into reusable gems or incorporate customizations into Blacklight itself.
|
47
|
-
For more information about Blacklight see our wiki ( http://projectblacklight.org/ ) and our GitHub repo ( https://github.com/projectblacklight/blacklight ).
|
48
|
-
|
49
|
-
### Welcome and Introductions (30m)
|
50
|
-
|
51
|
-
* Introductions
|
52
|
-
* Project planning
|
53
|
-
|
54
|
-
### Work (2h)
|
55
|
-
|
56
|
-
|
57
|
-
### Demos (30m)
|
58
|
-
|
59
|
-
|
60
|
-
# Code4Lib table volunteers
|
61
|
-
|
62
|
-
## Tuesday
|
63
|
-
|
64
|
-
- Tuesday (8:00 - 9:00):
|
65
|
-
barmintor
|
66
|
-
- Tuesday (Break #1; 10:00 - 10:20): bess
|
67
|
-
|
68
|
-
- Tuesday (Lunch-ish; 12:10 - 13:10): bess
|
69
|
-
|
70
|
-
- Tuesday (Break #2; 14:15 - 14:30): bess
|
71
|
-
|
72
|
-
- Tuesday (Breakout; 14:30 - 15:40):
|
73
|
-
cbeer
|
74
|
-
|
75
|
-
## Wednesday
|
76
|
-
|
77
|
-
- Wednesday (8 - 9am):
|
78
|
-
barmintor
|
79
|
-
- Wednesday (Break #1; 10:35 - 11:00): ksprague, ejames
|
80
|
-
|
81
|
-
- Wednesday (Lunch-ish; 12:00 - 13:00):
|
82
|
-
|
83
|
-
- Wednesday (Break #2; 14:25 - 14:40):
|
84
|
-
|
85
|
-
- Wednesday (Breakout; 14:40 - 15:30):
|
86
|
-
cbeer
|
87
|
-
|
88
|
-
- Wednesday (Break #3; 15:30 - 15:50):
|
89
|
-
|
90
|
-
## Thursday
|
91
|
-
|
92
|
-
- Thursday (8 - 9am):
|
93
|
-
barmintor
|
94
|
-
- Thursday (Break #1; 10:15-11:00):
|
@@ -1,130 +0,0 @@
|
|
1
|
-
Faceted search allows users to constrain searches by controlled vocabulary items.
|
2
|
-
|
3
|
-
Note that these must be INDEXED fields in the Solr index, and are generally a single token (e.g. a string).
|
4
|
-
|
5
|
-
By default, Blacklight will handle creating the Solr requests to handle the different configuration options below. For performance or other reasons, this behavior can be disabled by removing or commenting out:
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
config.add_facet_fields_to_solr_request!
|
9
|
-
```
|
10
|
-
|
11
|
-
Note: When disabled, you are responsible for ensuring Solr returns the necessary values to drive the Blacklight interface.
|
12
|
-
|
13
|
-
## Basic Configuration
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
config.add_facet_field 'format_facet'
|
17
|
-
```
|
18
|
-
|
19
|
-
* label
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
config.add_facet_field 'format_facet', label: "Format"
|
23
|
-
```
|
24
|
-
|
25
|
-
* sort
|
26
|
-
|
27
|
-
Note: setting 'index' causes Blacklight to sort by count and then by index. If your data is strings, you can use this to perform an alphabetical sort of the facets.
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
config.add_facet_field :my_count_sorted_field, sort: 'count'
|
31
|
-
config.add_facet_field :my_index_sorted_field, sort: 'index'
|
32
|
-
```
|
33
|
-
|
34
|
-
* collapse
|
35
|
-
|
36
|
-
```ruby
|
37
|
-
config.add_facet_field 'format_facet', collapse: true # the default
|
38
|
-
```
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
config.add_facet_field 'format_facet', collapse: false
|
42
|
-
```
|
43
|
-
|
44
|
-
* show
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
config.add_facet_field 'format_facet', show: false # don't display the facet, but configure it in case it displays in the constraints (or e.g. a saved search)
|
48
|
-
```
|
49
|
-
|
50
|
-
* helper_method
|
51
|
-
|
52
|
-
```ruby
|
53
|
-
config.add_facet_field 'format_facet', helper_method: :render_format_with_icon
|
54
|
-
```
|
55
|
-
|
56
|
-
```ruby
|
57
|
-
module ApplicationHelper
|
58
|
-
def render_format_with_icon value
|
59
|
-
content_tag :span do
|
60
|
-
content_tag :span, '', class: "glyphicon glyphicon-#{value.parameterize}" +
|
61
|
-
content_tag :span, value
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
```
|
66
|
-
|
67
|
-
* partial
|
68
|
-
|
69
|
-
```ruby
|
70
|
-
config.add_facet_field 'format_facet', partial: 'custom_format_facet'
|
71
|
-
```
|
72
|
-
## Single-value facets
|
73
|
-
|
74
|
-
* single
|
75
|
-
|
76
|
-
Only one value can be selected at a time. When the value is selected, the value of this field is ignored when calculating facet counts for this field.
|
77
|
-
|
78
|
-
```ruby
|
79
|
-
config.add_facet_field 'format_facet', single: true
|
80
|
-
```
|
81
|
-
|
82
|
-
## Tag/Ex Facets
|
83
|
-
|
84
|
-
Single-select facets (above) are one example of Solr's tag/ex functionality. More advanced uses of tag/ex can be done using the `tag` and `ex` configuration.
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
config.add_facet_field 'some_field', tag: 'xyz',ex: 'xyz'
|
88
|
-
config.add_facet_field 'mutually_exclusive_with_above', tag: 'xyz', ex: 'xyz'
|
89
|
-
```
|
90
|
-
|
91
|
-
## Query Facets
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
config.add_facet_field 'a_query_field', query: {
|
95
|
-
a_to_n: { label: 'A-N', fq: 'some_field:[A* TO N*]' }
|
96
|
-
m_to_z: { label: 'M-Z', fq: 'some_field:[A* TO N*]' }
|
97
|
-
}
|
98
|
-
```
|
99
|
-
|
100
|
-
## Pivot Facets
|
101
|
-
|
102
|
-
```ruby
|
103
|
-
config.add_facet_field 'a_pivot_facet', pivot: ['first_field', 'last_field']
|
104
|
-
```
|
105
|
-
|
106
|
-
## Date Facets
|
107
|
-
|
108
|
-
|
109
|
-
If you have date facets in Solr, you should add a hint to the Blacklight configuration to trigger date-based solr querying, and ensure the values are displayed using a localized date format provided by the Rails date helpers:
|
110
|
-
```ruby
|
111
|
-
config.add_facet_field 'date_format', date: true
|
112
|
-
```
|
113
|
-
|
114
|
-
If you want to use a particular localization format, you can provide that as well:
|
115
|
-
|
116
|
-
```ruby
|
117
|
-
config.add_facet_field :my_date_field, :date => { :format => :short }
|
118
|
-
```
|
119
|
-
|
120
|
-
## Range Facets
|
121
|
-
|
122
|
-
blacklight_range_limit
|
123
|
-
|
124
|
-
## Advanced Configuration
|
125
|
-
|
126
|
-
You can also use this facet configuration to inject field-specific configuration
|
127
|
-
|
128
|
-
```ruby
|
129
|
-
config.add_facet_field :my_field, solr_params: { 'facet.mincount' => 15 }
|
130
|
-
```
|
@@ -1,224 +0,0 @@
|
|
1
|
-
Note that Solr fields you configure for display must be STORED fields in the Solr index.
|
2
|
-
|
3
|
-
# Index View
|
4
|
-
|
5
|
-
![Index View](https://f.cloud.github.com/assets/111218/2058436/e322543c-8b71-11e3-90a3-6744cb6628c7.png)
|
6
|
-
|
7
|
-
## Basic configuration
|
8
|
-
|
9
|
-
The index view is configured from your CatalogController's blacklight configuration. Here is a listing of the configuration parameters Blacklight uses and their default values:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
|
13
|
-
configure_blacklight do |config|
|
14
|
-
...
|
15
|
-
|
16
|
-
config.index.title_field = unique_key
|
17
|
-
config.index.partials = [:index_header, :thumbnail, :index]
|
18
|
-
config.index.display_type_field = 'format'
|
19
|
-
config.index.group = false
|
20
|
-
|
21
|
-
...
|
22
|
-
end
|
23
|
-
```
|
24
|
-
|
25
|
-
The configuration keys are not limited or restricted, so plugins or applications that need additional index configuration may add additional parameters directly.
|
26
|
-
|
27
|
-
```ruby
|
28
|
-
config.index.my_custom_parameters = "some value"
|
29
|
-
```
|
30
|
-
|
31
|
-
#### title_field
|
32
|
-
|
33
|
-
The title field setting determines the Solr field that Blacklight will use to display the record title.
|
34
|
-
|
35
|
-
If you need additional customization (e.g. to concatenate two fields, etc), you can provide your own implementation of the `#document_heading` partial method, e.g.
|
36
|
-
|
37
|
-
```
|
38
|
-
module ApplicationHelper
|
39
|
-
def document_heading document = nil
|
40
|
-
document ||= @document
|
41
|
-
document.first(:main_title) + " - " + document.first(:sub_title)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
```
|
45
|
-
|
46
|
-
#### Partials and display_type_field
|
47
|
-
|
48
|
-
You can configure the partials that Blacklight will assemble to display a search result.
|
49
|
-
|
50
|
-
By default, Blacklight will render these three basic partials when displaying a document. The partial names are a combination of two configuration settings. The base name of the partial is given by the `partials` setting. The suffix is based on the type of document given by the value of the `display_type_field`. If a partial is not found with the given `display_type_field` value, it will attempt to render a default version of the base partial. If no matching partial is found, nothing will be displayed for that document.
|
51
|
-
|
52
|
-
For example, using the default values and a document without a `format` field, these partials will be rendered:
|
53
|
-
|
54
|
-
* `index_header_default.html.erb`: The document title and document actions
|
55
|
-
* `thumbnail_default.html.erb`: A representative thumbnail (from the `thumbnail_field` configuration below)
|
56
|
-
* `index_default.html.erb`: A list of document fields
|
57
|
-
|
58
|
-
However, if the document had a format field with the value `book`, Blacklight would attempt to render these partials:
|
59
|
-
|
60
|
-
* `index_header_book.html.erb`; if that doesn't exist, it will fall back to `index_header_default.html.erb`
|
61
|
-
* `thumbnail_book.html.erb`; fall back to `thumbnail_default.html.erb`
|
62
|
-
* `index_book.html.erb`; fall back to `index_default.html.erb`
|
63
|
-
|
64
|
-
Blacklight only provides default partials for these three base partials. If you were to provide an `app/views/catalog/_index_book.html.erb` partial, Blacklight would render that partial instead of the default.
|
65
|
-
|
66
|
-
|
67
|
-
#### (Advanced) Result Collapsing / Grouping
|
68
|
-
|
69
|
-
Blacklight can use Solr's result collapsing feature. To use this feature, set the `group` parameter to the name of the field that Blacklight should use to render collapsed result sets.
|
70
|
-
|
71
|
-
#### Respond_to
|
72
|
-
|
73
|
-
You can also affect which search results response formats are available, in addition to the out-of-the-box HTML, JSON, Atom and RSS feeds.
|
74
|
-
|
75
|
-
Options include:
|
76
|
-
|
77
|
-
- use the Rails default rendering options:
|
78
|
-
```ruby
|
79
|
-
config.index.respond_to.yaml = true
|
80
|
-
```
|
81
|
-
|
82
|
-
- don't render the format (e.g. for overriding defaults):
|
83
|
-
```ruby
|
84
|
-
config.index.respond_to.yaml = false
|
85
|
-
```
|
86
|
-
|
87
|
-
- options for render
|
88
|
-
```ruby
|
89
|
-
config.index.respond_to.yaml = { layout: 'custom-layout' }
|
90
|
-
```
|
91
|
-
|
92
|
-
- custom proc to render
|
93
|
-
```ruby
|
94
|
-
config.index.respond_to.yaml = lambda { render text: "stuff" }
|
95
|
-
```
|
96
|
-
|
97
|
-
- controller method to call to render
|
98
|
-
```ruby
|
99
|
-
config.index.respond_to.yaml = :my_custom_yaml_serialization
|
100
|
-
```
|
101
|
-
|
102
|
-
### Fields
|
103
|
-
|
104
|
-
The fields the `index_default` template uses to render fields are configured using `add_index_field`:
|
105
|
-
|
106
|
-
```
|
107
|
-
config.add_index_field 'title_display'
|
108
|
-
```
|
109
|
-
|
110
|
-
This will add a field to the display that will pull values from the Solr field 'title_display'. If the field is multivalued, Blacklight will concatenate them using a separator (", " by default). This value can also be configured:
|
111
|
-
|
112
|
-
```
|
113
|
-
config.add_index_field 'multivalued_title', separator: '; '
|
114
|
-
```
|
115
|
-
|
116
|
-
Additional configuration options can be also be used:
|
117
|
-
|
118
|
-
#### Labels
|
119
|
-
|
120
|
-
By default, Blacklight will calculate a default label by `humanizing` the Solr field (which is rarely desirable, but convenient for initial configuration). To customize the label, a `:label` option can be provided.
|
121
|
-
|
122
|
-
```ruby
|
123
|
-
config.add_index_field 'title_display', label: "Title"
|
124
|
-
```
|
125
|
-
|
126
|
-
Or, using i18n syntax, may look something like:
|
127
|
-
|
128
|
-
```ruby
|
129
|
-
config.add_index_field 'title_display', label: I18n.t('my.application.index.title_display')
|
130
|
-
```
|
131
|
-
|
132
|
-
The given label is also passed through an i18n filter for adding e.g. prefixes and suffixes. By default, Blacklight will append a ":" to the field value.
|
133
|
-
|
134
|
-
#### Model Accessors
|
135
|
-
|
136
|
-
If the value you wish to display is defined on the model, instead of in a single solr field, you can configure Blacklight to use an accessor on the SolrDocument instance:
|
137
|
-
|
138
|
-
```ruby
|
139
|
-
config.add_index_field 'title_display', :accessor: 'title'
|
140
|
-
```
|
141
|
-
|
142
|
-
This will call `document.title` to get the value of the field, e.g.:
|
143
|
-
|
144
|
-
```ruby
|
145
|
-
class SolrDocument
|
146
|
-
def title
|
147
|
-
first(:main_title) + " - " + first(:sub_title)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
```
|
151
|
-
|
152
|
-
will concatenate the main and sub titles.
|
153
|
-
#### Highlight
|
154
|
-
|
155
|
-
Solr supports query hit-highlighting. Blacklight can display the highlighted version of the field:
|
156
|
-
|
157
|
-
```ruby
|
158
|
-
config.add_index_field 'my_highlighted_field', highlight: true
|
159
|
-
```
|
160
|
-
|
161
|
-
#### Helper Method
|
162
|
-
|
163
|
-
When preparing a value for display, Blacklight can be configured to call a custom helper method.
|
164
|
-
|
165
|
-
```ruby
|
166
|
-
config.add_index_field 'some_field_with_an_external_link', helper_method: 'make_this_a_link'
|
167
|
-
```
|
168
|
-
|
169
|
-
```ruby
|
170
|
-
module ApplicationHelper
|
171
|
-
def make_this_a_link options={}
|
172
|
-
options[:document] # the original document
|
173
|
-
options[:field] # the field to render
|
174
|
-
options[:value] # the value of the field
|
175
|
-
|
176
|
-
link_to options[:value], options[:value]
|
177
|
-
end
|
178
|
-
end
|
179
|
-
```
|
180
|
-
|
181
|
-
#### Link To Search
|
182
|
-
|
183
|
-
Some display fields are also facet fields, and often it makes sense to link the displayed value to the corresponding facet selection.
|
184
|
-
|
185
|
-
```ruby
|
186
|
-
config.add_index_field 'genre', link_to_search: true
|
187
|
-
```
|
188
|
-
|
189
|
-
Or use the value in a link to a different field (e.g. if your display field is not indexed)
|
190
|
-
|
191
|
-
```ruby
|
192
|
-
config.add_index_field 'genre', link_to_search: 'genre_facet'
|
193
|
-
```
|
194
|
-
|
195
|
-
#### Schema.org configuration
|
196
|
-
|
197
|
-
```ruby
|
198
|
-
config.add_index_field 'genre', itemprop: "genre"
|
199
|
-
```
|
200
|
-
|
201
|
-
The genre values will be marked up as schema.org genre values.
|
202
|
-
|
203
|
-
### View Types
|
204
|
-
|
205
|
-
Blacklight provides a default "list" view of results.
|
206
|
-
|
207
|
-
### (Advanced) Results Grouping
|
208
|
-
|
209
|
-
# Show view
|
210
|
-
|
211
|
-
![Show view](https://f.cloud.github.com/assets/111218/2058440/e32f32a6-8b71-11e3-9bd5-20b0a3af2fea.png)
|
212
|
-
|
213
|
-
|
214
|
-
## Advanced Configuration
|
215
|
-
|
216
|
-
You can also use the field configuration to inject field-specific configuration
|
217
|
-
|
218
|
-
```ruby
|
219
|
-
config.add_index_field 'an_index_field', solr_params: { 'hl.alternativeField' => 'field_x'}
|
220
|
-
config.add_show_field 'a_show_field', solr_params: { 'hl.alternativeField' => 'field_y'}
|
221
|
-
# provided you also use: config.add_field_configuration_to_solr_request!
|
222
|
-
```
|
223
|
-
|
224
|
-
This will add field-specific parameters to the solr request.
|