blacklight 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +0 -6
- data/Gemfile +5 -0
- data/README.md +1 -1
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/autofocus.js +16 -0
- data/app/assets/javascripts/blacklight/blacklight.js +1 -0
- data/app/assets/javascripts/blacklight/bookmark_toggle.js +2 -5
- data/app/assets/javascripts/blacklight/checkbox_submit.js +3 -6
- data/app/assets/javascripts/blacklight/core.js +24 -1
- data/app/assets/javascripts/blacklight/css_dropdowns.js +2 -2
- data/app/assets/javascripts/blacklight/facet_expand_contract.js +4 -3
- data/app/assets/javascripts/blacklight/lightbox_dialog.js +7 -1
- data/app/assets/javascripts/blacklight/search_context.js +1 -1
- data/app/assets/javascripts/blacklight/select_submit.js +1 -1
- data/app/assets/javascripts/blacklight/zebra_stripe.js +1 -1
- data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +5 -0
- data/app/assets/stylesheets/blacklight/_facets.css.scss +6 -0
- data/app/assets/stylesheets/blacklight/_group.css.scss +14 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +1 -0
- data/app/controllers/bookmarks_controller.rb +2 -2
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +41 -24
- data/app/helpers/blacklight/catalog_helper_behavior.rb +48 -28
- data/app/helpers/blacklight/facets_helper_behavior.rb +9 -75
- data/app/models/record_mailer.rb +1 -16
- data/app/views/bookmarks/index.html.erb +2 -0
- data/app/views/catalog/_bookmark_control.html.erb +3 -4
- data/app/views/catalog/_document.html.erb +2 -1
- data/app/views/catalog/_document_header.html.erb +6 -3
- data/app/views/catalog/_email_form.html.erb +0 -7
- data/app/views/catalog/_facet_layout.html.erb +1 -1
- data/app/views/catalog/_group_default.html.erb +12 -0
- data/app/views/catalog/_index_default.html.erb +1 -1
- data/app/views/catalog/_opensearch_response_metadata.html.erb +2 -3
- data/app/views/catalog/_paginate_compact.html.erb +2 -2
- data/app/views/catalog/_results_pagination.html.erb +2 -2
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/catalog/_sms_form.html.erb +1 -21
- data/app/views/catalog/_thumbnail_default.html.erb +5 -0
- data/app/views/catalog/email_sent.html.erb +9 -0
- data/app/views/catalog/index.atom.builder +7 -8
- data/app/views/catalog/index.html.erb +6 -3
- data/app/views/catalog/librarian_view.html.erb +1 -1
- data/app/views/catalog/sms_sent.html.erb +9 -0
- data/app/views/feedback/complete.html.erb +2 -0
- data/app/views/feedback/show.html.erb +7 -5
- data/app/views/kaminari/blacklight_compact/_paginator.html.erb +1 -1
- data/app/views/layouts/blacklight.html.erb +1 -2
- data/app/views/saved_searches/index.html.erb +2 -0
- data/app/views/search_history/index.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.en.yml +11 -0
- data/config/locales/blacklight.fr.yml +15 -1
- data/gemfiles/rails3.gemfile +7 -0
- data/gemfiles/rails4.gemfile +7 -0
- data/lib/blacklight.rb +1 -0
- data/lib/blacklight/catalog.rb +101 -56
- data/lib/blacklight/configuration.rb +1 -1
- data/lib/blacklight/controller.rb +7 -4
- data/lib/blacklight/facet.rb +79 -0
- data/lib/blacklight/routes.rb +0 -1
- data/lib/blacklight/solr/document.rb +4 -0
- data/lib/blacklight/solr/document/marc_export.rb +1 -1
- data/lib/blacklight/solr_helper.rb +39 -8
- data/lib/blacklight/solr_response.rb +35 -3
- data/lib/blacklight/solr_response/facets.rb +4 -0
- data/lib/blacklight/solr_response/group.rb +33 -0
- data/lib/blacklight/solr_response/group_response.rb +49 -0
- data/lib/blacklight/solr_response/pagination_methods.rb +27 -0
- data/lib/blacklight/user.rb +30 -32
- data/lib/generators/blacklight/assets_generator.rb +3 -1
- data/lib/generators/blacklight/blacklight_generator.rb +28 -125
- data/lib/generators/blacklight/marc_generator.rb +66 -0
- data/lib/generators/blacklight/models_generator.rb +113 -0
- data/lib/generators/blacklight/templates/alternate_controller.rb +9 -0
- data/lib/generators/blacklight/templates/config/solr.yml +0 -2
- data/lib/generators/blacklight/templates/solr_document.rb +1 -13
- data/lib/railties/all_tests.rake +5 -8
- data/spec/controllers/catalog_controller_spec.rb +185 -113
- data/spec/features/alternate_controller_spec.rb +34 -0
- data/spec/features/bookmarks_spec.rb +58 -0
- data/spec/features/did_you_mean_spec.rb +135 -0
- data/spec/features/librarian_view_spec.rb +13 -0
- data/spec/features/record_view_spec.rb +37 -0
- data/spec/features/saved_searches_spec.rb +47 -0
- data/spec/features/search_filters_spec.rb +137 -0
- data/spec/features/search_history_spec.rb +75 -0
- data/spec/features/search_pagination_spec.rb +91 -0
- data/spec/features/search_results_spec.rb +68 -0
- data/spec/features/search_sort_spec.rb +20 -0
- data/spec/features/search_spec.rb +108 -0
- data/spec/helpers/blacklight_helper_spec.rb +45 -2
- data/spec/helpers/catalog_helper_spec.rb +134 -1
- data/spec/helpers/facets_helper_spec.rb +8 -0
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +78 -0
- data/spec/lib/blacklight/solr_response/group_spec.rb +70 -0
- data/spec/lib/blacklight_solr_response_spec.rb +11 -5
- data/spec/lib/blacklight_user_spec.rb +22 -41
- data/spec/lib/solr_helper_spec.rb +73 -1
- data/spec/models/record_mailer_spec.rb +3 -3
- data/spec/models/{solr_docment_spec.rb → solr_document_spec.rb} +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/support/features.rb +7 -0
- data/spec/support/features/session_helpers.rb +22 -0
- data/spec/test_app_templates/Gemfile.extra +0 -4
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -6
- data/spec/test_app_templates/lib/tasks/blacklight_test_app.rake +1 -9
- data/spec/views/catalog/_facets.html.erb_spec.rb +2 -1
- data/tasks/blacklight.rake +0 -10
- metadata +49 -58
- data/features/bookmarks.feature +0 -68
- data/features/did_you_mean.feature +0 -123
- data/features/librarian_view.feature +0 -18
- data/features/record_view.feature +0 -40
- data/features/saved_searches.feature +0 -49
- data/features/search.feature +0 -83
- data/features/search_filters.feature +0 -119
- data/features/search_history.feature +0 -85
- data/features/search_pagination.feature +0 -53
- data/features/search_results.feature +0 -61
- data/features/search_sort.feature +0 -27
- data/features/step_definitions/bookmarks_steps.rb +0 -6
- data/features/step_definitions/error_steps.rb +0 -5
- data/features/step_definitions/general_steps.rb +0 -50
- data/features/step_definitions/record_view_steps.rb +0 -12
- data/features/step_definitions/saved_searches_steps.rb +0 -19
- data/features/step_definitions/search_facets_steps.rb +0 -29
- data/features/step_definitions/search_history_steps.rb +0 -9
- data/features/step_definitions/search_pagination_steps.rb +0 -29
- data/features/step_definitions/search_result_steps.rb +0 -115
- data/features/step_definitions/search_steps.rb +0 -118
- data/features/step_definitions/user_steps.rb +0 -5
- data/features/step_definitions/web_steps.rb +0 -217
- data/features/support/env.rb +0 -65
- data/features/support/paths.rb +0 -48
- data/features/support/selectors.rb +0 -40
- data/lib/railties/blacklight_cucumber.rake +0 -126
- data/lib/solrmarc.log.1 +0 -854
@@ -20,7 +20,9 @@ module Blacklight
|
|
20
20
|
copy_file "blacklight.css.scss", "app/assets/stylesheets/blacklight.css.scss"
|
21
21
|
|
22
22
|
unless IO.read("app/assets/javascripts/application.js").include?('blacklight/blacklight')
|
23
|
-
|
23
|
+
marker = IO.read("app/assets/javascripts/application.js").include?('turbolinks') ?
|
24
|
+
'//= require turbolinks' : "//= require jquery_ujs"
|
25
|
+
insert_into_file "app/assets/javascripts/application.js", :after => marker do
|
24
26
|
%q{
|
25
27
|
//
|
26
28
|
// Required by Blacklight
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'rails/generators'
|
3
|
-
require 'rails/generators/migration'
|
4
3
|
|
5
4
|
class BlacklightGenerator < Rails::Generators::Base
|
6
|
-
include Rails::Generators::Migration
|
7
5
|
|
8
6
|
source_root File.expand_path('../templates', __FILE__)
|
9
7
|
|
@@ -12,128 +10,46 @@ class BlacklightGenerator < Rails::Generators::Base
|
|
12
10
|
|
13
11
|
desc """
|
14
12
|
This generator makes the following changes to your application:
|
15
|
-
1.
|
16
|
-
2.
|
17
|
-
3.
|
18
|
-
4.
|
19
|
-
5.
|
20
|
-
|
21
|
-
7. Injects behavior into your user application_controller.rb
|
22
|
-
8. Injects behavior into your user model
|
23
|
-
9. Creates a blacklight catalog controller in your /app/controllers directory
|
24
|
-
10. Creates a blacklight document in your /app/models directory
|
25
|
-
11. Adds Blacklight routes to your ./config/routes.rb
|
26
|
-
12. Enables internationalization.
|
13
|
+
1. Generates blacklight:models
|
14
|
+
2. Creates a number of public assets, including images, stylesheets, and javascript
|
15
|
+
3. Injects behavior into your user application_controller.rb
|
16
|
+
4. Adds example configurations for dealing with MARC-like data
|
17
|
+
5. Adds Blacklight routes to your ./config/routes.rb
|
18
|
+
|
27
19
|
|
28
20
|
Thank you for Installing Blacklight.
|
29
21
|
"""
|
30
22
|
|
31
|
-
# Implement the required interface for Rails::Generators::Migration.
|
32
|
-
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
33
|
-
def self.next_migration_number(path)
|
34
|
-
unless @prev_migration_nr
|
35
|
-
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
36
|
-
else
|
37
|
-
@prev_migration_nr += 1
|
38
|
-
end
|
39
|
-
@prev_migration_nr.to_s
|
40
|
-
end
|
41
|
-
|
42
|
-
def check_arguments
|
43
|
-
if File.exists?("app/models/#{model_name}.rb") and options[:devise]
|
44
|
-
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."
|
45
|
-
exit
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
# Content types used by Marc Document extension, possibly among others.
|
51
|
-
# Registering a unique content type with 'register' (rather than
|
52
|
-
# register_alias) will allow content-negotiation for the format.
|
53
|
-
def add_mime_types
|
54
|
-
puts "Updating Mime Types"
|
55
|
-
insert_into_file "config/initializers/mime_types.rb", :after => "# Be sure to restart your server when you modify this file." do <<EOF
|
56
|
-
Mime::Type.register_alias "text/plain", :refworks_marc_txt
|
57
|
-
Mime::Type.register_alias "text/plain", :openurl_kev
|
58
|
-
Mime::Type.register "application/x-endnote-refer", :endnote
|
59
|
-
Mime::Type.register "application/marc", :marc
|
60
|
-
Mime::Type.register "application/marcxml+xml", :marcxml,
|
61
|
-
["application/x-marc+xml", "application/x-marcxml+xml",
|
62
|
-
"application/marc+xml"]
|
63
|
-
EOF
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
23
|
def add_unicode_gem
|
68
24
|
gem "unicode", :platforms => [:mri_18, :mri_19] unless defined?(:RUBY_VERSION) and RUBY_VERSION == '2.0.0'
|
69
25
|
end
|
70
26
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
gem "devise-guests", "~> 0.3"
|
27
|
+
def add_bootstrap_gem
|
28
|
+
# Don't need a version here, because we specify the version in blacklight.gemspec
|
29
|
+
gem 'bootstrap-sass'
|
30
|
+
end
|
76
31
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
generate "devise:install"
|
82
|
-
generate "devise", model_name.classify
|
83
|
-
generate "devise_guests", model_name.classify
|
84
|
-
generate "devise:views"
|
85
|
-
|
86
|
-
# add the #to_s to the model.
|
87
|
-
insert_into_file("app/models/#{model_name}.rb", :before => /end(\n| )*$/) do
|
88
|
-
%{
|
89
|
-
# Method added by Blacklight; Blacklight uses #to_s on your
|
90
|
-
# user class to get a user-displayable login/identifier for
|
91
|
-
# the account.
|
92
|
-
def to_s
|
93
|
-
email
|
94
|
-
end
|
95
|
-
}
|
96
|
-
end
|
97
|
-
gsub_file("config/initializers/devise.rb", "config.sign_out_via = :delete", "config.sign_out_via = :get")
|
32
|
+
def bundle_install
|
33
|
+
Bundler.with_clean_env do
|
34
|
+
run "bundle install"
|
98
35
|
end
|
99
36
|
end
|
100
37
|
|
101
|
-
# Copy all files in templates/config directory to host config
|
102
|
-
def create_configuration_files
|
103
|
-
copy_file "config/solr.yml", "config/solr.yml"
|
104
|
-
copy_file "config/jetty.yml", "config/jetty.yml"
|
105
|
-
directory("config/SolrMarc")
|
106
|
-
end
|
107
|
-
|
108
38
|
# Copy all files in templates/public/ directory to public/
|
109
39
|
# Call external generator in AssetsGenerator, so we can
|
110
40
|
# leave that callable seperately too.
|
111
41
|
def copy_public_assets
|
112
42
|
generate "blacklight:assets"
|
113
43
|
end
|
114
|
-
|
115
|
-
# Setup the database migrations
|
116
|
-
def copy_migrations
|
117
|
-
# Can't get this any more DRY, because we need this order.
|
118
|
-
better_migration_template "create_searches.rb"
|
119
|
-
better_migration_template "create_bookmarks.rb"
|
120
|
-
better_migration_template "remove_editable_fields_from_bookmarks.rb"
|
121
|
-
better_migration_template "add_user_types_to_bookmarks_searches.rb"
|
122
|
-
end
|
123
44
|
|
45
|
+
def generate_blacklight_models
|
124
46
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
"# Connects this user object to Blacklights Bookmarks. " +
|
132
|
-
"\n include Blacklight::User\n"
|
133
|
-
end
|
134
|
-
else
|
135
|
-
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)
|
136
|
-
end
|
47
|
+
generator_args = []
|
48
|
+
if options[:devise]
|
49
|
+
generator_args << "--devise #{options[:devise]}"
|
50
|
+
end
|
51
|
+
|
52
|
+
generate 'blacklight:models', generator_args.join(" ")
|
137
53
|
end
|
138
54
|
|
139
55
|
# Add Blacklight to the application controller
|
@@ -148,10 +64,14 @@ EOF
|
|
148
64
|
end
|
149
65
|
end
|
150
66
|
|
151
|
-
#
|
152
|
-
def
|
153
|
-
|
154
|
-
|
67
|
+
# TODO
|
68
|
+
# def generate_stub_catalog_controller
|
69
|
+
## see blacklight:marc generator
|
70
|
+
##copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
|
71
|
+
#end
|
72
|
+
|
73
|
+
def generate_blacklight_marc_demo
|
74
|
+
generate 'blacklight:marc'
|
155
75
|
end
|
156
76
|
|
157
77
|
def inject_blacklight_routes
|
@@ -174,22 +94,5 @@ EOF
|
|
174
94
|
|
175
95
|
end
|
176
96
|
|
177
|
-
def add_bootstrap_gem
|
178
|
-
# Don't need a version here, because we specify the version in blacklight.gemspec
|
179
|
-
gem 'bootstrap-sass'
|
180
|
-
end
|
181
|
-
|
182
|
-
|
183
|
-
private
|
184
|
-
|
185
|
-
def better_migration_template (file)
|
186
|
-
begin
|
187
|
-
migration_template "migrations/#{file}", "db/migrate/#{file}"
|
188
|
-
sleep 1 # ensure scripts have different time stamps
|
189
|
-
rescue
|
190
|
-
puts " \e[1m\e[34mMigrations\e[0m " + $!.message
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
97
|
end
|
195
98
|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
class MarcGenerator < Rails::Generators::Base
|
5
|
+
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
desc """
|
9
|
+
1. Adds additional mime types to you application in the file '/config/initializers/mime_types.rb'
|
10
|
+
2. Creates config/SolrMarc/... with settings for SolrMarc
|
11
|
+
3. Creates a CatalogController with some some demo fields for MARC-like data
|
12
|
+
4. Injects MARC-specific behaviors into the SolrDocument
|
13
|
+
"""
|
14
|
+
|
15
|
+
# Content types used by Marc Document extension, possibly among others.
|
16
|
+
# Registering a unique content type with 'register' (rather than
|
17
|
+
# register_alias) will allow content-negotiation for the format.
|
18
|
+
def add_mime_types
|
19
|
+
puts "Updating Mime Types"
|
20
|
+
insert_into_file "config/initializers/mime_types.rb", :after => "# Be sure to restart your server when you modify this file." do <<EOF
|
21
|
+
Mime::Type.register_alias "text/plain", :refworks_marc_txt
|
22
|
+
Mime::Type.register_alias "text/plain", :openurl_kev
|
23
|
+
Mime::Type.register "application/x-endnote-refer", :endnote
|
24
|
+
Mime::Type.register "application/marc", :marc
|
25
|
+
Mime::Type.register "application/marcxml+xml", :marcxml,
|
26
|
+
["application/x-marc+xml", "application/x-marcxml+xml",
|
27
|
+
"application/marc+xml"]
|
28
|
+
EOF
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Copy all files in templates/config directory to host config
|
33
|
+
def create_configuration_files
|
34
|
+
directory("config/SolrMarc")
|
35
|
+
end
|
36
|
+
|
37
|
+
# Generate blacklight catalog controller
|
38
|
+
def create_blacklight_catalog
|
39
|
+
copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
|
40
|
+
end
|
41
|
+
|
42
|
+
# add MARC-specific extensions to the solr document
|
43
|
+
def add_marc_extension_to_solrdocument
|
44
|
+
|
45
|
+
insert_into_file "app/models/solr_document.rb", :after => "include Blacklight::Solr::Document" do <<EOF
|
46
|
+
|
47
|
+
# The following shows how to setup this blacklight document to display marc documents
|
48
|
+
extension_parameters[:marc_source_field] = :marc_display
|
49
|
+
extension_parameters[:marc_format_type] = :marcxml
|
50
|
+
use_extension( Blacklight::Solr::Document::Marc) do |document|
|
51
|
+
document.key?( :marc_display )
|
52
|
+
end
|
53
|
+
|
54
|
+
field_semantics.merge!(
|
55
|
+
:title => "title_display",
|
56
|
+
:author => "author_display",
|
57
|
+
:language => "language_facet",
|
58
|
+
:format => "format"
|
59
|
+
)
|
60
|
+
|
61
|
+
EOF
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Blacklight
|
5
|
+
class ModelsGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
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
|
+
desc """
|
14
|
+
This generator makes the following changes to your application:
|
15
|
+
1. Creates several database migrations if they do not exist in /db/migrate
|
16
|
+
2. Creates config/solr.yml with a default solr configuration
|
17
|
+
3. Injects behavior into your user model
|
18
|
+
4. Creates a blacklight document in your /app/models directory
|
19
|
+
"""
|
20
|
+
# Implement the required interface for Rails::Generators::Migration.
|
21
|
+
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
22
|
+
def self.next_migration_number(path)
|
23
|
+
if @prev_migration_nr
|
24
|
+
@prev_migration_nr += 1
|
25
|
+
else
|
26
|
+
if last_migration = Dir[File.join(path, '*.rb')].sort.last
|
27
|
+
@prev_migration_nr = last_migration.sub(File.join(path, '/'), '').to_i + 1
|
28
|
+
else
|
29
|
+
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
30
|
+
end
|
31
|
+
end
|
32
|
+
@prev_migration_nr.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_arguments
|
36
|
+
if File.exists?("app/models/#{model_name}.rb") and options[:devise]
|
37
|
+
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."
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Install Devise?
|
43
|
+
def generate_devise_assets
|
44
|
+
if options[:devise]
|
45
|
+
gem "devise"
|
46
|
+
gem "devise-guests", "~> 0.3"
|
47
|
+
|
48
|
+
Bundler.with_clean_env do
|
49
|
+
run "bundle install"
|
50
|
+
end
|
51
|
+
|
52
|
+
generate "devise:install"
|
53
|
+
generate "devise", model_name.classify
|
54
|
+
generate "devise_guests", model_name.classify
|
55
|
+
|
56
|
+
# add the #to_s to the model.
|
57
|
+
insert_into_file("app/models/#{model_name}.rb", :before => /end(\n| )*$/) do
|
58
|
+
%{
|
59
|
+
# Method added by Blacklight; Blacklight uses #to_s on your
|
60
|
+
# user class to get a user-displayable login/identifier for
|
61
|
+
# the account.
|
62
|
+
def to_s
|
63
|
+
email
|
64
|
+
end
|
65
|
+
}
|
66
|
+
end
|
67
|
+
gsub_file("config/initializers/devise.rb", "config.sign_out_via = :delete", "config.sign_out_via = :get")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Copy all files in templates/config directory to host config
|
72
|
+
def create_configuration_files
|
73
|
+
copy_file "config/solr.yml", "config/solr.yml"
|
74
|
+
copy_file "config/jetty.yml", "config/jetty.yml"
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# Setup the database migrations
|
79
|
+
def copy_migrations
|
80
|
+
# Can't get this any more DRY, because we need this order.
|
81
|
+
better_migration_template "create_searches.rb"
|
82
|
+
better_migration_template "create_bookmarks.rb"
|
83
|
+
better_migration_template "remove_editable_fields_from_bookmarks.rb"
|
84
|
+
better_migration_template "add_user_types_to_bookmarks_searches.rb"
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
# Add Blacklight to the user model
|
89
|
+
def inject_blacklight_user_behavior
|
90
|
+
file_path = "app/models/#{model_name.underscore}.rb"
|
91
|
+
if File.exists?(file_path)
|
92
|
+
inject_into_class file_path, model_name.classify do
|
93
|
+
"\n attr_accessible :email, :password, :password_confirmation if Rails::VERSION::MAJOR < 4\n" +
|
94
|
+
"# Connects this user object to Blacklights Bookmarks. " +
|
95
|
+
"\n include Blacklight::User\n"
|
96
|
+
end
|
97
|
+
else
|
98
|
+
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)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def create_solr_document
|
103
|
+
copy_file "solr_document.rb", "app/models/solr_document.rb"
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def better_migration_template(file)
|
109
|
+
migration_template "migrations/#{file}", "db/migrate/#{file}"
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
@@ -5,13 +5,6 @@ class SolrDocument
|
|
5
5
|
|
6
6
|
# self.unique_key = 'id'
|
7
7
|
|
8
|
-
# The following shows how to setup this blacklight document to display marc documents
|
9
|
-
extension_parameters[:marc_source_field] = :marc_display
|
10
|
-
extension_parameters[:marc_format_type] = :marcxml
|
11
|
-
use_extension( Blacklight::Solr::Document::Marc) do |document|
|
12
|
-
document.key?( :marc_display )
|
13
|
-
end
|
14
|
-
|
15
8
|
# Email uses the semantic field mappings below to generate the body of an email.
|
16
9
|
SolrDocument.use_extension( Blacklight::Solr::Document::Email )
|
17
10
|
|
@@ -24,10 +17,5 @@ class SolrDocument
|
|
24
17
|
# and Blacklight::Solr::Document#to_semantic_values
|
25
18
|
# Recommendation: Use field names from Dublin Core
|
26
19
|
use_extension( Blacklight::Solr::Document::DublinCore)
|
27
|
-
|
28
|
-
:title => "title_display",
|
29
|
-
:author => "author_display",
|
30
|
-
:language => "language_facet",
|
31
|
-
:format => "format"
|
32
|
-
)
|
20
|
+
|
33
21
|
end
|
data/lib/railties/all_tests.rake
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
namespace :blacklight do
|
2
2
|
begin
|
3
|
-
require 'cucumber/rake/task'
|
4
3
|
require 'rspec/core'
|
5
4
|
require 'rspec/core/rake_task'
|
6
5
|
|
7
|
-
desc "Run Blacklight
|
6
|
+
desc "Run Blacklight rspec, with test solr"
|
8
7
|
task :all_tests => :hudson
|
9
8
|
|
10
|
-
desc "Run Blacklight
|
9
|
+
desc "Run Blacklight rspec, with test solr"
|
11
10
|
task :hudson do
|
12
11
|
Rails.env = 'test' unless ENV['RAILS_ENV']
|
13
12
|
|
14
13
|
error = Jettywrapper.wrap(Jettywrapper.load_config) do
|
15
14
|
Rake::Task["blacklight:spec"].invoke
|
16
|
-
Rake::Task["blacklight:cucumber"].invoke
|
17
15
|
end
|
18
16
|
|
19
17
|
raise "test failures: #{error}" if error
|
@@ -21,22 +19,21 @@ namespace :blacklight do
|
|
21
19
|
|
22
20
|
namespace :all_tests do
|
23
21
|
task :rcov do
|
24
|
-
desc "Run Blacklight rspec
|
22
|
+
desc "Run Blacklight rspec tests with rcov"
|
25
23
|
|
26
24
|
rm "blacklight-coverage.data" if File.exist?("blacklight-coverage.data")
|
27
25
|
Rails.env = 'test' unless ENV['RAILS_ENV']
|
28
26
|
error = Jettywrapper.wrap(Jettywrapper.load_config) do
|
29
27
|
Rake::Task["blacklight:spec:rcov"].invoke
|
30
|
-
Rake::Task["blacklight:cucumber:rcov"].invoke
|
31
28
|
end
|
32
29
|
raise "test failures: #{error}" if error
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
36
33
|
rescue LoadError
|
37
|
-
desc "Not available! (
|
34
|
+
desc "Not available! (rspec not avail)"
|
38
35
|
task :all_tests do
|
39
|
-
abort 'Not available.
|
36
|
+
abort 'Not available. Rspec needs to be installed to run blacklight:all_tests'
|
40
37
|
end
|
41
38
|
end
|
42
39
|
end
|