blacklight 3.0pre1 → 3.0pre2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. data/.gitmodules +0 -6
  2. data/README.rdoc +94 -87
  3. data/blacklight.gemspec +1 -1
  4. data/config/routes.rb +1 -1
  5. data/lib/blacklight.rb +2 -2
  6. data/lib/blacklight/catalog.rb +10 -12
  7. data/lib/blacklight/controller.rb +2 -2
  8. data/lib/blacklight/engine.rb +5 -2
  9. data/lib/blacklight/solr/document.rb +1 -1
  10. data/lib/blacklight/solr/document/marc.rb +1 -16
  11. data/lib/blacklight/solr_helper.rb +43 -14
  12. data/lib/blacklight/version.rb +1 -1
  13. data/lib/generators/blacklight/assets_generator.rb +25 -0
  14. data/lib/generators/blacklight/blacklight_generator.rb +16 -1
  15. data/lib/generators/blacklight/jetty_generator.rb +101 -0
  16. data/lib/generators/blacklight/solr_conf_generator.rb +25 -0
  17. data/lib/generators/blacklight/templates/catalog_controller.rb +0 -1
  18. data/lib/generators/blacklight/templates/config/solr.yml +14 -2
  19. data/lib/generators/blacklight/templates/public/images/{blacklight/bg.png → bg.png} +0 -0
  20. data/lib/generators/blacklight/templates/public/images/{blacklight/border.png → border.png} +0 -0
  21. data/lib/generators/blacklight/templates/public/images/{blacklight/bul_sq_gry.gif → bul_sq_gry.gif} +0 -0
  22. data/lib/generators/blacklight/templates/public/images/{blacklight/checkmark.gif → checkmark.gif} +0 -0
  23. data/lib/generators/blacklight/templates/public/images/{blacklight/logo.png → logo.png} +0 -0
  24. data/lib/generators/blacklight/templates/public/images/{blacklight/magnifying_glass.gif → magnifying_glass.gif} +0 -0
  25. data/lib/generators/blacklight/templates/public/images/{blacklight/remove.gif → remove.gif} +0 -0
  26. data/lib/generators/blacklight/templates/public/images/{blacklight/separator.gif → separator.gif} +0 -0
  27. data/lib/generators/blacklight/templates/public/images/{blacklight/start_over.gif → start_over.gif} +0 -0
  28. data/lib/generators/blacklight/templates/public/javascripts/blacklight.js +5 -0
  29. data/lib/generators/blacklight/templates/public/stylesheets/blacklight.css +9 -3
  30. data/lib/generators/blacklight/templates/solr_conf/schema.xml +339 -0
  31. data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +578 -0
  32. data/lib/railties/all_tests.rake +11 -0
  33. data/lib/railties/blacklight.rake +0 -52
  34. data/lib/railties/blacklight_cucumber.rake +125 -0
  35. data/lib/railties/blacklight_rspec.rake +128 -0
  36. data/lib/railties/{test_solr_server.rb → jetty_solr_server.rb} +22 -45
  37. data/lib/railties/solr_marc.rake +24 -5
  38. data/test_support/.rspec +1 -0
  39. data/test_support/data/test_data.utf8.mrc +1 -0
  40. data/test_support/features/bookmarks.feature +88 -0
  41. data/test_support/features/did_you_mean.feature +129 -0
  42. data/test_support/features/folder.feature +67 -0
  43. data/test_support/features/librarian_view.feature +17 -0
  44. data/test_support/features/record_view.feature +34 -0
  45. data/test_support/features/saved_searches.feature +49 -0
  46. data/test_support/features/search.feature +86 -0
  47. data/test_support/features/search_filters.feature +121 -0
  48. data/test_support/features/search_history.feature +95 -0
  49. data/test_support/features/search_results.feature +61 -0
  50. data/test_support/features/search_sort.feature +29 -0
  51. data/test_support/features/step_definitions/bookmarks_steps.rb +5 -0
  52. data/test_support/features/step_definitions/error_steps.rb +4 -0
  53. data/test_support/features/step_definitions/folder_steps.rb +26 -0
  54. data/test_support/features/step_definitions/general_steps.rb +49 -0
  55. data/test_support/features/step_definitions/record_view_steps.rb +11 -0
  56. data/test_support/features/step_definitions/saved_searches_steps.rb +21 -0
  57. data/test_support/features/step_definitions/search_facets_steps.rb +28 -0
  58. data/test_support/features/step_definitions/search_history_steps.rb +8 -0
  59. data/test_support/features/step_definitions/search_result_steps.rb +113 -0
  60. data/test_support/features/step_definitions/search_steps.rb +102 -0
  61. data/test_support/features/step_definitions/user_steps.rb +4 -0
  62. data/test_support/features/step_definitions/web_steps.rb +211 -0
  63. data/test_support/features/support/env.rb +49 -0
  64. data/test_support/features/support/paths.rb +55 -0
  65. data/test_support/features/support/selectors.rb +39 -0
  66. data/test_support/features/unapi.feature +30 -0
  67. data/test_support/spec/controllers/application_controller_spec.rb +22 -0
  68. data/test_support/spec/controllers/catalog_controller_spec.rb +480 -0
  69. data/test_support/spec/controllers/folder_controller_spec.rb +40 -0
  70. data/test_support/spec/controllers/search_history_controller_spec.rb +45 -0
  71. data/test_support/spec/data/sample_docs.yml +655 -0
  72. data/test_support/spec/data/test_data.utf8.mrc +1 -0
  73. data/test_support/spec/helpers/blacklight_helper_spec.rb +482 -0
  74. data/test_support/spec/helpers/hash_as_hidden_fields_spec.rb +23 -0
  75. data/test_support/spec/helpers/render_constraints_helper_spec.rb +64 -0
  76. data/test_support/spec/helpers/search_history_helper_spec.rb +11 -0
  77. data/test_support/spec/helpers/solr_helper_spec.rb +873 -0
  78. data/test_support/spec/lib/blacklight_email_spec.rb +23 -0
  79. data/test_support/spec/lib/blacklight_sms_spec.rb +23 -0
  80. data/test_support/spec/lib/blacklight_solr_document_dublin_core_spec.rb +41 -0
  81. data/test_support/spec/lib/blacklight_solr_document_marc_spec.rb +88 -0
  82. data/test_support/spec/lib/blacklight_solr_document_spec.rb +173 -0
  83. data/test_support/spec/lib/blacklight_spec.rb +39 -0
  84. data/test_support/spec/lib/configurable_spec.rb +97 -0
  85. data/test_support/spec/lib/facet_paginator_spec.rb +93 -0
  86. data/test_support/spec/lib/marc_export_spec.rb +444 -0
  87. data/test_support/spec/lib/search_fields_spec.rb +105 -0
  88. data/test_support/spec/lib/tasks/blacklight_task_spec.rb +21 -0
  89. data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +59 -0
  90. data/test_support/spec/models/bookmark_spec.rb +37 -0
  91. data/test_support/spec/models/record_mailer_spec.rb +67 -0
  92. data/test_support/spec/models/search_spec.rb +55 -0
  93. data/test_support/spec/models/solr_docment_spec.rb +111 -0
  94. data/test_support/spec/rcov.opts +3 -0
  95. data/test_support/spec/spec.opts +4 -0
  96. data/test_support/spec/spec_helper.rb +38 -0
  97. data/test_support/spec/support/action_controller.rb +42 -0
  98. data/test_support/spec/support/assert_difference.rb +16 -0
  99. data/test_support/spec/support/include_text.rb +20 -0
  100. data/test_support/spec/views/catalog/_constraints_element.html.erb_spec.rb +59 -0
  101. data/test_support/spec/views/catalog/_document_list.html.erb_spec.rb +8 -0
  102. data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +182 -0
  103. data/test_support/spec/views/catalog/_index_partials/_default.erb_spec.rb +70 -0
  104. data/test_support/spec/views/catalog/_show_partials/_default.html.erb_spec.rb +70 -0
  105. data/test_support/spec/views/catalog/index.atom.builder_spec.rb +141 -0
  106. data/test_support/spec/views/catalog/show.html.erb_spec.rb +100 -0
  107. data/test_support/spec/views/catalog/unapi.xml.builder_spec.rb +45 -0
  108. metadata +95 -98
  109. data/lib/blacklight/marc.rb +0 -46
  110. data/lib/blacklight/marc/citation.rb +0 -251
  111. data/lib/railties/cucumber.rake +0 -53
  112. data/lib/railties/rspec.rake +0 -188
  113. data/spec/helpers/catalog_helper_spec.rb +0 -111
  114. data/spec/views/catalog/_sms_form.html.erb_spec.rb +0 -19
