blacklight 5.0.0.pre3 → 5.0.0.pre4

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -16
  3. data/Gemfile +4 -0
  4. data/README.md +15 -1
  5. data/VERSION +1 -1
  6. data/app/assets/stylesheets/blacklight/_bookmark.css.scss +1 -1
  7. data/app/assets/stylesheets/blacklight/_catalog.css.scss +2 -12
  8. data/app/assets/stylesheets/blacklight/_facets.css.scss +1 -1
  9. data/app/assets/stylesheets/blacklight/_header.css.scss +1 -0
  10. data/app/assets/stylesheets/blacklight/_modal.css.scss +4 -2
  11. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +0 -5
  12. data/app/controllers/bookmarks_controller.rb +4 -0
  13. data/app/helpers/blacklight/blacklight_helper_behavior.rb +26 -187
  14. data/app/helpers/blacklight/catalog_helper_behavior.rb +20 -8
  15. data/app/helpers/blacklight/facets_helper_behavior.rb +0 -83
  16. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -1
  17. data/app/helpers/blacklight/url_helper_behavior.rb +201 -0
  18. data/app/helpers/blacklight_url_helper.rb +3 -0
  19. data/app/views/bookmarks/_tools.html.erb +4 -7
  20. data/app/views/catalog/_citation.html.erb +1 -1
  21. data/app/views/catalog/_did_you_mean.html.erb +1 -1
  22. data/app/views/catalog/_document.html.erb +1 -1
  23. data/app/views/catalog/_search_form.html.erb +1 -1
  24. data/app/views/catalog/_show_more_like_this.html.erb +1 -1
  25. data/app/views/catalog/_view_type_group.html.erb +4 -4
  26. data/app/views/catalog/email.html.erb +2 -2
  27. data/app/views/catalog/facet.html.erb +1 -1
  28. data/app/views/catalog/show.html.erb +1 -1
  29. data/app/views/catalog/sms.html.erb +1 -1
  30. data/blacklight.gemspec +2 -2
  31. data/config/jetty.yml +4 -1
  32. data/config/locales/blacklight.en.yml +3 -0
  33. data/config/locales/blacklight.fr.yml +3 -0
  34. data/{lib/generators/blacklight/templates/migrations/create_searches.rb → db/migrate/20140202020201_create_searches.rb} +2 -0
  35. data/{lib/generators/blacklight/templates/migrations/create_bookmarks.rb → db/migrate/20140202020202_create_bookmarks.rb} +1 -2
  36. data/gemfiles/rails3.gemfile +2 -0
  37. data/gemfiles/rails4.gemfile +2 -0
  38. data/lib/blacklight.rb +1 -40
  39. data/lib/blacklight/base.rb +3 -9
  40. data/lib/blacklight/catalog.rb +3 -16
  41. data/lib/blacklight/catalog/search_context.rb +8 -1
  42. data/lib/blacklight/configurable.rb +1 -2
  43. data/lib/blacklight/configuration.rb +13 -3
  44. data/lib/blacklight/configuration/view_config.rb +71 -0
  45. data/lib/blacklight/engine.rb +1 -0
  46. data/lib/blacklight/routes.rb +0 -1
  47. data/lib/blacklight/solr/document.rb +0 -4
  48. data/lib/blacklight/solr_helper.rb +8 -2
  49. data/lib/blacklight/user.rb +1 -16
  50. data/lib/blacklight/utils.rb +72 -1
  51. data/lib/generators/blacklight/install_generator.rb +92 -0
  52. data/lib/generators/blacklight/models_generator.rb +1 -25
  53. data/lib/generators/blacklight/templates/catalog_controller.rb +28 -32
  54. data/spec/helpers/blacklight_helper_spec.rb +24 -417
  55. data/spec/helpers/catalog_helper_spec.rb +13 -13
  56. data/spec/helpers/facets_helper_spec.rb +0 -127
  57. data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -1
  58. data/spec/helpers/url_helper_spec.rb +360 -0
  59. data/spec/lib/blacklight/configuration_spec.rb +2 -3
  60. data/spec/lib/blacklight/solr_helper_spec.rb +11 -17
  61. data/spec/lib/blacklight/user_spec.rb +0 -41
  62. data/spec/lib/blacklight_spec.rb +0 -22
  63. data/spec/lib/utils_spec.rb +35 -4
  64. data/spec/spec_helper.rb +4 -3
  65. data/spec/test_app_templates/lib/generators/test_app_generator.rb +2 -2
  66. data/spec/views/catalog/_constraints.html.erb_spec.rb +4 -2
  67. data/spec/views/catalog/_index_default.erb_spec.rb +1 -1
  68. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -5
  69. data/spec/views/catalog/_show_default.erb_spec.rb +1 -1
  70. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +11 -3
  71. data/tasks/blacklight.rake +1 -5
  72. metadata +14 -16
  73. data/.gitmodules +0 -0
  74. data/app/views/catalog/endnote.endnote.erb +0 -1
  75. data/app/views/catalog/show.endnote.erb +0 -1
  76. data/lib/generators/blacklight/blacklight_generator.rb +0 -97
  77. data/lib/generators/blacklight/templates/migrations/add_user_types_to_bookmarks_searches.rb +0 -16
  78. data/lib/generators/blacklight/templates/migrations/remove_editable_fields_from_bookmarks.rb +0 -12
  79. data/lib/railties/all_tests.rake +0 -39
  80. data/lib/railties/blacklight_rspec.rake +0 -128
