blacklight 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +0 -6
  4. data/Gemfile +5 -0
  5. data/README.md +1 -1
  6. data/Rakefile +0 -1
  7. data/VERSION +1 -1
  8. data/app/assets/javascripts/blacklight/autofocus.js +16 -0
  9. data/app/assets/javascripts/blacklight/blacklight.js +1 -0
  10. data/app/assets/javascripts/blacklight/bookmark_toggle.js +2 -5
  11. data/app/assets/javascripts/blacklight/checkbox_submit.js +3 -6
  12. data/app/assets/javascripts/blacklight/core.js +24 -1
  13. data/app/assets/javascripts/blacklight/css_dropdowns.js +2 -2
  14. data/app/assets/javascripts/blacklight/facet_expand_contract.js +4 -3
  15. data/app/assets/javascripts/blacklight/lightbox_dialog.js +7 -1
  16. data/app/assets/javascripts/blacklight/search_context.js +1 -1
  17. data/app/assets/javascripts/blacklight/select_submit.js +1 -1
  18. data/app/assets/javascripts/blacklight/zebra_stripe.js +1 -1
  19. data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
  20. data/app/assets/stylesheets/blacklight/_catalog.css.scss +5 -0
  21. data/app/assets/stylesheets/blacklight/_facets.css.scss +6 -0
  22. data/app/assets/stylesheets/blacklight/_group.css.scss +14 -0
  23. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +1 -0
  24. data/app/controllers/bookmarks_controller.rb +2 -2
  25. data/app/helpers/blacklight/blacklight_helper_behavior.rb +41 -24
  26. data/app/helpers/blacklight/catalog_helper_behavior.rb +48 -28
  27. data/app/helpers/blacklight/facets_helper_behavior.rb +9 -75
  28. data/app/models/record_mailer.rb +1 -16
  29. data/app/views/bookmarks/index.html.erb +2 -0
  30. data/app/views/catalog/_bookmark_control.html.erb +3 -4
  31. data/app/views/catalog/_document.html.erb +2 -1
  32. data/app/views/catalog/_document_header.html.erb +6 -3
  33. data/app/views/catalog/_email_form.html.erb +0 -7
  34. data/app/views/catalog/_facet_layout.html.erb +1 -1
  35. data/app/views/catalog/_group_default.html.erb +12 -0
  36. data/app/views/catalog/_index_default.html.erb +1 -1
  37. data/app/views/catalog/_opensearch_response_metadata.html.erb +2 -3
  38. data/app/views/catalog/_paginate_compact.html.erb +2 -2
  39. data/app/views/catalog/_results_pagination.html.erb +2 -2
  40. data/app/views/catalog/_search_form.html.erb +1 -1
  41. data/app/views/catalog/_sms_form.html.erb +1 -21
  42. data/app/views/catalog/_thumbnail_default.html.erb +5 -0
  43. data/app/views/catalog/email_sent.html.erb +9 -0
  44. data/app/views/catalog/index.atom.builder +7 -8
  45. data/app/views/catalog/index.html.erb +6 -3
  46. data/app/views/catalog/librarian_view.html.erb +1 -1
  47. data/app/views/catalog/sms_sent.html.erb +9 -0
  48. data/app/views/feedback/complete.html.erb +2 -0
  49. data/app/views/feedback/show.html.erb +7 -5
  50. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +1 -1
  51. data/app/views/layouts/blacklight.html.erb +1 -2
  52. data/app/views/saved_searches/index.html.erb +2 -0
  53. data/app/views/search_history/index.html.erb +1 -1
  54. data/blacklight.gemspec +1 -1
  55. data/config/locales/blacklight.en.yml +11 -0
  56. data/config/locales/blacklight.fr.yml +15 -1
  57. data/gemfiles/rails3.gemfile +7 -0
  58. data/gemfiles/rails4.gemfile +7 -0
  59. data/lib/blacklight.rb +1 -0
  60. data/lib/blacklight/catalog.rb +101 -56
  61. data/lib/blacklight/configuration.rb +1 -1
  62. data/lib/blacklight/controller.rb +7 -4
  63. data/lib/blacklight/facet.rb +79 -0
  64. data/lib/blacklight/routes.rb +0 -1
  65. data/lib/blacklight/solr/document.rb +4 -0
  66. data/lib/blacklight/solr/document/marc_export.rb +1 -1
  67. data/lib/blacklight/solr_helper.rb +39 -8
  68. data/lib/blacklight/solr_response.rb +35 -3
  69. data/lib/blacklight/solr_response/facets.rb +4 -0
  70. data/lib/blacklight/solr_response/group.rb +33 -0
  71. data/lib/blacklight/solr_response/group_response.rb +49 -0
  72. data/lib/blacklight/solr_response/pagination_methods.rb +27 -0
  73. data/lib/blacklight/user.rb +30 -32
  74. data/lib/generators/blacklight/assets_generator.rb +3 -1
  75. data/lib/generators/blacklight/blacklight_generator.rb +28 -125
  76. data/lib/generators/blacklight/marc_generator.rb +66 -0
  77. data/lib/generators/blacklight/models_generator.rb +113 -0
  78. data/lib/generators/blacklight/templates/alternate_controller.rb +9 -0
  79. data/lib/generators/blacklight/templates/config/solr.yml +0 -2
  80. data/lib/generators/blacklight/templates/solr_document.rb +1 -13
  81. data/lib/railties/all_tests.rake +5 -8
  82. data/spec/controllers/catalog_controller_spec.rb +185 -113
  83. data/spec/features/alternate_controller_spec.rb +34 -0
  84. data/spec/features/bookmarks_spec.rb +58 -0
  85. data/spec/features/did_you_mean_spec.rb +135 -0
  86. data/spec/features/librarian_view_spec.rb +13 -0
  87. data/spec/features/record_view_spec.rb +37 -0
  88. data/spec/features/saved_searches_spec.rb +47 -0
  89. data/spec/features/search_filters_spec.rb +137 -0
  90. data/spec/features/search_history_spec.rb +75 -0
  91. data/spec/features/search_pagination_spec.rb +91 -0
  92. data/spec/features/search_results_spec.rb +68 -0
  93. data/spec/features/search_sort_spec.rb +20 -0
  94. data/spec/features/search_spec.rb +108 -0
  95. data/spec/helpers/blacklight_helper_spec.rb +45 -2
  96. data/spec/helpers/catalog_helper_spec.rb +134 -1
  97. data/spec/helpers/facets_helper_spec.rb +8 -0
  98. data/spec/lib/blacklight/solr_response/group_response_spec.rb +78 -0
  99. data/spec/lib/blacklight/solr_response/group_spec.rb +70 -0
  100. data/spec/lib/blacklight_solr_response_spec.rb +11 -5
  101. data/spec/lib/blacklight_user_spec.rb +22 -41
  102. data/spec/lib/solr_helper_spec.rb +73 -1
  103. data/spec/models/record_mailer_spec.rb +3 -3
  104. data/spec/models/{solr_docment_spec.rb → solr_document_spec.rb} +1 -1
  105. data/spec/spec_helper.rb +0 -1
  106. data/spec/support/features.rb +7 -0
  107. data/spec/support/features/session_helpers.rb +22 -0
  108. data/spec/test_app_templates/Gemfile.extra +0 -4
  109. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -6
  110. data/spec/test_app_templates/lib/tasks/blacklight_test_app.rake +1 -9
  111. data/spec/views/catalog/_facets.html.erb_spec.rb +2 -1
  112. data/tasks/blacklight.rake +0 -10
  113. metadata +49 -58
  114. data/features/bookmarks.feature +0 -68
  115. data/features/did_you_mean.feature +0 -123
  116. data/features/librarian_view.feature +0 -18
  117. data/features/record_view.feature +0 -40
  118. data/features/saved_searches.feature +0 -49
  119. data/features/search.feature +0 -83
  120. data/features/search_filters.feature +0 -119
  121. data/features/search_history.feature +0 -85
  122. data/features/search_pagination.feature +0 -53
  123. data/features/search_results.feature +0 -61
  124. data/features/search_sort.feature +0 -27
  125. data/features/step_definitions/bookmarks_steps.rb +0 -6
  126. data/features/step_definitions/error_steps.rb +0 -5
  127. data/features/step_definitions/general_steps.rb +0 -50
  128. data/features/step_definitions/record_view_steps.rb +0 -12
  129. data/features/step_definitions/saved_searches_steps.rb +0 -19
  130. data/features/step_definitions/search_facets_steps.rb +0 -29
  131. data/features/step_definitions/search_history_steps.rb +0 -9
  132. data/features/step_definitions/search_pagination_steps.rb +0 -29
  133. data/features/step_definitions/search_result_steps.rb +0 -115
  134. data/features/step_definitions/search_steps.rb +0 -118
  135. data/features/step_definitions/user_steps.rb +0 -5
  136. data/features/step_definitions/web_steps.rb +0 -217
  137. data/features/support/env.rb +0 -65
  138. data/features/support/paths.rb +0 -48
  139. data/features/support/selectors.rb +0 -40
  140. data/lib/railties/blacklight_cucumber.rake +0 -126
  141. data/lib/solrmarc.log.1 +0 -854
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4fe52e90e46cbe15dd254d6a09d75d0e9e652cb
4
- data.tar.gz: 93664d12f7ab1ad41476a4c7dcedc16cc5d1ef04
3
+ metadata.gz: b1463e41c998a83ef595ee4dafe4a390d5cd90be
4
+ data.tar.gz: a9b62fea9a0454a432ac5ecd95e8f8952438da5d
5
5
  SHA512:
