blacklight 3.1.2 → 3.2.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -2
- data/README.md +7 -2
- data/VERSION +1 -1
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/blacklight/blacklight.js +23 -1
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +369 -0
- data/app/assets/stylesheets/blacklight/_facets.css.scss +117 -0
- data/app/assets/stylesheets/blacklight/_folder.css.scss +38 -0
- data/app/assets/stylesheets/blacklight/_formatting.css.scss +164 -0
- data/app/assets/stylesheets/blacklight/_header.css.scss +36 -0
- data/app/assets/stylesheets/blacklight/_layout.css.scss +79 -0
- data/app/assets/stylesheets/blacklight/_print.css.scss +54 -0
- data/app/assets/stylesheets/blacklight/_search_history.css.scss +44 -0
- data/app/assets/stylesheets/blacklight/_susy_framework.css.scss +228 -0
- data/app/assets/stylesheets/blacklight/blacklight.css.scss +27 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +48 -0
- data/app/controllers/bookmarks_controller.rb +2 -1
- data/app/controllers/folder_controller.rb +4 -0
- data/app/controllers/saved_searches_controller.rb +4 -0
- data/app/controllers/search_history_controller.rb +4 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +64 -104
- data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -4
- data/app/helpers/blacklight/facets_helper_behavior.rb +52 -5
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +14 -59
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +56 -0
- data/app/helpers/search_history_constraints_helper.rb +3 -0
- data/app/models/record_mailer.rb +1 -2
- data/app/views/_flash_msg.html.erb +4 -5
- data/app/views/_user_util_links.html.erb +3 -1
- data/app/views/bookmarks/index.html.erb +2 -2
- data/app/views/catalog/_bookmark_control.html.erb +6 -6
- data/app/views/catalog/_facet_layout.html.erb +4 -0
- data/app/views/catalog/_facet_limit.html.erb +20 -33
- data/app/views/catalog/_facets.html.erb +1 -5
- data/app/views/catalog/_folder_control.html.erb +5 -5
- data/app/views/catalog/_index_default.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +4 -3
- data/app/views/catalog/_show_default.html.erb +1 -1
- data/app/views/catalog/_show_tools.html.erb +6 -6
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/index.atom.builder +2 -2
- data/app/views/catalog/index.rss.builder +1 -1
- data/app/views/catalog/opensearch.xml.builder +10 -0
- data/app/views/catalog/show.html.erb +1 -1
- data/app/views/folder/_tools.html.erb +4 -4
- data/app/views/layouts/blacklight.html.erb +25 -37
- data/app/views/record_mailer/email_record.text.erb +1 -1
- data/app/views/record_mailer/sms_record.text.erb +2 -2
- data/app/views/search_history/index.html.erb +1 -1
- data/blacklight.gemspec +11 -9
- data/lib/{generators/blacklight/templates/SolrMarc.jar → SolrMarc.jar} +0 -0
- data/lib/blacklight.rb +5 -3
- data/lib/blacklight/catalog.rb +3 -4
- data/lib/blacklight/configurable.rb +54 -39
- data/lib/blacklight/configuration.rb +126 -0
- data/lib/blacklight/configuration/fields.rb +142 -0
- data/lib/blacklight/configuration/search_field.rb +12 -0
- data/lib/blacklight/configuration/solr_field.rb +12 -0
- data/lib/blacklight/configuration/sort_field.rb +17 -0
- data/lib/blacklight/controller.rb +16 -14
- data/lib/blacklight/engine.rb +1 -1
- data/lib/blacklight/global_configurable.rb +46 -0
- data/lib/blacklight/search_fields.rb +21 -54
- data/lib/blacklight/solr/document.rb +13 -3
- data/lib/blacklight/solr_helper.rb +88 -52
- data/lib/blacklight/utils.rb +18 -0
- data/lib/generators/blacklight/assets_generator.rb +14 -20
- data/lib/generators/blacklight/blacklight_generator.rb +14 -6
- data/lib/generators/blacklight/jetty_generator.rb +1 -1
- data/lib/generators/blacklight/templates/assets/standard.css.scss +51 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +148 -0
- data/lib/generators/blacklight/templates/config/blacklight_config.rb +2 -239
- data/lib/generators/blacklight/templates/config/sass.rb +5 -0
- data/lib/generators/blacklight/templates/solr_conf/schema.xml +514 -164
- data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +1591 -323
- data/lib/generators/blacklight/templates/solr_document.rb +2 -0
- data/lib/railties/all_tests.rake +36 -3
- data/lib/railties/blacklight_cucumber.rake +6 -4
- data/lib/railties/blacklight_rspec.rake +5 -4
- data/test_support/bin/run-tests.sh +2 -13
- data/test_support/bin/test.sh +30 -23
- data/test_support/features/did_you_mean.feature +14 -13
- data/test_support/features/step_definitions/saved_searches_steps.rb +1 -1
- data/test_support/features/step_definitions/search_steps.rb +4 -4
- data/test_support/spec/controllers/application_controller_spec.rb +3 -13
- data/test_support/spec/controllers/catalog_controller_spec.rb +102 -24
- data/test_support/spec/controllers/folder_controller_spec.rb +7 -1
- data/test_support/spec/helpers/blacklight_helper_spec.rb +45 -34
- data/test_support/spec/helpers/facets_helper_spec.rb +68 -0
- data/test_support/spec/helpers/html_head_helper_spec.rb +37 -0
- data/test_support/spec/helpers/{render_constraints_helper_spec.rb → search_history_constraints_helper_spec.rb} +26 -7
- data/test_support/spec/lib/blacklight_configurable_spec.rb +92 -0
- data/test_support/spec/lib/blacklight_configuration_spec.rb +295 -0
- data/test_support/spec/lib/{configurable_spec.rb → global_configurable_spec.rb} +2 -2
- data/test_support/spec/lib/search_fields_spec.rb +26 -29
- data/test_support/spec/{helpers → lib}/solr_helper_spec.rb +268 -287
- data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +1 -1
- data/test_support/spec/lib/utils_spec.rb +58 -0
- data/test_support/spec/models/solr_docment_spec.rb +4 -8
- data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +27 -170
- data/test_support/spec/views/catalog/_index_default.erb_spec.rb +38 -20
- data/test_support/spec/views/catalog/_show_default.erb_spec.rb +38 -19
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +19 -1
- metadata +148 -145
- data/app/assets/stylesheets/blacklight/blacklight.css +0 -493
- data/app/assets/stylesheets/yui.css +0 -31
- data/app/views/catalog/opensearch.xml.erb +0 -11
- data/doc/Atom-Responses.md +0 -90
- data/doc/CUSTOMIZING.md +0 -121
- data/doc/Extending-blacklight-with-the-document-extension-framework.md +0 -1
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -131
- data/doc/Features.md +0 -147
- data/doc/Integration-with-Rails-Footnotes.md +0 -20
- data/doc/Pagination.md +0 -38
- data/doc/Quickstart.md +0 -97
- data/doc/Upgrading-Guide.md +0 -98
- data/doc/User-Authentication.md +0 -54
- data/doc/Using-a-custom-solr-uniquekey-field.md +0 -36
- data/lib/blacklight/comma_link_renderer.rb +0 -28
- data/lib/railties/jetty_solr_server.rb +0 -108
- data/test_support/spec/views/catalog/show.html.erb_spec.rb +0 -101
@@ -1,20 +0,0 @@
|
|
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
DELETED
@@ -1,38 +0,0 @@
|
|
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
DELETED
@@ -1,97 +0,0 @@
|
|
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]]
|
data/doc/Upgrading-Guide.md
DELETED
@@ -1,98 +0,0 @@
|
|
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.
|
data/doc/User-Authentication.md
DELETED
@@ -1,54 +0,0 @@
|
|
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]].
|
@@ -1,36 +0,0 @@
|
|
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'.
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'will_paginate/view_helpers/link_renderer'
|
3
|
-
|
4
|
-
# Custom link renderer for WillPaginate
|
5
|
-
# Inserts commas into large page numbers
|
6
|
-
# example: 443719 becomes 443,719
|
7
|
-
#
|
8
|
-
# Note: To use this class, please call:
|
9
|
-
# <%= will_paginate(@users, :renderer => CommaLinkRenderer) %>
|
10
|
-
|
11
|
-
module Blacklight
|
12
|
-
|
13
|
-
class CommaLinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
|
14
|
-
|
15
|
-
protected
|
16
|
-
# Just overriding the page_number method, so that large numbers are
|
17
|
-
# contain appropriate commas.
|
18
|
-
def page_number(page)
|
19
|
-
unless page == current_page
|
20
|
-
text = @template.number_with_delimiter(page)
|
21
|
-
link(text, page, :rel => rel_value(page))
|
22
|
-
else
|
23
|
-
tag(:em, page)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
# The ASF licenses this file to You under the Apache License, Version 2.0
|
3
|
-
# (the "License"); you may not use this file except in compliance with
|
4
|
-
# the License. You may obtain a copy of the License at
|
5
|
-
#
|
6
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
-
#
|
8
|
-
# Unless required by applicable law or agreed to in writing, software
|
9
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
-
# See the License for the specific language governing permissions and
|
12
|
-
# limitations under the License.
|
13
|
-
|
14
|
-
# A singleton class for starting/stopping a Solr server for testing purposes
|
15
|
-
# The behavior of TestSolrServer can be modified prior to start() by changing
|
16
|
-
# port, solr_home, and quiet properties.
|
17
|
-
|
18
|
-
class JettySolrServer
|
19
|
-
attr_accessor :port, :jetty_home, :solr_home, :quiet, :sleep_after_start, :pid
|
20
|
-
|
21
|
-
# configure the singleton with some defaults
|
22
|
-
def initialize(params = {})
|
23
|
-
@pid = nil
|
24
|
-
self.quiet = params.has_key?(:quiet) ? !!params[:quiet] : true
|
25
|
-
self.jetty_home = params[:jetty_home]
|
26
|
-
self.solr_home = params[:solr_home] || File.expand_path("./solr", self.jetty_home)
|
27
|
-
self.port = params[:jetty_port] || 8888
|
28
|
-
self.sleep_after_start = params[:sleep_after_start]
|
29
|
-
end
|
30
|
-
|
31
|
-
def wrap
|
32
|
-
puts "JettySolrServer: starting server on #{RUBY_PLATFORM}"
|
33
|
-
self.start
|
34
|
-
begin
|
35
|
-
yield
|
36
|
-
ensure
|
37
|
-
puts "JettySolrServer: stopping solr server"
|
38
|
-
self.stop
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def jetty_command
|
43
|
-
"java -Djetty.port=#{@port} -Dsolr.solr.home=#{@solr_home} -jar start.jar"
|
44
|
-
end
|
45
|
-
|
46
|
-
def start
|
47
|
-
puts "\nexecuting: #{jetty_command}\n\n"
|
48
|
-
|
49
|
-
platform_specific_start
|
50
|
-
|
51
|
-
if self.sleep_after_start
|
52
|
-
puts "sleeping #{self.sleep_after_start}s waiting for startup."
|
53
|
-
sleep self.sleep_after_start
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def stop
|
58
|
-
platform_specific_stop
|
59
|
-
end
|
60
|
-
|
61
|
-
if RUBY_PLATFORM =~ /mswin32/
|
62
|
-
require 'win32/process'
|
63
|
-
|
64
|
-
# start the solr server
|
65
|
-
def platform_specific_start
|
66
|
-
Dir.chdir(@jetty_home) do
|
67
|
-
@pid = Process.create(
|
68
|
-
:app_name => jetty_command,
|
69
|
-
:creation_flags => Process::DETACHED_PROCESS,
|
70
|
-
:process_inherit => false,
|
71
|
-
:thread_inherit => true,
|
72
|
-
:cwd => "#{@jetty_home}"
|
73
|
-
).process_id
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# stop a running solr server
|
78
|
-
def platform_specific_stop
|
79
|
-
Process.kill(1, @pid)
|
80
|
-
Process.wait
|
81
|
-
end
|
82
|
-
else # Not Windows
|
83
|
-
|
84
|
-
def jruby_raise_error?
|
85
|
-
raise 'JRuby requires that you start solr manually."' if defined?(JRUBY_VERSION)
|
86
|
-
end
|
87
|
-
|
88
|
-
# start the solr server
|
89
|
-
def platform_specific_start
|
90
|
-
jruby_raise_error?
|
91
|
-
|
92
|
-
Dir.chdir(@jetty_home) do
|
93
|
-
@pid = fork do
|
94
|
-
STDERR.close if @quiet
|
95
|
-
exec jetty_command
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# stop a running solr server
|
101
|
-
def platform_specific_stop
|
102
|
-
jruby_raise_error?
|
103
|
-
Process.kill('TERM', @pid)
|
104
|
-
Process.wait
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|