@@ -11,7 +11,7 @@
11
11
  <div id="doc_<%= @document.id.to_s.parameterize %>">
12
12
 
13
13
  <% # bookmark/folder functions -%>
14
- <%= render_document_partials @document, blacklight_config.show.partials %>
14
+ <%= render_document_partials @document, blacklight_config.view_config(:show).partials %>
15
15
 
16
16
  </div>
17
17
  </div>
@@ -1,5 +1,5 @@
1
1
  <div class="modal-header">
2
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
2
+ <button type="button" class="ajax-modal-close close" data-dismiss="modal" aria-hidden="true">×</button>
3
3
  <h1 class="modal-title"><%= t('blacklight.sms.form.title') %></h1>
4
4
  </div>
5
5
  <%= render :partial => 'sms_form' %>
data/blacklight.gemspec CHANGED
@@ -26,8 +26,8 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency "sass-rails"
27
27
  s.add_dependency "bootstrap-sass", "~> 3.0"
28
28
  s.add_dependency "deprecation"
29
- s.add_development_dependency "jettywrapper", ">= 1.4.1"
30
- s.add_development_dependency "blacklight_marc", "0.0.6"
29
+ s.add_development_dependency "jettywrapper", ">= 1.5.2"
30
+ s.add_development_dependency "blacklight_marc", "0.0.9"
31
31
  s.add_development_dependency "rspec-rails"
32
32
  s.add_development_dependency 'engine_cart', ">= 0.1.0"
33
33
  s.add_development_dependency "equivalent-xml"
data/config/jetty.yml CHANGED
@@ -1,4 +1,7 @@
1
- default:
1
+ development:
2
2
  startup_wait: 15
3
+ jetty_port: 8983
4
+ test:
5
+ startup_wait: 60
3
6
  jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
4
7
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
@@ -191,8 +191,11 @@ en:
191
191
  value: 'Remove constraint %{value}'
192
192
  label_value: 'Remove constraint %{label}: %{value}'
193
193
  start_over: 'Start Over'
194
+ index:
195
+ label: '%{label}:'
194
196
  show:
195
197
  title: '%{document_title} - %{application_name}'
198
+ label: '%{label}:'
196
199
  rss_feed: 'RSS for results'
197
200
  atom_feed: 'Atom for results'
198
201
  fields:
@@ -207,8 +207,11 @@ fr:
207
207
  value: 'Supprimer la restriction %{value}'
208
208
  label_value: 'Supprimer la restriction %{label}: %{value}'
209
209
  start_over: 'Accueil'
210
+ index:
211
+ label: '%{label}:'
210
212
  show:
211
213
  title: '%{document_title} - %{application_name}'
214
+ label: '%{label}:'
212
215
  rss_feed: 'RSS pour les résultats'
213
216
  atom_feed: 'Atom pour les résultats'
214
217
  fields:
@@ -4,9 +4,11 @@ class CreateSearches < ActiveRecord::Migration
4
4
  create_table :searches do |t|
5
5
  t.text :query_params
6
6
  t.integer :user_id
7
+ t.string :user_type
7
8
 
8
9
  t.timestamps
9
10
  end
11
+
10
12
  add_index :searches, :user_id
11
13
  end
12
14
 
@@ -3,10 +3,9 @@ class CreateBookmarks < ActiveRecord::Migration
3
3
  def self.up
4
4
  create_table :bookmarks do |t|
5
5
  t.integer :user_id, :null=>false
6
- t.text :url
6
+ t.string :user_type
7
7
  t.string :document_id
