blacklight 3.8.2 → 4.0.0.pre6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +12 -1
- data/app/assets/javascripts/blacklight/bootstrap_dropdowns.js +3 -0
- data/app/assets/javascripts/blacklight/checkbox_submit.js +12 -5
- data/app/assets/javascripts/blacklight/core.js +0 -1
- data/app/assets/javascripts/blacklight/css_dropdowns.js +10 -0
- data/app/assets/javascripts/blacklight/facet_expand_contract.js +5 -5
- data/app/assets/javascripts/blacklight/lightbox_dialog.js +68 -13
- data/app/assets/javascripts/blacklight/select_submit.js +19 -10
- data/app/assets/javascripts/improved-modal/bootstrap-modal.js +282 -0
- data/app/assets/javascripts/improved-modal/bootstrap-modalmanager.js +353 -0
- data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +16 -5
- data/app/assets/stylesheets/blacklight/_bookmark.css.scss +24 -6
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +115 -141
- data/app/assets/stylesheets/blacklight/_dropdown.css.scss +57 -0
- data/app/assets/stylesheets/blacklight/_facets.css.scss +127 -58
- data/app/assets/stylesheets/blacklight/_footer.css.scss +20 -0
- data/app/assets/stylesheets/blacklight/_header.css.scss +90 -21
- data/app/assets/stylesheets/blacklight/_layout.css.scss +10 -9
- data/app/assets/stylesheets/blacklight/_modal.css.scss +23 -0
- data/app/assets/stylesheets/blacklight/_print.css.scss +0 -7
- data/app/assets/stylesheets/blacklight/_responsive.css.scss +3 -0
- data/app/assets/stylesheets/blacklight/_search_history.css.scss +2 -4
- data/app/assets/stylesheets/blacklight/blacklight.css.scss +0 -1
- data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +9 -2
- data/app/assets/stylesheets/blacklight/responsive_partials/_catalog.css.scss +5 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/_facets.css.scss +37 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/_header.css.scss +30 -0
- data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +199 -0
- data/app/controllers/bookmarks_controller.rb +16 -10
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +124 -61
- data/app/helpers/blacklight/catalog_helper_behavior.rb +5 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +9 -9
- data/app/views/_flash_msg.html.erb +9 -4
- data/app/views/_user_util_links.html.erb +23 -17
- data/app/views/bookmarks/_tools.html.erb +7 -7
- data/app/views/bookmarks/index.html.erb +5 -13
- data/app/views/catalog/_bookmark_control.html.erb +2 -4
- data/app/views/catalog/_bookmark_form.html.erb +1 -1
- data/app/views/catalog/_citation.html.erb +21 -20
- data/app/views/catalog/_constraints.html.erb +8 -6
- data/app/views/catalog/_document_header.html.erb +6 -7
- data/app/views/catalog/_document_list.html.erb +1 -7
- data/app/views/catalog/_email_form.html.erb +42 -16
- data/app/views/catalog/_facet_layout.html.erb +1 -1
- data/app/views/catalog/_facet_limit.html.erb +1 -1
- data/app/views/catalog/_facet_pagination.html.erb +11 -14
- data/app/views/catalog/_facets.html.erb +16 -2
- data/app/views/catalog/_home.html.erb +2 -2
- data/app/views/catalog/_home_text.html.erb +5 -2
- data/app/views/catalog/_index_default.html.erb +2 -2
- data/app/views/catalog/_marc_view.html.erb +0 -1
- data/app/views/catalog/_paginate_compact.html.erb +5 -0
- data/app/views/catalog/_per_page_widget.html.erb +13 -7
- data/app/views/catalog/_previous_next_doc.html.erb +14 -4
- data/app/views/catalog/_refworks_form.html.erb +2 -2
- data/app/views/catalog/_results_pagination.html.erb +4 -1
- data/app/views/catalog/_search_form.html.erb +19 -13
- data/app/views/catalog/_show_default.html.erb +2 -2
- data/app/views/catalog/_show_more_like_this.html.erb +3 -0
- data/app/views/catalog/_show_sidebar.html.erb +14 -1
- data/app/views/catalog/_show_tools.html.erb +18 -18
- data/app/views/catalog/_sms_form.html.erb +35 -10
- data/app/views/catalog/_sort_and_per_page.html.erb +5 -3
- data/app/views/catalog/_sort_widget.html.erb +12 -6
- data/app/views/catalog/citation.html.erb +1 -1
- data/app/views/catalog/citation.js.erb +7 -0
- data/app/views/catalog/email.html.erb +5 -0
- data/app/views/catalog/facet.html.erb +28 -21
- data/app/views/catalog/index.html.erb +26 -26
- data/app/views/catalog/librarian_view.html.erb +7 -0
- data/app/views/catalog/show.html.erb +35 -29
- data/app/views/catalog/sms.html.erb +5 -0
- data/app/views/kaminari/blacklight/_first_page.html.erb +2 -2
- data/app/views/kaminari/blacklight/_gap.html.erb +4 -1
- data/app/views/kaminari/blacklight/_last_page.html.erb +2 -2
- data/app/views/kaminari/blacklight/_next_page.html.erb +3 -3
- data/app/views/kaminari/blacklight/_page.html.erb +4 -3
- data/app/views/kaminari/blacklight/_paginator.html.erb +5 -5
- data/app/views/kaminari/blacklight/_prev_page.html.erb +3 -3
- data/app/views/kaminari/blacklight_compact/_next_page.html.erb +9 -0
- data/app/views/kaminari/blacklight_compact/_paginator.html.erb +15 -0
- data/app/views/kaminari/blacklight_compact/_prev_page.html.erb +9 -0
- data/app/views/layouts/blacklight.html.erb +47 -27
- data/app/views/saved_searches/index.html.erb +2 -2
- data/app/views/search_history/index.html.erb +12 -7
- data/app/views/shared/_footer.html.erb +0 -0
- data/app/views/shared/_header_navbar.html.erb +25 -0
- data/blacklight.gemspec +2 -5
- data/config/locales/blacklight.en.yml +23 -15
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/catalog.rb +36 -14
- data/lib/blacklight/configuration.rb +10 -2
- data/lib/blacklight/mash.rb +151 -0
- data/lib/blacklight/solr/document.rb +73 -11
- data/lib/blacklight/solr/document/extensions.rb +0 -8
- data/lib/blacklight/solr/document/marc_export.rb +7 -2
- data/lib/blacklight/solr/document/more_like_this.rb +5 -0
- data/lib/blacklight/solr_helper.rb +43 -18
- data/lib/blacklight/solr_response.rb +60 -0
- data/lib/blacklight/solr_response/facets.rb +58 -0
- data/lib/blacklight/solr_response/more_like_this.rb +14 -0
- data/lib/blacklight/solr_response/spelling.rb +92 -0
- data/lib/generators/blacklight/assets_generator.rb +1 -14
- data/lib/generators/blacklight/blacklight_generator.rb +22 -21
- data/lib/generators/blacklight/jetty_generator.rb +1 -35
- data/{test_support → lib/generators/blacklight/templates}/alternate_controller.rb +0 -0
- data/lib/generators/blacklight/templates/blacklight.css.scss +4 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/config-test.properties +2 -2
- data/lib/generators/blacklight/templates/config/jetty.yml +6 -0
- data/lib/generators/blacklight/test_support_generator.rb +35 -0
- data/lib/railties/all_tests.rake +5 -23
- data/lib/railties/blacklight_cucumber.rake +2 -11
- data/lib/railties/blacklight_rspec.rake +2 -12
- data/test_support/bin/run-tests.sh +1 -1
- data/test_support/bin/setup-test-app.sh +123 -0
- data/test_support/bin/test.sh +21 -21
- data/test_support/features/bookmarks.feature +9 -3
- data/test_support/features/saved_searches.feature +3 -3
- data/test_support/features/search.feature +3 -3
- data/test_support/features/search_filters.feature +24 -26
- data/test_support/features/search_history.feature +9 -10
- data/test_support/features/search_sort.feature +4 -6
- data/test_support/features/step_definitions/general_steps.rb +0 -4
- data/test_support/features/step_definitions/search_result_steps.rb +2 -1
- data/test_support/features/step_definitions/search_steps.rb +32 -2
- data/test_support/spec/controllers/application_controller_spec.rb +8 -0
- data/test_support/spec/controllers/catalog_controller_spec.rb +3 -18
- data/test_support/spec/helpers/blacklight_helper_spec.rb +116 -20
- data/test_support/spec/helpers/catalog_helper_spec.rb +14 -6
- data/test_support/spec/helpers/facets_helper_spec.rb +1 -1
- data/test_support/spec/lib/blacklight_solr_document_more_like_this_spec.rb +18 -0
- data/test_support/spec/lib/blacklight_solr_document_spec.rb +54 -1
- data/test_support/spec/lib/blacklight_solr_response_spec.rb +153 -0
- data/test_support/spec/lib/facet_paginator_spec.rb +1 -1
- data/test_support/spec/lib/marc_export_spec.rb +14 -6
- data/test_support/spec/lib/solr_helper_spec.rb +22 -6
- data/test_support/spec/models/solr_docment_spec.rb +1 -4
- data/test_support/spec/{features → requests}/alternate_controller_spec.rb +3 -2
- data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +20 -4
- data/test_support/spec/views/catalog/_show_sidebar.erb_spec.rb +25 -0
- metadata +53 -131
- data/app/assets/javascripts/blacklight/more_facets.js +0 -16
- data/app/assets/javascripts/jquery-1.4.2.min.js +0 -154
- data/app/assets/javascripts/jquery-ui-1.8.1.custom.min.js +0 -756
- data/app/assets/javascripts/jquery.uiExt.ajaxyDialog.js +0 -180
- data/app/assets/stylesheets/blacklight/_formatting.css.scss +0 -164
- data/app/assets/stylesheets/blacklight/grids/_susy_grid.css.scss +0 -72
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-anim_basic_16x16.gif +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_gloss-wave_35_558fd0_500x100.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-icons_2e4f81_256x240.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- data/app/assets/stylesheets/jquery/ui-lightness/jquery-ui-1.8.1.custom.css +0 -486
- data/app/models/solr_document.rb +0 -5
- data/app/views/catalog/email.erb +0 -1
- data/app/views/catalog/sms.erb +0 -1
- data/doc/Atom-Responses.md +0 -90
- data/doc/Blacklight-3.2-Release-Notes-and-Upgrade-Guide.md +0 -191
- data/doc/Blacklight-3.3-release-notes-and-upgrade-guide.md +0 -37
- data/doc/Blacklight-3.4-release-notes-and-upgrade-guide.md +0 -27
- data/doc/Blacklight-3.5-release-notes-and-upgrade-guide.md +0 -44
- data/doc/Blacklight-3.6-release-notes-and-upgrade-guide.md +0 -25
- data/doc/Blacklight-3.7-release-notes-and-upgrade-guide.md +0 -78
- data/doc/Blacklight-3.8-release-notes-and-upgrade-guide.md +0 -11
- data/doc/Blacklight-Add-ons.md +0 -28
- data/doc/Blacklight-configuration.md +0 -301
- data/doc/Blacklight-on-Heroku.md +0 -135
- data/doc/Community-principles.md +0 -44
- data/doc/Configuring-and-Customizing-Blacklight.md +0 -271
- data/doc/Contributing-to-Blacklight.md +0 -25
- data/doc/Examples.md +0 -62
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
- data/doc/Home.md +0 -77
- data/doc/How-to-release-a-version.md +0 -37
- data/doc/Indexing-your-data-into-solr.md +0 -5
- data/doc/Integration-with-Rails-Footnotes.md +0 -20
- data/doc/Pagination.md +0 -38
- data/doc/Providing-your-own-view-templates.md +0 -109
- data/doc/Quickstart.md +0 -116
- data/doc/README.md +0 -77
- data/doc/README_SOLR.md +0 -245
- data/doc/Release-Notes-And-Upgrade-Guides.md +0 -14
- data/doc/Sunspot-for-indexing.md +0 -46
- data/doc/User-Authentication.md +0 -60
- data/doc/testing.md +0 -115
- data/lib/generators/blacklight/solr_conf_generator.rb +0 -26
- data/lib/generators/blacklight/templates/assets/standard.css.scss +0 -59
- data/lib/generators/blacklight/templates/config/blacklight_config.rb +0 -3
- data/lib/generators/blacklight/templates/config/compass.rb +0 -2
- data/lib/generators/blacklight/templates/solr_conf/schema.xml +0 -689
- data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +0 -1846
- data/lib/solrmarc.log.1 +0 -849
- data/test_support/spec/controllers/bookmarks_controller_spec.rb +0 -48
data/doc/Community-principles.md
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# Community Principles
|
2
|
-
|
3
|
-
## Overview
|
4
|
-
* Blacklight is an open source application for libraries (and anyone else), built on top of SOLR, and meant to deliver excellent access to all classes of information resources.
|
5
|
-
* Blacklight can ultimately be successful and sustainable in the long run only if it is an open project; that is, it takes contributions from a community of developers across many institutions to enhance and support it
|
6
|
-
* We will work to balance progress on Blacklight’s codebase with open community discussion and transparent decision making as coequal goals
|
7
|
-
* Blacklight code is available through the Apache 2.0 open source license.
|
8
|
-
|
9
|
-
## Technical Leadership
|
10
|
-
Technical leadership of the project will be through a small group of proven developers who have demonstrated commitment to Blacklight’s progress and success (and have commit rights to the source code)
|
11
|
-
|
12
|
-
Committers must be:
|
13
|
-
|
14
|
-
* technically adept
|
15
|
-
* constructive, positive members of the Blacklight software community
|
16
|
-
* committed to producing useful, practical code for the community
|
17
|
-
|
18
|
-
To become a committer, candidates must be…
|
19
|
-
|
20
|
-
* nominated by a current committer
|
21
|
-
* voted on and approved by a majority of the current committers
|
22
|
-
* committers may be voted out at any time by a (super?) majority of the other committers
|
23
|
-
|
24
|
-
Committers will have a regular meeting, usually in the form of a conference call, to coordinate development & direction.
|
25
|
-
|
26
|
-
Releases will be vetted and controlled by a designated lead or leads. These roles may shift from release to release.
|
27
|
-
|
28
|
-
## Code Contributions & Principles
|
29
|
-
* the users of, interest in, resources, and talent pool of the Blacklight community will spread far beyond the developers on the committers list, and their institutions
|
30
|
-
* Blacklight encourages and will facilitate taking code from contributors from many sources
|
31
|
-
the structure of the source code management (soon GIT) will facilitate incorporating and using code from many sources
|
32
|
-
* Blacklight committers will actively take code contributions from non-committers and incorporate it into the code trunk
|
33
|
-
* Working code wins
|
34
|
-
* You get what you give
|
35
|
-
* All contributed code must have full test coverage before it is committed. The current testing infrastructure is RSpec for everything but Rails views, and Cucumber for for Rails views.
|
36
|
-
* Tests must be committed at the same time code is.
|
37
|
-
* All javascript features (where feasible) should be added using “progressive enhancement” or “unobtrusive javascript” styles. Meaning the basic feature should work without Javascript, and the JS should be added as a progressive enhancement, and added via externally linked js files, not in-line in html source as script tags, onclick attributes, etc.
|
38
|
-
* All bugs and development tasks will be tracked in GitHub Issues
|
39
|
-
* All code must be documented before it’s committed
|
40
|
-
|
41
|
-
## Roadmap & Transparency
|
42
|
-
We will publish a roadmap to guide overall development. The items on this roadmap will be determined after an inclusive process of canvassing the wider Blacklight community, including code committers, contributors, users and a potential advisory board.
|
43
|
-
|
44
|
-
We envision regular/quarterly/semiannual/annual Blacklight convention of community members to help guide and galvanize new developments. These are likely to be appended to other community events, e.g., code4lib, for the sake of logistics.
|
@@ -1,271 +0,0 @@
|
|
1
|
-
# Configuring and Customizing Blacklight
|
2
|
-
|
3
|
-
There are lots of ways to override specific behaviors and views in Blacklight. Blacklight is distributed as a Ruby gem with a Rails Engine framework built in. All customization of Blacklight behavior should be done within your application (partly as good practice, but also to not lose your changes with every new Blacklight release).
|
4
|
-
|
5
|
-
If you find that there is no other way to make your customization, please describe your problem on the [[mailing list|http://groups.google.com/group/blacklight-development]] -- we'll do the best we can to help out, and even make changes to Blacklight as needed. If you are interested in contributing code to Blacklight, see the [[Contributing to Blacklight]] page.
|
6
|
-
|
7
|
-
## Configuration
|
8
|
-
|
9
|
-
|
10
|
-
Blacklight provides a Ruby on Rails -based interface to the Apache Solr Enterprise Search Server. More information about Solr is available at the [[Solr web site|http://lucene.apache.org/solr/]]. 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).
|
11
|
-
|
12
|
-
Although the out-of-the-box Blacklight application is configured to work with library MARC-based data, the configuration is easy to extend and modify to meet other needs. **All of these configurations for facet fields, index fields, solr search params logic, etc. go in your CatalogController**. By default, this will be located at *app/controllers/catalog_controller.rb*
|
13
|
-
|
14
|
-
**Note:** While it is sufficient to have just one CatalogController, You can actually create multiple variations of the catalog controller (ie. MusicCatalog, DvdCatalog), each with its own configuration settings and URL routing.
|
15
|
-
|
16
|
-
Once you have your Solr fields, you can then configure your Blacklight application to display arbitrary fields in different contexts
|
17
|
-
|
18
|
-
### Choose which Fields to Display in Search Results
|
19
|
-
|
20
|
-
* Displayed fields and labels can be customized on both the search results and document views.
|
21
|
-
Note that these must be STORED fields in the Solr index.
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
# [from app/controllers/catalog_controller.rb]
|
25
|
-
# solr fields to be displayed in the index (search results) view
|
26
|
-
# The ordering of the field names is the order of the display
|
27
|
-
config.add_index_field 'title_display', :label => 'Title:'
|
28
|
-
config.add_index_field 'title_vern_display', :label => 'Title:'
|
29
|
-
config.add_index_field 'author_display', :label => 'Author:'
|
30
|
-
config.add_index_field 'author_vern_display', :label => 'Author:'
|
31
|
-
```
|
32
|
-
|
33
|
-
### Targeting Search Queries at Configurable Fields
|
34
|
-
|
35
|
-
* 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]]
|
36
|
-
[[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_fields.png|frame|alt=Search fields in action]]
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
# [from app/controllers/catalog_controller.rb]
|
40
|
-
# Now we see how to over-ride Solr request handler defaults, in this
|
41
|
-
# case for a BL "search field", which is really a dismax aggregate
|
42
|
-
# of Solr search fields.
|
43
|
-
|
44
|
-
config.add_search_field('title') do |field|
|
45
|
-
# solr_parameters hash are sent to Solr as ordinary url query params.
|
46
|
-
field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
|
47
|
-
|
48
|
-
# :solr_local_parameters will be sent using Solr LocalParams
|
49
|
-
# syntax, as eg {! qf=$title_qf }. This is neccesary to use
|
50
|
-
# Solr parameter de-referencing like $title_qf.
|
51
|
-
# See: http://wiki.apache.org/solr/LocalParams
|
52
|
-
field.solr_local_parameters = {
|
53
|
-
:qf => '$title_qf',
|
54
|
-
:pf => '$title_pf'
|
55
|
-
}
|
56
|
-
end
|
57
|
-
```
|
58
|
-
|
59
|
-
### Choosing & Configuring Facets
|
60
|
-
|
61
|
-
- Faceted search allows users to constrain searches by controlled vocabulary items
|
62
|
-
[[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_facets.png|frame|alt=Search facets in action]]
|
63
|
-
Note that these must be INDEXED fields in the Solr index, and are generally a single token (e.g. a string).
|
64
|
-
|
65
|
-
```ruby
|
66
|
-
# [from app/controllers/catalog_controller.rb]
|
67
|
-
# solr fields that will be treated as facets by the blacklight application
|
68
|
-
# The ordering of the field names is the order of the display
|
69
|
-
config.add_facet_field 'format', :label => 'Format'
|
70
|
-
config.add_facet_field 'pub_date', :label => 'Publication Year'
|
71
|
-
config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
|
72
|
-
config.add_facet_field 'language_facet', :label => 'Language', :limit => true
|
73
|
-
```
|
74
|
-
|
75
|
-
Blacklight also supports Solr facet queries:
|
76
|
-
|
77
|
-
```ruby
|
78
|
-
config.add_facet_field 'pub_date_query', :label => 'Publication Year', :query => {
|
79
|
-
:last_5_years => { :label => 'Last 5 Years', :fq => "[#{Time.now.year-5} TO *]"}
|
80
|
-
}
|
81
|
-
```
|
82
|
-
|
83
|
-
You can also tell Solr how to sort facets (either by count or index):
|
84
|
-
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.
|
85
|
-
```ruby
|
86
|
-
config.add_facet_field :my_count_sorted_field, :sort => 'count'
|
87
|
-
config.add_facet_field :my_index_sorted_field, :sort => 'index'
|
88
|
-
```
|
89
|
-
|
90
|
-
|
91
|
-
If you want Solr to add the configured facets and facet queries to the Solr query it sends, you should also add:
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
config.add_facet_fields_to_solr_request!
|
95
|
-
```
|
96
|
-
|
97
|
-
If you have date facets in Solr, you should add a hint to the Blacklight configuration:
|
98
|
-
|
99
|
-
```ruby
|
100
|
-
config.add_facet_field :my_date_field, :date => true
|
101
|
-
```
|
102
|
-
|
103
|
-
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:
|
104
|
-
|
105
|
-
```ruby
|
106
|
-
config.add_facet_field :my_date_field, :date => { :format => :short }
|
107
|
-
```
|
108
|
-
|
109
|
-
### Map from User Queries to Solr Parameters
|
110
|
-
|
111
|
-
* Blacklight provides flexible mapping from user queries to solr parameters, which are easily overridden in local applications (see [[Extending or Modifying Blacklight Search Behavior]]).
|
112
|
-
|
113
|
-
```ruby
|
114
|
-
# [from app/controllers/catalog_controller.rb]
|
115
|
-
# Each symbol identifies a _method_ that must be in
|
116
|
-
# this class, taking two parameters (solr_parameters, user_parameters)
|
117
|
-
# Can be changed in local apps or by plugins, eg:
|
118
|
-
# CatalogController.include ModuleDefiningNewMethod
|
119
|
-
# CatalogController.solr_search_params_logic << :new_method
|
120
|
-
# CatalogController.solr_search_params_logic.delete(:we_dont_want)
|
121
|
-
self.solr_search_params_logic = [:default_solr_parameters , :add_query_to_solr, :add_facet_fq_to_solr, :add_facetting_to_solr, :add_sorting_paging_to_solr ]
|
122
|
-
```
|
123
|
-
|
124
|
-
> Source: [[./lib/blacklight/solr_helper.rb|https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr_helper.rb#L70]]
|
125
|
-
|
126
|
-
### Document Extension Framework
|
127
|
-
|
128
|
-
The main use case for extensions is for transforming a Document to another
|
129
|
-
format. Either to another type of Ruby object, or to an exportable string in
|
130
|
-
a certain format.
|
131
|
-
|
132
|
-
An Blacklight::Solr::Document extension is simply a ruby module which is mixed
|
133
|
-
in to individual Document instances. The intended use case is for documents
|
134
|
-
containing some particular format of source material, such as Marc. An
|
135
|
-
extension can be registered with your document class, along with a block
|
136
|
-
containing custom logic for which documents to apply the extension to.
|
137
|
-
|
138
|
-
```ruby
|
139
|
-
SolrDocument.use_extension(MyExtension) {|document| my_logic_on_document(document}
|
140
|
-
```
|
141
|
-
|
142
|
-
MyExtension will be mixed-in (using ruby 'extend') only to those documents
|
143
|
-
where the block results in true.
|
144
|
-
|
145
|
-
Underlying metadata formats, or other alternative document views, are linked to from the HTML page <head>.
|
146
|
-
|
147
|
-
# Customizing the User Interface
|
148
|
-
## Layouts
|
149
|
-
|
150
|
-
The built-in Blacklight controllers all by default use a Rails view layout called "blacklight", that lives in the Blacklight source. This ends up being a bit confusing, but is the best way we have at present to have out of the box default using a layout with full functionality, without stepping on a possibly existing local 'application' layout.
|
151
|
-
|
152
|
-
To change what layout the Blacklight controllers use, simply implement a method #layout_name in your local application_controller.rb that returns the name of the layout you'd like them to use.
|
153
|
-
|
154
|
-
```ruby
|
155
|
-
# [from app/controllers/application_controller.rb]
|
156
|
-
class ApplicationController < ActionController::Base
|
157
|
-
...
|
158
|
-
def layout_name
|
159
|
-
"application"
|
160
|
-
end
|
161
|
-
...
|
162
|
-
end
|
163
|
-
```
|
164
|
-
|
165
|
-
When implementing your own layout instead of using the stock one, you may want to look at the Blacklight app/views/layouts/blacklight.html.erb file to see what helper methods are called there, to maintain full Blacklight functionality you may want to call these same helper methods.
|
166
|
-
|
167
|
-
* `render_head_content` renders content within the
|
168
|
-
html `<head>` tag, which includes document-specific alternative
|
169
|
-
formats as well as tags generated by plugins, etc.
|
170
|
-
* `sidebar_items` renders features including sidebar content, e.g. facet
|
171
|
-
lists.
|
172
|
-
* flash messages
|
173
|
-
* user util links
|
174
|
-
|
175
|
-
## Overriding Views (templates and partials)
|
176
|
-
As a Rails Engine, you can easily override views in your app. You can see what views and partials are provided by looking in `[[./app/views|https://github.com/projectblacklight/blacklight/tree/master/app/views]]` inside the Blacklight source.
|
177
|
-
|
178
|
-
Once you find the view you'd like to change, you should create a file with the same name and relative path in your own application (e.g. if you wanted to override [[./app/views/catalog/_show_partials/_default.html.erb|https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/_show_partials/_default.html.erb]] you would create ./app/views/catalog/_show_partials/_default.html.erb in your local application. Frequently, you will start by copying the existing Blacklight view and modifying it from there.
|
179
|
-
|
180
|
-
It is generally recommended that you override as little as possible, in order to maximize your forward compatibility. Look to override either a small, focused partial template, or a helper method of partial template called from a larger template, so your application's version can call out to those same helpers or partial templates within blacklight core code.
|
181
|
-
|
182
|
-
## Overriding the CatalogController
|
183
|
-
Overriding the Blacklight `CatalogController` implementation is easy, and the skeleton of the `CatalogController` is generated into your application for you when you install Blacklight.
|
184
|
-
|
185
|
-
See the [[Extending or Modifying Blacklight Search Behavior]] for tips and approaches to customizing the catalog.
|
186
|
-
|
187
|
-
## Overriding Other Controllers
|
188
|
-
|
189
|
-
1. Find the controller you're interested in blacklight's app/controllers/ .
|
190
|
-
2. Create a file with the same name in your local app/controllers.
|
191
|
-
3. This file requires the original class, and then re-opens it to add more methods.
|
192
|
-
|
193
|
-
```ruby
|
194
|
-
require "#{Blacklight.controllers_dir}/some_controller"
|
195
|
-
|
196
|
-
class SomeController < ApplicationController
|
197
|
-
# custom code goes here
|
198
|
-
end
|
199
|
-
```
|
200
|
-
|
201
|
-
In that "custom code goes here", you can redefine certain methods (action methods or otherwise) to do something different. You can also add new methods (again action methods or otherwise), etc.
|
202
|
-
|
203
|
-
It's kind of hard to call 'super' to call original functionality:
|
204
|
-
|
205
|
-
* the ruby language features here make 'super' unavailable, although you can work around that confusingly with the rails #alias_method_chain method.
|
206
|
-
* but more importantly, action methods in particular don't really suit themselves to being over-ridden and called by super, because the original implementation often does something you'd want to change but there's no easy way to 'undo' -- calling 'render', which can only be called once.
|
207
|
-
|
208
|
-
So basically, if you find yourself wanting to access some functionaltiy in the original implementation of a method that you also want to over-ride -- the best solution is probably to refactor Blacklight core code to put that functionality in a subsidiary method, so you can over-ride the action method entirely but call that logic from core. Action methods should be short and sweet anyway.
|
209
|
-
|
210
|
-
|
211
|
-
## Custom View Helpers
|
212
|
-
|
213
|
-
(This is accurate for Blacklight 3.1.1 and subsequent. Before that, things were messier).
|
214
|
-
|
215
|
-
One of the most common things you might need to do is create a view helper -- especially to override some Blacklight behavior implemented in it's own view helpers. The first step is looking at Blacklight source to determine what view helper method you want to override.
|
216
|
-
|
217
|
-
Blacklight comes packaged with several view helper modules. There is a BlacklightHelper in (blacklight source) app/helpers/blacklight_helper.rb , and several others that correspond to specific controller. (Note, depending on version of Rails and configuration, all helpers may get loaded for every request, even ones that are named to correspond only to a particular other controller).
|
218
|
-
|
219
|
-
If you simply created a local helper with the same name as a helper in Blacklight, that will end up preventing the Blacklight helper from being loaded at all though, which is not what you want to do to override.
|
220
|
-
|
221
|
-
We've structured each Blacklight view helper module into two parts to make it easy to selectively over-ride methods. For instance, here's Blacklight's app/helpers/blacklight_helper.rb:
|
222
|
-
|
223
|
-
```ruby
|
224
|
-
module BlacklightHelper
|
225
|
-
include Blacklight::BlacklightHelperBehavior
|
226
|
-
end
|
227
|
-
```
|
228
|
-
|
229
|
-
Now, the actual methods will be found in app/helpers/blacklight/blacklight_helper_behavior.rb instead.
|
230
|
-
|
231
|
-
If you want to over-ride a helper method, copy the wrapper blacklight_helper into your local app, with the 'include' line, and now you can individually over-ride methods from BlacklightHelperBehavior, and the other methods you don't over-ride will still have their default implementation.
|
232
|
-
|
233
|
-
YOUR `app/helpers/blacklight_helper.rb`
|
234
|
-
|
235
|
-
```ruby
|
236
|
-
module BlacklightHelper
|
237
|
-
include Blacklight::BlacklightHelperBehavior
|
238
|
-
|
239
|
-
def application_name
|
240
|
-
"Bestest University Search"
|
241
|
-
end
|
242
|
-
end
|
243
|
-
```
|
244
|
-
|
245
|
-
One helper you might want to over-ride for customization is #render_document_partial (currently defined in [[blacklight_helper|https://github.com/projectblacklight/blacklight/blob/master/app/helpers/blacklight_helper.rb]]), which you can over-ride to choose differnet local partial views to display a document on search results or detail page, possibly varying depending on type of document according to your own local logic.
|
246
|
-
|
247
|
-
## Adding in your own CSS or Javascript
|
248
|
-
|
249
|
-
Within your local application, you can use the [[Rails Asset Pipeline|http://guides.rubyonrails.org/asset_pipeline.html]] to manipulate javascript and css documents.
|
250
|
-
|
251
|
-
**todo??** better instructions for over-riding BL's built in CSS using SASS? (jrochkind thought jamesws wrote such already, but can't find them now)
|
252
|
-
|
253
|
-
The Blacklight generator added a file to your app at `./app/assets/stylesheets/blacklight_themes/standard.css.scss`, elements of the BL default theme can be customized or over-ridden there. If there's something you want to do but aren't sur e the best way, feel free to ask on the listserv.
|
254
|
-
|
255
|
-
### jquery-ui
|
256
|
-
|
257
|
-
Blacklight by default uses [jquery-ui](http://jqueryui.com/) for some UI widgets.
|
258
|
-
|
259
|
-
The Blacklight gem provides it's own JQuery-UI theme, and makes it work with the rails asset pipeline even precompiled. (as of BL 3.3.1).
|
260
|
-
|
261
|
-
To disable Blacklight's provision of JQuery-UI theme:
|
262
|
-
|
263
|
-
* comment out `*= require 'jquery/ui-lightness/jquery-ui-1.8.1.custom.css'` from your `./app/assets/stylesheets/application.css`
|
264
|
-
* add `Blacklight::Engine.config.jquery_images=false` to your `./config/application.rb` or some other control point that happens before Rails initialization.
|
265
|
-
|
266
|
-
Then [create your own JQuery-UI theme](http://jqueryui.com/themeroller/), and set it up yourself to be included and used in the rails asset pipeline. This can be tricky, [here's a blog post on options](http://bibwild.wordpress.com/2011/12/08/jquery-ui-css-and-images-and-rails-asset-pipeline/).
|
267
|
-
|
268
|
-
## See also
|
269
|
-
|
270
|
-
* [[Extending or Modifying Blacklight Search Behavior]]
|
271
|
-
* [[Pagination]]
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# Contributing to Blacklight
|
2
|
-
Blacklight is a collaborative open source project by developers at various institutions, which we each work on largely motivated by our own local institutions' needs. We work on the shared project together so we can benefit from each other's code, but most developers primary priorities are to their own local development. In this it is like many such projects.
|
3
|
-
|
4
|
-
The Blacklight developers do want to create a product that is easy for newcomers to install and get started with -- both as a service to the community and in the interests of our own institutions in creating a sustainable project and product that continue to thrive through personnel changes. However, the developers may not always have time to find or fix bugs that may be affecting you, or lead you through every detail of getting Blacklight to work for you.
|
5
|
-
|
6
|
-
But we do try when we can -- please don't be scared to ask a question on the [[Blacklight mailing list|http://groups.google.com/group/blacklight-development]], just don't be shocked if we can't always give you the answer you want. We always welcome patch submissions; and we are always excited to hear about what others are doing with Blacklight. We're also always looking for more committers, although we usually like to see a patch or two before considering granting committer status.
|
7
|
-
|
8
|
-
If you follow this short guide, it will make it much easier for the community to review your changes, and the core team to get them included in the next release. If you are new to Git, be sure to read Github's (really good) [[step-by-step directions|http://help.github.com/fork-a-repo/]] for contributing to projects. If you want a basic introduction to git, check out [[Git Reference|http://gitref.org/]].
|
9
|
-
|
10
|
-
We also encourage a lot of peripheral functionality -- especially for features that may not be used by most implementations, as the Blacklight install base has a wide range of users -- to consider developing stand-alone, optional [[Blacklight add-ons]].
|
11
|
-
|
12
|
-
## Adding a ticket
|
13
|
-
Let us know you're interested in working on a feature by filing a ticket in our [[issue tracker|https://github.com/projectblacklight/blacklight/issues]].
|
14
|
-
|
15
|
-
## Making Your Changes
|
16
|
-
|
17
|
-
* Fork the project (Github has really good step-by-step directions
|
18
|
-
* Start a feature/bugfix branch
|
19
|
-
* Commit and push until you are happy with your contribution
|
20
|
-
* Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
|
21
|
-
* After making your changes, be sure to run the [[Blacklight rspec and cucumber tests|Testing]] to make sure everything works.
|
22
|
-
* Submit your change as a [[Pull Request|http://help.github.com/pull-requests/]].
|
23
|
-
|
24
|
-
## Support
|
25
|
-
If you are interested in working on the Blacklight plugin, but want guidance or support, please send an email to our [[Blacklight-development mailing list|http://groups.google.com/group/blacklight-development]] and we'll be glad to help.
|
data/doc/Examples.md
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
You can see a demonstration of the generic Blacklight plugin at http://demo.projectblacklight.org
|
2
|
-
|
3
|
-
Columbia University:
|
4
|
-
|
5
|
-
* Academic Commons (Institutional Repository) - http://academiccommons.columbia.edu/
|
6
|
-
* New Arrivals (Subset of OPAC) - http://newarrivals.cul.columbia.edu
|
7
|
-
* Staff Collection Viewer (Internal only)
|
8
|
-
* CLIO Beta (opac replacement + metasearch) - http://cliobeta.columbia.edu
|
9
|
-
|
10
|
-
Agriculture Network Information Center
|
11
|
-
http://www.agnic.org/search
|
12
|
-
|
13
|
-
Historical State (NCSU Libraries)
|
14
|
-
http://historicalstate.lib.ncsu.edu
|
15
|
-
|
16
|
-
Johns Hopkins University Libraries (Catalyst)
|
17
|
-
http://catalyst.library.jhu.edu
|
18
|
-
|
19
|
-
Northwest Digital Archives
|
20
|
-
http://nwda.projectblacklight.org
|
21
|
-
|
22
|
-
Northwestern University Library Archival and Manuscript Collections
|
23
|
-
http://findingaids.library.northwestern.edu
|
24
|
-
|
25
|
-
NRM (Natural Resource Management) knowledge online
|
26
|
-
http://nrmonline.nrm.gov.au/
|
27
|
-
|
28
|
-
Rock & Roll Hall of Fame
|
29
|
-
http://catalog.rockhall.com/
|
30
|
-
|
31
|
-
Stanford University
|
32
|
-
http://searchworks.stanford.edu
|
33
|
-
|
34
|
-
University of Virginia
|
35
|
-
http://search.lib.virginia.edu
|
36
|
-
|
37
|
-
University of Wisconsin-Madison
|
38
|
-
http://forward.library.wisconsin.edu/
|
39
|
-
|
40
|
-
United States Holocaust Memorial Museum
|
41
|
-
(Currently internal only; public instance soon)
|
42
|
-
|
43
|
-
WGBH Open Vault
|
44
|
-
http://openvault.wgbh.org
|
45
|
-
|
46
|
-
NCSU Libraries' Digital Collections: Rare and Unique Materials
|
47
|
-
http://d.lib.ncsu.edu/collections/
|
48
|
-
|
49
|
-
University of Hull:
|
50
|
-
|
51
|
-
* Institutional repository - http://hydra.hull.ac.uk
|
52
|
-
* Library catalogue prototype - http://blacklight.hull.ac.uk/
|
53
|
-
|
54
|
-
The UI component of the Hydra Framework - http://projecthydra.org
|
55
|
-
|
56
|
-
The New York Public Library
|
57
|
-
|
58
|
-
* Andre Studios 1930-1941 - http://andrestudios.nypl.org
|
59
|
-
|
60
|
-
## Media/Presentations
|
61
|
-
|
62
|
-
* ["Highly Relevant Search Result Ranking for Large Law Enforcement Information Sharing Systems"](http://www.lucidimagination.com/blog/2011/06/01/solr-and-law-enforcement-highly-relevant-results-can-be-a-crime/), presented by Ronald Mayer of Forensic Logic at Lucene Revolution 2011 - Blacklight was used to quickly provide a proof-of-concept on law enforcement data.
|
@@ -1,141 +0,0 @@
|
|
1
|
-
# Extending or Modifying Blacklight Search Behavior
|
2
|
-
|
3
|
-
Solr parameters used by for a given request can come from several different places.
|
4
|
-
|
5
|
-
* Solr request handler: `solrconfig.xml` in your solr config
|
6
|
-
* Application logic: logic in the BL rails app itself
|
7
|
-
|
8
|
-
## Solr request handler
|
9
|
-
|
10
|
-
The Solr [[Request Handlers|http://wiki.apache.org/solr/SolrRequestHandler]] may be configured in the [[solrconfig.xml|http://wiki.apache.org/solr/SolrConfigXml]] and are baked into the request handler itself. Depending on how you have blacklight configured, your app may be using the same Solr request handler for all searches, or may be using different request handlers for different "search fields".
|
11
|
-
|
12
|
-
The request handler is often set up with default parameters:
|
13
|
-
|
14
|
-
```xml
|
15
|
-
<requestHandler name="standard" class="solr.SearchHandler" >
|
16
|
-
<lst name="defaults">
|
17
|
-
<str name="echoParams">explicit</str>
|
18
|
-
<str name="rows">10</str>
|
19
|
-
<str name="fl">*</str>
|
20
|
-
<str name="facet">true</str>
|
21
|
-
<str name="facet.mincount">1</str>
|
22
|
-
<str name="facet.limit">30</str>
|
23
|
-
<str name="facet.field">access_facet</str>
|
24
|
-
<str name="facet.field">author_person_facet</str>
|
25
|
-
<str name="facet.field">author_other_facet</str>
|
26
|
-
<str name="facet.field">building_facet</str>
|
27
|
-
<str name="facet.field">callnum_1_facet</str>
|
28
|
-
<str name="facet.field">era_facet</str>
|
29
|
-
<str name="facet.field">format</str>
|
30
|
-
<str name="facet.field">geographic_facet</str>
|
31
|
-
<str name="facet.field">language</str>
|
32
|
-
<str name="facet.field">pub_date_group_facet</str>
|
33
|
-
<str name="facet.field">topic_facet</str>
|
34
|
-
</lst>
|
35
|
-
</requestHandler>
|
36
|
-
```
|
37
|
-
## Configuration
|
38
|
-
|
39
|
-
The default application logic (explained below) looks in configuration for things like the name of a the solr request handler to use, and default request parameters to send on every solr search request (or with every request from a certain blacklight search type/field). An example getting started configuration is generally installed into your app when you install Blacklight at `[[./app/controllers/catalog_controller.rb|https://github.com/projectblacklight/blacklight/blob/master/lib/generators/blacklight/templates/catalog_controller.rb]]`.
|
40
|
-
|
41
|
-
## Application logic
|
42
|
-
|
43
|
-
The logic Blacklight uses to determine how to map user-supplied parameters into Solr request parameters for a given application request is in the [[#solr_search_params method in the SolrHelper module|https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr_helper.rb#L76]]. Note that `[[CatalogController|https://github.com/projectblacklight/blacklight/blob/master/app/controllers/catalog_controller.rb]]` extends `[[SolrHelper|https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr_helper.rb]]`, so the `SolrHelper` methods become available in the `CatalogController` (and other controllers, if they extend `SolrHelper` too).
|
44
|
-
|
45
|
-
Behind the scenes, #solr_search_params uses the `class_inheritable_accessor` method [[solr_search_params_logic|https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr_helper.rb#L30]]. solr_search_params_logic is essentially a class variable that is mixed into the CatalogController and provides an ordered list of methods to call that may inspect the supplied user parameters and add, remove, or modify the Solr request parameters that will be sent to an [[RSolr|https://github.com/mwmitchell/rsolr/]] object, which in turn will convert the hash into query parameters for a Solr request. One confusing thing is that RSolr and [[RSolr-ext|https://github.com/mwmitchell/rsolr-ext]] provide their own mappings from certain custom terms to Solr-recognized request parameters. For instance, a `:per_page` key in that hash will get mapped to the Solr `&rows` parameter -- but a `:rows` key will also. Blacklight developers have found that using these special RSolr "aliases" leads to confusion, as well as confusing bugs (if both `:per_page` and `:rows` are set in the hash, what happens can be hard to predict). So we try to avoid using the special RSolr aliases, and just use ordinary Solr parameters in our hashes. But you may encounter older code that uses the RSolr aliases.
|
46
|
-
|
47
|
-
There can be similar confusing behavior or bugs if one piece of code adds a key to a `Hash` using a `Symbol`, but another piece of code looks for and/or adds that same key to the `Hash` using a `String` instead. RSolr happens to accepts either one, but if both are present RSolr behavior can be unexpected. And even before it gets to RSolr, you may have code that thinks it replaced a key but did not becuase it was using the wrong form. Blacklight developers have agreed to try and always use `Symbol` based keys in hashes meant for Solr parameters, to try and avoid these problems. Longer term, we could probably make some code changes to make this kind of error less likely.
|
48
|
-
|
49
|
-
The default `#solr_search_params_logic` is meant to handle very common cases and patterns based on simple configuration options from the controller and the user-supplied URL parameters.
|
50
|
-
|
51
|
-
* `[[blacklight_config.default_solr_params|https://github.com/projectblacklight/blacklight/blob/master/lib/generators/blacklight/templates/catalog_controller.rb#L9]]`
|
52
|
-
* Default params sent to solr with every search, including the default :qt param, which determines which Solr request handler will be targetted. Some people like to use solrconfig.xml request handler defaults exclusively, and include only a :qt here; others find it more convenient to specify some defaults at the application level here.
|
53
|
-
* `[[blacklight_config.search_fields|https://github.com/projectblacklight/blacklight/blob/master/lib/generators/blacklight/templates/catalog_controller.rb#L81]]`
|
54
|
-
* Each search field will be presented in a select menu in the BL user interface search box. These 'search fields' don't neccesarily correspond 1-to-1 with Solr fields. What they instead correspond to is Solr parameter over-rides that will be used for this BL UI search field. Those over-rides are present here.
|
55
|
-
* You could simply chose a different `:qt` Solr request handler for each search field, which has it's own default parameters in the sorlconfig.xml. This is what we started out doing with Solr, but found it led to much duplication of information in solrconfig.xml.
|
56
|
-
* You can continue using the same Solr request handler, but simply specify different parameters which will be included in the http query string sent to Solr here, with the `:solr_parameters` key. This works fine, but some people don't like how it makes your Solr requests much longer/more complex in the Solr logs; and/or they prefer to control this Solr side instead of Application side.
|
57
|
-
* For the best of both worlds, although it's a bit confusing at first, you can use the `:solr_local_parameters` key to have parameters supplied to Solr using the Solr [[LocalParams|http://wiki.apache.org/solr/LocalParams]] syntax, which means you can use "parameter dereferencing" with dollar-sign-prefixed references to variables defined in solrconfig.xml request handler. This is what the current example BL setup does.
|
58
|
-
|
59
|
-
So the default implementation of `#solr_search_params` takes these configured parameters, combines them with certain query parameters from the current users HTTP request to the BL app, and prepares a Hash of parameters that will be sent to solr. For common use patterns, this is all you need.
|
60
|
-
|
61
|
-
But sometimes you want to add some custom logic to `#solr_search_params` to come up with the solr params Hash in different ways. Typically to support a new UI feature of some kind, either in your local app or in a Blacklight add-on plugin you are developing.
|
62
|
-
|
63
|
-
|
64
|
-
# Extending Blacklight::SolrHelper#solr_search_params
|
65
|
-
|
66
|
-
To add new search behaviors (e.g. authorization controls, pre-parsing query strings, etc), the easiest route is to add additional steps to the `#solr_search_params_logic`, either at the beginning of the list (to set default parameters) or at the end of the list (to force particular parameters). Because `#solr_search_params_logic` is just an ordinary array, you may perform any normal array operation (e.g. push/pop/delete/insert) to customize the parameter generation to meet your needs.
|
67
|
-
|
68
|
-
`#solr_search_params_logic` steps take two inputs, the hash of `solr_parameters` and the hash of `user_parameters` (often provided by the URL parameters), and modifies the `solr_parameters` directly, as needed.
|
69
|
-
|
70
|
-
You can add custom solr_search_params_logic steps within your controller (or in many other places, including initializers, mixins, etc) by adding a Symbol with the name of a method (provided by the controller) you wish to use, e.g.:
|
71
|
-
|
72
|
-
*./config/initializers/blacklight_config.rb*
|
73
|
-
|
74
|
-
```ruby
|
75
|
-
class CatalogController
|
76
|
-
self.solr_search_params_logic += :show_only_public_records
|
77
|
-
end
|
78
|
-
```
|
79
|
-
The controller must provide the method added to `solr_search_params_logic`, in this case `show_only_public_records`. It is often convenient to do this in a separate `Module` and include it into the controller:
|
80
|
-
|
81
|
-
*./app/controllers/catalog_controller.rb*
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
require 'blacklight/catalog'
|
85
|
-
class CatalogController < ApplicationController
|
86
|
-
include Blacklight::Catalog
|
87
|
-
include MyApplication::SolrHelper::Authorization
|
88
|
-
|
89
|
-
# Instead of defining this within an initializer, you may instead wish to do it on the controller directly:
|
90
|
-
# self.solr_search_params_logic << :show_only_public_records
|
91
|
-
|
92
|
-
# You could also define the actual method here, but this is not recommended.
|
93
|
-
# def show_only_public_records solr_parameters, user_parameters
|
94
|
-
# [...]
|
95
|
-
# end
|
96
|
-
end
|
97
|
-
```
|
98
|
-
|
99
|
-
The included module then defines the logic method:
|
100
|
-
|
101
|
-
*./lib/my_application/solr_helper/authorization.rb*
|
102
|
-
|
103
|
-
```ruby
|
104
|
-
module MyApplication::SolrHelper::Authorization
|
105
|
-
# You could also add the logic here
|
106
|
-
# def self.included base
|
107
|
-
# base.solr_search_params_logic << :show_only_public_records
|
108
|
-
# end
|
109
|
-
|
110
|
-
# solr_search_params_logic methods take two arguments
|
111
|
-
# @param [Hash] solr_parameters a hash of parameters to be sent to Solr (via RSolr)
|
112
|
-
# @param [Hash] user_parameters a hash of user-supplied parameters (often via `params`)
|
113
|
-
def show_only_public_records solr_parameters, user_parameters
|
114
|
-
# add a new solr facet query ('fq') parameter that limits results to those with a 'public_b' field of 1
|
115
|
-
solr_parameters[:fq] ||= []
|
116
|
-
solr_parameters[:fq] << 'public_b:1'
|
117
|
-
end
|
118
|
-
end
|
119
|
-
```
|
120
|
-
|
121
|
-
## Other examples
|
122
|
-
|
123
|
-
In addition to providing this behavior locally, some Blacklight plugins also extend the `#solr_search_params`:
|
124
|
-
|
125
|
-
* [[Blacklight Range Limit|https://github.com/projectblacklight/blacklight_range_limit/blob/master/lib/blacklight_range_limit/controller_override.rb]]
|
126
|
-
|
127
|
-
* A walk through on adding a checkbox limit at: http://bibwild.wordpress.com/2011/06/13/customing-blacklight-a-limit-checkbox/
|
128
|
-
|
129
|
-
* A much more complicated walk-through on adding an 'unstemmed search' checkbox limit: http://bibwild.wordpress.com/2011/06/20/customizing-blacklight-disable-automatic-stemming/
|
130
|
-
|
131
|
-
## Suppressing search results
|
132
|
-
|
133
|
-
You can configure your `solrconfig.xml` to not show results based on fields in your solr document. For example, if you have a solr boolean field such as `show_b`, you can suppress any records that have this field present. To do so, add:
|
134
|
-
```
|
135
|
-
<lst name="appends"><str name="fq">-show_b:["" TO *]</str></lst>
|
136
|
-
```
|
137
|
-
to the request handler in your `solrconfig.xml` file. If you would like this to be for standard solr searches, add the above line to this request handler:
|
138
|
-
```
|
139
|
-
<requestHandler name="search" class="solr.SearchHandler" default="true">
|
140
|
-
```
|
141
|
-
By doing so, solr queries that use the "document" request handler will still give you any records with the show_b field, but solr queries with the "search" handler will not.
|