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
@@ -1,106 +0,0 @@
|
|
1
|
-
# Discovery configuration
|
2
|
-
|
3
|
-
In this section, we will discuss some of the features available to control the discovery experience, including pagination, sorting, and fielded searches.
|
4
|
-
|
5
|
-
## Per Page
|
6
|
-
|
7
|
-
<img align="right" src="https://f.cloud.github.com/assets/111218/2491030/2ce8acc0-b1d7-11e3-8466-659a1759dde7.png" />
|
8
|
-
|
9
|
-
Three configuration options control the behavior of the per-page and pagination controls.
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
config.per_page # [10,20,50,100]
|
13
|
-
config.default_per_page # the first per_page value, or the value given here
|
14
|
-
config.max_per_page # 100
|
15
|
-
```
|
16
|
-
|
17
|
-
The options presented in the per-page dropdown are the values for the `per_page` configuration, in the order given. The `default_per_page` can be used if you want to offer a default per-page value that isn't the smallest value. Finally, `max_per_page` is used as a sanity check for user-supplied values.
|
18
|
-
|
19
|
-
We can explicitly set the configuration in our `CatalogController` configuration:
|
20
|
-
|
21
|
-
<img align="right" src="https://f.cloud.github.com/assets/111218/2491066/6cc93f38-b1d9-11e3-9047-f6beccbb93ff.png" />
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
class CatalogController
|
25
|
-
...
|
26
|
-
configure_blacklight do |config|
|
27
|
-
...
|
28
|
-
config.per_page = [6,12,24,48]
|
29
|
-
config.default_per_page = 24
|
30
|
-
end
|
31
|
-
end
|
32
|
-
```
|
33
|
-
|
34
|
-
## Sort Fields
|
35
|
-
|
36
|
-
You can configure the available sort options. The sort parameter is passed through to Solr, so the value must be a supported [sort format](http://wiki.apache.org/solr/CommonQueryParameters#sort).
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', :label => 'relevance'
|
40
|
-
config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
|
41
|
-
config.add_sort_field 'author_sort asc, title_sort asc', :label => 'author'
|
42
|
-
config.add_sort_field 'title_sort asc, pub_date_sort desc', :label => 'title'
|
43
|
-
```
|
44
|
-
|
45
|
-
#### An aside about Blacklight solr field configurations
|
46
|
-
|
47
|
-
The Blacklight solr field configuration is very expressive, and supports several different flavors of configuration. These are all functionally equivalent:
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
|
51
|
-
|
52
|
-
# for sort fields, the `sort` key contains the Solr sort information. For other fields, the `field` key is used.
|
53
|
-
config.add_sort_field :sort => 'pub_date_sort desc, title_sort asc', :label => 'year'
|
54
|
-
|
55
|
-
# the "key" (first argument) will be used in user-facing url parameters.
|
56
|
-
config.add_sort_field 'year', :sort => 'pub_date_sort desc, title_sort asc', :label => 'year'
|
57
|
-
|
58
|
-
# The block format may be useful when using complex logic in the configuration settings
|
59
|
-
config.add_sort_field 'year' do |field|
|
60
|
-
field.sort = 'pub_date_sort desc, title_sort asc'
|
61
|
-
field.label = field.key.humanize
|
62
|
-
end
|
63
|
-
|
64
|
-
# The array-format allows you to add multiple values at once.
|
65
|
-
config.add_sort_field [
|
66
|
-
{sort: 'pub_date_sort desc, title_sort asc', label: 'year}, { sort: '....', ...}
|
67
|
-
]
|
68
|
-
```
|
69
|
-
|
70
|
-
You may choose the format that is appropriately concise and legible in the context of your application and configuration.
|
71
|
-
|
72
|
-
The `add_*_field` is appending values to a configuration hash. In some cases, it may be useful to modify that hash directly.
|
73
|
-
|
74
|
-
```ruby
|
75
|
-
config.sort_fields['year'].label = "Year Created"
|
76
|
-
```
|
77
|
-
|
78
|
-
## Targeting Search Queries at Configurable Fields
|
79
|
-
|
80
|
-
Search queries can be targeted at configurable fields (or sets of fields) to return precise search results.
|
81
|
-
|
82
|
-
<img src="https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_fields.png" />
|
83
|
-
|
84
|
-
```ruby
|
85
|
-
config.add_search_field 'all_fields', :label => 'All Fields'
|
86
|
-
```
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
# Now we see how to over-ride Solr request handler defaults, in this
|
90
|
-
# case for a BL "search field", which is really a dismax aggregate
|
91
|
-
# of Solr search fields.
|
92
|
-
|
93
|
-
config.add_search_field('title') do |field|
|
94
|
-
# solr_parameters hash are sent to Solr as ordinary url query params.
|
95
|
-
field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
|
96
|
-
|
97
|
-
# :solr_local_parameters will be sent using Solr LocalParams
|
98
|
-
# syntax, as eg {! qf=$title_qf }. This is neccesary to use
|
99
|
-
# Solr parameter de-referencing like $title_qf.
|
100
|
-
# See: http://wiki.apache.org/solr/LocalParams
|
101
|
-
field.solr_local_parameters = {
|
102
|
-
:qf => '$title_qf',
|
103
|
-
:pf => '$title_pf'
|
104
|
-
}
|
105
|
-
end
|
106
|
-
```
|
@@ -1,257 +0,0 @@
|
|
1
|
-
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).
|
2
|
-
|
3
|
-
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.
|
4
|
-
|
5
|
-
## Configuration
|
6
|
-
|
7
|
-
|
8
|
-
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).
|
9
|
-
|
10
|
-
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*
|
11
|
-
|
12
|
-
**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.
|
13
|
-
|
14
|
-
Once you have your Solr fields, you can then configure your Blacklight application to display arbitrary fields in different contexts
|
15
|
-
|
16
|
-
### Choose which Fields to Display in Search Results
|
17
|
-
|
18
|
-
* Displayed fields and labels can be customized on both the search results and document views.
|
19
|
-
Note that these must be STORED fields in the Solr index.
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
# [from app/controllers/catalog_controller.rb]
|
23
|
-
# solr fields to be displayed in the index (search results) view
|
24
|
-
# The ordering of the field names is the order of the display
|
25
|
-
config.add_index_field 'title_display', :label => 'Title:'
|
26
|
-
config.add_index_field 'title_vern_display', :label => 'Title:'
|
27
|
-
config.add_index_field 'author_display', :label => 'Author:'
|
28
|
-
config.add_index_field 'author_vern_display', :label => 'Author:'
|
29
|
-
```
|
30
|
-
|
31
|
-
### Targeting Search Queries at Configurable Fields
|
32
|
-
|
33
|
-
* 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]]
|
34
|
-
[[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_fields.png|frame|alt=Search fields in action]]
|
35
|
-
|
36
|
-
```ruby
|
37
|
-
# [from app/controllers/catalog_controller.rb]
|
38
|
-
# Now we see how to over-ride Solr request handler defaults, in this
|
39
|
-
# case for a BL "search field", which is really a dismax aggregate
|
40
|
-
# of Solr search fields.
|
41
|
-
|
42
|
-
config.add_search_field('title') do |field|
|
43
|
-
# solr_parameters hash are sent to Solr as ordinary url query params.
|
44
|
-
field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
|
45
|
-
|
46
|
-
# :solr_local_parameters will be sent using Solr LocalParams
|
47
|
-
# syntax, as eg {! qf=$title_qf }. This is neccesary to use
|
48
|
-
# Solr parameter de-referencing like $title_qf.
|
49
|
-
# See: http://wiki.apache.org/solr/LocalParams
|
50
|
-
field.solr_local_parameters = {
|
51
|
-
:qf => '$title_qf',
|
52
|
-
:pf => '$title_pf'
|
53
|
-
}
|
54
|
-
end
|
55
|
-
```
|
56
|
-
|
57
|
-
### Choosing & Configuring Facets
|
58
|
-
|
59
|
-
- Faceted search allows users to constrain searches by controlled vocabulary items
|
60
|
-
[[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_facets.png|frame|alt=Search facets in action]]
|
61
|
-
Note that these must be INDEXED fields in the Solr index, and are generally a single token (e.g. a string).
|
62
|
-
|
63
|
-
```ruby
|
64
|
-
# [from app/controllers/catalog_controller.rb]
|
65
|
-
# solr fields that will be treated as facets by the blacklight application
|
66
|
-
# The ordering of the field names is the order of the display
|
67
|
-
config.add_facet_field 'format', :label => 'Format'
|
68
|
-
config.add_facet_field 'pub_date', :label => 'Publication Year'
|
69
|
-
config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
|
70
|
-
config.add_facet_field 'language_facet', :label => 'Language', :limit => true
|
71
|
-
```
|
72
|
-
|
73
|
-
Blacklight also supports Solr facet queries:
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
config.add_facet_field 'pub_date_query', :label => 'Publication Year', :query => {
|
77
|
-
:last_5_years => { :label => 'Last 5 Years', :fq => "[#{Time.now.year-5} TO *]"}
|
78
|
-
}
|
79
|
-
```
|
80
|
-
|
81
|
-
You can also tell Solr how to sort facets (either by count or index):
|
82
|
-
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.
|
83
|
-
```ruby
|
84
|
-
config.add_facet_field :my_count_sorted_field, :sort => 'count'
|
85
|
-
config.add_facet_field :my_index_sorted_field, :sort => 'index'
|
86
|
-
```
|
87
|
-
|
88
|
-
|
89
|
-
If you want Solr to add the configured facets and facet queries to the Solr query it sends, you should also add:
|
90
|
-
|
91
|
-
```ruby
|
92
|
-
config.add_facet_fields_to_solr_request!
|
93
|
-
```
|
94
|
-
|
95
|
-
If you have date facets in Solr, you should add a hint to the Blacklight configuration:
|
96
|
-
|
97
|
-
```ruby
|
98
|
-
config.add_facet_field :my_date_field, :date => true
|
99
|
-
```
|
100
|
-
|
101
|
-
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:
|
102
|
-
|
103
|
-
```ruby
|
104
|
-
config.add_facet_field :my_date_field, :date => { :format => :short }
|
105
|
-
```
|
106
|
-
|
107
|
-
### Map from User Queries to Solr Parameters
|
108
|
-
|
109
|
-
* Blacklight provides flexible mapping from user queries to solr parameters, which are easily overridden in local applications (see [[Extending or Modifying Blacklight Search Behavior]]).
|
110
|
-
|
111
|
-
```ruby
|
112
|
-
# [from app/controllers/catalog_controller.rb]
|
113
|
-
# Each symbol identifies a _method_ that must be in
|
114
|
-
# this class, taking two parameters (solr_parameters, user_parameters)
|
115
|
-
# Can be changed in local apps or by plugins, eg:
|
116
|
-
# CatalogController.include ModuleDefiningNewMethod
|
117
|
-
# CatalogController.solr_search_params_logic << :new_method
|
118
|
-
# CatalogController.solr_search_params_logic.delete(:we_dont_want)
|
119
|
-
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 ]
|
120
|
-
```
|
121
|
-
|
122
|
-
> Source: [[./lib/blacklight/solr_helper.rb|https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr_helper.rb#L70]]
|
123
|
-
|
124
|
-
### Document Extension Framework
|
125
|
-
|
126
|
-
The main use case for extensions is for transforming a Document to another
|
127
|
-
format. Either to another type of Ruby object, or to an exportable string in
|
128
|
-
a certain format.
|
129
|
-
|
130
|
-
An Blacklight::Solr::Document extension is simply a ruby module which is mixed
|
131
|
-
in to individual Document instances. The intended use case is for documents
|
132
|
-
containing some particular format of source material, such as Marc. An
|
133
|
-
extension can be registered with your document class, along with a block
|
134
|
-
containing custom logic for which documents to apply the extension to.
|
135
|
-
|
136
|
-
```ruby
|
137
|
-
SolrDocument.use_extension(MyExtension) {|document| my_logic_on_document(document}
|
138
|
-
```
|
139
|
-
|
140
|
-
MyExtension will be mixed-in (using ruby 'extend') only to those documents
|
141
|
-
where the block results in true.
|
142
|
-
|
143
|
-
Underlying metadata formats, or other alternative document views, are linked to from the HTML page <head>.
|
144
|
-
|
145
|
-
# Customizing the User Interface
|
146
|
-
## Layouts
|
147
|
-
|
148
|
-
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.
|
149
|
-
|
150
|
-
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.
|
151
|
-
|
152
|
-
```ruby
|
153
|
-
# [from app/controllers/application_controller.rb]
|
154
|
-
class ApplicationController < ActionController::Base
|
155
|
-
...
|
156
|
-
def layout_name
|
157
|
-
"application"
|
158
|
-
end
|
159
|
-
...
|
160
|
-
end
|
161
|
-
```
|
162
|
-
|
163
|
-
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](https://github.com/projectblacklight/blacklight/blob/master/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.
|
164
|
-
|
165
|
-
* `render_head_content` renders content within the
|
166
|
-
html `<head>` tag, which includes document-specific alternative
|
167
|
-
formats as well as tags generated by plugins, etc.
|
168
|
-
* `sidebar_items` renders features including sidebar content, e.g. facet
|
169
|
-
lists.
|
170
|
-
* flash messages
|
171
|
-
* user util links
|
172
|
-
|
173
|
-
## Overriding Views (templates and partials)
|
174
|
-
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.
|
175
|
-
|
176
|
-
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.
|
177
|
-
|
178
|
-
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.
|
179
|
-
|
180
|
-
## Overriding the CatalogController
|
181
|
-
Overriding the Blacklight `CatalogController` implementation is easy, and the skeleton of the `CatalogController` is generated into your application for you when you install Blacklight.
|
182
|
-
|
183
|
-
See the [[Extending or Modifying Blacklight Search Behavior]] for tips and approaches to customizing the catalog.
|
184
|
-
|
185
|
-
## Overriding Other Controllers
|
186
|
-
|
187
|
-
1. Find the controller you're interested in blacklight's app/controllers/ .
|
188
|
-
2. Create a file with the same name in your local app/controllers.
|
189
|
-
3. This file requires the original class, and then re-opens it to add more methods.
|
190
|
-
|
191
|
-
```ruby
|
192
|
-
require "#{Blacklight.controllers_dir}/some_controller"
|
193
|
-
|
194
|
-
class SomeController < ApplicationController
|
195
|
-
# custom code goes here
|
196
|
-
end
|
197
|
-
```
|
198
|
-
|
199
|
-
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.
|
200
|
-
|
201
|
-
It's kind of hard to call 'super' to call original functionality:
|
202
|
-
|
203
|
-
* the ruby language features here make 'super' unavailable, although you can work around that confusingly with the rails #alias_method_chain method.
|
204
|
-
* 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.
|
205
|
-
|
206
|
-
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.
|
207
|
-
|
208
|
-
|
209
|
-
## Custom View Helpers
|
210
|
-
|
211
|
-
(This is accurate for Blacklight 3.1.1 and subsequent. Before that, things were messier).
|
212
|
-
|
213
|
-
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.
|
214
|
-
|
215
|
-
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).
|
216
|
-
|
217
|
-
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.
|
218
|
-
|
219
|
-
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:
|
220
|
-
|
221
|
-
```ruby
|
222
|
-
module BlacklightHelper
|
223
|
-
include Blacklight::BlacklightHelperBehavior
|
224
|
-
end
|
225
|
-
```
|
226
|
-
|
227
|
-
Now, the actual methods will be found in app/helpers/blacklight/blacklight_helper_behavior.rb instead.
|
228
|
-
|
229
|
-
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.
|
230
|
-
|
231
|
-
YOUR `app/helpers/blacklight_helper.rb`
|
232
|
-
|
233
|
-
```ruby
|
234
|
-
module BlacklightHelper
|
235
|
-
include Blacklight::BlacklightHelperBehavior
|
236
|
-
|
237
|
-
def application_name
|
238
|
-
"Bestest University Search"
|
239
|
-
end
|
240
|
-
end
|
241
|
-
```
|
242
|
-
|
243
|
-
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 different 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.
|
244
|
-
|
245
|
-
## Adding in your own CSS or Javascript
|
246
|
-
|
247
|
-
Within your local application, you can use the [[Rails Asset Pipeline|http://guides.rubyonrails.org/asset_pipeline.html]] to manipulate javascript and css documents.
|
248
|
-
|
249
|
-
**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)
|
250
|
-
|
251
|
-
The Blacklight generator added a file to your app at `./app/assets/stylesheets/blacklight.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 sure of the best way, feel free to ask on the listserv.
|
252
|
-
|
253
|
-
|
254
|
-
## See also
|
255
|
-
|
256
|
-
* [[Extending or Modifying Blacklight Search Behavior]]
|
257
|
-
* [[Pagination]]
|
@@ -1,13 +0,0 @@
|
|
1
|
-
If your solr ids happen to have dots in them, Rails is going interpret the dots as the separator between the file name and the file exension, and your documents won't be displayed on the show view. In order to fix that you can override the default routes like this:
|
2
|
-
|
3
|
-
```ruby
|
4
|
-
ALLOW_DOTS ||= /[a-zA-Z0-9_.:]+/
|
5
|
-
MyApp::Application.routes.draw do
|
6
|
-
root :to => "catalog#index"
|
7
|
-
...
|
8
|
-
resources :catalog, :only => [:show, :update], :constraints => { :id => ALLOW_DOTS, :format => false }
|
9
|
-
Blacklight::Routes.new(self, {}).catalog
|
10
|
-
end
|
11
|
-
```
|
12
|
-
|
13
|
-
you must put the line defining the route with the constraints before you call Blacklight::Routes because the first route that matches is the one that will be used.
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# Contributing to Blacklight
|
2
|
-
|
3
|
-
Blacklight is a collaborative, open source project produced by developers from many diverse organizations. The Blacklight developers want to create an out-of-the-box framework that is easy 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.
|
4
|
-
|
5
|
-
Development is largely motivated by the needs of each developer’s organization, and we work on the shared project together so we can benefit from the community’s development efforts, experiences building discovery systems, and shared problem solving.
|
6
|
-
|
7
|
-
We always welcome contributions from the community, especially to add new features, address bugs or defects, and clarify existing code for future developers.
|
8
|
-
|
9
|
-
## Adding a ticket
|
10
|
-
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]].
|
11
|
-
|
12
|
-
## Making Your Changes
|
13
|
-
|
14
|
-
* Fork the project
|
15
|
-
* Start a feature/bugfix branch
|
16
|
-
* Commit and push until you are happy with your contribution
|
17
|
-
* Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
|
18
|
-
* After making your changes, be sure to run the [[Blacklight tests|Testing]] to make sure everything works.
|
19
|
-
* Submit your change as a [[Pull Request|http://help.github.com/pull-requests/]].
|
20
|
-
|
21
|
-
## Support
|
22
|
-
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.
|
23
|
-
|
24
|
-
## Becoming a Committer
|
25
|
-
|
26
|
-
Anyone can contribute to Blacklight using pull requests, the issue tracker, and being active on the mailing list and IRC channels. Being a contributor means that you take an active interest in the project and contribute regularly in some way, ranging from asking sensible questions (which documents the project and provides feedback to developers) to providing new features as patches.
|
27
|
-
|
28
|
-
If you become a valuable contributor to the project you may be invited to become a committer. Blacklight code contributors become committers after being sponsored by one of the current active committers. The committers will take an Apache-style (+1/0/-1) vote to elevate them, and then a formal invitation will be extended to the contributor.
|
29
|
-
|
30
|
-
Committers should be:
|
31
|
-
|
32
|
-
- technically adept
|
33
|
-
- constructive, positive members of the Blacklight software community
|
34
|
-
- committed to producing useful, practical code for the community
|
35
|
-
|
36
|
-
You're expected to:
|
37
|
-
|
38
|
-
- contribute patches and new functionality to Blacklight and other shared development efforts (RSolr, Blacklight plugins, etc)
|
39
|
-
- actively participate in technical discussions on the email list, IRC, and github
|
40
|
-
- answer user support questions via the various channels
|
41
|
-
- review pull requests from fellow committers and the community
|
42
|
-
- test-drive new release candidates against your own institution's Blacklight applications
|
43
|
-
- participate in regular committer meetings, usually in the form of conference calls, to coordinate development & direction
|
data/doc/Examples.md
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
## Out of the Box Demo
|
2
|
-
|
3
|
-
You can see a demonstration of the generic Blacklight plugin at http://demo.projectblacklight.org
|
4
|
-
|
5
|
-
## Implementations
|
6
|
-
|
7
|
-
### Agriculture Network Information Center
|
8
|
-
http://www.agnic.org/search
|
9
|
-
|
10
|
-
### American Legislative and Issue Campaign Exchange (ALICE)
|
11
|
-
http://alicelaw.org/
|
12
|
-
|
13
|
-
### Archive Engine West
|
14
|
-
http://aew.orbiscascade.org
|
15
|
-
|
16
|
-
### Bibliothèque Clermont Université
|
17
|
-
http://195.221.120.231
|
18
|
-
|
19
|
-
### Columbia University:
|
20
|
-
|
21
|
-
* CLIO - Unified search and discovery - http://clio.columbia.edu
|
22
|
-
* Academic Commons - Institutional Repository - http://academiccommons.columbia.edu
|
23
|
-
* Human Rights Web Archive - http://hrwa.cul.columbia.edu
|
24
|
-
* Special Collection Site - Lindquist - http://lindquist.cul.columbia.edu
|
25
|
-
|
26
|
-
### Cornell University
|
27
|
-
http://newcatalog.library.cornell.edu/
|
28
|
-
|
29
|
-
### Danmarks Tekniske Universitet (Technical University of Denmark)
|
30
|
-
DTU Findit - http://findit.dtu.dk
|
31
|
-
|
32
|
-
### Indiana University Libraries
|
33
|
-
* IUCAT library catalog - http://iucat.iu.edu/
|
34
|
-
* Digital Collections Search - http://webapp1.dlib.indiana.edu/dcs/
|
35
|
-
|
36
|
-
### Johns Hopkins University Libraries (Catalyst)
|
37
|
-
http://catalyst.library.jhu.edu
|
38
|
-
|
39
|
-
### Lowcountry Digital Library (College of Charleston)
|
40
|
-
* http://lcdl.library.cofc.edu/
|
41
|
-
* Code4Lib Article - http://journal.code4lib.org/articles/8327
|
42
|
-
|
43
|
-
### The National Library of Medicine's Digital Collections
|
44
|
-
http://collections.nlm.nih.gov
|
45
|
-
|
46
|
-
### NCSU Libraries' Digital Collections: Rare and Unique Materials
|
47
|
-
This application superseded the Historical State application which was also a Blacklight application.
|
48
|
-
http://d.lib.ncsu.edu/collections/
|
49
|
-
|
50
|
-
### The New York Public Library
|
51
|
-
|
52
|
-
* Andre Studios 1930-1941 - http://andrestudios.nypl.org
|
53
|
-
* Prints & Photographs Online Catalog - http://wallachprintsandphotos.nypl.org/
|
54
|
-
|
55
|
-
### Northwestern University Library Archival and Manuscript Collections
|
56
|
-
http://findingaids.library.northwestern.edu
|
57
|
-
|
58
|
-
### NRM (Natural Resource Management) knowledge online
|
59
|
-
http://nrmonline.nrm.gov.au/
|
60
|
-
|
61
|
-
### The Pennsylvania State University (Penn State)
|
62
|
-
https://scholarsphere.psu.edu/
|
63
|
-
|
64
|
-
### Rock & Roll Hall of Fame
|
65
|
-
http://catalog.rockhall.com/
|
66
|
-
|
67
|
-
### Stanford University
|
68
|
-
|
69
|
-
* http://searchworks.stanford.edu (catalog) / https://github.com/sul-dlss/SearchWorks
|
70
|
-
* http://bv.stanford.edu (finding aid for special collection)
|
71
|
-
* http://frda.stanford.edu (full text plus image collection) / http://github.com/sul-dlss/frda
|
72
|
-
* http://revslib.stanford.edu / http://github.com/sul-dlss/revs
|
73
|
-
|
74
|
-
### Tufts University
|
75
|
-
http://dl.tufts.edu
|
76
|
-
|
77
|
-
### University of Miami
|
78
|
-
https://library.miami.edu/udvd
|
79
|
-
|
80
|
-
### University of Virginia
|
81
|
-
http://search.lib.virginia.edu
|
82
|
-
|
83
|
-
### University of Wisconsin-Madison
|
84
|
-
http://search.library.wisconsin.edu/
|
85
|
-
|
86
|
-
### United States Holocaust Memorial Museum
|
87
|
-
http://collections.ushmm.org
|
88
|
-
|
89
|
-
### WGBH Open Vault
|
90
|
-
http://openvault.wgbh.org
|
91
|
-
|
92
|
-
### University of Hull
|
93
|
-
|
94
|
-
* Institutional repository
|
95
|
-
http://hydra.hull.ac.uk
|
96
|
-
* Library catalogue
|
97
|
-
http://libsearch.hull.ac.uk/
|
98
|
-
https://github.com/uohull/blah
|
99
|
-
|
100
|
-
### Universiteitsbibliotheek Gent (Ghent University Library, Belgium)
|
101
|
-
http://lib.ugent.be
|
102
|
-
|
103
|
-
### The World Maritime University (using Koha ILS )
|
104
|
-
http://beacon.wmu.se
|
105
|
-
|
106
|
-
### Yale University
|
107
|
-
* Collection of Musical Instruments
|
108
|
-
http://collection-media.yale.edu/
|
109
|
-
* School of Music media site
|
110
|
-
http://music-media.yale.edu/
|
111
|
-
|
112
|
-
|
113
|
-
The UI component of the Hydra Framework - http://projecthydra.org
|
114
|
-
|
115
|
-
|
116
|
-
## Media/Presentations
|
117
|
-
|
118
|
-
* ["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.
|
119
|
-
|
120
|
-
* [Podcast: Project Blacklight, Hydra and Libraries in the Digital Age](http://www.lucidworks.com/blog/podcast-project-blacklight-hydra-and-libraries-in-the-digital-age/) Interview with Bess Sadler for the SolrCluster podcast. Origins of the Blacklight software, the Hydra Project, some of the challenges facing libraries with regard to search and management of digital content, and future Blacklight development projects like Spotlight and GeoBlacklight are discussed.
|