8
8
  t.string :title
9
- t.text :notes
10
9
  t.timestamps
11
10
  end
12
11
  end
@@ -8,6 +8,8 @@ gem 'rails', "~> 3.2"
8
8
  gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
9
9
 
10
10
  group :test do
11
+ gem 'simplecov', require: false
12
+ gem 'coveralls', require: false
11
13
  gem 'devise'
12
14
  gem 'devise-guests'
13
15
  gem "bootstrap-sass"
@@ -8,6 +8,8 @@ gem 'rails', '~> 4.0.0'
8
8
  gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
9
9
 
10
10
  group :test do
11
+ gem 'simplecov', require: false
12
+ gem 'coveralls', require: false
11
13
  gem 'devise'
12
14
  gem 'devise-guests'
13
15
  gem "bootstrap-sass"
data/lib/blacklight.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'kaminari'
3
3
  require 'rsolr'
4
-
5
4
  module Blacklight
6
5
 
7
6
  autoload :Configurable, 'blacklight/configurable'
@@ -34,11 +33,6 @@ module Blacklight
34
33
  class << self
35
34
  attr_accessor :solr, :solr_config
36
35
  end
37
-
38
- # Adding a little jruby support
39
- def self.jruby?
40
- defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
41
- end
42
36
 
43
37
  def self.solr_file
44
38
  "#{::Rails.root.to_s}/config/solr.yml"
@@ -65,7 +59,7 @@ module Blacklight
65
59
 
66
60
  return @solr_yml if @solr_yml
67
61
  unless File.exists?(solr_file)
68
- raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight\"?"
62
+ raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight:install\"?"
69
63
  end
70
64
 
71
65
  begin
@@ -103,38 +97,5 @@ module Blacklight
103
97
  def self.root
104
98
  @root ||= File.expand_path(File.dirname(File.dirname(__FILE__)))
105
99
  end
106
-
107
- # This is useful for modifying Blacklight models.
108
- # In the main app you can then do this:
109
- # require "#{MyEngine.models_dir}/bookmark"
110
- # class Bookmark
111
- # ...
112
- # end
113
- # BE AWARE - When you do this, you are monkey patching Blacklight
114
- # we should eventually find a better way - such as the acts_as pattern
115
- def self.models_dir
116
- "#{root}/app/models"
117
- end
118
-
119
- def self.controllers_dir
120
- "#{root}/app/controllers"
121
- end
122
-
123
-
124
- # Searches Rails.root then Blacklight.root for a valid path
125
- # returns a full path if a valid path is found
126
- # returns nil if nothing is found.
127
- # First looks in Rails.root, then Blacklight.root
128
- #
129
- # Example:
130
- # full_path_to_solr_marc_jar = Blacklight.locate_path 'solr_marc', 'SolrMarc.jar'
131
-
132
- def self.locate_path(*subpath_fragments)
133
- subpath = subpath_fragments.join('/')
134
- base_match = [Rails.root, self.root].find do |base|
135
- File.exists? File.join(base, subpath)
136
- end
137
- File.join(base_match.to_s, subpath) if base_match
138
- end
139
100
 
140
101
  end
@@ -5,6 +5,8 @@ module Blacklight::Base
5
5
  include Blacklight::Configurable
6
6
  include Blacklight::SolrHelper
7
7
 
8
+ require 'blacklight/catalog/search_context'
9
+ include Blacklight::Catalog::SearchContext
8
10
 
9
11
  included do
10
12
  # When RSolr::RequestError is raised, the rsolr_request_error method is executed.
@@ -37,12 +39,4 @@ module Blacklight::Base
37
39
  redirect_to root_path
38
40
  end
39
41
  end
40
-
41
- def blacklight_solr
42
- @solr ||= RSolr.connect(blacklight_solr_config)
43
- end
44
-
45
- def blacklight_solr_config
46
- Blacklight.solr_config
47
- end
48
- end
42
+ end
@@ -3,9 +3,6 @@ module Blacklight::Catalog
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  include Blacklight::Base
6
-
7
- require 'blacklight/catalog/search_context'
8
- include Blacklight::Catalog::SearchContext
9
6
 
10
7
  SearchHistoryWindow = 100 # how many searches to save in session history
11
8
 
@@ -98,13 +95,7 @@ module Blacklight::Catalog
98
95
  format.js { render :layout => false }
99
96
  end
100
97
  end