data/.gitmodules CHANGED
@@ -1,6 +0,0 @@
1
- [submodule "test_app/jetty"]
2
- path = test_app/jetty
3
- url = git://github.com/projectblacklight/blacklight-jetty.git
4
- [submodule "test_app/data"]
5
- path = test_app/data
6
- url = git://github.com/projectblacklight/blacklight-data.git
data/README.rdoc CHANGED
@@ -25,7 +25,18 @@ Install blacklight
25
25
  Run your database migrations
26
26
 
27
27
  $ rake db:migrate
28
-
28
+
29
+ You will need a Solr setup, referred to in your config/solr.yml. You can install
30
+ an example jetty container with Solr, that has Solr configured to work with
31
+ Blacklight's defaults, like:
32
+ $ rails generate blacklight:jetty
33
+
34
+ You can also install your own Solr or use an existing install. But Blacklight
35
+ configuration needs to match your Solr setup, and there are certain things
36
+ in a Solr setup that Blacklight requires. To generate some Solr config files
37
+ that match what default Blacklight expects:
38
+ $ rails generate blacklight:solr_conf path/to/output/directory/
39
+
29
40
  Start up your application
30
41
 
31
42
  $ rails server
@@ -48,7 +59,15 @@ If you have a user model already, the Blacklight generator will connect to it au
48
59
  match 'new_user_session', :to => 'Your User Session Controller # Log in action'
