blacklight 5.9.4 → 5.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +11 -10
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -14
- data/app/helpers/blacklight/configuration_helper_behavior.rb +16 -10
- data/app/helpers/blacklight/facets_helper_behavior.rb +15 -14
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/bookmark.rb +1 -4
- data/app/models/search.rb +3 -6
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_facet_limit.html.erb +5 -3
- data/app/views/catalog/_facet_pivot.html.erb +4 -4
- data/app/views/catalog/_home_text.html.erb +8 -48
- data/app/views/catalog/_index_default.html.erb +3 -3
- data/app/views/catalog/_show_default.html.erb +3 -3
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/jetty.yml +0 -3
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +2 -0
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/lib/blacklight.rb +70 -26
- data/lib/blacklight/abstract_repository.rb +29 -0
- data/lib/blacklight/base.rb +7 -7
- data/lib/blacklight/bookmarks.rb +5 -5
- data/lib/blacklight/catalog.rb +34 -19
- data/lib/blacklight/catalog/search_context.rb +1 -1
- data/lib/blacklight/configuration.rb +112 -46
- data/lib/blacklight/configuration/facet_field.rb +9 -7
- data/lib/blacklight/configuration/field.rb +27 -0
- data/lib/blacklight/configuration/fields.rb +25 -20
- data/lib/blacklight/configuration/search_field.rb +6 -8
- data/lib/blacklight/configuration/solr_field.rb +3 -18
- data/lib/blacklight/configuration/sort_field.rb +6 -7
- data/lib/blacklight/document.rb +156 -0
- data/lib/blacklight/document/dublin_core.rb +41 -0
- data/lib/blacklight/document/email.rb +16 -0
- data/lib/blacklight/document/export.rb +107 -0
- data/lib/blacklight/document/extensions.rb +56 -0
- data/lib/blacklight/document/schema_org.rb +7 -0
- data/lib/blacklight/document/semantic_fields.rb +51 -0
- data/lib/blacklight/document/sms.rb +14 -0
- data/lib/blacklight/document_presenter.rb +3 -3
- data/lib/blacklight/exceptions.rb +9 -2
- data/lib/blacklight/facet.rb +21 -16
- data/lib/blacklight/request_builders.rb +60 -284
- data/lib/blacklight/routes.rb +1 -1
- data/lib/blacklight/search_builder.rb +130 -0
- data/lib/blacklight/search_helper.rb +316 -0
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/document.rb +4 -187
- data/lib/blacklight/solr/document/dublin_core.rb +3 -37
- data/lib/blacklight/solr/document/email.rb +4 -13
- data/lib/blacklight/solr/document/export.rb +3 -103
- data/lib/blacklight/solr/document/extensions.rb +4 -52
- data/lib/blacklight/solr/document/more_like_this.rb +1 -1
- data/lib/blacklight/solr/document/schema_org.rb +4 -4
- data/lib/blacklight/solr/document/sms.rb +4 -11
- data/lib/blacklight/solr/facet_paginator.rb +2 -2
- data/lib/blacklight/solr/search_builder.rb +264 -0
- data/lib/blacklight/solr_helper.rb +6 -261
- data/lib/blacklight/solr_repository.rb +30 -24
- data/lib/blacklight/solr_response.rb +3 -3
- data/lib/blacklight/user.rb +1 -2
- data/lib/blacklight/utils.rb +0 -23
- data/lib/generators/blacklight/controller_generator.rb +38 -0
- data/lib/generators/blacklight/document_generator.rb +20 -0
- data/lib/generators/blacklight/install_generator.rb +38 -39
- data/lib/generators/blacklight/models_generator.rb +2 -62
- data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
- data/lib/generators/blacklight/templates/config/{solr.yml → blacklight.yml} +3 -0
- data/lib/generators/blacklight/templates/config/jetty.yml +0 -3
- data/lib/generators/blacklight/templates/solr_document.rb +6 -6
- data/lib/generators/blacklight/test_support_generator.rb +1 -6
- data/lib/generators/blacklight/user_generator.rb +59 -0
- data/lib/railties/blacklight.rake +16 -7
- data/spec/controllers/catalog_controller_spec.rb +9 -15
- data/spec/features/facets_spec.rb +8 -0
- data/spec/helpers/configuration_helper_spec.rb +6 -13
- data/spec/helpers/facets_helper_spec.rb +3 -2
- data/spec/lib/blacklight/configuration_spec.rb +11 -38
- data/spec/lib/blacklight/{solr/document → document}/dublin_core_spec.rb +4 -4
- data/spec/lib/blacklight/{solr/document → document}/email_spec.rb +2 -2
- data/spec/lib/blacklight/{solr/document → document}/sms_spec.rb +2 -2
- data/spec/lib/blacklight/search_builder_spec.rb +145 -0
- data/spec/lib/blacklight/search_helper_spec.rb +775 -0
- data/spec/lib/blacklight/solr/document/more_like_this_spec.rb +1 -1
- data/spec/lib/blacklight/solr/search_builder_spec.rb +561 -0
- data/spec/lib/blacklight/solr_helper_spec.rb +5 -1291
- data/spec/lib/blacklight/solr_repository_spec.rb +13 -13
- data/spec/models/record_mailer_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- data/tasks/blacklight.rake +1 -1
- data/template.demo.rb +1 -1
- metadata +33 -45
- data/doc/Adding-new-document-actions.md +0 -94
- data/doc/Atom-Responses.md +0 -90
- data/doc/Blacklight-Add-ons.md +0 -23
- data/doc/Blacklight-configuration.md +0 -411
- data/doc/Blacklight-on-Heroku.md +0 -100
- data/doc/Blacklight-out-of-the-box.md +0 -47
- data/doc/Bookmarks.md +0 -1
- data/doc/Code4Lib-2014.md +0 -94
- data/doc/Configuration---Facet-Fields.md +0 -130
- data/doc/Configuration---Results-View.md +0 -224
- data/doc/Configuration---Solr-fields.md +0 -106
- data/doc/Configuring-and-Customizing-Blacklight.md +0 -257
- data/doc/Configuring-rails-routes.md +0 -13
- data/doc/Contributing-to-Blacklight.md +0 -43
- data/doc/Examples.md +0 -120
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
- data/doc/Home.md +0 -100
- data/doc/How-to-release-a-version.md +0 -45
- data/doc/Indexing-your-data-into-solr.md +0 -36
- data/doc/Internationalization.md +0 -32
- data/doc/JSON-API.md +0 -83
- data/doc/Pagination.md +0 -52
- data/doc/Providing-your-own-view-templates.md +0 -69
- data/doc/Quickstart.md +0 -153
- data/doc/README_SOLR.md +0 -245
- data/doc/Saved-Searches.md +0 -5
- data/doc/Solr-Configuration.md +0 -154
- data/doc/Sunspot-for-indexing.md +0 -46
- data/doc/Support.md +0 -33
- data/doc/Theming.md +0 -62
- data/doc/Understanding-Rails-and-Blacklight.md +0 -75
- data/doc/User-Authentication.md +0 -60
- data/doc/_Sidebar.md +0 -9
- data/doc/testing.md +0 -58
data/doc/Saved-Searches.md
DELETED
data/doc/Solr-Configuration.md
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
# Blacklight configuration
|
2
|
-
|
3
|
-
The example Blacklight configuration is a simple application for displaying library holdings. In this section, we will describe the Blacklight configuration settings that determine how the Blacklight interface works with your data.
|
4
|
-
|
5
|
-
## Connecting to Solr
|
6
|
-
|
7
|
-
The Solr connection parameters are configured globally in `config/solr.yml`. It looks something like this:
|
8
|
-
|
9
|
-
```yaml
|
10
|
-
# config/solr.yml
|
11
|
-
development:
|
12
|
-
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr" %>
|
13
|
-
test: &test
|
14
|
-
url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8888}/solr" %>
|
15
|
-
```
|
16
|
-
|
17
|
-
The configuration is used to configure [RSolr::Client](https://github.com/rsolr/rsolr/blob/master/lib/rsolr/client.rb). Available options include:
|
18
|
-
|
19
|
-
* url
|
20
|
-
* proxy
|
21
|
-
* open_timeout
|
22
|
-
* read_timeout
|
23
|
-
* retry_503
|
24
|
-
* retry_after_limit
|
25
|
-
|
26
|
-
### Dynamic configuration
|
27
|
-
|
28
|
-
|
29
|
-
Blacklight pre-parses the YAML file using ERB, which means you can use environment variables to configure the Solr location. With the default configuration, this means you can start Blacklight and point it at an external solr index without changing the `solr.yml` file:
|
30
|
-
|
31
|
-
```console
|
32
|
-
$ SOLR_URL="http://my.production.server/solr/core/" rails server
|
33
|
-
```
|
34
|
-
|
35
|
-
### Run-time configuration
|
36
|
-
|
37
|
-
The `solr.yml` configuration is applied globally to all Solr connections from your application. If you need to configure dynamic (e.g. per-user or per-controller) connections, Blacklight provides and uses instance-level accessor methods. Applications can override these accessors in By overriding these accessors, applications can provide either custom RSolr clients (e.g. [rsolr-async](https://github.com/mwmitchell/rsolr-async)) or per-user or per-controller solr connections:
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
class CatalogController < ApplicationController
|
41
|
-
include Blacklight::Catalog
|
42
|
-
include MyApplicationRuntimeConfiguration
|
43
|
-
end
|
44
|
-
|
45
|
-
module MyApplicationRuntimeConfiguration
|
46
|
-
def solr_repository
|
47
|
-
@solr_repository ||= MyCustomSolrRepository.new(blacklight_config)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class MyCustomSolrRepository < Blacklight::SolrRepository
|
52
|
-
def blacklight_solr
|
53
|
-
@blacklight_solr ||= RSolr::Custom::Client.new :user => current_user.id
|
54
|
-
end
|
55
|
-
end
|
56
|
-
```
|
57
|
-
|
58
|
-
|
59
|
-
## Solr Configuration
|
60
|
-
|
61
|
-
### Schema
|
62
|
-
|
63
|
-
|
64
|
-
#### Solr Unique Key
|
65
|
-
|
66
|
-
If your solr configuration uses a unique field other than `id`, you must configure your `SolrDocument` (in app/models/solr_document.rb) to set the unique key:
|
67
|
-
|
68
|
-
```ruby
|
69
|
-
# app/models/solr_document.rb
|
70
|
-
|
71
|
-
class SolrDocument
|
72
|
-
include Blacklight::Solr::Document
|
73
|
-
|
74
|
-
self.unique_key = 'my_unique_key_field'
|
75
|
-
|
76
|
-
...
|
77
|
-
end
|
78
|
-
```
|
79
|
-
|
80
|
-
### Blacklight search requests
|
81
|
-
|
82
|
-
[Search Handler](http://wiki.apache.org/solr/SearchHandler)
|
83
|
-
|
84
|
-
Blacklight configuration parameters to directly add solr request parameters:
|
85
|
-
* default_solr_params
|
86
|
-
* qt
|
87
|
-
* solr_path
|
88
|
-
* document_solr_request_handler
|
89
|
-
* document_solr_path
|
90
|
-
* document_unique_id_param
|
91
|
-
* default_document_solr_params
|
92
|
-
|
93
|
-
### Request handlers
|
94
|
-
|
95
|
-
Blacklight supports rapid application development by allowing you to configure Blacklight to send every parameter in every solr request. One of the ways to productionize this is to move the static logic into Solr request handlers. [Request Handlers](http://wiki.apache.org/solr/SolrRequestHandler) are configured in the [solrconfig.xml](http://wiki.apache.org/solr/SolrConfigXml).
|
96
|
-
|
97
|
-
Request handler parameters can be configured three different ways:
|
98
|
-
|
99
|
-
* defaults - provides default param values that will be used if the param does not have a value specified at request time.
|
100
|
-
* appends - provides param values that will be used in addition to any values specified at request time (or as defaults.
|
101
|
-
* invariants - provides param values that will be used in spite of any values provided at request time. They are a way of letting the Solr maintainer lock down the options available to Solr clients. Any params values specified here are used regardless of what values may be specified in either the query, the "defaults", or the "appends" params.
|
102
|
-
|
103
|
-
Here is an example request handler demonstrating all types of configuration:
|
104
|
-
|
105
|
-
```xml
|
106
|
-
<requestHandler name="standard" class="solr.StandardRequestHandler">
|
107
|
-
<lst name="defaults">
|
108
|
-
<!-- assume they want 50 rows unless they tell us otherwise -->
|
109
|
-
<int name="rows">50</int>
|
110
|
-
<!-- assume they only want popular products unless they provide a different fq -->
|
111
|
-
<str name="fq">popularity:[1 TO *]</str>
|
112
|
-
</lst>
|
113
|
-
<lst name="appends">
|
114
|
-
<!-- no matter what other fq are also used, always restrict to only inStock products -->
|
115
|
-
<str name="fq">inStock:true</str>
|
116
|
-
</lst>
|
117
|
-
<lst name="invariants">
|
118
|
-
<!-- don't let them turn on faceting -->
|
119
|
-
<bool name="facet">false</bool>
|
120
|
-
</lst>
|
121
|
-
|
122
|
-
</requestHandler>
|
123
|
-
```
|
124
|
-
|
125
|
-
|
126
|
-
#### Document request handler
|
127
|
-
|
128
|
-
In addition to the search request handler, we strongly encourage you to configure a request handler for retrieving single documents. This request handler can be highly optimized to remove unnecessary parameters and processing, makes it easier to understand the Solr request log, and allows you to easily change request parameters for search and single-item behaviors separately.
|
129
|
-
|
130
|
-
The blacklight document request handler looks like this:
|
131
|
-
|
132
|
-
```xml
|
133
|
-
<requestHandler name="document" class="solr.SearchHandler" >
|
134
|
-
<lst name="defaults">
|
135
|
-
<str name="echoParams">all</str>
|
136
|
-
<str name="fl">*</str>
|
137
|
-
<str name="rows">1</str>
|
138
|
-
<bool name="facet">false</bool>
|
139
|
-
<str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
|
140
|
-
</lst>
|
141
|
-
</requestHandler>
|
142
|
-
```
|
143
|
-
|
144
|
-
If you're using Solr 4.0+, you may also consider using the [Solr Real-Time Get](https://cwiki.apache.org/confluence/display/solr/RealTime+Get) request handler.
|
145
|
-
|
146
|
-
```xml
|
147
|
-
<requestHandler name="/get" class="solr.RealTimeGetHandler">
|
148
|
-
<lst name="defaults">
|
149
|
-
<str name="omitHeader">true</str>
|
150
|
-
<str name="wt">json</str>
|
151
|
-
<str name="indent">true</str>
|
152
|
-
</lst>
|
153
|
-
</requestHandler>
|
154
|
-
```
|
data/doc/Sunspot-for-indexing.md
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
If you have a Rails application as your data store, you may look to [Sunspot](http://outoftime.github.com/sunspot/) to help index your ActiveRecord models. Sunspot provides a nice DSL that makes it easy to index your models and associations. There is one gotcha, though, for using Sunspot with Blacklight. Both Sunspot and Blacklight expect the Solr uniqueKey to be in the "id" field. Sunspot will use the class of your model plus the primary key of that instance as the value for the id field. So a value for the id field may look like this: "Resource 123".
|
2
|
-
|
3
|
-
When a Sunspot-indexed Solr is used with Blacklight your model names and primary keys are exposed in your URLs. You may want to use a different value as your id value for Blacklight to use for document recall and URLs. For instance you want to use a unique filename as your id value for Blacklight.
|
4
|
-
|
5
|
-
You can use something like the following monkeypatch of Sunspot (1.2) by placing it in config/initializers/sunspot_monkeypatch_id.rb. It takes the value of the id field that Sunspot creates (Resource 123) and places it in the resource_id_ss field. It then overwrites the id value with the value from the filename field. The second part then takes a Solr hit and reverses it so that Sunspot can retrieve your models.
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
# for using a different value for the id field of your Solr documents
|
9
|
-
Sunspot::Indexer.module_eval do
|
10
|
-
alias :old_prepare :prepare
|
11
|
-
def prepare(model)
|
12
|
-
document = old_prepare(model)
|
13
|
-
document.fields_by_name(:resource_id_ss).first.value = document.fields_by_name(:id).first.value
|
14
|
-
if !document.fields_by_name(:filename).blank? and !document.fields_by_name(:filename).first.blank?
|
15
|
-
document.fields_by_name(:id).first.value = document.fields_by_name(:filename).first.value
|
16
|
-
end
|
17
|
-
document
|
18
|
-
end
|
19
|
-
|
20
|
-
alias :old_remove :remove
|
21
|
-
def remove(*models)
|
22
|
-
@connection.delete_by_id(
|
23
|
-
models.map do |model|
|
24
|
-
prepare(model).fields_by_name(:id).first.value
|
25
|
-
end
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
# to allow searching with Sunspot's DSL as well to retrieve your models
|
32
|
-
class Sunspot::Search::Hit
|
33
|
-
def initialize(raw_hit, highlights, search)
|
34
|
-
raw_hit['id'] = raw_hit['resource_id_ss']
|
35
|
-
@class_name, @primary_key = *raw_hit['id'].match(/([^ ]+) (.+)/)[1..2]
|
36
|
-
@score = raw_hit['score']
|
37
|
-
@search = search
|
38
|
-
@stored_values = raw_hit
|
39
|
-
@stored_cache = {}
|
40
|
-
@highlights = highlights
|
41
|
-
end
|
42
|
-
end
|
43
|
-
```
|
44
|
-
|
45
|
-
|
46
|
-
|
data/doc/Support.md
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
## Context
|
2
|
-
|
3
|
-
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.
|
4
|
-
|
5
|
-
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.
|
6
|
-
|
7
|
-
But we do try when we can -- please don't be scared to ask a question on the listserv, just don't be shocked if we can't always give you the answer you want. We always welcome patches; 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.
|
8
|
-
|
9
|
-
## Wiki
|
10
|
-
|
11
|
-
Some guides are available on this wiki, including installation instructions. We hope the wiki documentation will continue to expand and improve. If you figure something out that wasn't already in the wiki, please feel free to edit or add a wiki page on it to help those who come after you. If there's something you think needs documenting but you aren't sure you understand it well enough to document it, feel free to add a note to that effect in the wiki too, as a stub.
|
12
|
-
|
13
|
-
## Code-level documentation
|
14
|
-
|
15
|
-
Auto-generated code-level API documentation is available at: [http://rdoc.info/github/projectblacklight/blacklight](http://rdoc.info/github/projectblacklight/blacklight).
|
16
|
-
|
17
|
-
## Mailing list
|
18
|
-
|
19
|
-
The blacklight listserv can be found at: [http://groups.google.com/group/blacklight-development](http://groups.google.com/group/blacklight-development).
|
20
|
-
|
21
|
-
Searching the archives might be helpful.
|
22
|
-
|
23
|
-
Don't be scared to ask a question on the list. We appreciate you checking the documentation first and asking an educated question, but don't beat your head against the wall -- sometimes the existing documentation may be out of date and inaccurate.
|
24
|
-
|
25
|
-
In order to reduce spam, the first time you post your email will be held in a moderation queue, but as soon as your first message is approved your posts won't be held for moderation any longer. (Is this really true on the google groups hosted list? Not sure.)
|
26
|
-
|
27
|
-
## IRC channel
|
28
|
-
|
29
|
-
Some Blacklight developers hang out on our IRC channel, usually during North American office hours. On chat.freenode.net, channel #blacklight. Stop in and say hi, we're happy to help with questions when we have time.
|
30
|
-
|
31
|
-
## The Code
|
32
|
-
|
33
|
-
Blacklight code is hosted on GitHub, which provides a pretty impressive web GUI for browsing the code and revision history.
|
data/doc/Theming.md
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# Theming Blacklight
|
2
|
-
|
3
|
-
|
4
|
-
Blacklight uses the [[Twitter Bootstrap|http://twitter.github.com/bootstrap]] framework for styling the out-of-the-box UI. While there is some Blacklight-specific customizations, most (if not all) the "styling" (colors, fonts, etc) are handled by Bootstrap.
|
5
|
-
|
6
|
-
## Bootswatches
|
7
|
-
|
8
|
-
One approach to styling Bootstrap-based sites is using "bootswatches", which are simple bootstrap themes that override SASS variables, mixins and declarations.
|
9
|
-
|
10
|
-
First, add the [[bootswatch-rails gem|https://github.com/maxim/bootswatch-rails]] to your Gemfile (and run ```bundle install```):
|
11
|
-
|
12
|
-
```ruby
|
13
|
-
gem 'bootswatch-rails'
|
14
|
-
```
|
15
|
-
|
16
|
-
This will give you the set of themes from [[http://bootswatch.com/]], converted to SASS and exposed to the Rails asset pipeline.
|
17
|
-
|
18
|
-
Out of the box, your application's blacklight stylesheet (generated by default to ```app/assets/stylesheets/blacklight.css.scss```) looks something like:
|
19
|
-
|
20
|
-
```css
|
21
|
-
@import 'bootstrap';
|
22
|
-
|
23
|
-
@import 'blacklight/blacklight';
|
24
|
-
```
|
25
|
-
|
26
|
-
To add the one of the bootswatch themes ('cerulean' in this example):
|
27
|
-
|
28
|
-
```css
|
29
|
-
@import "bootswatch/cerulean/variables";
|
30
|
-
|
31
|
-
@import "bootstrap";
|
32
|
-
|
33
|
-
@import "bootswatch/cerulean/bootswatch";
|
34
|
-
|
35
|
-
@import 'blacklight/blacklight'
|
36
|
-
```
|
37
|
-
|
38
|
-
![Blacklight with the Cerulean theme applied](http://projectblacklight.org/images/blacklight-cerulean.png)
|
39
|
-
|
40
|
-
The [[bootswatch-rails|https://github.com/maxim/bootswatch-rails]] documentation provides similar directions, a list of available out-of-the-box themes, and more.
|
41
|
-
|
42
|
-
> As of this writing, not all bootswatch-rails themes seem to be bootstrap 2.1.x compatible, or do weird things to the Blacklight navbar, etc. Your milage may vary.
|
43
|
-
|
44
|
-
## Developing a Customized "Local" Theme
|
45
|
-
|
46
|
-
In most cases, you will want to develop your own theme within your Blacklight app, outside of the Bootswatch gem. To do this, you can do the following in your ```app/assets/stylesheets``` directory:
|
47
|
-
|
48
|
-
1. create your own _variables.scss and _bootswatch.scss files in stylesheets/ (easiest way to do this is to copy those files from the [[bootstrap-sass project|https://github.com/thomas-mcdonald/bootstrap-sass/tree/master/vendor/assets/stylesheets/bootstrap]] or an existing theme and customize from there)
|
49
|
-
2. change application.css to application.css.scss
|
50
|
-
3. add the import statements given in the above "theming" example to application.css.scss
|
51
|
-
4. delete blacklight.css.scss
|
52
|
-
|
53
|
-
So, your application.css.scss should look like this:
|
54
|
-
```css
|
55
|
-
@import "variables";
|
56
|
-
|
57
|
-
@import "bootstrap";
|
58
|
-
|
59
|
-
@import "bootswatch";
|
60
|
-
|
61
|
-
@import 'blacklight/blacklight'
|
62
|
-
```
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# Understanding Rails
|
2
|
-
|
3
|
-
In order to understand how Blacklight works, you should have a basic knowledge about how Rails works. In the previous section, we offered resources to develop a general understanding of Rails. In this section, we'll look at the most important concepts that contribute to the way Blacklight functions.
|
4
|
-
|
5
|
-
Blacklight is packaged as a [Rails Engine](http://guides.rubyonrails.org/engines.html), which means it is a Ruby gem that provides functionality to a Rails application, including functionality, javascript and css assets, etc. Installing Blacklight is as simple as adding the Blacklight gem to your Rails application's gemfile, and running the included `blacklight:install` generator (see Installing).
|
6
|
-
|
7
|
-
## Controllers
|
8
|
-
|
9
|
-
Blacklight generates a `CatalogController` into your application. This controller adds discovery and single-item "show" actions. This controller is where you can perform the majority of your Blacklight configuration and customization. The configuration options are discussed in future chapters.
|
10
|
-
|
11
|
-
Blacklight also provides several controllers to the host application. These controllers respect the `CatalogController` configurations.
|
12
|
-
|
13
|
-
> Engine model and controller classes can be extended by open classing them in the main Rails application (since model and controller classes are just Ruby classes that inherit Rails specific functionality).
|
14
|
-
|
15
|
-
|
16
|
-
## Models
|
17
|
-
|
18
|
-
As with the `CatalogController` above, Blacklight generates a `SolrDocument` model into your application. This model is used to translate Solr response documents into Rails models. Unlike many Rails models, the `SolrDocument` is not backed by an ActiveRecord row, but is merely a read-only, Ruby-friendly representation of Solr's response.
|
19
|
-
|
20
|
-
Within the `SolrDocument` model, you can provide custom model methods, accessors, and behaviors to the documents returned from Solr.
|
21
|
-
|
22
|
-
The `SolrDocument` also provides an extension framework for conditionally adding additional behavior to documents. The extension framework is discussed in greater detail later.
|
23
|
-
|
24
|
-
|
25
|
-
## Views
|
26
|
-
|
27
|
-
Blacklight views can by customized by simply creating a new view within your application with the same name as the Blacklight view you want to override. If you wanted to override the view provided by the Blacklight `app/views/catalog/_per_page_widget.html.erb` partial, you could create the file `app/views/catalog/_per_page_widget.html.erb` in your own application.
|
28
|
-
|
29
|
-
> When Rails looks for a view to render, it will first look in the app/views directory of the application. If it cannot find the view there, then it will check in the app/views directories of all engines which have this directory.
|
30
|
-
|
31
|
-
## Layout
|
32
|
-
|
33
|
-
Blacklight provides a generic layout to the application.
|
34
|
-
|
35
|
-
If you're integrating Blacklight into an existing Rails application,
|
36
|
-
Blacklight also expects the host application's layout to be responsible for rendering Rails flash messages and a shared Bootstrap modal. In addition, the layout should include:
|
37
|
-
|
38
|
-
A place for Blacklight views (and, mainly, plugins) to inject content into the <head>:
|
39
|
-
|
40
|
-
```erb
|
41
|
-
<head>
|
42
|
-
...
|
43
|
-
<%= content_for(:head) %>
|
44
|
-
...
|
45
|
-
</head>
|
46
|
-
```
|
47
|
-
|
48
|
-
The layout should also provide a Bootstrap container and row wrapper:
|
49
|
-
|
50
|
-
```erb
|
51
|
-
<div class="container">
|
52
|
-
...
|
53
|
-
<div class="row">
|
54
|
-
<%= yield %>
|
55
|
-
</div>
|
56
|
-
</div>
|
57
|
-
```
|
58
|
-
|
59
|
-
|
60
|
-
## Routes
|
61
|
-
|
62
|
-
Many Rails engines are "mounted" and are entirely isolated from the main application's routes. Blacklight routes, however, are injected directly into your application. Blacklight routes are added by a generator, and add this line to your `config/routes.rb`.
|
63
|
-
|
64
|
-
```ruby
|
65
|
-
blacklight_for :catalog
|
66
|
-
```
|
67
|
-
|
68
|
-
Mostly legacy. Allows for some greater flexibility.
|
69
|
-
|
70
|
-
## Assets
|
71
|
-
|
72
|
-
Blacklight adds assets to your application. Pick-and-choose, or override. Javascript is implemented using a pluggable approach, which we hope provides an easy way to customize behavior.
|
73
|
-
|
74
|
-
|
75
|
-
## Locales and i18n
|
data/doc/User-Authentication.md
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
Blacklight does not require user authentication, however, if included, Blacklight can provide additional features for users ([[Bookmarks]], [[Saved Searches]], etc). Because of the wide range of institutional needs and capabilities, Blacklight does not require a specific user authentication provider.
|
2
|
-
|
3
|
-
## Installing with Devise
|
4
|
-
|
5
|
-
If you are rolling your own user authentication system, we highly recommend [[Devise|https://github.com/plataformatec/devise]], an extremely flexible authentication solution that is relatively straightforward. For directions to install the Blacklight gem using devise, see the [[Quickstart]].
|
6
|
-
|
7
|
-
## Install and Use (with a custom user authentication system)
|
8
|
-
|
9
|
-
Create a new rails 3 application
|
10
|
-
```bash
|
11
|
-
$ rails new my_app
|
12
|
-
```
|
13
|
-
|
14
|
-
Add blacklight to your gem file
|
15
|
-
```bash
|
16
|
-
edit ./my_app/Gemfile
|
17
|
-
```
|
18
|
-
```ruby.
|
19
|
-
# Append this line to the end of the file:
|
20
|
-
gem 'blacklight'
|
21
|
-
```
|
22
|
-
|
23
|
-
```bash
|
24
|
-
$ bundle install
|
25
|
-
```
|
26
|
-
|
27
|
-
If you have a `User` model already, the Blacklight generator will connect to it automatically during installation. However, you will need to make sure the following named routes are included in your /config/routes.rb file:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
match 'your_login', :to => 'Your User Session Controller # Log in action', :as => 'new_user_session'
|
31
|
-
match 'your_logout', :to => 'Your User Session Controller # Log Out action', :as => 'destroy_user_session'
|
32
|
-
match 'your_account_page', :to => 'Your User Session Controller # Account edit action', :as => 'edit_user_registration'
|
33
|
-
```
|
34
|
-
|
35
|
-
One blacklight view partial uses `#to_s` on your user model to get a user-displayable account name/identifier for the currently logged in account, so you probably want to have such a method.
|
36
|
-
|
37
|
-
Finally, you will need to make sure the following methods are available both on controllers and as helpers:
|
38
|
-
|
39
|
-
* `current_user` - Which should return an ActiveRecord-based user object that include Blacklight::User
|
40
|
-
* `user_session` - Which are included in your /config/routes.rb file:
|
41
|
-
|
42
|
-
Optionally,
|
43
|
-
* `guest_user` - Which should return an ActiveRecord-based temporary guest user object available across the current user session.
|
44
|
-
* `current_or_guest_user` - Which should return the `current_user`, if available, or `guest_user`. If you don't provide this method, a stub method (that just returns `current_user`) will be provided for you.
|
45
|
-
|
46
|
-
If you are supporting guest users, if a guest user logs in, you should call `#transfer_guest_user_actions_to_current_user` to move any persisted data to the permanent user.
|
47
|
-
|
48
|
-
> The `devise-guests` gem implements the `guest_user`, `current_or_guest_user` and callbacks for Blacklight applications using devise. It may be a useful reference for rolling your own functionality. See [DeviseGuests::Controllers::Helpers](https://github.com/cbeer/devise-guests/blob/master/lib/devise-guests/controllers/helpers.rb)
|
49
|
-
|
50
|
-
Once these are in place, you can run the Blacklight Installation Generator:
|
51
|
-
|
52
|
-
```bash
|
53
|
-
$ rails generate blacklight [MODEL NAME]
|
54
|
-
```
|
55
|
-
Where model name is the name of your user model.
|
56
|
-
|
57
|
-
Execute your migrations, and you should be good to go.
|
58
|
-
```bash
|
59
|
-
$ rake db:migrate
|
60
|
-
```
|
data/doc/_Sidebar.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
[[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/logo.png]]
|
2
|
-
|
3
|
-
[[Quickstart Guide|Quickstart]]
|
4
|
-
|
5
|
-
[[Site Search|http://projectblacklight.org/search.html]]
|
6
|
-
|
7
|
-
[[Demo|http://demo.projectblacklight.org]]
|
8
|
-
|
9
|
-
[[Example installations|Examples]]
|