101
- # grabs a bunch of documents to export to endnote
102
- def endnote
103
- @response, @documents = get_solr_response_for_field_values(SolrDocument.unique_key,params[:id])
104
- respond_to do |format|
105
- format.endnote { render :layout => false }
106
- end
107
- end
98
+
108
99
 
109
100
  # Email Action (this will render the appropriate view on GET requests and process the form and send the email on POST requests)
110
101
  def email
@@ -242,11 +233,7 @@ module Blacklight::Catalog
242
233
  render "index", :status => 404
243
234
  end
244
235
 
245
- def blacklight_solr
246
- @solr ||= RSolr.connect(blacklight_solr_config)
247
- end
248
-
249
- def blacklight_solr_config
250
- Blacklight.solr_config
236
+ def start_new_search_session?
237
+ action_name == "index"
251
238
  end
252
239
  end
@@ -26,7 +26,7 @@ module Blacklight::Catalog::SearchContext
26
26
  # The current search session
27
27
  def current_search_session
28
28
 
29
- @current_search_session ||= if action_name == "index"
29
+ @current_search_session ||= if start_new_search_session?
30
30
  find_or_initialize_search_session_from_params params
31
31
  elsif params[:search_context].present?
32
32
  find_or_initialize_search_session_from_params JSON.load(params[:search_context])
@@ -50,6 +50,13 @@ module Blacklight::Catalog::SearchContext
50
50
  @current_search_session
51
51
  end
52
52
 
53
+ ##
54
+ # If the current action should start a new search session, this should be
55
+ # set to true
56
+ def start_new_search_session?
57
+ false
58
+ end
59
+
53
60
  def find_or_initialize_search_session_from_params params
54
61
  params_copy = params.reject { |k,v| blacklisted_search_session_params.include?(k.to_sym) or v.blank? }
55
62
 
@@ -41,8 +41,7 @@ module Blacklight::Configurable
41
41
  end
42
42
 
43
43
  ##
44
- # The default configuration object, by default it reads from Blacklight.config for backwards
45
- # compatibility with Blacklight <= 3.1
44
+ # The default configuration object
46
45
  def default_configuration
47
46
  Blacklight::Configurable.default_configuration.inheritable_copy
48
47
  end
@@ -4,6 +4,8 @@ module Blacklight
4
4
  # fields to display, facets to show, sort options, and search fields.
5
5
  class Configuration < OpenStructWithHashAccess
6
6
 
7
+ require 'blacklight/configuration/view_config'
8
+
7
9
  # Set up Blacklight::Configuration.default_values to contain
8
10
  # the basic, required Blacklight fields
9
11
  class << self
@@ -17,13 +19,13 @@ module Blacklight
17
19
  :default_solr_params => {},
18
20
  :document_solr_request_handler => nil,
19
21
  :default_document_solr_params => {},
20
- :show => OpenStructWithHashAccess.new(:partials => [:show_header, :show], :html_title => unique_key, :heading => unique_key),
21
- :index => OpenStructWithHashAccess.new(:partials => [:index_header, :thumbnail, :index], :show_link => unique_key, :record_display_type => 'format', :group => false),
22
+ :show => ViewConfig::Show.new(:partials => [:show_header, :show]),
23
+ :index => ViewConfig::Index.new(:partials => [:index_header, :thumbnail, :index], :title_field => unique_key, :display_type_field => 'format', :group => false),
24
+ :view => NestedOpenStructWithHashAccess.new(ViewConfig, 'list'),
22
25
  :spell_max => 5,
23
26
  :max_per_page => 100,
24
27
  :per_page => [10,20,50,100],
25
28
  :search_history_window => Blacklight::Catalog::SearchHistoryWindow,
26
- :document_index_view_types => ['list'],
27
29
  :add_facet_fields_to_solr_request => false,
28
30
  :add_field_configuration_to_solr_request => false,
29
31
  :http_method => :get
@@ -114,5 +116,13 @@ module Blacklight
114
116
  yield self if block_given?
115
117
  self
116
118
  end
119
+
120
+ def view_config view_type
121
+ if view_type == :show
122
+ self.index.merge self.show
123
+ else
124
+ self.index.merge view.fetch(view_type, {})
125
+ end
126
+ end
117
127
  end
118
128
  end