49
60
  match 'destroy_user_session', :to => 'Your User Session Controller # Log Out action'
50
61
 
51
- And you will need to make sure the following helper methods are available:
62
+ One blacklight view uses #to_s on your user model to get a user-displayable
63
+ account name/identifier for the currently logged in account, you probably
64
+ want to have such a method.
65
+
66
+ (TODO: Instructions on how to tell BL the name of your user model if it's
67
+ not User?)
68
+
69
+ And you will need to make sure the following methods are available both
70
+ on controllers and as helpers:
52
71
 
53
72
  current_user - Which should return a user object that include Blacklight::User
54
73
  user_session - Which should return a user session
@@ -67,99 +86,87 @@ Start up your application
67
86
 
68
87
  Visit the catalog at: http://localhost/catalog
69
88
 
70
- == Setting up a development environment
71
-
72
- Checkout the code:
73
-
74
- $ git clone git@github.com:projectblacklight/blacklight.git blacklight
75
- $ cd blacklight
76
-
77
- (While the rails3 branch is still a seperate branch called 'rails3':)
78
- $ git checkout -t origin/rails3
79
-
80
- Now create a test bed application inside of Blacklight that will allow you
81
- to include Blacklight as a gem.
82
- The test_app directory already exists, and contains a .gitignore file that
83
- will mean all of the generated code is ingored. - There are a few directories
84
- already in palce in test_app that WILL be included in the git repository. These
85
- include:
86
- * test_app/features - which contains cucumber tests for blacklight
87
- * test_app/spec - rspec tests
88
- * test_app/jetty - The blacklight Jetty module (discussed later)
89
- * test_app/data - Another remote module.
90
-
91
- To create the rails application:
92
-
93
- $ rails new test_app --skip-test-unit --skip-git
94
-
95
- Or if you are using Jruby:
96
-
97
- $ jruby -S rails new test_app -m http://jruby.org/rails3.rb --skip-test-unit --skip-git
98
-
99
- Add gem 'blacklight' to the test applications Gemfile:
100
-
101
- gem 'blacklight', :path => '../'
89
+ == Using Blacklight source checkout as gem for development
102
90
 
103
- Run bundle install in the test app
104
- $ bundle install
91
+ The ordinary install instructions install the BL gem (which is not
92
+ full source code) in wherever your system installs gems.
105
93
 
