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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1463e41c998a83ef595ee4dafe4a390d5cd90be
|
4
|
+
data.tar.gz: a9b62fea9a0454a432ac5ecd95e8f8952438da5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b6f5e61c7ed3faf05c151ff3915fe48fedac1be2edb2b9f0deae5879265118e8d1f7b961541915a54b41ac2098cea36fb1d4c5d77eaf125360c60a17721b5b
|
7
|
+
data.tar.gz: 54d4dc8f7f4fe286dd0ec6faae2c73e95e1e7fb644f6418d3cf6b52de96cd7cacc84c5baa5e6ce65472f507c4548d83f38a3d884134bf5e0047fda2f69be42dd
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -16,9 +16,3 @@ notifications:
|
|
16
16
|
- blacklight-commits@googlegroups.com
|
17
17
|
|
18
18
|
env: JRUBY_OPTS="-J-Xms512m -J-Xmx1024m"
|
19
|
-
# jruby + rails 4.0.0 don't work well together
|
20
|
-
# jruby and rails 3.2.14 don't work well together either:
|
21
|
-
# https://github.com/rails/rails/issues/11595
|
22
|
-
matrix:
|
23
|
-
allow_failures:
|
24
|
-
- rvm: jruby-19mode
|
data/Gemfile
CHANGED
@@ -8,7 +8,12 @@ gem 'simplecov-rcov', :platform => :mri
|
|
8
8
|
|
9
9
|
group :test do
|
10
10
|
gem 'devise'
|
11
|
+
gem 'devise-guests'
|
12
|
+
gem "bootstrap-sass"
|
13
|
+
gem 'turbolinks'
|
14
|
+
gem "unicode", :platforms => [:mri_18, :mri_19]
|
11
15
|
end
|
16
|
+
|
12
17
|
if File.exists?('spec/test_app_templates/Gemfile.extra')
|
13
18
|
eval File.read('spec/test_app_templates/Gemfile.extra'), nil, 'spec/test_app_templates/Gemfile.extra'
|
14
19
|
end
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Blacklight
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/projectblacklight/blacklight.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight)
|
3
|
+
[![Build Status](https://travis-ci.org/projectblacklight/blacklight.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight) [![Gem Version](https://badge.fury.io/rb/blacklight.png)](http://badge.fury.io/rb/blacklight)
|
4
4
|
|
5
5
|
Blacklight is an open source Solr user interface discovery platform.
|
6
6
|
You can use Blacklight to enable searching and browsing of your collections.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.4.0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//= require blacklight/core
|
2
|
+
(function($) {
|
3
|
+
Blacklight.do_search_autofocus_fallback = function() {
|
4
|
+
if (typeof Modernizer != "undefined") {
|
5
|
+
if (Modernizr.autofocus) {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
$('input[autofocus]').focus();
|
11
|
+
}
|
12
|
+
|
13
|
+
Blacklight.onLoad(function() {
|
14
|
+
Blacklight.do_search_autofocus_fallback();
|
15
|
+
});
|
16
|
+
})(jQuery);
|
@@ -5,6 +5,7 @@
|
|
5
5
|
//
|
6
6
|
// These javascript files are compiled in via the Rails asset pipeline:
|
7
7
|
//= require blacklight/core
|
8
|
+
//= require blacklight/autofocus
|
8
9
|
//= require blacklight/bookmark_toggle
|
9
10
|
//= require blacklight/facet_expand_contract
|
10
11
|
//= require blacklight/lightbox_dialog
|
@@ -3,17 +3,14 @@
|
|
3
3
|
(function($) {
|
4
4
|
//change form submit toggle to checkbox
|
5
5
|
Blacklight.do_bookmark_toggle_behavior = function() {
|
6
|
-
$(Blacklight.do_bookmark_toggle_behavior.selector).bl_checkbox_submit({
|
7
|
-
checked_label: "In Bookmarks",
|
8
|
-
unchecked_label: "Bookmark",
|
9
|
-
progress_label: "Saving...",
|
6
|
+
$(Blacklight.do_bookmark_toggle_behavior.selector).bl_checkbox_submit({
|
10
7
|
//css_class is added to elements added, plus used for id base
|
11
8
|
css_class: "toggle_bookmark"
|
12
9
|
});
|
13
10
|
};
|
14
11
|
Blacklight.do_bookmark_toggle_behavior.selector = "form.bookmark_toggle";
|
15
12
|
|
16
|
-
|
13
|
+
Blacklight.onLoad(function() {
|
17
14
|
Blacklight.do_bookmark_toggle_behavior();
|
18
15
|
});
|
19
16
|
|
@@ -70,10 +70,10 @@
|
|
70
70
|
//Set the Rails hidden field that fakes an HTTP verb
|
71
71
|
//properly for current state action.
|
72
72
|
form.find("input[name=_method]").val("delete");
|
73
|
-
span.text(
|
73
|
+
span.text(form.attr('data-present'));
|
74
74
|
} else {
|
75
75
|
form.find("input[name=_method]").val("put");
|
76
|
-
span.text(
|
76
|
+
span.text(form.attr('data-absent'));
|
77
77
|
}
|
78
78
|
}
|
79
79
|
|
@@ -81,7 +81,7 @@
|
|
81
81
|
update_state_for(checked);
|
82
82
|
|
83
83
|
checkbox.click(function() {
|
84
|
-
span.text(
|
84
|
+
span.text(form.attr('data-inprogress'));
|
85
85
|
label.attr("disabled", "disabled");
|
86
86
|
checkbox.attr("disabled", "disabled");
|
87
87
|
|
@@ -123,9 +123,6 @@
|
|
123
123
|
};
|
124
124
|
|
125
125
|
$.fn.bl_checkbox_submit.defaults = {
|
126
|
-
checked_label: "",
|
127
|
-
unchecked_label: "",
|
128
|
-
progress_label: "Saving...",
|
129
126
|
//css_class is added to elements added, plus used for id base
|
130
127
|
css_class: "bl_checkbox_submit",
|
131
128
|
success: function() {} //callback
|
@@ -1 +1,24 @@
|
|
1
|
-
Blacklight = {
|
1
|
+
Blacklight = function() {
|
2
|
+
var buffer = new Array;
|
3
|
+
return {
|
4
|
+
onLoad: function(func) {
|
5
|
+
buffer.push(func);
|
6
|
+
},
|
7
|
+
|
8
|
+
activate: function() {
|
9
|
+
for(var i = 0; i < buffer.length; i++) {
|
10
|
+
buffer[i].call();
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}();
|
15
|
+
|
16
|
+
if (typeof Turbolinks !== "undefined") {
|
17
|
+
$(document).on('page:load', function() {
|
18
|
+
Blacklight.activate();
|
19
|
+
});
|
20
|
+
}
|
21
|
+
$(document).ready(function() {
|
22
|
+
Blacklight.activate();
|
23
|
+
});
|
24
|
+
|
@@ -33,8 +33,9 @@ Blacklight.do_facet_expand_contract_behavior = function() {
|
|
33
33
|
});
|
34
34
|
});
|
35
35
|
};
|
36
|
-
|
37
|
-
Blacklight.
|
38
|
-
|
36
|
+
|
37
|
+
Blacklight.onLoad(function() {
|
38
|
+
Blacklight.do_facet_expand_contract_behavior();
|
39
|
+
});
|
39
40
|
})(jQuery);
|
40
41
|
|
@@ -1,5 +1,11 @@
|
|
1
1
|
//= require blacklight/core
|
2
2
|
Blacklight.setup_modal = function(link_selector, form_selector, launch_modal) {
|
3
|
+
|
4
|
+
// Event indicating blacklight is setting up a modal link
|
5
|
+
var e = $.Event('lightbox.setup_modal');
|
6
|
+
$(link_selector).trigger(e);
|
7
|
+
if (e.isDefaultPrevented()) return;
|
8
|
+
|
3
9
|
$(link_selector).click(function(e) {
|
4
10
|
link = $(this)
|
5
11
|
|
@@ -59,6 +65,6 @@ Blacklight.check_close_ajax_modal = function() {
|
|
59
65
|
|
60
66
|
}
|
61
67
|
|
62
|
-
|
68
|
+
Blacklight.onLoad(function() {
|
63
69
|
Blacklight.setup_modal("a.lightboxLink,a.more_facets_link,.ajax_modal_launch", "#ajax-modal form.ajax_form", true);
|
64
70
|
});
|
@@ -17,6 +17,7 @@ $btnInfoBackground: #9ad0fe;
|
|
17
17
|
@import "blacklight/header";
|
18
18
|
@import "blacklight/footer";
|
19
19
|
@import "blacklight/catalog";
|
20
|
+
@import "blacklight/group";
|
20
21
|
@import "blacklight/bookmark";
|
21
22
|
@import "blacklight/facets";
|
22
23
|
@import "blacklight/search_history";
|
@@ -12,8 +12,8 @@ class BookmarksController < CatalogController
|
|
12
12
|
|
13
13
|
# Blacklight uses #search_action_url to figure out the right URL for
|
14
14
|
# the global search box
|
15
|
-
def search_action_url
|
16
|
-
catalog_index_url
|
15
|
+
def search_action_url *args
|
16
|
+
catalog_index_url *args
|
17
17
|
end
|
18
18
|
helper_method :search_action_url
|
19
19
|
|
@@ -74,8 +74,8 @@ module Blacklight::BlacklightHelperBehavior
|
|
74
74
|
render :partial=>'catalog/search_form'
|
75
75
|
end
|
76
76
|
|
77
|
-
def search_action_url
|
78
|
-
catalog_index_url
|
77
|
+
def search_action_url *args
|
78
|
+
catalog_index_url *args
|
79
79
|
end
|
80
80
|
|
81
81
|
def extra_body_classes
|
@@ -186,21 +186,9 @@ module Blacklight::BlacklightHelperBehavior
|
|
186
186
|
document = args.shift || options[:document]
|
187
187
|
|
188
188
|
field = args.shift || options[:field]
|
189
|
-
value = options[:value]
|
190
|
-
|
191
|
-
|
192
189
|
field_config = index_fields(document)[field]
|
190
|
+
value = options[:value] || get_field_values(document, field, field_config, options)
|
193
191
|
|
194
|
-
value ||= case
|
195
|
-
when value
|
196
|
-
value
|
197
|
-
when (field_config and field_config.helper_method)
|
198
|
-
send(field_config.helper_method, options.merge(:document => document, :field => field))
|
199
|
-
when (field_config and field_config.highlight)
|
200
|
-
document.highlight_field(field_config.field).map { |x| x.html_safe } if document.has_highlight_field? field_config.field
|
201
|
-
else
|
202
|
-
document.get(field, :sep => nil) if field
|
203
|
-
end
|
204
192
|
|
205
193
|
render_field_value value
|
206
194
|
end
|
@@ -322,23 +310,39 @@ module Blacklight::BlacklightHelperBehavior
|
|
322
310
|
document = args.shift || options[:document]
|
323
311
|
|
324
312
|
field = args.shift || options[:field]
|
325
|
-
value = options[:value]
|
326
|
-
|
327
|
-
|
328
313
|
field_config = document_show_fields(document)[field]
|
314
|
+
value = options[:value] || get_field_values(document, field, field_config, options)
|
315
|
+
|
316
|
+
render_field_value value
|
317
|
+
end
|
329
318
|
|
330
|
-
|
331
|
-
|
332
|
-
|
319
|
+
##
|
320
|
+
# Get the value of a document's field after applying any value lookups, e.g.:
|
321
|
+
# - helper_method
|
322
|
+
# - link_to_search
|
323
|
+
# - highlight
|
324
|
+
# TODO : maybe this should be merged with render_field_value, and the ugly signature
|
325
|
+
# simplified by pushing some of this logic into the "model"
|
326
|
+
def get_field_values document, field, field_config, options = {}
|
327
|
+
|
328
|
+
case
|
333
329
|
when (field_config and field_config.helper_method)
|
334
330
|
send(field_config.helper_method, options.merge(:document => document, :field => field))
|
331
|
+
when (field_config and field_config.link_to_search)
|
332
|
+
link_field = if field_config.link_to_search === true
|
333
|
+
field_config.field
|
334
|
+
else
|
335
|
+
field_config.link_to_search
|
336
|
+
end
|
337
|
+
|
338
|
+
Array(document.get(field, :sep => nil)).map do |v|
|
339
|
+
link_to render_field_value(v), search_action_url(add_facet_params(link_field, v, {}))
|
340
|
+
end if field
|
335
341
|
when (field_config and field_config.highlight)
|
336
342
|
document.highlight_field(field_config.field).map { |x| x.html_safe } if document.has_highlight_field? field_config.field
|
337
343
|
else
|
338
344
|
document.get(field, :sep => nil) if field
|
339
345
|
end
|
340
|
-
|
341
|
-
render_field_value value
|
342
346
|
end
|
343
347
|
|
344
348
|
def should_render_show_field? document, solr_field
|
@@ -533,9 +537,10 @@ module Blacklight::BlacklightHelperBehavior
|
|
533
537
|
|
534
538
|
my_params.reject! { |k,v| v.nil? }
|
535
539
|
|
536
|
-
# removing action and
|
540
|
+
# removing action, controller, and id from duplicate params so that we don't get hidden fields for them.
|
537
541
|
my_params.delete(:action)
|
538
542
|
my_params.delete(:controller)
|
543
|
+
my_params.delete(:id)
|
539
544
|
# commit is just an artifact of submit button, we don't need it, and
|
540
545
|
# don't want it to pile up with another every time we press submit again!
|
541
546
|
my_params.delete(:commit)
|
@@ -603,5 +608,17 @@ module Blacklight::BlacklightHelperBehavior
|
|
603
608
|
val
|
604
609
|
end
|
605
610
|
|
611
|
+
##
|
612
|
+
# Should we render a grouped response (because the response
|
613
|
+
# contains a grouped response instead of the normal response)
|
614
|
+
def render_grouped_response?
|
615
|
+
return @response.grouped?
|
616
|
+
end
|
617
|
+
|
618
|
+
##
|
619
|
+
# Render the grouped response
|
620
|
+
def render_grouped_document_index grouped_key = nil
|
621
|
+
render :partial => 'catalog/group_default'
|
622
|
+
end
|
606
623
|
|
607
624
|
end
|
@@ -5,28 +5,7 @@ module Blacklight::CatalogHelperBehavior
|
|
5
5
|
# it translates to a Kaminari-paginatable
|
6
6
|
# object, with the keys Kaminari views expect.
|
7
7
|
def paginate_params(response)
|
8
|
-
|
9
|
-
per_page = response.rows
|
10
|
-
per_page = 1 if per_page < 1
|
11
|
-
|
12
|
-
current_page = (response.start / per_page).ceil + 1
|
13
|
-
num_pages = (response.total / per_page.to_f).ceil
|
14
|
-
|
15
|
-
total_count = response.total
|
16
|
-
|
17
|
-
start_num = response.start + 1
|
18
|
-
end_num = start_num + response.docs.length - 1
|
19
|
-
|
20
|
-
OpenStruct.new(:start => start_num,
|
21
|
-
:end => end_num,
|
22
|
-
:per_page => per_page,
|
23
|
-
:current_page => current_page,
|
24
|
-
:num_pages => num_pages,
|
25
|
-
:limit_value => per_page, # backwards compatibility
|
26
|
-
:total_count => total_count,
|
27
|
-
:first_page? => current_page > 1,
|
28
|
-
:last_page? => current_page < num_pages
|
29
|
-
)
|
8
|
+
response
|
30
9
|
end
|
31
10
|
|
32
11
|
# Equivalent to kaminari "paginate", but takes an RSolr::Response as first argument.
|
@@ -35,8 +14,7 @@ module Blacklight::CatalogHelperBehavior
|
|
35
14
|
# kaminari paginate, passed on through.
|
36
15
|
# will output HTML pagination controls.
|
37
16
|
def paginate_rsolr_response(response, options = {}, &block)
|
38
|
-
|
39
|
-
paginate Kaminari.paginate_array(response.docs, :total_count => pagination_info.total_count).page(pagination_info.current_page).per(pagination_info.per_page), options, &block
|
17
|
+
paginate response, options, &block
|
40
18
|
end
|
41
19
|
|
42
20
|
#
|
@@ -47,21 +25,31 @@ module Blacklight::CatalogHelperBehavior
|
|
47
25
|
#
|
48
26
|
# Pass in an RSolr::Response. Displays the "showing X through Y of N" message.
|
49
27
|
def render_pagination_info(response, options = {})
|
50
|
-
pagination_info = paginate_params(response)
|
51
|
-
|
52
28
|
# TODO: i18n the entry_name
|
53
29
|
entry_name = options[:entry_name]
|
54
30
|
entry_name ||= response.docs.first.class.name.underscore.sub('_', ' ') unless response.docs.empty?
|
55
31
|
entry_name ||= t('blacklight.entry_name.default')
|
56
32
|
|
57
33
|
|
58
|
-
|
34
|
+
end_num = if render_grouped_response?
|
35
|
+
format_num(response.start + response.groups.length)
|
36
|
+
else
|
37
|
+
format_num(response.start + response.docs.length)
|
38
|
+
end
|
39
|
+
|
40
|
+
case response.total_count
|
59
41
|
when 0; t('blacklight.search.pagination_info.no_items_found', :entry_name => entry_name.pluralize ).html_safe
|
60
42
|
when 1; t('blacklight.search.pagination_info.single_item_found', :entry_name => entry_name).html_safe
|
61
|
-
else; t('blacklight.search.pagination_info.pages', :entry_name => entry_name.pluralize, :current_page =>
|
43
|
+
else; t('blacklight.search.pagination_info.pages', :entry_name => entry_name.pluralize, :current_page => response.current_page, :num_pages => response.total_pages, :start_num => format_num(response.start + 1) , :end_num => end_num, :total_num => response.total_count, :count => response.total_pages).html_safe
|
62
44
|
end
|
63
45
|
end
|
64
46
|
|
47
|
+
def document_counter_with_offset idx
|
48
|
+
unless render_grouped_response?
|
49
|
+
idx + 1 + @response.params[:start].to_i
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
65
53
|
# Like #render_pagination_info above, but for an individual
|
66
54
|
# item show page. Displays "showing X of Y items" message. Actually takes
|
67
55
|
# data from session though (not a great design).
|
@@ -107,4 +95,36 @@ module Blacklight::CatalogHelperBehavior
|
|
107
95
|
response.total > 1
|
108
96
|
end
|
109
97
|
|
98
|
+
def should_autofocus_on_search_box?
|
99
|
+
controller.is_a? Blacklight::Catalog and
|
100
|
+
action_name == "index" and
|
101
|
+
params[:q].to_s.empty? and
|
102
|
+
params[:f].to_s.empty?
|
103
|
+
end
|
104
|
+
|
105
|
+
def has_thumbnail? document
|
106
|
+
blacklight_config.index.thumbnail_method or
|
107
|
+
blacklight_config.index.thumbnail_field && document.has_field?(blacklight_config.index.thumbnail_field)
|
108
|
+
end
|
109
|
+
|
110
|
+
def render_thumbnail_tag document, image_options = {}, url_options = {}
|
111
|
+
value = if blacklight_config.index.thumbnail_method
|
112
|
+
send(blacklight_config.index.thumbnail_method, document, image_options)
|
113
|
+
elsif blacklight_config.index.thumbnail_field
|
114
|
+
image_tag thumbnail_url(document), image_options
|
115
|
+
end
|
116
|
+
|
117
|
+
if value
|
118
|
+
link_to_document document, url_options.merge(:label => value)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def thumbnail_url document
|
123
|
+
document.get(blacklight_config.index.thumbnail_field, :sep => nil).first if document.has_field?(blacklight_config.index.thumbnail_field)
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_group_facet_params_and_redirect group
|
127
|
+
add_facet_params_and_redirect(group.field, group.key)
|
128
|
+
end
|
129
|
+
|
110
130
|
end
|