@@ -0,0 +1,71 @@
1
+ require 'deprecation'
2
+
3
+ class Blacklight::Configuration
4
+ class ViewConfig < Blacklight::OpenStructWithHashAccess
5
+ class Show < ViewConfig
6
+ extend Deprecation
7
+ self.deprecation_horizon = 'blacklight 6.0'
8
+
9
+ def html_title
10
+ Deprecation.warn(self.class, "config.show.html_title is deprecated; use config.show.title_field instead")
11
+ fetch(:html_title, title_field)
12
+ end
13
+
14
+ def heading
15
+ Deprecation.warn(self.class, "config.show.heading is deprecated; use config.show.title_field instead")
16
+ fetch(:heading, title_field)
17
+ end
18
+
19
+ def display_type
20
+ Deprecation.warn(self.class, "config.show.display_type is deprecated; use config.show.display_type_field instead")
21
+ fetch(:display_type, display_type_field)
22
+ end
23
+
24
+ def html_title= value
25
+ Deprecation.warn(self.class, "config.show.html_title is deprecated; use config.show.title_field instead")
26
+ super value
27
+ self.title_field = value
28
+ end
29
+
30
+ def heading= value
31
+ Deprecation.warn(self.class, "config.show.heading is deprecated; use config.show.title_field instead")
32
+ super value
33
+ self.title_field = value
34
+ end
35
+
36
+ def display_type= value
37
+ Deprecation.warn(self.class, "config.show.display_type is deprecated; use config.show.display_type_field instead")
38
+ super value
39
+ self.display_type_field = value
40
+ end
41
+ end
42
+
43
+ class Index < ViewConfig
44
+ extend Deprecation
45
+ self.deprecation_horizon = 'blacklight 6.0'
46
+
47
+ def record_display_type
48
+ Deprecation.warn(self.class, "config.index.record_display_type is deprecated; use config.index.display_type_field instead")
49
+ fetch(:record_display_type, display_type_field)
50
+ end
51
+
52
+ def record_display_type= value
53
+ Deprecation.warn(self.class, "config.index.record_display_type is deprecated; use config.index.display_type_field instead")
54
+ super value
55
+ self.display_type_field = value
56
+ end
57
+
58
+ def show_link
59
+ Deprecation.warn(self.class, "config.index.show_link is deprecated; use config.index.title_field instead")
60
+ fetch(:show_link, title_field)
61
+ end
62
+
63
+ def show_link= value
64
+ Deprecation.warn(self.class, "config.index.show_link is deprecated; use config.index.title_field instead")
65
+ super value
66
+ self.title_field = value
67
+ end
68
+
69
+ end
70
+ end
71
+ end
@@ -1,5 +1,6 @@
1
1
  module Blacklight
2
2
  class Engine < Rails::Engine
3
+ engine_name "blacklight"
3
4
 
4
5
  require 'bootstrap-sass'
5
6
  require 'blacklight/rails/routes'
@@ -102,7 +102,6 @@ module Blacklight
102
102
  get "#{primary_resource}/email", :as => "email_#{primary_resource}"
103
103
  post "#{primary_resource}/email"
104
104
  get "#{primary_resource}/sms", :as => "sms_#{primary_resource}"
105
- get "#{primary_resource}/endnote", :as => "endnote_#{primary_resource}"
106
105
  end
107
106
  end
108
107
 
@@ -161,10 +161,6 @@ module Blacklight::Solr::Document
161
161
  @unique_key ||= 'id'
162
162
  end
163
163
 
164
- def connection
165
- @connection ||= Blacklight.solr
166
- end
167
-
168
164
  # Returns array of hashes of registered extensions. Each hash
169
165
  # has a :module_obj key and a :condition_proc key. Usually this
170
166
  # method is only used internally in #apply_extensions, but if you
@@ -558,13 +558,12 @@ module Blacklight::SolrHelper
558
558
  end
559
559
 
560
560
  # returns a solr params hash
561
- # if field is nil, the value is fetched from blacklight_config[:index][:show_link]
562
561
  # the :fl (solr param) is set to the "field" value.
563
562
  # per_page is set to 10
564
563
  def solr_opensearch_params(field=nil)
565
564
  solr_params = solr_search_params
566
565
  solr_params[:per_page] = 10
567
- solr_params[:fl] = blacklight_config.index.show_link
566
+ solr_params[:fl] = field || blacklight_config.view_config('opensearch').title_field
568
567
  solr_params
569
568
  end
570
569
 
@@ -616,4 +615,11 @@ module Blacklight::SolrHelper
616
615
  blacklight_config.index.group
617
616
  end
618
617
 
618
+ def blacklight_solr
619
+ @solr ||= RSolr.connect(blacklight_solr_config)
620
+ end
621
+
622
+ def blacklight_solr_config
623
+ Blacklight.solr_config
624
+ end
619
625
  end