106
- Install and configure blacklight (with devise setting)
107
- $ rails generate blacklight --devise
94
+ Sometimes, especially for development, it's useful to check out
95
+ a complete copy of the blacklight source code, and link your app
96
+ to that as a 'gem' instead.
108
97
 
109
- Remove index.html - which will allow the routes to take you directly to the catalog page.
110
- $ rm public/index.html (allow us to redirect to catalog)
98
+ Checkout the code:
111
99
 
112
- Migrate your database
113
- $ rake db:migrate
100
+ $ git clone git@github.com:projectblacklight/blacklight.git
114
101
 
115
- Get Solr running somewhere. If you don't have Solr installed, blacklight comes with a default setup.
102
+ (While the rails3 branch is still a seperate branch called 'rails3',
103
+ if you'd like to checkout the rails3 branch, or any other particular
104
+ branch/tag using ordinary git commands:
116
105
  $ cd blacklight
117
- $ git submodule init
118
- $ git submodule update
119
- $ cd test_app
120
- $ rake solr:marc:index_test_data RAILS_ENV=test
121
- $ cd jetty
122
- $ java -jar start.jar
123
-
124
- Start up your Server, and take a test run. (from blacklight/test_app)
125
- $ rails server
126
-
127
- Now go check it out, should be running.
128
-
129
- == Running the tests
130
-
131
- You will need to add some gems to your test_app's Gemfile
132
-
133
- group :development, :test do
134
- gem "rspec"
135
- gem "rspec-rails", "~>2.5.0"
136
- gem "cucumber-rails"
137
- gem "database_cleaner"
138
- gem "capybara"
139
- gem "webrat"
140
- gem "aruba"
141
- end
142
-
143
- Run bundle install
106
+ $ git checkout -t origin/rails3
107
+ )
144
108
 