6
- metadata.gz: e508d1e83f7f38a6527e7ed21e31ed36546e1c2e66c974b47c02cdde164391fde2c848d6166ce75681e2c106090efebde185521f0abb4a16726ef82592bd8ad7
7
- data.tar.gz: a377322e06b7ddf13ce83865d580c4add9df4353abbe9d9b023a8f0149fa2e5bc8a49ad7c994c78ec66b3193b0b2df687ac407e61b3a0ece97cbb7a3a79f73f5
6
+ metadata.gz: 57b6f5e61c7ed3faf05c151ff3915fe48fedac1be2edb2b9f0deae5879265118e8d1f7b961541915a54b41ac2098cea36fb1d4c5d77eaf125360c60a17721b5b
7
+ data.tar.gz: 54d4dc8f7f4fe286dd0ec6faae2c73e95e1e7fb644f6418d3cf6b52de96cd7cacc84c5baa5e6ce65472f507c4548d83f38a3d884134bf5e0047fda2f69be42dd
data/.gitignore CHANGED
@@ -10,6 +10,7 @@ webrat-*
10
10
  config/SolrMarc/*.log*
11
11
  rerun.txt
12
12
  solr_marc/solrmarc.log
13
+ lib/solrmarc.log.*
13
14
  tmp/*
14
15
  *.log
15
16
  .bundle
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
@@ -6,7 +6,6 @@ rescue LoadError
6
6
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
7
  end
8
8
 
9
- require 'rake'
10
9
  Bundler::GemHelper.install_tasks
11
10
 
12
11
  # load rake tasks defined in lib/tasks that are not loaded in lib/active_fedora.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.3.0
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
- $(document).ready(function() {
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(options.checked_label);
73
+ span.text(form.attr('data-present'));
74
74
  } else {
75
75
  form.find("input[name=_method]").val("put");
76
- span.text(options.unchecked_label);
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(options.progress_label);
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
+
@@ -4,7 +4,7 @@
4
4
  $(this).toggleClass("hovering");
5
5
  });
6
6
  };
7
- $(document).ready(function() {
7
+ Blacklight.onLoad(function() {
8
8
  Blacklight.add_css_dropdown_click_support();
9
9
  });
10
- })(jQuery);
10
+ })(jQuery);
@@ -33,8 +33,9 @@ Blacklight.do_facet_expand_contract_behavior = function() {
33
33
  });
34
34
  });
35
35
  };
36
- $(document).ready(function() {
37
- Blacklight.do_facet_expand_contract_behavior();
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
- $(document).ready( function() {
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
  });
@@ -20,7 +20,7 @@
20
20
  });
21
21
 
22
22
  };
23
- $(document).ready(function() {
23
+ Blacklight.onLoad(function() {
24
24
  Blacklight.do_search_context_behavior();
25
25
  });
26
26
  })(jQuery);
@@ -11,7 +11,7 @@
11
11
 
12
12
  }
13
13
 
14
- $(document).ready(function() {
14
+ Blacklight.onLoad(function() {
15
15
  $('#sort-form').hide();
16
16
  $('#sort-dropdown').show();
17
17
  Blacklight.update_css_dropdown('#sort-dropdown', "Sort by ", "")
@@ -7,7 +7,7 @@
7
7
  Blacklight.do_zebra_stripe.selector = "table.zebra tr:even, ul.zebra li:even";
8
8
 
9
9
 
10
- $(document).ready(function() {
10
+ Blacklight.onLoad(function() {
11
11
  Blacklight.do_zebra_stripe();
12
12
  });
13
13
  })(jQuery);
@@ -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";
@@ -248,3 +248,8 @@ span.page a,span.page.current
248
248
  #email_form {
249
249
  @extend .span6;
250
250
  }
251
+
252
+ .document-thumbnail {
253
+ float: right;
254
+ padding-left: 20px;
255
+ }
@@ -3,6 +3,12 @@
3
3
  div.facet_limit {
4
4
  clear: both;
5
5
  }
6
+
7
+ h5 a {
8
+ color: inherit;
9
+ text-decoration: none;
10
+ }
11
+
6
12
  ul {
7
13
  padding-top:0.5em;
8
14
  margin-left: 14px;
@@ -0,0 +1,14 @@
1
+ .group-key {
2
+ border-bottom: 1px solid $dark_border_color;
3
+ clear: right;
4
+ }
5
+
6
+ .grouped-documents {
7
+ .document {
8
+ border-bottom: 0;
9
+ }
10
+ }
11
+
12
+ .more-in-group {
13
+ float: right;
14
+ }
@@ -19,6 +19,7 @@ $main_container_bg_color: #FFFFFF !default;
19
19
 
20
20
  /* separates documents, facets */
21
21
  $dotted_border_color: #CCC !default;
22
+ $dark_border_color: #333 !default;
22
23
 
23
24
  /* background color of page */
24
25
  $page_bg_color: #2E4F81 !default;
@@ -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
- value ||= case
331
- when value
332
- value
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 controller from duplicate params so that we don't get hidden fields for them.
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
- pagination_info = paginate_params(response)
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
- case pagination_info.total_count
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 => pagination_info.current_page, :num_pages => pagination_info.num_pages, :start_num => format_num(pagination_info.start), :end_num => format_num(pagination_info.end), :total_num => pagination_info.total_count, :count => pagination_info.num_pages).html_safe
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