blacklight 5.9.4 → 5.10.0
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +11 -10
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -14
- data/app/helpers/blacklight/configuration_helper_behavior.rb +16 -10
- data/app/helpers/blacklight/facets_helper_behavior.rb +15 -14
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/bookmark.rb +1 -4
- data/app/models/search.rb +3 -6
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_facet_limit.html.erb +5 -3
- data/app/views/catalog/_facet_pivot.html.erb +4 -4
- data/app/views/catalog/_home_text.html.erb +8 -48
- data/app/views/catalog/_index_default.html.erb +3 -3
- data/app/views/catalog/_show_default.html.erb +3 -3
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/jetty.yml +0 -3
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +2 -0
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/lib/blacklight.rb +70 -26
- data/lib/blacklight/abstract_repository.rb +29 -0
- data/lib/blacklight/base.rb +7 -7
- data/lib/blacklight/bookmarks.rb +5 -5
- data/lib/blacklight/catalog.rb +34 -19
- data/lib/blacklight/catalog/search_context.rb +1 -1
- data/lib/blacklight/configuration.rb +112 -46
- data/lib/blacklight/configuration/facet_field.rb +9 -7
- data/lib/blacklight/configuration/field.rb +27 -0
- data/lib/blacklight/configuration/fields.rb +25 -20
- data/lib/blacklight/configuration/search_field.rb +6 -8
- data/lib/blacklight/configuration/solr_field.rb +3 -18
- data/lib/blacklight/configuration/sort_field.rb +6 -7
- data/lib/blacklight/document.rb +156 -0
- data/lib/blacklight/document/dublin_core.rb +41 -0
- data/lib/blacklight/document/email.rb +16 -0
- data/lib/blacklight/document/export.rb +107 -0
- data/lib/blacklight/document/extensions.rb +56 -0
- data/lib/blacklight/document/schema_org.rb +7 -0
- data/lib/blacklight/document/semantic_fields.rb +51 -0
- data/lib/blacklight/document/sms.rb +14 -0
- data/lib/blacklight/document_presenter.rb +3 -3
- data/lib/blacklight/exceptions.rb +9 -2
- data/lib/blacklight/facet.rb +21 -16
- data/lib/blacklight/request_builders.rb +60 -284
- data/lib/blacklight/routes.rb +1 -1
- data/lib/blacklight/search_builder.rb +130 -0
- data/lib/blacklight/search_helper.rb +316 -0
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/document.rb +4 -187
- data/lib/blacklight/solr/document/dublin_core.rb +3 -37
- data/lib/blacklight/solr/document/email.rb +4 -13
- data/lib/blacklight/solr/document/export.rb +3 -103
- data/lib/blacklight/solr/document/extensions.rb +4 -52
- data/lib/blacklight/solr/document/more_like_this.rb +1 -1
- data/lib/blacklight/solr/document/schema_org.rb +4 -4
- data/lib/blacklight/solr/document/sms.rb +4 -11
- data/lib/blacklight/solr/facet_paginator.rb +2 -2
- data/lib/blacklight/solr/search_builder.rb +264 -0
- data/lib/blacklight/solr_helper.rb +6 -261
- data/lib/blacklight/solr_repository.rb +30 -24
- data/lib/blacklight/solr_response.rb +3 -3
- data/lib/blacklight/user.rb +1 -2
- data/lib/blacklight/utils.rb +0 -23
- data/lib/generators/blacklight/controller_generator.rb +38 -0
- data/lib/generators/blacklight/document_generator.rb +20 -0
- data/lib/generators/blacklight/install_generator.rb +38 -39
- data/lib/generators/blacklight/models_generator.rb +2 -62
- data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
- data/lib/generators/blacklight/templates/config/{solr.yml → blacklight.yml} +3 -0
- data/lib/generators/blacklight/templates/config/jetty.yml +0 -3
- data/lib/generators/blacklight/templates/solr_document.rb +6 -6
- data/lib/generators/blacklight/test_support_generator.rb +1 -6
- data/lib/generators/blacklight/user_generator.rb +59 -0
- data/lib/railties/blacklight.rake +16 -7
- data/spec/controllers/catalog_controller_spec.rb +9 -15
- data/spec/features/facets_spec.rb +8 -0
- data/spec/helpers/configuration_helper_spec.rb +6 -13
- data/spec/helpers/facets_helper_spec.rb +3 -2
- data/spec/lib/blacklight/configuration_spec.rb +11 -38
- data/spec/lib/blacklight/{solr/document → document}/dublin_core_spec.rb +4 -4
- data/spec/lib/blacklight/{solr/document → document}/email_spec.rb +2 -2
- data/spec/lib/blacklight/{solr/document → document}/sms_spec.rb +2 -2
- data/spec/lib/blacklight/search_builder_spec.rb +145 -0
- data/spec/lib/blacklight/search_helper_spec.rb +775 -0
- data/spec/lib/blacklight/solr/document/more_like_this_spec.rb +1 -1
- data/spec/lib/blacklight/solr/search_builder_spec.rb +561 -0
- data/spec/lib/blacklight/solr_helper_spec.rb +5 -1291
- data/spec/lib/blacklight/solr_repository_spec.rb +13 -13
- data/spec/models/record_mailer_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- data/tasks/blacklight.rake +1 -1
- data/template.demo.rb +1 -1
- metadata +33 -45
- data/doc/Adding-new-document-actions.md +0 -94
- data/doc/Atom-Responses.md +0 -90
- data/doc/Blacklight-Add-ons.md +0 -23
- data/doc/Blacklight-configuration.md +0 -411
- data/doc/Blacklight-on-Heroku.md +0 -100
- data/doc/Blacklight-out-of-the-box.md +0 -47
- data/doc/Bookmarks.md +0 -1
- data/doc/Code4Lib-2014.md +0 -94
- data/doc/Configuration---Facet-Fields.md +0 -130
- data/doc/Configuration---Results-View.md +0 -224
- data/doc/Configuration---Solr-fields.md +0 -106
- data/doc/Configuring-and-Customizing-Blacklight.md +0 -257
- data/doc/Configuring-rails-routes.md +0 -13
- data/doc/Contributing-to-Blacklight.md +0 -43
- data/doc/Examples.md +0 -120
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
- data/doc/Home.md +0 -100
- data/doc/How-to-release-a-version.md +0 -45
- data/doc/Indexing-your-data-into-solr.md +0 -36
- data/doc/Internationalization.md +0 -32
- data/doc/JSON-API.md +0 -83
- data/doc/Pagination.md +0 -52
- data/doc/Providing-your-own-view-templates.md +0 -69
- data/doc/Quickstart.md +0 -153
- data/doc/README_SOLR.md +0 -245
- data/doc/Saved-Searches.md +0 -5
- data/doc/Solr-Configuration.md +0 -154
- data/doc/Sunspot-for-indexing.md +0 -46
- data/doc/Support.md +0 -33
- data/doc/Theming.md +0 -62
- data/doc/Understanding-Rails-and-Blacklight.md +0 -75
- data/doc/User-Authentication.md +0 -60
- data/doc/_Sidebar.md +0 -9
- data/doc/testing.md +0 -58
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
module Blacklight
|
|
2
|
-
class SolrRepository
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
attr_accessor :logger
|
|
7
|
-
|
|
8
|
-
include ActiveSupport::Benchmarkable
|
|
9
|
-
|
|
10
|
-
def initialize blacklight_config
|
|
11
|
-
@blacklight_config = blacklight_config
|
|
2
|
+
class SolrRepository < AbstractRepository
|
|
3
|
+
unless defined? RSolr
|
|
4
|
+
Deprecation.warn self, "RSolr should be in your gemfile. Blacklight 6.0 will not load rsolr by default"
|
|
5
|
+
require 'rsolr'
|
|
12
6
|
end
|
|
13
7
|
|
|
8
|
+
extend Deprecation
|
|
9
|
+
self.deprecation_horizon = 'blacklight 6.0'
|
|
14
10
|
##
|
|
15
11
|
# Find a single solr document result (by id) using the document configuration
|
|
16
12
|
# @param [String] document's unique key value
|
|
@@ -19,9 +15,9 @@ module Blacklight
|
|
|
19
15
|
doc_params = params.reverse_merge(qt: blacklight_config.document_solr_request_handler)
|
|
20
16
|
.reverse_merge(blacklight_config.default_document_solr_params)
|
|
21
17
|
.merge(blacklight_config.document_unique_id_param => id)
|
|
22
|
-
|
|
18
|
+
|
|
23
19
|
solr_response = send_and_receive blacklight_config.document_solr_path || blacklight_config.solr_path, doc_params
|
|
24
|
-
raise Blacklight::Exceptions::
|
|
20
|
+
raise Blacklight::Exceptions::RecordNotFound.new if solr_response.documents.empty?
|
|
25
21
|
solr_response
|
|
26
22
|
end
|
|
27
23
|
|
|
@@ -45,29 +41,39 @@ module Blacklight
|
|
|
45
41
|
def send_and_receive(path, solr_params = {})
|
|
46
42
|
benchmark("Solr fetch", level: :debug) do
|
|
47
43
|
key = blacklight_config.http_method == :post ? :data : :params
|
|
48
|
-
res =
|
|
44
|
+
res = connection.send_and_receive(path, {key=>solr_params.to_hash, method:blacklight_config.http_method})
|
|
49
45
|
|
|
50
|
-
solr_response = blacklight_config.
|
|
46
|
+
solr_response = blacklight_config.response_model.new(res, solr_params, document_model: blacklight_config.document_model)
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
Rails.logger.debug("Solr query: #{solr_params.inspect}")
|
|
49
|
+
Rails.logger.debug("Solr response: #{solr_response.inspect}") if defined?(::BLACKLIGHT_VERBOSE_LOGGING) and ::BLACKLIGHT_VERBOSE_LOGGING
|
|
54
50
|
solr_response
|
|
55
51
|
end
|
|
56
52
|
rescue Errno::ECONNREFUSED => e
|
|
57
|
-
raise Blacklight::Exceptions::ECONNREFUSED.new("Unable to connect to Solr instance using #{
|
|
53
|
+
raise Blacklight::Exceptions::ECONNREFUSED.new("Unable to connect to Solr instance using #{connection.inspect}")
|
|
54
|
+
rescue RSolr::Error::Http => e
|
|
55
|
+
raise Blacklight::Exceptions::InvalidRequest.new(e.message)
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
def blacklight_solr
|
|
61
|
-
|
|
59
|
+
connection
|
|
62
60
|
end
|
|
61
|
+
deprecation_deprecate blacklight_solr: :connection
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
@blacklight_solr_config ||= Blacklight.solr_config
|
|
63
|
+
def blacklight_solr=(conn)
|
|
64
|
+
self.connection = conn
|
|
67
65
|
end
|
|
66
|
+
deprecation_deprecate :blacklight_solr= => :connection=
|
|
68
67
|
|
|
69
|
-
def
|
|
70
|
-
|
|
68
|
+
def blacklight_solr_config
|
|
69
|
+
connection_config
|
|
71
70
|
end
|
|
71
|
+
deprecation_deprecate blacklight_solr_config: :connection_config
|
|
72
|
+
|
|
73
|
+
protected
|
|
74
|
+
|
|
75
|
+
def build_connection
|
|
76
|
+
RSolr.connect(connection_config)
|
|
77
|
+
end
|
|
72
78
|
end
|
|
73
|
-
end
|
|
79
|
+
end
|
|
@@ -16,12 +16,12 @@ class Blacklight::SolrResponse < HashWithIndifferentAccess
|
|
|
16
16
|
include MoreLikeThis
|
|
17
17
|
|
|
18
18
|
attr_reader :request_params
|
|
19
|
-
attr_accessor :
|
|
19
|
+
attr_accessor :document_model
|
|
20
20
|
|
|
21
21
|
def initialize(data, request_params, options = {})
|
|
22
22
|
super(force_to_utf8(data))
|
|
23
23
|
@request_params = request_params
|
|
24
|
-
self.
|
|
24
|
+
self.document_model = options[:solr_document_model] || options[:document_model] || SolrDocument
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def header
|
|
@@ -52,7 +52,7 @@ class Blacklight::SolrResponse < HashWithIndifferentAccess
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def documents
|
|
55
|
-
docs.collect{|doc|
|
|
55
|
+
docs.collect{|doc| document_model.new(doc, self) }
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def grouped
|
data/lib/blacklight/user.rb
CHANGED
|
@@ -24,10 +24,9 @@ module Blacklight::User
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def bookmarked_document_ids
|
|
27
|
-
Deprecation.warn self, "The User#bookmarked_document_ids method is deprecated and will be removed in Blacklight 6.0"
|
|
28
|
-
|
|
29
27
|
self.bookmarks.pluck(:document_id)
|
|
30
28
|
end
|
|
29
|
+
deprecation_deprecate bookmarked_document_ids: "use current_user.bookmarks.pluck(:document_id) instead"
|
|
31
30
|
|
|
32
31
|
def document_is_bookmarked?(document)
|
|
33
32
|
bookmarks_for_documents([document]).any?
|
data/lib/blacklight/utils.rb
CHANGED
|
@@ -1,28 +1,5 @@
|
|
|
1
1
|
require 'ostruct'
|
|
2
2
|
module Blacklight
|
|
3
|
-
|
|
4
|
-
module Utils
|
|
5
|
-
def self.needs_attr_accessible?
|
|
6
|
-
if rails_3?
|
|
7
|
-
!strong_parameters_enabled?
|
|
8
|
-
else
|
|
9
|
-
protected_attributes_enabled?
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.rails_3?
|
|
14
|
-
Rails::VERSION::MAJOR == 3
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def self.strong_parameters_enabled?
|
|
18
|
-
defined?(ActionController::StrongParameters)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def self.protected_attributes_enabled?
|
|
22
|
-
defined?(ActiveModel::MassAssignmentSecurity)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
3
|
##
|
|
27
4
|
# An OpenStruct that responds to common Hash methods
|
|
28
5
|
class OpenStructWithHashAccess < OpenStruct
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Blacklight
|
|
2
|
+
class ControllerGenerator < Rails::Generators::Base
|
|
3
|
+
|
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
5
|
+
|
|
6
|
+
argument :controller_name , type: :string , default: "catalog"
|
|
7
|
+
|
|
8
|
+
desc """
|
|
9
|
+
This generator makes the following changes to your application:
|
|
10
|
+
1. Injects behavior into your user application_controller.rb
|
|
11
|
+
2. Creates a Blacklight::Catalog-based controller
|
|
12
|
+
3. Adds routes for your controller
|
|
13
|
+
|
|
14
|
+
Thank you for Installing Blacklight.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
# Add Blacklight to the application controller
|
|
18
|
+
def inject_blacklight_controller_behavior
|
|
19
|
+
inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
|
20
|
+
" # Adds a few additional behaviors into the application controller \n" +
|
|
21
|
+
" include Blacklight::Controller\n" +
|
|
22
|
+
" layout 'blacklight'\n\n"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Generate blacklight catalog controller
|
|
27
|
+
def create_blacklight_catalog
|
|
28
|
+
template "catalog_controller.rb", "app/controllers/#{controller_name}_controller.rb"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def inject_blacklight_routes
|
|
32
|
+
# These will end up in routes.rb file in reverse order
|
|
33
|
+
# we add em, since each is added at the top of file.
|
|
34
|
+
# we want "root" to be FIRST for optimal url generation.
|
|
35
|
+
route("blacklight_for :#{controller_name}")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
class DocumentGenerator < Rails::Generators::Base
|
|
5
|
+
include Rails::Generators::Migration
|
|
6
|
+
|
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
8
|
+
|
|
9
|
+
argument :model_name, :type => :string , :default => "solr_document"
|
|
10
|
+
|
|
11
|
+
desc """
|
|
12
|
+
This generator makes the following changes to your application:
|
|
13
|
+
1. Creates a blacklight document in your /app/models directory
|
|
14
|
+
"""
|
|
15
|
+
def create_solr_document
|
|
16
|
+
template "solr_document.rb", "app/models/#{model_name}.rb"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -4,6 +4,9 @@ module Blacklight
|
|
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
|
5
5
|
|
|
6
6
|
argument :model_name , type: :string , default: "user"
|
|
7
|
+
argument :controller_name, type: :string , default: "catalog"
|
|
8
|
+
argument :document_name, type: :string , default: "solr_document"
|
|
9
|
+
|
|
7
10
|
class_option :devise , type: :boolean, default: false, aliases: "-d", desc: "Use Devise as authentication logic."
|
|
8
11
|
class_option :jettywrapper, type: :boolean, default: false, desc: "Use jettywrapper to download and control Jetty"
|
|
9
12
|
class_option :marc , type: :boolean, default: false, aliases: "-m", desc: "Generate MARC-based demo ."
|
|
@@ -11,11 +14,11 @@ module Blacklight
|
|
|
11
14
|
desc """
|
|
12
15
|
This generator makes the following changes to your application:
|
|
13
16
|
1. Generates blacklight:models
|
|
14
|
-
2.
|
|
15
|
-
3.
|
|
16
|
-
4.
|
|
17
|
-
5. Adds
|
|
18
|
-
|
|
17
|
+
2. Adds rsolr to the Gemfile
|
|
18
|
+
3. Creates a number of public assets, including images, stylesheets, and javascript
|
|
19
|
+
4. Injects behavior into your user application_controller.rb
|
|
20
|
+
5. Adds example configurations for dealing with MARC-like data
|
|
21
|
+
6. Adds Blacklight routes to your ./config/routes.rb
|
|
19
22
|
|
|
20
23
|
Thank you for Installing Blacklight.
|
|
21
24
|
"""
|
|
@@ -31,6 +34,10 @@ module Blacklight
|
|
|
31
34
|
"require 'jettywrapper'\n"
|
|
32
35
|
end
|
|
33
36
|
|
|
37
|
+
def add_rsolr_gem
|
|
38
|
+
gem "rsolr", "~> 1.0.6"
|
|
39
|
+
end
|
|
40
|
+
|
|
34
41
|
def bundle_install
|
|
35
42
|
Bundler.with_clean_env do
|
|
36
43
|
run "bundle install"
|
|
@@ -43,51 +50,31 @@ module Blacklight
|
|
|
43
50
|
def copy_public_assets
|
|
44
51
|
generate "blacklight:assets"
|
|
45
52
|
end
|
|
53
|
+
|
|
54
|
+
def generate_blacklight_document
|
|
55
|
+
generate 'blacklight:document', document_name
|
|
56
|
+
end
|
|
46
57
|
|
|
47
58
|
def generate_blacklight_models
|
|
59
|
+
generate 'blacklight:models'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def generate_blacklight_user
|
|
48
63
|
|
|
49
|
-
generator_args = []
|
|
64
|
+
generator_args = [model_name]
|
|
50
65
|
if options[:devise]
|
|
51
66
|
generator_args << "--devise #{options[:devise]}"
|
|
52
67
|
end
|
|
53
68
|
|
|
54
|
-
generate 'blacklight:
|
|
69
|
+
generate 'blacklight:user', generator_args.join(" ")
|
|
55
70
|
end
|
|
56
71
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
|
60
|
-
" # Adds a few additional behaviors into the application controller \n" +
|
|
61
|
-
" include Blacklight::Controller\n" +
|
|
62
|
-
" # Please be sure to impelement current_user and user_session. Blacklight depends on \n" +
|
|
63
|
-
" # these methods in order to perform user specific actions. \n\n" +
|
|
64
|
-
" layout 'blacklight'\n\n"
|
|
65
|
-
end
|
|
72
|
+
def generate_controller
|
|
73
|
+
generate 'blacklight:controller', controller_name
|
|
66
74
|
end
|
|
67
75
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def generate_blacklight_marc_demo
|
|
74
|
-
if options[:marc]
|
|
75
|
-
gem "blacklight-marc", "5.5.0"
|
|
76
|
-
|
|
77
|
-
Bundler.with_clean_env do
|
|
78
|
-
run "bundle install"
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
generate 'blacklight_marc:marc'
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def inject_blacklight_routes
|
|
86
|
-
# These will end up in routes.rb file in reverse order
|
|
87
|
-
# we add em, since each is added at the top of file.
|
|
88
|
-
# we want "root" to be FIRST for optimal url generation.
|
|
89
|
-
route('blacklight_for :catalog')
|
|
90
|
-
route('root :to => "catalog#index"')
|
|
76
|
+
def add_default_catalog_route
|
|
77
|
+
route("root to: \"#{controller_name}#index\"")
|
|
91
78
|
end
|
|
92
79
|
|
|
93
80
|
def add_sass_configuration
|
|
@@ -107,5 +94,17 @@ EOF
|
|
|
107
94
|
def add_blacklight_initializer
|
|
108
95
|
template "config/initializers/blacklight_initializer.rb"
|
|
109
96
|
end
|
|
97
|
+
|
|
98
|
+
def generate_blacklight_marc_demo
|
|
99
|
+
if options[:marc]
|
|
100
|
+
gem "blacklight-marc", "~> 5.0"
|
|
101
|
+
|
|
102
|
+
Bundler.with_clean_env do
|
|
103
|
+
run "bundle install"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
generate 'blacklight_marc:marc'
|
|
107
|
+
end
|
|
108
|
+
end
|
|
110
109
|
end
|
|
111
110
|
end
|
|
@@ -7,54 +7,14 @@ module Blacklight
|
|
|
7
7
|
|
|
8
8
|
source_root File.expand_path('../templates', __FILE__)
|
|
9
9
|
|
|
10
|
-
argument :model_name, :type => :string , :default => "user"
|
|
11
|
-
class_option :devise , :type => :boolean, :default => false, :aliases => "-d", :desc => "Use Devise as authentication logic (this is default)."
|
|
12
|
-
|
|
13
10
|
desc """
|
|
14
11
|
This generator makes the following changes to your application:
|
|
15
12
|
1. Creates several database migrations if they do not exist in /db/migrate
|
|
16
|
-
2. Creates config/
|
|
17
|
-
3. Injects behavior into your user model
|
|
18
|
-
4. Creates a blacklight document in your /app/models directory
|
|
13
|
+
2. Creates config/blacklight.yml with a default configuration
|
|
19
14
|
"""
|
|
20
|
-
|
|
21
|
-
def check_arguments
|
|
22
|
-
if File.exists?("app/models/#{model_name}.rb") and options[:devise]
|
|
23
|
-
puts "Because you have selected \"#{model_name}\", which is an existing class, you will need to install devise manually and then run this generator without the Devise option. You can find additional information here: https://github.com/plataformatec/devise. \n Please be sure to include a to_s method in #{model_name} that returns the users name or email, as this will be used by Blacklight to provide a link to user specific information."
|
|
24
|
-
exit
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Install Devise?
|
|
29
|
-
def generate_devise_assets
|
|
30
|
-
if options[:devise]
|
|
31
|
-
gem "devise"
|
|
32
|
-
gem "devise-guests", "~> 0.3"
|
|
33
|
-
|
|
34
|
-
Bundler.with_clean_env do
|
|
35
|
-
run "bundle install"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
generate "devise:install"
|
|
39
|
-
generate "devise", model_name.classify
|
|
40
|
-
generate "devise_guests", model_name.classify
|
|
41
|
-
|
|
42
|
-
# add the #to_s to the model.
|
|
43
|
-
insert_into_file("app/models/#{model_name}.rb", before: /end(\n| )*$/) do
|
|
44
|
-
"\n # Method added by Blacklight; Blacklight uses #to_s on your\n" +
|
|
45
|
-
" # user class to get a user-displayable login/identifier for\n" +
|
|
46
|
-
" # the account.\n" +
|
|
47
|
-
" def to_s\n" +
|
|
48
|
-
" email\n" +
|
|
49
|
-
" end\n"
|
|
50
|
-
end
|
|
51
|
-
gsub_file("config/initializers/devise.rb", "config.sign_out_via = :delete", "config.sign_out_via = :get")
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
15
|
# Copy all files in templates/config directory to host config
|
|
56
16
|
def create_configuration_files
|
|
57
|
-
copy_file "config/
|
|
17
|
+
copy_file "config/blacklight.yml", "config/blacklight.yml"
|
|
58
18
|
end
|
|
59
19
|
|
|
60
20
|
|
|
@@ -64,25 +24,5 @@ This generator makes the following changes to your application:
|
|
|
64
24
|
end
|
|
65
25
|
|
|
66
26
|
|
|
67
|
-
# Add Blacklight to the user model
|
|
68
|
-
def inject_blacklight_user_behavior
|
|
69
|
-
file_path = "app/models/#{model_name.underscore}.rb"
|
|
70
|
-
if File.exists?(file_path)
|
|
71
|
-
inject_into_class file_path, model_name.classify do
|
|
72
|
-
"\n if Blacklight::Utils.needs_attr_accessible?\n" +
|
|
73
|
-
"\n attr_accessible :email, :password, :password_confirmation" +
|
|
74
|
-
"\n end\n" +
|
|
75
|
-
"# Connects this user object to Blacklights Bookmarks. " +
|
|
76
|
-
"\n include Blacklight::User\n"
|
|
77
|
-
end
|
|
78
|
-
else
|
|
79
|
-
say_status("warning", "Blacklight authenticated user functionality not installed, as a user model could not be found at /app/models/user.rb. If you used a different name, please re-run the migration and provide that name as an argument. Such as `rails -g blacklight client`", :yellow)
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def create_solr_document
|
|
84
|
-
copy_file "solr_document.rb", "app/models/solr_document.rb"
|
|
85
|
-
end
|
|
86
|
-
|
|
87
27
|
end
|
|
88
28
|
end
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
|
2
|
-
|
|
3
|
-
class CatalogController < ApplicationController
|
|
2
|
+
class <%= controller_name.classify %>Controller < ApplicationController
|
|
4
3
|
|
|
5
4
|
include Blacklight::Catalog
|
|
6
5
|
|
|
7
6
|
configure_blacklight do |config|
|
|
8
|
-
## Default parameters to send to solr for all search-like requests. See also
|
|
7
|
+
## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
|
|
9
8
|
config.default_solr_params = {
|
|
10
9
|
:qt => 'search',
|
|
11
10
|
:rows => 10
|
|
@@ -17,7 +16,7 @@ class CatalogController < ApplicationController
|
|
|
17
16
|
# items to show per page, each number in the array represent another option to choose from.
|
|
18
17
|
#config.per_page = [10,20,50,100]
|
|
19
18
|
|
|
20
|
-
## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see
|
|
19
|
+
## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SearchHelper#solr_doc_params) or
|
|
21
20
|
## parameters included in the Blacklight-jetty document requestHandler.
|
|
22
21
|
#
|
|
23
22
|
#config.default_document_solr_params = {
|
|
@@ -11,8 +11,11 @@
|
|
|
11
11
|
# how to start up solr, generally for automated testing.
|
|
12
12
|
|
|
13
13
|
development:
|
|
14
|
+
adapter: solr
|
|
14
15
|
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
|
|
15
16
|
test: &test
|
|
17
|
+
adapter: solr
|
|
16
18
|
url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8888}/solr/blacklight-core" %>
|
|
17
19
|
production:
|
|
20
|
+
adapter: solr
|
|
18
21
|
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
|