145
- $ bundle install
146
-
147
- Install cucumber
148
-
149
- $ rails generate cucumber:install
109
+ Now, in your local app's Gemfile, simply specify that it should find
110
+ the Blacklight gem at this source checkout location:
111
+
112
+ gem 'blacklight', :path=>"./relative/path/to/blacklight_checkout"
113
+
114
+ You can have the blacklight source checkout anywhere you want, referred
115
+ to by absolute or relative path. You can have it inside your local app's
116
+ directory if you want, or you can have it outside using a relative path
117
+ beginning with "../". If you have it inside your app's root, you can
118
+ even use 'git submodule' techniques to link your app to a particular
119
+ git commit, like some of us did in Rails2 Blacklight. (But you probably
120
+ don't want it in your local apps ./vendor/plugins, that'll likely
121
+ confuse Rails, since it's already being referred to in your Gemfile).
122
+
123
+ == Running Blacklight's own tests
124
+
125
+ Any application that refers to a Blacklight gem using a source checkout
126
+ (see above) can run the automated tests (cucumber and rspec) that
127
+ come with Blacklight source.
128
+
129
+ Of course, if you've customized the app quite a bit, the tests may not
130
+ pass, as they test expected default behavior in some cases. So ordinarily
131
+ tests are run against a pretty basic stub app. The tests also
132
+ test authentication features, so expect the app to have auth features
133
+ installed, for instance with a Devise install.
134
+
135
+ To run the tests:
136
+
137
+ * Create a stub app with BL with devise, following the ordinary instructions for
138
+ installing blacklight, but linking to a source checkout of Blacklight
139
+ following the instructions above in "Using Blacklight source checkout
140
+ as gem for development"
141
+ * You also need to include some gems in your test app's Gemfile needed for
142
+ running our tests:
143
+ group :development, :test do
144
+ gem "rspec"
145
+ gem "rspec-rails", "~>2.5.0"
146
+ gem "cucumber-rails"
147
+ gem "database_cleaner"
148
+ gem "capybara"
149
+ gem "webrat"
150
+ gem "aruba"
151
+ end
152
+ * run `bundle install` in the test app, and don't forget `rake db:migrate`
153
+ * complete the install of cucumber: 'rails g cucumber:install'
154
+ * remove /public/index.html (blacklight tests expect / to map to catalog)
155
+ * You need to install a jetty/solr with test data for testing. You can do that
156
+ like this (from your stub app home directory):
157
+ rails generate blacklight:jetty test_jetty -e test
158
+ rake solr:marc:index_test_data RAILS_ENV=test
159
+ * Now use some rake tasks that come with Blacklight to actually run the tests.
160
+ Run these from your stub app:
161
+ * rake blacklight:cucumber:with_solr -- run tests in BL, start and stop the test jetty/solr around tests
162
+ * rake blacklight:cucumber -- run tests in BL, no jetty/solr. (Tests will fail unless you start it yourself)
163
+ * rake blacklight:spec:with_solr
164
+ * rake blacklight:spec
165
+ * the standard rails tasks for cucumber/rspec are all included with
166
+ blacklight: prefix, and should work as expected, but using
167
+ specs/features defined in BL plugin instead of in your local
168
+ app. (Not every variant has a :with_solr yet).
150
169
 
151
- If you haven't yet done this to load the bundled jetty/solr environment and test data in your blacklight checkout, from the blacklight checkout dir:
152
- git submodule init
153
- git submodule update
154
-
155
- Load in the test data
156
-
157
- $ rake solr:marc:index_test_data RAILS_ENV=test
158
-
159
- Run the tests
160
-
161
- $ rake solr:spec
162
- $ rake solr:features
163
170
 
164
171
  ==Pre-requisites
165
172
  Whichever method you choose for installation, be sure you have all the pre-requisites in place. You can find these detailed in {PRE-REQUISITES}[https://github.com/projectblacklight/blacklight/wiki/PRE-REQUISITES]
data/blacklight.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  end
29
29
 
30
30
  # Required Gems
31
- s.add_dependency "rails", "= 3.0.6"
31
+ s.add_dependency "rails", "~> 3.0"
32
32
  s.add_dependency "nokogiri", "~>1.5.0.beta.3" # XML Parser
33
33
  s.add_dependency "marc" # Marc record parser
34
34
  s.add_dependency "rsolr", '1.0.0' # Library for interacting with rSolr.
data/config/routes.rb CHANGED
@@ -25,7 +25,7 @@ Rails.application.routes.draw do
25
25
 
26
26
  # Saved Searches
27
27
  match "saved_searches/clear", :to => "saved_searches#clear", :as => "clear_saved_searches"
28
- match "saved_searches/index", :to => "saved_searches#index", :as => "saved_searches"
28
+ match "saved_searches", :to => "saved_searches#index", :as => "saved_searches"
29
29
  match "saved_searches/save/:id", :to => "saved_searches#save", :as => "save_search"
30
30
  match "saved_searches/forget/:id", :to => "saved_searches#forget", :as => "forget_search"
31
31
 
data/lib/blacklight.rb CHANGED
@@ -63,8 +63,8 @@ module Blacklight
63
63
  @solr_config ||= begin
64
64
  raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight\"?" unless File.exists?(solr_file)
65
65
  solr_config = YAML::load(File.open(solr_file))
66
- raise "The #{RAILS_ENV} environment settings were not found in the solr.yml config" unless solr_config[RAILS_ENV]
67
- solr_config[RAILS_ENV].symbolize_keys
66
+ raise "The #{::Rails.env} environment settings were not found in the solr.yml config" unless solr_config[::Rails.env]
67
+ solr_config[::Rails.env].symbolize_keys
68
68
  end
69
69
  end
70
70
 
@@ -1,24 +1,22 @@
1
1
  module Blacklight::Catalog
2
+ extend ActiveSupport::Concern
3
+ include Blacklight::SolrHelper
2
4
 
3
5
  # The following code is executed when someone includes blacklight::catalog in their
4
6
  # own controller.
5
- def self.included(base)
6
- # These two helper methods are provided by the blacklight solr::helper
7
- base.send :helper_method, :facet_limit_hash
8
- base.send :helper_method, :facet_limit_for
9
-
10
- base.send :before_filter, :search_session, :history_session
11
- base.send :before_filter, :delete_or_assign_search_session_params, :only => :index
12
- base.send :after_filter, :set_additional_search_session_values, :only=>:index
7
+ included do
8
+ before_filter :search_session, :history_session
9
+ before_filter :delete_or_assign_search_session_params, :only => :index
10
+ after_filter :set_additional_search_session_values, :only=>:index
13
11
 
14
12
  # Whenever an action raises SolrHelper::InvalidSolrID, this block gets executed.
15
13
  # Hint: the SolrHelper #get_solr_response_for_doc_id method raises this error,
16
14
  # which is used in the #show action here.
17
- base.send :rescue_from, Blacklight::Exceptions::InvalidSolrID, :with => :invalid_solr_id_error
15
+ rescue_from Blacklight::Exceptions::InvalidSolrID, :with => :invalid_solr_id_error
18
16
  # When RSolr::RequestError is raised, the rsolr_request_error method is executed.
19
17
  # The index action will more than likely throw this one.
20
18
  # Example, when the standard query parser is used, and a user submits a "bad" query.
21
- base.send :rescue_from, RSolr::Error::Http, :with => :rsolr_request_error
19
+ rescue_from RSolr::Error::Http, :with => :rsolr_request_error
22
20
  end
23
21
 
24
22
 
@@ -281,7 +279,7 @@ module Blacklight::Catalog
281
279
 
282
280
  # when solr (RSolr) throws an error (RSolr::RequestError), this method is executed.
283
281
  def rsolr_request_error(exception)
284
- if RAILS_ENV == "development"
282
+ if Rails.env == "development"
285
283
  raise exception # Rails own code will catch and give usual Rails error page with stack trace
286
284
  else
287
285
  flash_notice = "Sorry, I don't understand your search."
@@ -299,7 +297,7 @@ module Blacklight::Catalog
299
297
 
300
298
  # when a request for /catalog/BAD_SOLR_ID is made, this method is executed...
301
299
  def invalid_solr_id_error
302
- if RAILS_ENV == "development"
300
+ if Rails.env == "development"
303
301
  render # will give us the stack trace
304
302
  else
305
303
  flash[:notice] = "Sorry, you have requested a record that doesn't exist."
@@ -39,9 +39,9 @@ module Blacklight::Controller
39
39
  # http://api.rubyonrails.org/classes/ActionController/Filters/ClassMethods.html
40
40
  # for how to turn off a filter in a sub-class and such.
41
41
  def default_html_head
42
- stylesheet_links << ['yui', 'jquery/ui-lightness/jquery-ui-1.8.1.custom.css', 'blacklight', {:plugin=>:blacklight, :media=>'all'}]
42
+ stylesheet_links << ['blacklight/yui', 'blacklight/jquery/ui-lightness/jquery-ui-1.8.1.custom.css', 'blacklight/blacklight', {:media=>'all'}]
43
43
 
44
- javascript_includes << ['jquery-1.4.2.min.js', 'jquery-ui-1.8.1.custom.min.js', 'blacklight', { :plugin=>:blacklight } ]
44
+ javascript_includes << ['blacklight/jquery-1.4.2.min.js', 'blacklight/jquery-ui-1.8.1.custom.min.js', 'blacklight/blacklight' ]
45
45
  end
46
46
 
47
47
 
@@ -24,8 +24,11 @@ module Blackight
24
24
 
25
25
  # This makes our rake tasks visible.
26
26
  rake_tasks do
27
- load "railties/blacklight.rake"
28
- load "railties/solr_marc.rake"
27
+ Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..'))) do
28
+ Dir.glob(File.join('railties', '*.rake')).each do |railtie|
29
+ load railtie
30
+ end
31
+ end
29
32
  end
30
33
 
31
34
  end
@@ -124,7 +124,7 @@ module Blacklight::Solr::Document
124
124
  begin
125
125
  mime_type = "Mime::#{short_name.to_s.upcase}".constantize
126
126
  content_type = mime_type.to_s unless content_type
127
- rescue NameError
127
+ rescue NameError,LoadError
128
128
  # not registered, we need to register. Use register_alias to be least
129
129
  # likely to interfere with host app.
130
130
  Mime::Type.register_alias(content_type, short_name)
@@ -25,22 +25,7 @@ module Blacklight::Solr::Document::Marc
25
25
  # Register our exportable formats, we inherit these from MarcExport
26
26
  Blacklight::Solr::Document::MarcExport.register_export_formats( document )
27
27
  end
28
-
29
- # DEPRECATED. Here for legacy purposes, but use to_marc instead. Or
30
- # internally, use the protected _marc_helper method to get the
31
- # (somewhat confusingly named) Blacklight::Marc::Document helper object.
32
- #
33
- # This method gets attached to a SolrDocument.
34
- # it uses the marc_source_field and marc_format_type
35
- # class attributes to create the Blacklight::Marc::Document instance.
36
- # Only returns a Blacklight::Marc::Document instance if
37
- # the self.class.marc_source_field key exists.
38
- def marc
39
- warn "[DEPRECATION] aDocument.marc is deprecated. Please use aDocument.respond_to?(:to_marc) / aDocument.respond_to?(:marc), or aDocument.exports_as.keys.include?(:some_format) / aDocument.export_as(:some_format) instead."
40
-
41
- _marc_helper
42
- end
43
-
28
+
44
29
  # ruby-marc object
45
30
  def to_marc
46
31
  @_ruby_marc_obj ||= load_marc
@@ -5,42 +5,71 @@
5
5
  #
6
6
  # Override these methods in your own controller for customizations:
7
7
  #
8
- # class CatalogController < ActionController::Base
8
+ # class CatalogController < ActionController::Base
9
9
  #
10
- # include Blacklight::SolrHelper
10
+ # include Blacklight::Catalog
11
11
  #
12
- # def solr_search_params
13
- # super.merge :per_page=>10
12
+ # def solr_search_params
13
+ # super.merge :per_page=>10
14
+ # end
14
15
  # end
16
+ #
17
+ # Or by including in local extensions:
18
+ # module LocalSolrHelperExtension
19
+ # [ local overrides ]
20
+ # end
21
+ #
22
+ # class CatalogController < ActionController::Base
23
+ #
24
+ # include Blacklight::Catalog
25
+ # include LocalSolrHelperExtension
15
26
  #
16
- # end
27
+ # def solr_search_params
28
+ # super.merge :per_page=>10
29
+ # end
30
+ # end
31
+ #
32
+ # Or by using ActiveSupport::Concern:
33
+ #
34
+ # module LocalSolrHelperExtension
35
+ # extend ActiveSupport::Concern
36
+ # include Blacklight::SolrHelper
37
+ #
38
+ # [ local overrides ]
39
+ # end
17
40
  #
41
+ # class CatalogController < ApplicationController
42
+ # include LocalSolrHelperExtension
43
+ # include Blacklight::Catalog
44
+ # end
18
45
 
19
46
  module Blacklight::SolrHelper
47
+ extend ActiveSupport::Concern
48
+
20
49
  MaxPerPage = 100
21
-
22
- def self.included(klass)
23
- if klass.respond_to?(:helper_method)
24
- klass.helper_method(:facet_limit_hash)
25
- klass.helper_method(:facet_limit_for)
50
+
51
+ included do
52
+ if self.respond_to?(:helper_method)
53
+ helper_method(:facet_limit_hash)
54
+ helper_method(:facet_limit_for)
26
55
  end
27
-
56
+
28
57
  # We want to install a class-level place to keep
29
58
  # solr_search_params_logic method names. Compare to before_filter,
30
59
  # similar design. Since we're a module, we have to add it in here.
31
60
  # There are too many different semantic choices in ruby 'class variables',
32
61
  # we choose this one for now, supplied by Rails.
33
- klass.class_inheritable_accessor :solr_search_params_logic
62
+ class_inheritable_accessor :solr_search_params_logic
63
+
34
64
  # Set defaults. Each symbol identifies a _method_ that must be in
35
65
  # this class, taking two parameters (solr_parameters, user_parameters)
36
66
  # Can be changed in local apps or by plugins, eg:
37
67
  # CatalogController.include ModuleDefiningNewMethod
38
68
  # CatalogController.solr_search_params_logic << :new_method
39
69
  # CatalogController.solr_search_params_logic.delete(:we_dont_want)
40
- klass.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 ]
70
+ 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 ]
41
71
  end
42
72
 
43
-
44
73
  # A helper method used for generating solr LocalParams, put quotes
45
74
  # around the term unless it's a bare-word. Escape internal quotes
46
75
  # if needed.