blacklight 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.1
1
+ 3.1.2
data/blacklight.gemspec CHANGED
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency "nokogiri", "~>1.5" # XML Parser
25
25
  s.add_dependency "unicode" # provides C-form normalization of unicode characters, as required by refworks.
26
26
  s.add_dependency "marc", "~> 0.4.3" # Marc record parser
27
- s.add_dependency "rsolr", '~> 1.0' # Library for interacting with rSolr.
28
- s.add_dependency "rsolr-ext", '~> 1.0' # extension to the above for some rails-ish behaviors - currently embedded in our solr document ojbect.
27
+ s.add_dependency "rsolr", '1.0.2' # Library for interacting with rSolr.
28
+ s.add_dependency "rsolr-ext", '1.0.3' # extension to the above for some rails-ish behaviors - currently embedded in our solr document ojbect.
29
29
  s.add_dependency "kaminari" # the pagination (page 1,2,3, etc..) of our search results
30
30
 
31
31
  end
@@ -0,0 +1,90 @@
1
+ Blacklight will provide atom responses for all catalog/index results. Just add ".atom" on to the end of your path component, `/catalog.atom`, or `/catalog/index.atom`.
2
+ ```xml
3
+ <?xml version="1.0" encoding="UTF-8"?>
4
+ <feed xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom">
5
+ <title>Blacklight Search Results</title>
6
+ <author>
7
+ <name>Blacklight</name>
8
+ </author>
9
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="self"/>
10
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=html&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="alternate" type="text/html"/>
11
+ <id>http://demo.projectblacklight.org/?commit=search&amp;amp;format=html&amp;amp;q=urdu&amp;amp;search_field=all_fields&amp;amp;type=text%2Fhtml</id>
12
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=2&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="next"/>
13
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=1&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="first"/>
14
+ <link href="http://demo.projectblacklight.org/?commit=search&amp;amp;format=atom&amp;amp;page=15&amp;amp;q=urdu&amp;amp;search_field=all_fields" rel="last"/>
15
+ <link href="http://demo.projectblacklight.org/catalog/opensearch.xml" rel="search" type="application/opensearchdescription+xml"/>
16
+ <opensearch:totalResults>147</opensearch:totalResults>
17
+ <opensearch:startIndex>0</opensearch:startIndex>
18
+ <opensearch:itemsPerPage>10</opensearch:itemsPerPage>
19
+ <opensearch:Query searchTerms="urdu" startPage="1" role="request"/>
20
+ <updated>2011-05-11T17:46:58Z</updated>
21
+ <entry>
22
+ <title>Urdu&#772; d&#803;ra&#772;ma&#772;</title>
23
+ <updated>2011-05-11T17:46:58Z</updated>
24
+ <link href="http://demo.projectblacklight.org/catalog/2008306442" rel="alternate" type="text/html"/>
25
+ <link href="http://demo.projectblacklight.org/catalog/2008306442.dc_xml" rel="alternate" title="dc_xml" type="text/xml" />
26
+ <link href="http://demo.projectblacklight.org/catalog/2008306442.xml" rel="alternate" title="xml" type="application/xml" />
27
+ <id>http://demo.projectblacklight.org/catalog/2008306442</id>
28
+ <author>
29
+ <name>Farg&#818;h&#818;a&#772;nah, 1979-</name>
30
+ </author>
31
+ <summary type="html">
32
+ &lt;dl class="defList"&gt;
33
+
34
+
35
+ &lt;dt class="blacklight-title_display"&gt;Title:&lt;/dt&gt;
36
+ &lt;dd class="blacklight-title_display"&gt;Urdu&#772; d&#803;ra&#772;ma&#772;&lt;/dd&gt;
37
+
38
+ &lt;dt class="blacklight-author_display"&gt;Author:&lt;/dt&gt;
39
+ &lt;dd class="blacklight-author_display"&gt;Farg&#818;h&#818;a&#772;nah, 1979-&lt;/dd&gt;
40
+
41
+
42
+ <!-- [...] -->
43
+ &lt;/dl&gt;
44
+ </summary>
45
+ </entry>
46
+ <!-- [...] -->
47
+ </feed>
48
+ ```
49
+
50
+
51
+ The same HTML summary included in your HTML results pages are included as an `atom:summary` element -- the atom template uses the `[[#render_document_partial|https://github.com/projectblacklight/blacklight/blob/master/app/helpers/blacklight_helper.rb#L311]]` helper method to generate this HTML summary, so if you've over-ridden that for your app, it will be used as the `atom:summary` content instead.
52
+
53
+ ## API Usage
54
+ The Atom response is intended to be pretty full of data, so it can fill many traditional API requests. It makes use of every relevant atom or [[OpenSearch|http://www.opensearch.org/Home]] element that could be conveniently included.
55
+
56
+ The Atom response also supports arbitrary format representations in the `atom:content` element. You can include `&content_format=some_format` in your request URL (e.g. `[[/catalog.atom?content_format=oai_dc_xml|http://demo.projectblacklight.org/catalog.atom?q=urdu&content_format=oai_dc_xml]]`). Any format a given document can be exported as using the [[Blacklight document framework|Extending-blacklight-with-the-document-extension-framework]] is available. Not every document can export in every format -- if a format is requested one or more of the items in your atom result can not export as, it will not have an `atom:content` element. Non-XML-based formats are supported, as the content is Base64-encoded (as per Atom spec, unless the format is `text/plain`).
57
+ ```xml
58
+ <?xml version="1.0" encoding="UTF-8"?>
59
+ <feed xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom">
60
+ <title>Blacklight Search Results</title>
61
+ <author>
62
+ <name>Blacklight</name>
63
+ </author>
64
+ <link href="http://demo.projectblacklight.org/?content_format=oai_dc_xml&amp;amp;format=atom&amp;amp;per_page=1" rel="self"/>
65
+ <!-- [...] -->
66
+ <entry>
67
+ <title>The book of the dance in the 20th century selections from the Jane Bourne Parton collection of books on the dance</title>
68
+ <updated>2011-05-11T17:59:32Z</updated>
69
+ <link href="http://demo.projectblacklight.org/catalog/u1" rel="alternate" type="text/html"/>
70
+ <link href="http://demo.projectblacklight.org/catalog/u1.dc_xml" rel="alternate" title="dc_xml" type="text/xml" />
71
+ <link href="http://demo.projectblacklight.org/catalog/u1.xml" rel="alternate" title="xml" type="application/xml" />
72
+ <id>http://demo.projectblacklight.org/catalog/u1</id>
73
+ <author>
74
+ <name>Roatcap, Adela Spindler</name>
75
+ </author>
76
+ <summary type="html">
77
+ <!-- [...] -->
78
+ </summary>
79
+ <!-- [ Here is the export format as OAI Dublin Core XML ] -->
80
+ <content type="text/xml">
81
+ <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:language>English</dc:language><dc:title>The book of the dance in the 20th century selections from the Jane Bourne Parton collection of books on the dance</dc:title><dc:format>Book</dc:format></oai_dc:dc> </content>
82
+ </entry>
83
+ </feed>
84
+ ```
85
+
86
+ This means that if you add on a document extension that provides more export formats for some or all of your documents, that will automatically be available in the atom response.
87
+
88
+ If you choose to use the [[Blacklight CQL add-on|https://github.com/projectblacklight/blacklight_cql]], the combination of [[CQL|http://www.loc.gov/standards/sru/specs/cql.html]] requests and Atom responses provides a pretty good more-or-less standards-based API to search results through Blacklight.
89
+
90
+ The Atom response generating template is at `app/views/catalog/index.builder.atom`.
@@ -0,0 +1,121 @@
1
+ # Customizing Blacklight
2
+
3
+ There are lots of way 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
+ ## Layouts
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ ```ruby
14
+ def layout_name
15
+ "application"
16
+ end
17
+ ```
18
+
19
+ When implmeenting 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. An example would be insertion of alternate format auto-discovery link tags in the head section; if you call out to BL helpers, BL will make sure it happens. Another example would be the sidebar_items helper; if you don't call out to that, your page won't include sidebar content such as facet lists.
20
+
21
+ ## Overriding Views (templates and partials)
22
+ 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.
23
+
24
+ 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.
25
+
26
+ 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.
27
+
28
+ ## Overriding the Catalog controller
29
+ Overriding the Blacklight CatalogController implementation is easy, and the skeleton of the `CatalogController` is generated into your application for you when you install Blacklight.
30
+
31
+ See the [[Extending or Modifying Blacklight Search Behavior]] for tips and approaches to customizing the catalog.
32
+
33
+ ## Overriding Other Controllers
34
+
35
+ 1. Find the controller you're interested in in blacklight's app/controllers/ .
36
+ 2. Create a file with the same name in your local app/controllers.
37
+ 3. This file requires the original class, and then re-opens it to add more methods.
38
+
39
+ ```ruby
40
+ require "#{Blacklight.controllers_dir}/some_controller"
41
+
42
+ class SomeController < ApplicationController
43
+ # custom code goes here
44
+ end
45
+ ```
46
+
47
+ 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.
48
+
49
+ It's kind of hard to call 'super' to call original functionality:
50
+
51
+ * the ruby language features here make 'super' unavailable, although you can work around that confusingly with the rails #alias_method_chain method.
52
+ * 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.
53
+
54
+ 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.
55
+
56
+
57
+ ## Custom View Helpers
58
+
59
+ (This is accurate for Blacklight 3.1.1 and subsequent. Before that, things were messier).
60
+
61
+ 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.
62
+
63
+ 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).
64
+
65
+ 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.
66
+
67
+ 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:
68
+
69
+ ```ruby
70
+ module BlacklightHelper
71
+ include Blacklight::BlacklightHelperBehavior
72
+ end
73
+ ```
74
+
75
+ Now, the actual methods will be found in app/helpers/blacklight/blacklight_helper_behavior.rb instead.
76
+
77
+ 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 BlacklightHelpersBehavior, and the other methods you don't over-ride will still have their default implementation.
78
+
79
+ YOUR `app/helpers/blacklight_helper.rb`
80
+
81
+ ```ruby
82
+ module BlacklightHelper
83
+ include Blacklight::BlacklightHelperBehavior
84
+
85
+ def application_name
86
+ "Bestest University Search"
87
+ end
88
+ end
89
+ ```
90
+
91
+ 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.
92
+
93
+ ## Adding in your own CSS or Javascript
94
+
95
+ You probably already have a local `app/controllers/application_controller.rb`. If you've installed the Blacklight plugin already, it probably looks something like this:
96
+ ```ruby
97
+ class ApplicationController < ActionController::Base
98
+ # Adds a few additional behaviors into the application controller
99
+ include Blacklight::Controller
100
+ end
101
+ ```
102
+
103
+ Now create a css file called whatever you want in the application's `./public/stylesheets` directory inside the class definition, add like so:
104
+ ```ruby
105
+ class ApplicationController < ActionController::Base
106
+ before_filter :add_my_own_assets
107
+
108
+ protected
109
+ def add_my_own_assets
110
+ stylesheet_links << "my_css"
111
+
112
+ # You can do something similar with javascript files too:
113
+ # javascript_includes << "my_js"
114
+ end
115
+ end
116
+ ```
117
+
118
+ ## See also
119
+
120
+ * [[Extending or Modifying Blacklight Search Behavior]]
121
+ * [[Pagination]]
@@ -0,0 +1 @@
1
+ See [[Blacklight::Solr::Document rdoc|http://rdoc.info/github/projectblacklight/blacklight/master/Blacklight/Solr/Document]]
@@ -0,0 +1,131 @@
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 `[[./config/initializers/blacklight_config.rb|https://github.com/projectblacklight/blacklight/blob/master/lib/generators/blacklight/templates/config/blacklight_config.rb]]`.
40
+
41
+ Nothing special about the filename 'blacklight_config.rb', anything in a Rails app at `./config/initializers/*.rb` gets run on application startup, what matters it the code.
42
+
43
+ ## Application logic
44
+
45
+ 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).
46
+
47
+ 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. We 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.
48
+
49
+ 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.
50
+
51
+ The default `#solr_search_params_logic` is meant to handle very common cases and patterns based on simple configuration options, usually set in the `config/blacklight_config.rb` file, and the user-supplied URL parameters.
52
+
53
+ * `[[Blacklight.config[:default_solr_params]|https://github.com/projectblacklight/blacklight/blob/master/config/initializers/blacklight_config.rb#L44]]`
54
+ * 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.
55
+ * `[[Blacklight.config[:search_fields]|https://github.com/projectblacklight/blacklight/blob/master/config/initializers/blacklight_config.rb#L194]]`
56
+ * An array of hashes, each of which defines a 'search field' which 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.
57
+ * 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.
58
+ * 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.
59
+ * 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.
60
+
61
+ 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.
62
+
63
+ 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.
64
+
65
+
66
+ # Extending Blacklight::SolrHelper#solr_search_params
67
+
68
+ 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.
69
+
70
+ `#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.
71
+
72
+ You can add custom solr_search_params_logic steps within the `blacklight_config.rb` (or in many other places) by adding a Symbol with the name of a method (provided by the controller) you wish to use, e.g.:
73
+
74
+ *./config/initializers/blacklight_config.rb*
75
+
76
+ ```ruby
77
+ CatalogController.solr_search_params_logic << :show_only_public_records
78
+ ```
79
+ (note, this method of using an initiailizer has trouble if the local CatalogController is reloaded with Rails development-mode class reloading, it'll miss the mod to solr_search_params_logic on reload. To get around this, either use `to_prepare do`, or just mod the solr_search_params_logic in the local CatalogController class definition, as below)
80
+
81
+ 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:
82
+
83
+ *./app/controllers/catalog_controller.rb*
84
+
85
+ ```ruby
86
+ require 'blacklight/catalog'
87
+ class CatalogController < ApplicationController
88
+ include Blacklight::Catalog
89
+ include MyApplication::SolrHelper::Authorization
90
+
91
+ # Instead of defining this within an initializer, you may instead wish to do it on the controller directly:
92
+ # self.solr_search_params_logic << :show_only_public_records
93
+
94
+ # You could also define the actual method here, but this is not recommended.
95
+ # def show_only_public_records solr_parameters, user_parameters
96
+ # [...]
97
+ # end
98
+ end
99
+ ```
100
+
101
+ The included module then defines the logic method:
102
+
103
+ *./lib/my_application/solr_helper/authorization.rb*
104
+
105
+ ```ruby
106
+ module MyApplication::SolrHelper::Authorization
107
+ # You could also add the logic here
108
+ # def self.included base
109
+ # base.solr_search_params_logic << :show_only_public_records
110
+ # end
111
+
112
+ # solr_search_params_logic methods take two arguments
113
+ # @param [Hash] solr_parameters a hash of parameters to be sent to Solr (via RSolr)
114
+ # @param [Hash] user_parameters a hash of user-supplied parameters (often via `params`)
115
+ def show_only_public_records solr_parameters, user_parameters
116
+ # add a new solr facet query ('fq') parameter that limits results to those with a 'public_b' field of 1
117
+ solr_parameters[:fq] ||= []
118
+ solr_parameters[:fq] << 'public_b:1'
119
+ end
120
+ end
121
+ ```
122
+
123
+ ## Other examples
124
+
125
+ In addition to providing this behavior locally, some Blacklight plugins also extend the `#solr_search_params`:
126
+
127
+ * [[Blacklight Range Limit|https://github.com/projectblacklight/blacklight_range_limit/blob/master/lib/blacklight_range_limit/controller_override.rb]]
128
+
129
+ * A walk through on adding a checkbox limit at: http://bibwild.wordpress.com/2011/06/13/customing-blacklight-a-limit-checkbox/
130
+
131
+ * 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/
data/doc/Features.md ADDED
@@ -0,0 +1,147 @@
1
+ ## Discovery
2
+ ### Search Features
3
+ Blacklight uses Solr as its "search engine". More information about Solr is available at the [[Solr web site|http://lucene.apache.org/solr/]]
4
+
5
+ * 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]]
6
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_fields.png|frame|alt=Search fields in action]]
7
+
8
+ ```ruby
9
+ # Now we see how to over-ride Solr request handler defaults, in this
10
+ # case for a BL "search field", which is really a dismax aggregate
11
+ # of Solr search fields.
12
+ config[:search_fields] << {
13
+ :key => 'title',
14
+ # solr_parameters hash are sent to Solr as ordinary url query params.
15
+ :solr_parameters => {
16
+ :"spellcheck.dictionary" => "title"
17
+ },
18
+ # :solr_local_parameters will be sent using Solr LocalParams
19
+ # syntax, as eg {! qf=$title_qf }. This is neccesary to use
20
+ # Solr parameter de-referencing like $title_qf.
21
+ # See: http://wiki.apache.org/solr/LocalParams
22
+ :solr_local_parameters => {
23
+ :qf => "$title_qf",
24
+ :pf => "$title_pf"
25
+ }
26
+ }
27
+ ```
28
+
29
+ > Source: [[./config/initializers/blacklight_config.rb|https://github.com/projectblacklight/blacklight/blob/master/lib/generators/blacklight/templates/config/blacklight_config.rb#L155]]
30
+
31
+
32
+ - Faceted search allows users to constrain searches by controlled vocabulary items
33
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_facets.png|frame|alt=Search facets in action]]
34
+
35
+ ```ruby
36
+ # solr fields that will be treated as facets by the blacklight application
37
+ # The ordering of the field names is the order of the display
38
+ # TODO: Reorganize facet data structures supplied in config to make simpler
39
+ # for human reading/writing, kind of like search_fields. Eg,
40
+ # config[:facet] << {:field_name => "format", :label => "Format", :limit => 10}
41
+ config[:facet] = {
42
+ :field_names => (facet_fields = [
43
+ "format",
44
+ "pub_date",
45
+ "subject_topic_facet",
46
+ "language_facet",
47
+ "lc_1letter_facet",
48
+ "subject_geo_facet",
49
+ "subject_era_facet"
50
+ ]),
51
+ :labels => {
52
+ "format" => "Format",
53
+ "pub_date" => "Publication Year",
54
+ "subject_topic_facet" => "Topic",
55
+ "language_facet" => "Language",
56
+ "lc_1letter_facet" => "Call Number",
57
+ "subject_era_facet" => "Era",
58
+ "subject_geo_facet" => "Region"
59
+ },
60
+ # Setting a limit will trigger Blacklight's 'more' facet values link.
61
+ # * If left unset, then all facet values returned by solr will be displayed.
62
+ # * If set to an integer, then "f.somefield.facet.limit" will be added to
63
+ # solr request, with actual solr request being +1 your configured limit --
64
+ # you configure the number of items you actually want _displayed_ in a page.
65
+ # * If set to 'true', then no additional parameters will be sent to solr,
66
+ # but any 'sniffed' request limit parameters will be used for paging, with
67
+ # paging at requested limit -1. Can sniff from facet.limit or
68
+ # f.specific_field.facet.limit solr request params. This 'true' config
69
+ # can be used if you set limits in :default_solr_params, or as defaults
70
+ # on the solr side in the request handler itself. Request handler defaults
71
+ # sniffing requires solr requests to be made with "echoParams=all", for
72
+ # app code to actually have it echo'd back to see it.
73
+ :limits => {
74
+ "subject_topic_facet" => 20,
75
+ "language_facet" => true
76
+ }
77
+ }
78
+ ```
79
+
80
+ > Source: [[./config/initializers/blacklight_config.rb|https://github.com/projectblacklight/blacklight/blob/master/lib/generators/blacklight/templates/config/blacklight_config.rb#L39]]
81
+
82
+ * Blacklight provides basic spellcheck suggestions for poor search queries
83
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/search_spellcheck.png|frame|alt=Spellchecking user queries]]
84
+
85
+ * Blacklight provides flexible mapping from user queries to solr parameters, which are easily overridable in local applications (see [[Extending or Modifying Blacklight Search Behavior]]).
86
+
87
+ ```ruby
88
+ # Each symbol identifies a _method_ that must be in
89
+ # this class, taking two parameters (solr_parameters, user_parameters)
90
+ # Can be changed in local apps or by plugins, eg:
91
+ # CatalogController.include ModuleDefiningNewMethod
92
+ # CatalogController.solr_search_params_logic << :new_method
93
+ # CatalogController.solr_search_params_logic.delete(:we_dont_want)
94
+ 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 ]
95
+ ```
96
+
97
+ > Source: [[./lib/blacklight/solr_helper.rb|https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr_helper.rb#L70]]
98
+
99
+
100
+ ### Other
101
+ - Stable URLs allow users to bookmark, share, and save search queries for later access
102
+ - Recent searches are saved in the Search History for quick access to previous queries
103
+ - Folder + Bookmarks allow users to collect and keep track of items as they browse
104
+ - Every Blacklight search provides RSS and [[Atom Responses]] of search results
105
+ - Blacklight supports [[OpenSearch|http://www.opensearch.org/Home]], a collection of simple formats for the sharing of search results. The OpenSearch description document format can be used to describe a search engine so that it can be used by search client applications. The OpenSearch response elements can be used to extend existing syndication formats, such as RSS and Atom, with the extra metadata needed to return search results. (From OpenSearch Introduction)
106
+
107
+ ## Access
108
+ ### Export
109
+ - Cite
110
+ - Refworks
111
+ - Endnote
112
+ - Email
113
+ - SMS
114
+ - Librarian View
115
+
116
+ For compatible records, an [[OpenURL/Z39.88 COinS|http://www.zotero.org/support/dev/making_coins]] object is embedded in each document, which allows plugins like Zotero to easily extract data from the page.
117
+
118
+ ### Semantic Fields
119
+
120
+ ### Document Extension Framework
121
+
122
+ The main use case for extensions is for transforming a Document to another
123
+ format. Either to another type of Ruby object, or to an exportable string in
124
+ a certain format.
125
+
126
+ An Blacklight::Solr::Document extension is simply a ruby module which is mixed
127
+ in to individual Document instances. The intended use case is for documents
128
+ containing some particular format of source material, such as Marc. An
129
+ extension can be registered with your document class, along with a block
130
+ containing custom logic for which documents to apply the extension to.
131
+
132
+ ```ruby
133
+ SolrDocument.use_extension(MyExtension) {|document| my_logic_on_document(document}
134
+ ```
135
+
136
+ MyExtension will be mixed-in (using ruby 'extend') only to those documents
137
+ where the block results in true.
138
+
139
+ Underlying metadata formats, or other alternative document views, are linked to from the HTML page <head>.
140
+
141
+ ### Data Formats
142
+ MaRC
143
+
144
+ ## Testing
145
+
146
+
147
+ Additional features are available through [[Blacklight Add-ons]].
@@ -0,0 +1,20 @@
1
+ [[Rails Footnotes|https://github.com/josevalim/rails-footnotes]] is a helpful plugin that displays footnotes in your application for easy debugging, such as sessions, request parameters, cookies, filter chain, routes, queries, etc. Installing Rails Footnotes is very easy, just add this to your Gemfile:
2
+ ```ruby
3
+ gem 'rails-footnotes', '>= 3.7', :group => :development
4
+ ```
5
+
6
+ And add something like this to config/initializers/footnotes.rb to run the Footnotes plugin:
7
+ ```ruby
8
+ if defined?(Footnotes) && Rails.env.development?
9
+ Footnotes.run!
10
+ end
11
+ ```
12
+
13
+ To add RSolr debugging information to the footnotes panel, you can use the [[RSolr Footnotes|https://github.com/cbeer/rsolr-footnotes]] gem by adding this to your Gemfile:
14
+ ```ruby
15
+ gem "rsolr-footnotes", :group => :development
16
+ ```
17
+
18
+ RSolr footnotes will capture every solr request with basic performance information and provide a link back to the Solr request URL.
19
+
20
+ [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/rsolr_footnotes_example.png|frame|alt=Example of RSolr Footnotes in the Blacklight Demo App]]
data/doc/Pagination.md ADDED
@@ -0,0 +1,38 @@
1
+ Blacklight uses [kaminari](https://github.com/amatsuda/kaminari) for providing pagination of Solr responses.
2
+
3
+ One motivation for this is so a pagination view theme can be provided that you can use for your custom code with ordinary ActiveRecord or anything else kaminari can handle, to have consistency between the rest of your app's pagination and Blacklight's Solr response pagination.
4
+
5
+ ## How it works
6
+
7
+ The Blacklight #paginate_params helper method takes an RSolr::Response, and converts it to something Kaminari #paginate can handle. (Basically just by translating some attribute names). So you could call:
8
+
9
+ paginate( paginate_params(@response) ) # where @response is an RSolr::Response
10
+
11
+ But there's a shortcut Blacklight helper method which compacts this, #paginate_rsolr_response:
12
+
13
+ paginate_solr_response @response, :theme => 'blacklight'
14
+
15
+ The `theme => 'blacklight'` part will be passed through kaminari, and tell kaminari to use the theme that the Blacklight plugin supplies at [app/views/kaminari/blacklight](https://github.com/projectblacklight/blacklight/tree/master/app/views/kaminari/blacklight)
16
+
17
+ Any other arguments of ordinary kaminari paginate can also be passed in there. If all client code uses #paginate_solr_response, it also provides a 'hook' for local apps to completely over-ride pagination rendering, perhaps not even using kaminari.
18
+
19
+ Additionally, we sometimes want to output a "Showing X through Y of N" message, which kaminari doesnt' have a way to do by default, so we just provide our own way in a Blacklight view helper method, which takes a RSolr::Response too:
20
+
21
+ render_pagination_info(@response)
22
+
23
+ ## Changing the kaminari theme
24
+
25
+ If you want to change how pagination links are rendered, the easiest/cleanest thing to do is to over-ride the 'blacklight' theme that the Blacklight plugin defines. Copy the view templates in Blacklight source at app/views/kaminari/blacklight to your own local app/views/kaminari/blacklight. You actually only need to copy files you'll want to modify, templates not overridden with a local copy will still be found by kaminari from the Blacklight gem. You can use any techniques available for creating a kaminari theme when editing these files, including over-riding more kaminari view templates if available. See the kaminari documentation.
26
+
27
+ There are other ways you could change how Blacklight pagination renders, but by doing it this way, any code (in core Blacklight or additional plugins you install) that tries to render pagination using kaminari with 'blacklight' theme will get your locally defined theme.
28
+
29
+ The "pagination info" (showing X through Y of N) is not part of the kaminari theme, but just a blacklight view helper method, #render_pagination_info. To change this, just over-ride this method [[over-ride locally|CUSTOMIZING]] like any other Blacklight view helper method.
30
+
31
+ ## Using kaminari theme for your own pagination
32
+
33
+ Your local app may show pagination of ActiveRecord objects, that you'd like to appear consistent with other Blacklight pagination. Just use kaminari to show the pagination HTML, with the theme :blacklight. This technique can be used for anything kaminari can paginate, such as Mongoid et al, in addition to ActiveRecord. Fetch the ActiveRecords using ordinary kaminari techniques (see kaminari docs) and then:
34
+
35
+ paginate @my_active_records, :theme => 'blacklight'
36
+
37
+ That's it. There's currently no great way to display the #render_pagination_info for anything but RSolr::Response.
38
+
data/doc/Quickstart.md ADDED
@@ -0,0 +1,97 @@
1
+ ## Pre-requisites
2
+ * ruby v 1.8.7 or higher
3
+ * git
4
+ * java 1.5 or higher
5
+ * access to a command prompt on the machine to install
6
+     (preferably unix based)
7
+
8
+ In addition, you must have the Bundler and Rails ruby gems installed:
9
+
10
+ ```bash
11
+ $ gem install bundler
12
+ $ gem install rails
13
+ ```
14
+
15
+ ## Install and Use
16
+
17
+ 1. Create a new rails 3 application
18
+
19
+ ```bash
20
+ $ rails new my_app
21
+ # create
22
+ # create README
23
+ # create Rakefile
24
+ # create config.ru
25
+ # create .gitignore
26
+ # create Gemfile
27
+ # [...]
28
+
29
+ $ cd my_app
30
+ ```
31
+
32
+ Rails automatically created an `index.html` file; Blacklight will provide a default `root` route, so you probably want to remove it:
33
+
34
+ ```bash
35
+ $ rm public/index.html
36
+ ```
37
+
38
+ 2. Append this line to your application's `Gemfile`
39
+
40
+ ```ruby
41
+ gem 'blacklight'
42
+ ```
43
+ and update the bundle
44
+
45
+ ```bash
46
+ $ bundle install
47
+ ```
48
+
49
+ 3. Install blacklight using Devise for user authentication:
50
+
51
+ ```bash
52
+ $ gem install devise
53
+ $ rails generate blacklight --devise
54
+ ```
55
+ If you would prefer to integrate with an alternative user authentication provider, see the [[User Authentication]] documentation.
56
+
57
+ 4. Run your database migrations
58
+
59
+ ```bash
60
+ $ rake db:migrate
61
+ ```
62
+
63
+ 5. You will need to install and configure Solr. You can install
64
+ Blacklight's example Solr configuration (using the jetty servlet container) that is configured to work with
65
+ Blacklight's defaults, like:
66
+
67
+ ```bash
68
+ $ rails generate blacklight:jetty
69
+ ```
70
+
71
+ Alternatively, you can also install your own copy of Solr or point Blacklight at an existing Solr server ( referred to in your `config/solr.yml`). The Blacklight
72
+ configuration must match your Solr configuration. In addition, Blacklight has minor expectations about the Solr configuration and schemas. You can generate the Blacklight demonstration solrconfig and schema files using:
73
+
74
+ ```bash
75
+ $ rails generate blacklight:solr_conf path/to/output/directory/
76
+ ```
77
+
78
+ 6. Make sure your Solr server is running. If you installed the Blacklight demo Solr/Jetty package, you can start the Jetty/Solr server using:
79
+
80
+ ```bash
81
+ $ cd jetty && java -jar start.jar &
82
+ $ cd ..
83
+ ```
84
+
85
+ 6. Index some data. You can index test MARC records provided Blacklight running:
86
+
87
+ ```bash
88
+ $ rake solr:marc:index_test_data
89
+ ```
90
+
91
+ 7. Start up your application
92
+
93
+ ```bash
94
+ $ rails server
95
+ ```
96
+
97
+ Visit the catalog at [[http://localhost:3000/catalog]]
@@ -0,0 +1,98 @@
1
+ This page outlines the basic steps needed to upgrade your customized installation of Blacklight to work with the new Rails 3 branch available in our repository. This is very much in beta now - and while we would love feedback, I don't recommend you use this branch in any sort of production environment.
2
+
3
+ ## Rails 3 Specific Changes:
4
+ Please see [[http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade]] - for a good introduction.
5
+
6
+ 1. Start by installing Rails3, generate a new app, make sure it works. doing this not only proves your rails3 installation is working, but it will also get you familiar with the command line tools - which are very different now.
7
+ 1. Now, create a new rails app on top of your existing application. This will make all sorts of modifications, creating and updating your Gemfile, Rakefile, application.rb, locals, new javascript, etc... You should also remove all the files in /script/ except for rails - since these scripts are no longer used.
8
+ ```bash
9
+ $ rails new my_existing_app
10
+ ```
11
+
12
+ 1. Routes are WAY different in rails 3. Please see [[http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/]]
13
+ 1. Most of your application specific configuration now takes place in a file called config/application.rb - you will need to move most of what is currently in your config/environment.rb and config/boot.rb into this new file. (see the link at the top of thie section for a good overview of how this works)
14
+ 1. The lib directory is no longer auto-loaded - and the general recommendation is not to make it so (though it is possible inside of config/application.rb) - I went through and added requires methods where and when they are needed in the individual files, which is nice - because now it is far more clear what needs what.
15
+ 1. Rails3 escapes strings by default. You will have to add html_safe to any ruby string variables printed within "<%=" tags
16
+
17
+ ## Other Gems that will need upgrading
18
+ 1. If you were using the ExceptionNotification gem, things have changed in rails, There is a good explanation here:
19
+ http://stackoverflow.com/questions/3524127/exception-notification-gem-and-rails-3
20
+ 1. If your are using Rspec, you will need to upgrade it in your gem file to version 2. And you will need to re-run the generator
21
+ ```ruby
22
+ gem 'rspec', '>2.0.0'
23
+ $rails generate spec:install
24
+ ```
25
+ 1. Recapcha, and Prawnto - I was previously using these as plugins, but they have good gems now, so I removed these from the plugin directory, and added them to the gemfile.
26
+ 1. If you are using Marc, make sure you are running 0.4.1 - ran into some problems related to changes in the way Rails3 handles json prior to this upgrade.
27
+
28
+ ## Blacklight Specific Changes
29
+ 1. There is no application_helper.rb file in blacklight now. It was moved to blacklight_helper, and its methods are made available automatically. (see blacklight/engine.rb for more information) So if you were attepting to include this file and override it, don't. Just redefine the methods in your application_helper, and you should be fine.
30
+ 1. Remove the blacklight plugin directory from /vendor - since you will be installing in as a gem. If you have blacklight checked out somewhere, you can point to it in your gem file as follows:
31
+ ```ruby
32
+ gem 'blacklight', :path => '../some/file/path/to/blacklight'
33
+ ```
34
+ otherwise, just reference the blacklight gem, which we will make available on rubygems shortly.
35
+ ```ruby
36
+ gem 'blacklight'
37
+ ```
38
+ 1. Most of the configuration of blacklight is done through monkey patching at present. In Virgo you would often see lines like:
39
+ ```ruby
40
+ require_dependency 'vendor/plugins/blacklight/....
41
+ ```
42
+ at the top of a file that re-opened the class and made modifications to it.
43
+ You would now need to change this to:
44
+ ```ruby
45
+ require "#{Blacklight.controllers_dir}/bookmarks_controller" For controllers, and ...
46
+ require "#{Blacklight.models_dir}/bookmark" For models.
47
+ ```
48
+ 1. Blacklight no longer includes a user model or session controller. It seems that everyone just rolls their own anyway. So here you will need to add in whatever you need - in my case, that was just creating a user model. Which looks like this:
49
+ ```ruby
50
+ class User < ActiveRecord::Base
51
+ include Blacklight::User
52
+ acts_as_authentic
53
+ end
54
+ ```
55
+ Please also see the notes on the application controller below ...
56
+
57
+ 1. Execute the Blacklight Generator - This will add all kinds of files to your local application - including stylesheets, images, jar files, database migrations, etc.. It will try it's best to be "idempotent" as Jonathan likes to say - that it is shouldn't mess anything up to run this over and over again. It will verify that the changes it's making are not already in place.
58
+ ```bash
59
+ $ rails generate blacklight
60
+ ```
61
+ 1. For the most part, you override a blacklight controller by including the class and then reopening it. Unfortunately, the catalog controller was unique in the way it number of additional lib files it required and included, and it caused a number of problems attepting to just override it. So a catalog controller is generated for you on installation (unless you already have one). You catalog controller should look something like this (which allows you to easily override solrhelper and catalog controller methods)
62
+ ```ruby
63
+ class CatalogController < ApplicationController
64
+ include Blacklight::SolrHelper
65
+ inlcude Blacklight::Catalog
66
+ .....
67
+ end
68
+ ```
69
+ If you end up overriding a large number of solrhelper methods, you can also override the solr helpers in your own file, and then include that file.
70
+ ```ruby
71
+ module UVA::SolrHelper
72
+ include Blacklight::SolrHelper
73
+ .....
74
+ end
75
+
76
+ class CatalogController < ApplicationController
77
+ include UVA::SolrHelper
78
+ include Blacklight::Catalog
79
+ ....
80
+ end
81
+ ```
82
+ 1. Application Controller
83
+ The blacklight generator, will add a line to your application controller if isn't there already which will cause the application controller to include the base controller logic for blacklight:
84
+ ```ruby
85
+ class ApplicationController < ActionController::Base
86
+ include Blacklight::Controller
87
+ end
88
+ ```
89
+ This blacklight controller forces the the blacklight layout, adds the default_html_head before filter and associated helper methods, and creates a few helper methods for users. Blacklight by no means requires the inclusion of this file. In the case of Virgo, we do not.
90
+
91
+ You will most likely need to define the following methods in your application controller, paticularly if you have any sort of custom user authentication.
92
+
93
+ * `user_session` - which should return the current rails session object.
94
+ * `current_user` - which should return a user object that includes Blacklight::User
95
+ * `new_user_session_path` - which should return the path for logging into your application
96
+ * `destroy_user_session_path` - which should return the path for logging out of your application.
97
+
98
+ SolrDocument is no longer a file in Blacklight, but rather a generated model in your application, in this way you can easily override and modify the behavior of individual documents. This is automatically created for you, I just wanted to draw you attention to it.
@@ -0,0 +1,54 @@
1
+ After [[CODEBASE-325|http://jira.projectblacklight.org/jira/browse/CODEBASE-325]] is implemented, 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 'blackight'
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 a user object that include Blacklight::User
40
+ * `user_session` - Which are included in your /config/routes.rb file:
41
+
42
+ Once these are in place, you can run the Blacklight Installation Generator:
43
+
44
+ ```bash
45
+ $ rails generate blacklight [MODEL NAME]
46
+ ```
47
+ Where model name is the name of your user model.
48
+
49
+ Execute your migrations, and you should be good to go.
50
+ ```bash
51
+ $ rake db:migrate
52
+ ```
53
+
54
+ If you need to install Solr or the sample data, follow the directions from the see the [[Quickstart]].
@@ -0,0 +1,36 @@
1
+ > The [[`uniqueKey`|http://wiki.apache.org/solr/UniqueKey]] encodes the identity semantics of a document. In database jargon, the primary key.
2
+
3
+ The default `uniqueKey` field in Blacklight is "id", however it is possible to configure Blacklight to use a different field. To configure the `uniqueKey` field to use, you must in Blacklight, you can update the Blacklight initializer in `./config/blacklight_initializer.rb`:
4
+
5
+ ```ruby
6
+ Blacklight.configure(:shared) do |config|
7
+ config[:unique_key] = "my_custom_unique_key_field"
8
+ ```
9
+
10
+ (You could also make this change "in code" by defining a `Class`-level `unique_key` method on `SolrDocument`, e.g.:
11
+ ```ruby
12
+ class SolrDocument
13
+ def self.unique_key
14
+ "my_custom_unique_key_field"
15
+ end
16
+ end
17
+ ```
18
+ )
19
+
20
+ You must also modify the `document` request handler in Solr to map the user parameter `id` to the Solr `uniqueKey` field, e.g.:
21
+
22
+ ```xml
23
+ <!-- for requests to get a single document; use id=666 instead of q=id:666 -->
24
+ <requestHandler name="document" class="solr.SearchHandler" >
25
+ <lst name="defaults">
26
+ <str name="echoParams">all</str>
27
+ <str name="fl">*</str>
28
+ <str name="rows">1</str>
29
+ <str name="q">{!raw f=my_custom_unique_key_field v=$id}</str> <!-- use id=666 instead of q=id:666 -->
30
+ </lst>
31
+ </requestHandler>
32
+ ```
33
+
34
+ ## Code Standards
35
+
36
+ When writing code in Blacklight (or a dependent plugin or local app) that needs to look at the unique ID for a SolrDocument, you should always ask for someDocument.id and *not* someDocument['id'], in order for your code to work with configured unique_key, not hard-coded to a key named 'id'.
metadata CHANGED
@@ -1,10 +1,15 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: blacklight
3
- version: !ruby/object:Gem::Version
4
- version: 3.1.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
5
  prerelease:
6
+ segments:
7
+ - 3
8
+ - 1
9
+ - 2
10
+ version: 3.1.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Jonathan Rochkind
9
14
  - Matt Mitchell
10
15
  - Chris Beer
@@ -16,96 +21,125 @@ authors:
16
21
  autorequire:
17
22
  bindir: bin
18
23
  cert_chain: []
19
- date: 2011-10-12 00:00:00.000000000 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rails
23
- requirement: &2153500840 !ruby/object:Gem::Requirement
24
+
25
+ date: 2011-12-06 00:00:00 Z
26
+ dependencies:
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: &id001 !ruby/object:Gem::Requirement
24
29
  none: false
25
- requirements:
30
+ requirements:
26
31
  - - ~>
27
- - !ruby/object:Gem::Version
28
- version: '3.0'
29
- type: :runtime
32
+ - !ruby/object:Gem::Version
33
+ hash: 7
34
+ segments:
35
+ - 3
36
+ - 0
37
+ version: "3.0"
38
+ version_requirements: *id001
30
39
  prerelease: false
31
- version_requirements: *2153500840
32
- - !ruby/object:Gem::Dependency
33
- name: nokogiri
34
- requirement: &2153500360 !ruby/object:Gem::Requirement
40
+ name: rails
41
+ type: :runtime
42
+ - !ruby/object:Gem::Dependency
43
+ requirement: &id002 !ruby/object:Gem::Requirement
35
44
  none: false
36
- requirements:
45
+ requirements:
37
46
  - - ~>
38
- - !ruby/object:Gem::Version
39
- version: '1.5'
47
+ - !ruby/object:Gem::Version
48
+ hash: 5
49
+ segments:
50
+ - 1
51
+ - 5
52
+ version: "1.5"
53
+ version_requirements: *id002
54
+ prerelease: false
55
+ name: nokogiri
40
56
  type: :runtime
57
+ - !ruby/object:Gem::Dependency
58
+ requirement: &id003 !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ version_requirements: *id003
41
68
  prerelease: false
42
- version_requirements: *2153500360
43
- - !ruby/object:Gem::Dependency
44
69
  name: unicode
45
- requirement: &2153499980 !ruby/object:Gem::Requirement
46
- none: false
47
- requirements:
48
- - - ! '>='
49
- - !ruby/object:Gem::Version
50
- version: '0'
51
70
  type: :runtime
52
- prerelease: false
53
- version_requirements: *2153499980
54
- - !ruby/object:Gem::Dependency
55
- name: marc
56
- requirement: &2153499440 !ruby/object:Gem::Requirement
71
+ - !ruby/object:Gem::Dependency
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
- requirements:
74
+ requirements:
59
75
  - - ~>
60
- - !ruby/object:Gem::Version
76
+ - !ruby/object:Gem::Version
77
+ hash: 9
78
+ segments:
79
+ - 0
80
+ - 4
81
+ - 3
61
82
  version: 0.4.3
83
+ version_requirements: *id004
84
+ prerelease: false
85
+ name: marc
62
86
  type: :runtime
87
+ - !ruby/object:Gem::Dependency
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - "="
92
+ - !ruby/object:Gem::Version
93
+ hash: 19
94
+ segments:
95
+ - 1
96
+ - 0
97
+ - 2
98
+ version: 1.0.2
99
+ version_requirements: *id005
63
100
  prerelease: false
64
- version_requirements: *2153499440
65
- - !ruby/object:Gem::Dependency
66
101
  name: rsolr
67
- requirement: &2153498940 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ~>
71
- - !ruby/object:Gem::Version
72
- version: '1.0'
73
102
  type: :runtime
103
+ - !ruby/object:Gem::Dependency
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - "="
108
+ - !ruby/object:Gem::Version
109
+ hash: 17
110
+ segments:
111
+ - 1
112
+ - 0
113
+ - 3
114
+ version: 1.0.3
115
+ version_requirements: *id006
74
116
  prerelease: false
75
- version_requirements: *2153498940
76
- - !ruby/object:Gem::Dependency
77
117
  name: rsolr-ext
78
- requirement: &2153498480 !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ~>
82
- - !ruby/object:Gem::Version
83
- version: '1.0'
84
118
  type: :runtime
119
+ - !ruby/object:Gem::Dependency
120
+ requirement: &id007 !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ version_requirements: *id007
85
130
  prerelease: false
86
- version_requirements: *2153498480
87
- - !ruby/object:Gem::Dependency
88
131
  name: kaminari
89
- requirement: &2153498100 !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ! '>='
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
132
  type: :runtime
96
- prerelease: false
97
- version_requirements: *2153498100
98
- description: Blacklight is a free and open source ruby-on-rails based discovery interface
99
- (a.k.a. “next-generation catalog”) especially optimized for heterogeneous collections.
100
- You can use it as a library catalog, as a front end for a digital repository, or
101
- as a single-search interface to aggregate digital content that would otherwise be
102
- siloed.
103
- email:
133
+ description: "Blacklight is a free and open source ruby-on-rails based discovery interface (a.k.a. \xE2\x80\x9Cnext-generation catalog\xE2\x80\x9D) especially optimized for heterogeneous collections. You can use it as a library catalog, as a front end for a digital repository, or as a single-search interface to aggregate digital content that would otherwise be siloed."
134
+ email:
104
135
  - blacklight-development@googlegroups.com
105
136
  executables: []
137
+
106
138
  extensions: []
139
+
107
140
  extra_rdoc_files: []
108
- files:
141
+
142
+ files:
109
143
  - .gitignore
110
144
  - .gitmodules
111
145
  - .yardopts
@@ -231,6 +265,17 @@ files:
231
265
  - config/locales/kaminari.yml
232
266
  - config/routes.rb
233
267
  - db/seeds.rb
268
+ - doc/Atom-Responses.md
269
+ - doc/CUSTOMIZING.md
270
+ - doc/Extending-blacklight-with-the-document-extension-framework.md
271
+ - doc/Extending-or-Modifying-Blacklight-Search-Behavior.md
272
+ - doc/Features.md
273
+ - doc/Integration-with-Rails-Footnotes.md
274
+ - doc/Pagination.md
275
+ - doc/Quickstart.md
276
+ - doc/Upgrading-Guide.md
277
+ - doc/User-Authentication.md
278
+ - doc/Using-a-custom-solr-uniquekey-field.md
234
279
  - install.rb
235
280
  - install/solr.yml
236
281
  - lib/blacklight.rb
@@ -365,32 +410,36 @@ files:
365
410
  - uninstall.rb
366
411
  homepage: http://projectblacklight.org/
367
412
  licenses: []
413
+
368
414
  post_install_message:
369
415
  rdoc_options: []
370
- require_paths:
416
+
417
+ require_paths:
371
418
  - lib
372
- required_ruby_version: !ruby/object:Gem::Requirement
419
+ required_ruby_version: !ruby/object:Gem::Requirement
373
420
  none: false
374
- requirements:
375
- - - ! '>='
376
- - !ruby/object:Gem::Version
377
- version: '0'
378
- segments:
421
+ requirements:
422
+ - - ">="
423
+ - !ruby/object:Gem::Version
424
+ hash: 3
425
+ segments:
379
426
  - 0
380
- hash: -4207963229405450438
381
- required_rubygems_version: !ruby/object:Gem::Requirement
427
+ version: "0"
428
+ required_rubygems_version: !ruby/object:Gem::Requirement
382
429
  none: false
383
- requirements:
384
- - - ! '>='
385
- - !ruby/object:Gem::Version
386
- version: '0'
387
- segments:
430
+ requirements:
431
+ - - ">="
432
+ - !ruby/object:Gem::Version
433
+ hash: 3
434
+ segments:
388
435
  - 0
389
- hash: -4207963229405450438
436
+ version: "0"
390
437
  requirements: []
438
+
391
439
  rubyforge_project: blacklight
392
- rubygems_version: 1.8.10
440
+ rubygems_version: 1.8.12
393
441
  signing_key:
394
442
  specification_version: 3
395
443
  summary: A next-geration Library Catalag for Universities
396
444
  test_files: []
445
+