blacklight 3.7.2 → 3.8.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.
Files changed (37) hide show
  1. data/VERSION +1 -1
  2. data/app/assets/javascripts/blacklight/blacklight.js +0 -1
  3. data/app/assets/javascripts/blacklight/checkbox_submit.js +1 -1
  4. data/app/assets/javascripts/blacklight/lightbox_dialog.js +2 -1
  5. data/app/assets/javascripts/blacklight/more_facets.js +1 -0
  6. data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -1
  7. data/app/assets/stylesheets/blacklight/_bookmark.css.scss +20 -0
  8. data/app/assets/stylesheets/blacklight/_catalog.css.scss +2 -6
  9. data/app/controllers/bookmarks_controller.rb +10 -2
  10. data/app/helpers/blacklight/blacklight_helper_behavior.rb +20 -12
  11. data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -3
  12. data/app/helpers/blacklight/facets_helper_behavior.rb +5 -0
  13. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +4 -0
  14. data/app/views/{folder → bookmarks}/_tools.html.erb +8 -13
  15. data/app/views/bookmarks/index.html.erb +14 -22
  16. data/app/views/catalog/_document_header.html.erb +1 -1
  17. data/app/views/catalog/_facet_pagination.html.erb +8 -12
  18. data/app/views/catalog/_per_page_widget.html.erb +7 -0
  19. data/app/views/catalog/_search_form.html.erb +1 -1
  20. data/app/views/catalog/_sort_and_per_page.html.erb +2 -12
  21. data/app/views/catalog/_sort_widget.html.erb +6 -0
  22. data/config/locales/blacklight.en.yml +0 -12
  23. data/lib/blacklight/catalog.rb +4 -0
  24. data/lib/blacklight/configuration.rb +1 -0
  25. data/lib/blacklight/controller.rb +9 -0
  26. data/lib/blacklight/solr/facet_paginator.rb +13 -21
  27. data/lib/blacklight/solr_helper.rb +12 -9
  28. data/lib/generators/blacklight/blacklight_generator.rb +1 -1
  29. data/test_support/features/bookmarks.feature +4 -20
  30. data/test_support/features/support/paths.rb +2 -2
  31. data/test_support/spec/helpers/facets_helper_spec.rb +20 -0
  32. data/test_support/spec/lib/facet_paginator_spec.rb +3 -18
  33. data/test_support/spec/lib/solr_helper_spec.rb +3 -3
  34. metadata +8 -8
  35. data/app/assets/javascripts/blacklight/folder_toggle.js +0 -24
  36. data/app/assets/stylesheets/blacklight/_folder.css.scss +0 -38
  37. data/app/views/folder/index.html.erb +0 -44
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.7.2
1
+ 3.8.0
@@ -7,7 +7,6 @@
7
7
  //= require blacklight/core
8
8
  //= require blacklight/bookmark_toggle
9
9
  //= require blacklight/facet_expand_contract
10
- //= require blacklight/folder_toggle
11
10
  //= require blacklight/lightbox_dialog
12
11
  //= require blacklight/more_facets
13
12
  //= require blacklight/search_context
@@ -1,6 +1,6 @@
1
1
  /* A JQuery plugin (should this be implemented as a widget instead? not sure)
2
2
  that will convert a "toggle" form, with single submit button to add/remove
3
- something, like used for Bookmarks/Folder, into an AJAXy checkbox instead.
3
+ something, like used for Bookmarks, into an AJAXy checkbox instead.
4
4
 
5
5
  Apply to a form. Does require certain assumption about the form:
6
6
  1) The same form 'action' href must be used for both ADD and REMOVE
@@ -2,7 +2,8 @@
2
2
  (function($) {
3
3
  Blacklight.do_lightbox_dialog = function() {
4
4
  $("a.lightboxLink").ajaxyDialog({
5
- chainAjaxySelector: false
5
+ chainAjaxySelector: false,
6
+ position: ['center', 50]
6
7
  });
7
8
  //But make the librarian link wider than 300px default.
8
9
  $('a.lightboxLink#librarianLink').ajaxyDialog("option", "width", 650);
@@ -4,6 +4,7 @@
4
4
  Blacklight.do_more_facets_behavior = function () {
5
5
  $( Blacklight.do_more_facets_behavior.selector ).ajaxyDialog({
6
6
  width: $(window).width() / 2,
7
+ position: ['center', 50],
7
8
  chainAjaxySelector: "a.next_page, a.prev_page, a.sort_change"
8
9
  });
9
10
  };
@@ -16,8 +16,8 @@
16
16
  @import "blacklight/formatting";
17
17
  @import "blacklight/header";
18
18
  @import "blacklight/catalog";
19
+ @import "blacklight/bookmark";
19
20
  @import "blacklight/facets";
20
- @import "blacklight/folder";
21
21
  @import "blacklight/search_history";
22
22
  @import "blacklight/print";
23
23
 
@@ -0,0 +1,20 @@
1
+ ul.tools
2
+ {
3
+ margin:0;
4
+ padding:0;
5
+ list-style: none;
6
+
7
+ li
8
+ {
9
+ display: inline;
10
+ list-style: none;
11
+ margin: 0;
12
+ margin-right: 10px;
13
+ }
14
+ }
15
+
16
+ #sidebar .tools {
17
+ li {
18
+ display: block;
19
+ }
20
+ }
@@ -217,7 +217,7 @@
217
217
  margin-bottom:0.5em;
218
218
  margin-left:1em;
219
219
 
220
- .folder_toggle,.bookmark_toggle
220
+ .bookmark_toggle
221
221
  {
222
222
  display:inline;
223
223
  }
@@ -349,7 +349,7 @@ label.checked
349
349
  font-weight:700;
350
350
  }
351
351
 
352
- label.toggle_bookmark,label.toggle_folder
352
+ label.toggle_bookmark
353
353
  {
354
354
  color:inherit;
355
355
  display:inline-block;
@@ -358,10 +358,6 @@ label.toggle_bookmark,label.toggle_folder
358
358
  text-align:left;
359
359
  }
360
360
 
361
- label.toggle_folder
362
- {
363
- min-width:6em;
364
- }
365
361
 
366
362
  span.page a,span.page.current
367
363
  {
@@ -1,12 +1,20 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  # note that while this is mostly restful routing, the #update and #destroy actions
3
3
  # take the Solr document ID as the :id, NOT the id of the actual Bookmark action.
4
- class BookmarksController < ApplicationController
4
+ class BookmarksController < CatalogController
5
+ include Blacklight::Configurable
6
+ include Blacklight::SolrHelper
7
+
8
+ copy_blacklight_config_from(CatalogController)
9
+
5
10
 
6
11
  before_filter :verify_user
7
12
 
8
13
  def index
9
- @bookmarks = current_or_guest_user.bookmarks.page(params[:page])
14
+ @bookmarks = current_or_guest_user.bookmarks
15
+ bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }
16
+
17
+ @response, @document_list = get_solr_response_for_field_values("id", bookmark_ids)
10
18
  end
11
19
 
12
20
  def update
@@ -284,16 +284,11 @@ module Blacklight::BlacklightHelperBehavior
284
284
  link_url = url_for(query_params)
285
285
  link_to opts[:label], link_url
286
286
  end
287
-
288
- # Create form input type=hidden fields representing the entire search context,
289
- # for inclusion in a form meant to change some aspect of it, like
290
- # re-sort or change records per page. Can pass in params hash
291
- # as :params => hash, otherwise defaults to #params. Can pass
292
- # in certain top-level params keys to _omit_, defaults to :page
293
- def search_as_hidden_fields(options={})
294
-
295
- options = {:params => params, :omit_keys => [:page]}.merge(options)
296
- my_params = options[:params].dup
287
+
288
+ def params_for_search(options={})
289
+ my_params = (options[:params] || params).dup
290
+ options[:omit_keys] ||= []
291
+
297
292
  options[:omit_keys].each do |omit_key|
298
293
  case omit_key
299
294
  when Hash
@@ -307,13 +302,26 @@ module Blacklight::BlacklightHelperBehavior
307
302
  else
308
303
  my_params.delete(omit_key)
309
304
  end
310
- end
305
+ end
306
+
311
307
  # removing action and controller from duplicate params so that we don't get hidden fields for them.
312
308
  my_params.delete(:action)
313
309
  my_params.delete(:controller)
314
310
  # commit is just an artifact of submit button, we don't need it, and
315
311
  # don't want it to pile up with another every time we press submit again!
316
312
  my_params.delete(:commit)
313
+
314
+ my_params
315
+ end
316
+
317
+ # Create form input type=hidden fields representing the entire search context,
318
+ # for inclusion in a form meant to change some aspect of it, like
319
+ # re-sort or change records per page. Can pass in params hash
320
+ # as :params => hash, otherwise defaults to #params. Can pass
321
+ # in certain top-level params keys to _omit_, defaults to :page
322
+ def search_as_hidden_fields(options={})
323
+ my_params = params_for_search({:omit_keys => [:page]}.merge(options))
324
+
317
325
  # hash_as_hidden_fields in hash_as_hidden_fields.rb
318
326
  return hash_as_hidden_fields(my_params)
319
327
  end
@@ -341,7 +349,7 @@ module Blacklight::BlacklightHelperBehavior
341
349
  @template_format = old_format
342
350
  return result
343
351
  end
344
-
352
+
345
353
  # puts together a collection of documents into one refworks export string
346
354
  def render_refworks_texts(documents)
347
355
  val = ''
@@ -9,8 +9,9 @@ module Blacklight::CatalogHelperBehavior
9
9
  per_page = 1 if per_page < 1
10
10
  current_page = (response.start / per_page).ceil + 1
11
11
  num_pages = (response.total / per_page.to_f).ceil
12
- Struct.new(:current_page, :num_pages, :limit_value).new(current_page, num_pages, per_page)
13
- end
12
+
13
+ Struct.new(:current_page, :num_pages, :limit_value, :total_count, :first_page?, :last_page?).new(current_page, num_pages, per_page, response.total, current_page > 1, current_page < num_pages)
14
+ end
14
15
 
15
16
  # Equivalent to kaminari "paginate", but takes an RSolr::Response as first argument.
16
17
  # Will convert it to something kaminari can deal with (using #paginate_params), and
@@ -46,7 +47,7 @@ module Blacklight::CatalogHelperBehavior
46
47
  entry_name = options[:entry_name] ||
47
48
  (response.empty?? t('blacklight.entry_name.default') : response.docs.first.class.name.underscore.sub('_', ' '))
48
49
 
49
- case response.docs.length
50
+ case response.total
50
51
  when 0; t('blacklight.search.pagination_info.no_items_found', :entry_name => entry_name.pluralize ).html_safe
51
52
  when 1; t('blacklight.search.pagination_info.single_item_found', :entry_name => entry_name).html_safe
52
53
  else; t('blacklight.search.pagination_info.pages', :entry_name => entry_name.pluralize, :current_page => current_page, :num_pages => num_pages, :start_num => start_num, :end_num => end_num, :total_num => total_num, :count => num_pages).html_safe
@@ -67,6 +68,10 @@ module Blacklight::CatalogHelperBehavior
67
68
  def search_field_label(params)
68
69
  h( label_for_search_field(params[:search_field]) )
69
70
  end
71
+
72
+ def current_sort_field
73
+ blacklight_config.sort_fields[params[:sort]] || blacklight_config.sort_fields.first.last
74
+ end
70
75
 
71
76
  # Export to Refworks URL, called in _show_tools
72
77
  def refworks_export_url(document = @document)
@@ -19,6 +19,11 @@ module Blacklight::FacetsHelperBehavior
19
19
  blacklight_config.facet_fields.keys
20
20
  end
21
21
 
22
+ def has_facet_values? fields = facet_field_names, options = {}
23
+ solr_fields = fields.map { |solr_field| facet_by_field_name(solr_field) }.compact
24
+ solr_fields.any? { |display_facet| !display_facet.items.empty? }
25
+ end
26
+
22
27
  # Render a collection of facet fields
23
28
  def render_facet_partials fields = facet_field_names, options = {}
24
29
  solr_fields = fields.map { |solr_field| facet_by_field_name(solr_field) }.compact
@@ -7,6 +7,10 @@
7
7
  # search results page (render_constraints(_*))
8
8
  module Blacklight::RenderConstraintsHelperBehavior
9
9
 
10
+ def query_has_constraints?(localized_params = params)
11
+ !(localized_params[:q].blank? and localized_params[:f].blank?)
12
+ end
13
+
10
14
  # Render actual constraints, not including header or footer
11
15
  # info.
12
16
  def render_constraints(localized_params = params)
@@ -1,23 +1,18 @@
1
- <ul class="folderTools">
1
+ <ul class="tools">
2
2
  <li class="cite">
3
- <%= link_to t('blacklight.tools.cite'), citation_catalog_path(:sort=>params[:sort], :per_page=>params[:per_page], :id => @documents.collect{|doc| doc.id}), {:id => 'citeLink', :name => 'citation'} %>
3
+ <%= link_to t('blacklight.tools.cite'), citation_catalog_path(:sort=>params[:sort], :per_page=>params[:per_page], :id => @bookmarks.collect{|doc| doc.document_id}), {:id => 'citeLink', :name => 'citation', :class => 'lightboxLink'} %>
4
4
  </li>
5
5
  <li class="refworks">
6
- <%= render :partial => 'catalog/refworks_form', :locals => {:documents=>@documents} %>
6
+ <%= render :partial => 'catalog/refworks_form', :locals => {:documents=>@bookmarks.collect{|doc| doc.document_id}} %>
7
7
  </li>
8
+
8
9
  <li class="endnote">
9
- <%= link_to t('blacklight.tools.endnote'), endnote_catalog_path(:sort=>params[:sort], :per_page=>params[:per_page], :id => @documents.collect {|doc| doc.id}, :format => 'endnote')%>
10
+ <%= link_to t('blacklight.tools.endnote'), endnote_catalog_path(:sort=>params[:sort], :per_page=>params[:per_page], :id => @bookmarks.collect {|doc| doc.document_id}, :format => 'endnote')%>
10
11
  </li>
11
12
  <li class="email">
12
- <%= link_to t('blacklight.tools.email'), email_catalog_path(:sort=>params[:sort], :per_page=>params[:per_page], :id => @documents.collect {|doc| doc.id}), :class=>"lightboxLink", :id => "emailLink" %>
13
+ <%= link_to t('blacklight.tools.email'), email_catalog_path(:sort=>params[:sort], :per_page=>params[:per_page], :id => @bookmarks.collect {|doc| doc.document_id}), :class=>"lightboxLink", :id => "emailLink" %>
13
14
  </li>
14
- <% if has_user_authentication_provider? and current_user %>
15
- <li>
16
- <%= render :partial=>'catalog/bookmark_form', :locals=>{:documents=>@documents} %>
17
- </li>
18
- <% end %>
19
15
  <li>
20
- <%= link_to t('blacklight.tools.clear'), clear_folder_path, :method => :delete %>
16
+ <%= link_to t('blacklight.bookmarks.clear.action_title'), clear_bookmarks_path, :method => :delete, :data => { :confirm => t('blacklight.bookmarks.clear.action_confirm') } %>
21
17
  </li>
22
- </ul>
23
-
18
+ </ul>
@@ -4,30 +4,22 @@
4
4
 
5
5
  <h2><%= t('blacklight.bookmarks.need_login') %></h2>
6
6
 
7
- <%- elsif @bookmarks.blank? -%>
7
+ <%- elsif @document_list.blank? -%>
8
8
 
9
- <h2><%= t('blacklight.bookmarks.no_bookmarks') %></h2>
9
+ <h3><%= t('blacklight.bookmarks.no_bookmarks') %></h3>
10
+ <% else %>
10
11
 
11
- <%- else -%>
12
-
13
- <%= paginate @bookmarks, :theme => 'blacklight' %>
14
- <div id="userBookmarks">
15
- <p>
16
- <%= link_to t('blacklight.bookmarks.clear.action_title'), clear_bookmarks_path, :method => :delete, :data => { :confirm => t('blacklight.bookmarks.clear.action_confirm') } %>
17
- </p>
18
-
19
- <h2><%= t('blacklight.bookmarks.list_title') %></h2>
20
-
21
- <table class="zebra">
22
- <% @bookmarks.each do |bm| %>
23
- <tr>
24
- <td><%= link_to h(bm.title), polymorphic_path(bm.document) %></td>
25
- <td><%= button_to t('blacklight.bookmarks.delete'), {:controller => "bookmarks", :action => "destroy", :id => CGI.escape(bm.document_id)},
26
- :method => :delete, :data => { :confirm => t('blacklight.bookmarks.remove.action_confirm') } %></td>
27
- </tr>
28
- <% end %>
29
- </table>
12
+ <div class="pageEntriesInfo">
13
+ <%= render_pagination_info @response, :entry_name=>'item' %>
30
14
  </div>
31
15
 
32
- <% end %>
16
+ <%= render 'sort_and_per_page' %>
17
+ <%= render 'results_pagination' %>
33
18
 
19
+ <% sidebar_items << capture do %>
20
+ <%= render 'tools' %>
21
+ <% end %>
22
+ <%= render :partial => 'catalog/document_list' %>
23
+ <%= render 'results_pagination' %>
24
+ <% end %>
25
+
@@ -2,7 +2,7 @@
2
2
  <% # header bar for doc items in index view -%>
3
3
  <div class="documentHeader">
4
4
 
5
- <% # bookmark/folder functions for items/docs -%>
5
+ <% # bookmark functions for items/docs -%>
6
6
  <%= render_index_doc_actions document %>
7
7
 
8
8
  <% # main title container for doc partial view -%>
@@ -1,17 +1,13 @@
1
1
  <% if @pagination.has_previous? || @pagination.has_next? %>
2
2
  <div class="prev_next_links">
3
- <% if @pagination.has_previous? -%>
4
- <%= link_to(raw(t('views.pagination.previous')), catalog_facet_path( @pagination.params_for_previous_url( params) ) , :class=>:prev_page) %>
5
- <% else -%>
6
- <span class="disabled ui-state-active prev_page"><%= raw(t 'views.pagination.previous') %></span>
7
- <% end -%>
8
-
9
- <% if @pagination.has_next? -%>
10
- <%= link_to(raw(t('views.pagination.next')), catalog_facet_path( @pagination.params_for_next_url(params)), :class => :next_page ) %>
11
- <% else -%>
12
- <span class="disabled ui-state-active next_page"><%= raw(t 'views.pagination.next') %></span>
13
- <% end -%>
14
-
3
+ <%= link_to_previous_page @pagination, raw(t('views.pagination.previous')), :params => params, :param_name => Blacklight::Solr::FacetPaginator.request_keys[:page], :class => 'ui-state-active next_page' do %>
4
+ <span class="disabled ui-state-active prev_page"><%= raw(t('views.pagination.previous')) %></span>
5
+ <% end %>
6
+ <%= link_to_next_page @pagination, raw(t('views.pagination.next')), :params => params, :param_name => Blacklight::Solr::FacetPaginator.request_keys[:page], :class => 'ui-state-active prev_page' do %>
7
+
8
+ <span class="disabled ui-state-active next_page"><%= raw(t('views.pagination.next')) %></span>
9
+ <% end %>
10
+
15
11
  </div>
16
12
  <% end %>
17
13
 
@@ -0,0 +1,7 @@
1
+
2
+ <%-# kind of hacky way to get this to work on catalog and folder controllers. May be able to simple do {:action=>"index"} but I'm not sure -%>
3
+ <%= form_tag params[:controller] == "folder" ? folder_index_path : url_for(:action=>'index'), :method=>:get, :class=>'sort', :id => "sort_form" do %>
4
+ <%= label_tag(:sort, t('blacklight.search.sort.label', :select => select_tag(:sort, options_for_select(sort_fields, h(params[:sort])))).html_safe) %>
5
+ <%= search_as_hidden_fields(:omit_keys => [:page, :sort]) %>
6
+ <%= submit_tag t('blacklight.search.sort.submit') %>
7
+ <% end unless sort_fields.empty? %>
@@ -1,5 +1,5 @@
1
1
  <div id="search" class="search">
2
- <%= form_tag url_for(:action=>'index'), :method => :get do %>
2
+ <%= form_tag search_action_url, :method => :get do %>
3
3
  <h2 class="search"><%= label_tag(:q, t('blacklight.search.form.q')) %></h2>
4
4
  <%= text_field_tag :q, params[:q], :class => "q" %>
5
5
  <% unless search_fields.empty? %>
@@ -1,17 +1,7 @@
1
1
  <div id="sortAndPerPage">
2
2
  <% unless @response.total < 2 %>
3
- <%-# kind of hacky way to get this to work on catalog and folder controllers. May be able to simple do {:action=>"index"} but I'm not sure -%>
4
- <%= form_tag params[:controller] == "folder" ? folder_index_path : url_for(:action=>'index'), :method=>:get, :class=>'per_page' do %>
5
- <%= label_tag(:per_page, t('blacklight.search.per_page.label', :select => select_tag(:per_page, options_for_select(['10', '20', '50', '100'], h(params[:per_page])), :title => t('blacklight.search.per_page.title'))).html_safe) %>
6
- <%= search_as_hidden_fields(:omit_keys => [:page, :per_page]) %>
7
- <%= submit_tag t('blacklight.search.per_page.submit') %>
8
- <% end %>
3
+ <%= render :partial => 'sort_widget' %>
9
4
 
10
- <%-# kind of hacky way to get this to work on catalog and folder controllers. May be able to simple do {:action=>"index"} but I'm not sure -%>
11
- <%= form_tag params[:controller] == "folder" ? folder_index_path : url_for(:action=>'index'), :method=>:get, :class=>'sort', :id => "sort_form" do %>
12
- <%= label_tag(:sort, t('blacklight.search.sort.label', :select => select_tag(:sort, options_for_select(sort_fields, h(params[:sort])))).html_safe) %>
13
- <%= search_as_hidden_fields(:omit_keys => [:page, :sort]) %>
14
- <%= submit_tag t('blacklight.search.sort.submit') %>
15
- <% end unless sort_fields.empty? %>
5
+ <%= render :partial => 'per_page_widget' %>
16
6
  <% end %>
17
7
  </div>
@@ -0,0 +1,6 @@
1
+ <%-# kind of hacky way to get this to work on catalog and folder controllers. May be able to simple do {:action=>"index"} but I'm not sure -%>
2
+ <%= form_tag params[:controller] == "folder" ? folder_index_path : url_for(:action=>'index'), :method=>:get, :class=>'per_page' do %>
3
+ <%= label_tag(:per_page, t('blacklight.search.per_page.label', :select => select_tag(:per_page, options_for_select(blacklight_config.per_page, h(params[:per_page])), :title => t('blacklight.search.per_page.title'))).html_safe) %>
4
+ <%= search_as_hidden_fields(:omit_keys => [:page, :per_page]) %>
5
+ <%= submit_tag t('blacklight.search.per_page.submit') %>
6
+ <% end %>
@@ -66,15 +66,6 @@ en:
66
66
  complete:
67
67
  title: 'Thank-you for your feedback'
68
68
 
69
- folder:
70
- title: 'Selected Items'
71
- add:
72
- success: '%{title} successfully added to selected items'
73
- remove:
74
- success: '%{title} successfully removed from selected items'
75
- clear:
76
- success: 'Selected items cleared.'
77
-
78
69
  saved_searches:
79
70
  add:
80
71
  success: 'Successfully saved your search.'
@@ -192,9 +183,6 @@ en:
192
183
  other: 'Showing item <b>%{current} of %{total}</b> from your search.'
193
184
  documents:
194
185
  counter: '%{counter}. '
195
- folder:
196
- select: 'Select'
197
- unselect: 'Unselect'
198
186
  facets:
199
187
  title: 'Limit your search'
200
188
  sort:
@@ -10,6 +10,7 @@ module Blacklight::Catalog
10
10
  # The following code is executed when someone includes blacklight::catalog in their
11
11
  # own controller.
12
12
  included do
13
+ helper_method :search_action_url
13
14
  before_filter :search_session, :history_session
14
15
  before_filter :delete_or_assign_search_session_params, :only => :index
15
16
  after_filter :set_additional_search_session_values, :only=>:index
@@ -24,6 +25,9 @@ module Blacklight::Catalog
24
25
  rescue_from RSolr::Error::Http, :with => :rsolr_request_error
25
26
  end
26
27
 
28
+ def search_action_url
29
+ url_for(:action => 'index', :only_path => true)
30
+ end
27
31
 
28
32
  # get search results from the solr index
29
33
  def index
@@ -16,6 +16,7 @@ module Blacklight
16
16
  :index => OpenStructWithHashAccess.new(:show_link => SolrDocument.unique_key),
17
17
  :spell_max => 5,
18
18
  :max_per_page => 100,
19
+ :per_page => [10,20,50,100],
19
20
  :add_facet_fields_to_solr_request => false
20
21
  }
21
22
 
@@ -25,6 +25,7 @@ module Blacklight::Controller
25
25
  base.send :helper_method, :stylesheet_links
26
26
  base.send :helper_method, :javascript_includes
27
27
  base.send :helper_method, :has_user_authentication_provider?
28
+ base.send :helper_method, :blacklight_config
28
29
 
29
30
 
30
31
  # This callback runs when a user first logs in
@@ -32,6 +33,14 @@ module Blacklight::Controller
32
33
 
33
34
  end
34
35
 
36
+ def default_catalog_controller
37
+ CatalogController
38
+ end
39
+
40
+ def blacklight_config
41
+ default_catalog_controller.blacklight_config
42
+ end
43
+
35
44
  # test for exception notifier plugin
36
45
  def error
37
46
  raise RuntimeError, "Generating a test error..."
@@ -17,7 +17,7 @@ module Blacklight::Solr
17
17
  # and need to make them accessible in a list so we can easily
18
18
  # strip em out before redirecting to catalog/index.
19
19
  # class variable (via class-level ivar)
20
- @request_keys = {:sort => :'catalog_facet.sort', :offset => :'catalog_facet.offset', :limit => :'catalog_facet.limit'}
20
+ @request_keys = {:sort => :'facet.sort', :page => :'facet.page'}
21
21
  class << self; attr_accessor :request_keys end # create a class method
22
22
  def request_keys ; self.class.request_keys ; end # shortcut
23
23
 
@@ -49,34 +49,27 @@ module Blacklight::Solr
49
49
  end
50
50
  end
51
51
 
52
+ def current_page
53
+ 1 + @offset/@limit
54
+ end
55
+
52
56
  def has_next?
53
57
  @has_next
54
58
  end
55
59
 
56
- # Pass in your current request params, returns a param hash
57
- # suitable to passing to an ActionHelper method (resource-based url_for, or
58
- # link_to or url_for) navigating to the next facet value batch. Returns nil
59
- # if there is no has_next?
60
- def params_for_next_url(params)
61
- return nil unless has_next?
62
-
63
- return params.merge(request_keys[:offset] => offset + limit )
64
- end
65
-
66
60
  def has_previous?
67
61
  @has_previous
68
62
  end
69
-
70
- # Pass in your current request params, returns a param hash
71
- # suitable to passing to an ActionHelper method (resource-based url_for, or
72
- # link_to or url_for) navigating to the previous facet value batch. Returns
73
- # nil if there is no has_previous?
74
- def params_for_previous_url(params)
75
- return nil unless has_previous?
76
63
 
77
- return params.merge(request_keys[:offset] => offset - limit )
64
+ def last_page?
65
+ !has_next?
66
+ end
67
+
68
+ def first_page?
69
+ !has_previous?
78
70
  end
79
71
 
72
+
80
73
  # Pass in a desired solr facet solr key ('count' or 'index', see
81
74
  # http://wiki.apache.org/solr/SimpleFacetParameters#facet.limit
82
75
  # under facet.sort ), and your current request params.
@@ -85,8 +78,7 @@ module Blacklight::Solr
85
78
  def params_for_resort_url(sort_method, params)
86
79
  # When resorting, we've got to reset the offset to start at beginning,
87
80
  # no way to make it make sense otherwise.
88
- return params.merge(request_keys[:sort] => sort_method,
89
- request_keys[:offset] => 0)
81
+ return params.merge(request_keys[:sort] => sort_method, request_keys[:page] => nil)
90
82
  end
91
83
 
92
84
  end
@@ -436,17 +436,20 @@ module Blacklight::SolrHelper
436
436
  # Now override with our specific things for fetching facet values
437
437
  solr_params[:"facet.field"] = facet_field
438
438
 
439
- # Need to set as f.facet_field.facet.limit to make sure we
440
- # override any field-specific default in the solr request handler.
441
- solr_params[:"f.#{facet_field}.facet.limit"] =
439
+
440
+ limit =
442
441
  if respond_to?(:facet_list_limit)
443
- facet_list_limit.to_s.to_i + 1
442
+ facet_list_limit.to_s.to_i
444
443
  elsif solr_params["facet.limit"]
445
- solr_params["facet.limit"].to_i + 1
444
+ solr_params["facet.limit"].to_i
446
445
  else
447
- 20 + 1
446
+ 20
448
447
  end
449
- solr_params[:"f.#{facet_field}.facet.offset"] = input[ Blacklight::Solr::FacetPaginator.request_keys[:offset] ].to_i # will default to 0 if nil
448
+
449
+ # Need to set as f.facet_field.facet.* to make sure we
450
+ # override any field-specific default in the solr request handler.
451
+ solr_params[:"f.#{facet_field}.facet.limit"] = limit + 1
452
+ solr_params[:"f.#{facet_field}.facet.offset"] = ( input.fetch(Blacklight::Solr::FacetPaginator.request_keys[:page] , 1).to_i - 1 ) * ( limit )
450
453
  solr_params[:"f.#{facet_field}.facet.sort"] = input[ Blacklight::Solr::FacetPaginator.request_keys[:sort] ] if input[ Blacklight::Solr::FacetPaginator.request_keys[:sort] ]
451
454
  solr_params[:rows] = 0
452
455
 
@@ -456,9 +459,9 @@ module Blacklight::SolrHelper
456
459
  # a solr query method
457
460
  # used to paginate through a single facet field's values
458
461
  # /catalog/facet/language_facet
459
- def get_facet_pagination(facet_field, extra_controller_params={})
462
+ def get_facet_pagination(facet_field, user_params=params || {}, extra_controller_params={})
460
463
 
461
- solr_params = solr_facet_params(facet_field, params, extra_controller_params)
464
+ solr_params = solr_facet_params(facet_field, user_params, extra_controller_params)
462
465
 
463
466
  # Make the solr call
464
467
  response =find(blacklight_config.solr_request_handler, solr_params)
@@ -123,7 +123,7 @@ EOF
123
123
  file_path = "app/models/#{model_name.underscore}.rb"
124
124
  if File.exists?(file_path)
125
125
  inject_into_class file_path, model_name.classify do
126
- "# Connects this user object to Blacklights Bookmarks and Folders. " +
126
+ "# Connects this user object to Blacklights Bookmarks. " +
127
127
  "\n include Blacklight::User\n"
128
128
  end
129
129
  else
@@ -17,26 +17,10 @@ Feature: Bookmarks
17
17
  When I go to the bookmarks page
18
18
  Then I should see "You have no bookmarks"
19
19
 
20
- Scenario: User Has Bookmarks
21
- Given I am logged in as "user1"
22
- And "user1" has bookmarked an item with title "foo bar"
23
- When I go to the bookmarks page
24
- Then I should see "Your Bookmarks"
25
- And I should see "foo bar"
26
-
27
- Scenario: Deleting a Bookmark
28
- Given I am logged in as "user1"
29
- And "user1" has bookmarked an item with title "foo bar"
30
- And I am on the bookmarks page
31
- Then I should see a "Remove" button
32
- When I press "Remove"
33
- Then I should see "Successfully removed bookmark."
34
-
35
20
  Scenario: Clearing Bookmarks
36
- Given I am logged in as "user1"
37
- And "user1" has bookmarked an item with title "foo bar"
38
- And "user1" has bookmarked an item with title "boo baz"
39
- And I am on the bookmarks page
21
+ Given I am on the document page for id 2007020969
22
+ And I press "Bookmark"
23
+ When I am on the bookmarks page
40
24
  Then I should see "Clear Bookmarks"
41
25
  When I follow "Clear Bookmarks"
42
26
  Then I should see "Cleared your bookmarks."
@@ -74,5 +58,5 @@ Feature: Bookmarks
74
58
  And I press "Bookmark"
75
59
  And I am logged in as "user1"
76
60
  When I go to the bookmarks page
77
- Then I should see a "Remove" button
61
+ Then I should see a "Remove bookmark" button
78
62
 
@@ -17,8 +17,8 @@ module NavigationHelpers
17
17
  #catalog_index_path
18
18
  root_path
19
19
 
20
- when /the folder page/
21
- folder_index_path
20
+ when /the bookmarks page/
21
+ bookmarks_path
22
22
 
23
23
  when /the document page for id (.+)/
24
24
  catalog_path($1)
@@ -6,6 +6,26 @@ describe FacetsHelper do
6
6
  helper.stub(:blacklight_config).and_return blacklight_config
7
7
  end
8
8
 
9
+ describe "has_facet_values?" do
10
+ it "should be true if there are any facets to display" do
11
+
12
+ a = mock(:items => [1,2])
13
+ b = mock(:items => ['b','c'])
14
+ empty = mock(:items => [])
15
+
16
+ fields = [a,b,empty]
17
+ helper.has_facet_values?(fields).should be_true
18
+ end
19
+
20
+ it "should be false if all facets are empty" do
21
+
22
+ empty = mock(:items => [])
23
+
24
+ fields = [empty]
25
+ helper.has_facet_values?(fields).should_not be_true
26
+ end
27
+ end
28
+
9
29
  describe "should_render_facet?" do
10
30
  before do
11
31
  @config = Blacklight::Configuration.new do |config|
@@ -11,23 +11,16 @@ describe 'Blacklight::Solr::FacetPaginator' do
11
11
  @limit = 6
12
12
 
13
13
  @sort_key = Blacklight::Solr::FacetPaginator.request_keys[:sort]
14
- @offset_key = Blacklight::Solr::FacetPaginator.request_keys[:offset]
15
- @limit_key = Blacklight::Solr::FacetPaginator.request_keys[:limit]
14
+ @page_key = Blacklight::Solr::FacetPaginator.request_keys[:page]
16
15
  end
17
16
  context 'when there are limit+1 results' do
18
17
  before(:each) do
19
- @paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, @offset_key => 0, :limit => 6)
18
+ @paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :limit => 6)
20
19
  end
21
20
  it 'should have next' do
22
21
  @paginator.should be_has_next
23
22
  end
24
- it 'should generate proper next params' do
25
- next_params = @paginator.params_for_next_url(:original1 => "original1", :original2 => "original2")
26
23
 
27
- next_params[:original1].should == "original1"
28
- next_params[:original2].should == "original2"
29
- next_params[@offset_key].should == 0 + @limit
30
- end
31
24
  end
32
25
  it 'should not have next when there are fewer results' do
33
26
  paginator = Blacklight::Solr::FacetPaginator.new(@six_facet_values, :offset => 0, :limit => @limit)
@@ -44,14 +37,6 @@ describe 'Blacklight::Solr::FacetPaginator' do
44
37
  @paginator.should be_has_previous
45
38
  end
46
39
 
47
- it 'should generate proper previous params' do
48
- next_params = @paginator.params_for_previous_url(:original1 => "original1", :original2 => "original2")
49
-
50
- next_params[:original1].should == "original1"
51
- next_params[:original2].should == "original2"
52
- next_params[@offset_key].should == @offset - @limit
53
- end
54
-
55
40
  end
56
41
  it 'should not have previous when offset is 0' do
57
42
  paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 0, :limit => @limit)
@@ -66,7 +51,7 @@ describe 'Blacklight::Solr::FacetPaginator' do
66
51
  click_params = paginator.params_for_resort_url('count', {})
67
52
 
68
53
  click_params[ @sort_key ].should == 'count'
69
- click_params[ @offset_key ].to_s.should == "0"
54
+ click_params[ @page_key ].should be_nil
70
55
  end
71
56
  it 'should limit items to limit, if limit is smaller than items.length' do
72
57
  paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 100, :limit => 6, :sort => 'index')
@@ -433,7 +433,7 @@ describe 'Blacklight::SolrHelper' do
433
433
  @generated_solr_facet_params = solr_facet_params(@facet_field)
434
434
 
435
435
  @sort_key = Blacklight::Solr::FacetPaginator.request_keys[:sort]
436
- @offset_key = Blacklight::Solr::FacetPaginator.request_keys[:offset]
436
+ @page_key = Blacklight::Solr::FacetPaginator.request_keys[:page]
437
437
  @config = Blacklight::Configuration.new do |config|
438
438
  config.add_facet_fields_to_solr_request!
439
439
  config.add_facet_field 'format'
@@ -452,8 +452,8 @@ describe 'Blacklight::SolrHelper' do
452
452
  @generated_solr_facet_params[:"f.#{@facet_field}.facet.offset"].should == 0
453
453
  end
454
454
  it 'uses offset manually set, and converts it to an integer' do
455
- solr_params = solr_facet_params(@facet_field, @offset_key => "100")
456
- solr_params[:"f.#{@facet_field}.facet.offset"].should == 100
455
+ solr_params = solr_facet_params(@facet_field, @page_key => 2)
456
+ solr_params[:"f.#{@facet_field}.facet.offset"].should == 20
457
457
  end
458
458
  it 'defaults limit to 20' do
459
459
  solr_params = solr_facet_params(@facet_field)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.2
4
+ version: 3.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
- date: 2012-10-15 00:00:00.000000000 Z
20
+ date: 2012-11-02 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -233,7 +233,6 @@ files:
233
233
  - app/assets/javascripts/blacklight/checkbox_submit.js
234
234
  - app/assets/javascripts/blacklight/core.js
235
235
  - app/assets/javascripts/blacklight/facet_expand_contract.js
236
- - app/assets/javascripts/blacklight/folder_toggle.js
237
236
  - app/assets/javascripts/blacklight/lightbox_dialog.js
238
237
  - app/assets/javascripts/blacklight/more_facets.js
239
238
  - app/assets/javascripts/blacklight/search_context.js
@@ -243,9 +242,9 @@ files:
243
242
  - app/assets/javascripts/jquery-ui-1.8.1.custom.min.js
244
243
  - app/assets/javascripts/jquery.uiExt.ajaxyDialog.js
245
244
  - app/assets/stylesheets/blacklight/_blacklight_base.css.scss
245
+ - app/assets/stylesheets/blacklight/_bookmark.css.scss
246
246
  - app/assets/stylesheets/blacklight/_catalog.css.scss
247
247
  - app/assets/stylesheets/blacklight/_facets.css.scss
248
- - app/assets/stylesheets/blacklight/_folder.css.scss
249
248
  - app/assets/stylesheets/blacklight/_formatting.css.scss
250
249
  - app/assets/stylesheets/blacklight/_header.css.scss
251
250
  - app/assets/stylesheets/blacklight/_layout.css.scss
@@ -295,6 +294,7 @@ files:
295
294
  - app/models/search.rb
296
295
  - app/views/_flash_msg.html.erb
297
296
  - app/views/_user_util_links.html.erb
297
+ - app/views/bookmarks/_tools.html.erb
298
298
  - app/views/bookmarks/index.html.erb
299
299
  - app/views/catalog/_bookmark_control.html.erb
300
300
  - app/views/catalog/_bookmark_form.html.erb
@@ -315,6 +315,7 @@ files:
315
315
  - app/views/catalog/_index_default.html.erb
316
316
  - app/views/catalog/_marc_view.html.erb
317
317
  - app/views/catalog/_opensearch_response_metadata.html.erb
318
+ - app/views/catalog/_per_page_widget.html.erb
318
319
  - app/views/catalog/_previous_next_doc.html.erb
319
320
  - app/views/catalog/_refworks_form.html.erb
320
321
  - app/views/catalog/_results_pagination.html.erb
@@ -324,6 +325,7 @@ files:
324
325
  - app/views/catalog/_show_tools.html.erb
325
326
  - app/views/catalog/_sms_form.html.erb
326
327
  - app/views/catalog/_sort_and_per_page.html.erb
328
+ - app/views/catalog/_sort_widget.html.erb
327
329
  - app/views/catalog/citation.html.erb
328
330
  - app/views/catalog/email.erb
329
331
  - app/views/catalog/endnote.endnote.erb
@@ -341,8 +343,6 @@ files:
341
343
  - app/views/catalog/sms.erb
342
344
  - app/views/feedback/complete.html.erb
343
345
  - app/views/feedback/show.html.erb
344
- - app/views/folder/_tools.html.erb
345
- - app/views/folder/index.html.erb
346
346
  - app/views/kaminari/blacklight/_first_page.html.erb
347
347
  - app/views/kaminari/blacklight/_gap.html.erb
348
348
  - app/views/kaminari/blacklight/_last_page.html.erb
@@ -508,7 +508,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
508
508
  version: '0'
509
509
  segments:
510
510
  - 0
511
- hash: -3316550167436372560
511
+ hash: -3050377984529966753
512
512
  required_rubygems_version: !ruby/object:Gem::Requirement
513
513
  none: false
514
514
  requirements:
@@ -517,7 +517,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
517
517
  version: '0'
518
518
  segments:
519
519
  - 0
520
- hash: -3316550167436372560
520
+ hash: -3050377984529966753
521
521
  requirements: []
522
522
  rubyforge_project: blacklight
523
523
  rubygems_version: 1.8.23
@@ -1,24 +0,0 @@
1
- //= require blacklight/core
2
- //= require blacklight/checkbox_submit
3
- (function($) {
4
- Blacklight.do_folder_toggle_behavior = function() {
5
- $( Blacklight.do_folder_toggle_behavior.selector ).bl_checkbox_submit({
6
- checked_label: "Selected",
7
- unchecked_label: "Select",
8
- css_class: "toggle_folder",
9
- success: function(new_state) {
10
-
11
- if (new_state) {
12
- $("#folder_number").text(parseInt($("#folder_number").text()) + 1);
13
- }
14
- else {
15
- $("#folder_number").text(parseInt($("#folder_number").text()) - 1);
16
- }
17
- }
18
- });
19
- };
20
- Blacklight.do_folder_toggle_behavior.selector = "form.folder_toggle";
21
- $(document).ready(function() {
22
- Blacklight.do_folder_toggle_behavior();
23
- });
24
- })(jQuery);
@@ -1,38 +0,0 @@
1
- ul.folderTools
2
- {
3
- @include border-radius(0 0 4px 4px);
4
- background-color: $search_ui_bg_color;
5
- border-color: $search_ui_border_color;
6
- border-style:solid;
7
- border-width:0 1px 1px;
8
- margin:0;
9
- padding:0.66em;
10
-
11
- li
12
- {
13
- display:inline-block;
14
- margin:0 10px;
15
- }
16
-
17
- li form
18
- {
19
- display:inline;
20
- }
21
-
22
- li.refworks form input.submit
23
- {
24
- display:none;
25
- }
26
- }
27
-
28
- ul.tools
29
- {
30
- margin:0;
31
- padding:0;
32
-
33
- li
34
- {
35
- display:inline;
36
- margin:0 10px;
37
- }
38
- }
@@ -1,44 +0,0 @@
1
- <% sidebar_items << capture do %>
2
- <p><%= link_back_to_catalog %></p>
3
- <% end %>
4
- <h1><%= t('blacklight.folder.title') %></h1>
5
-
6
- <% unless @documents.empty? %>
7
- <%- # just adding pageEntriedInfo div to get the proper rounded corners at the top -%>
8
- <div class="pageEntriesInfo"></div>
9
- <%= render "catalog/sort_and_per_page" %>
10
- <%= render "catalog/results_pagination" %>
11
-
12
- <%= render 'tools' %>
13
- <% end %>
14
-
15
- <div id="documents">
16
- <% @documents.each_with_index do |document, i| %>
17
- <% # container for a single doc -%>
18
- <div class="document">
19
- <% # header bar for doc items in index view -%>
20
- <div class="documentHeader">
21
- <div class="documentFunctions">
22
- <div class="in_folder">
23
- <%= render :partial=>'catalog/folder_control', :locals=>{:document=>document} %>
24
- </div>
25
- </div>
26
-
27
- <h3 class="index_title"><%= i + 1 + @response.params[:start].to_i%>. <%= link_to_document document, :label => document_show_link_field, :results_view => false %></h3>
28
-
29
-
30
- </div>
31
-
32
- <%= render_document_partial document, :index %>
33
- <% if document.respond_to?(:export_as_openurl_ctx_kev) %>
34
- <!--
35
- // COinS, for Zotero among others.
36
- // This document_partial_name(@document) business is not quite right,
37
- // but has been there for a while.
38
- -->
39
- <span class="Z3988" title="<%= document.export_as_openurl_ctx_kev(document_partial_name(document)) %>"></span>
40
- <% end %>
41
- </div>
42
-
43
- <% end %>
44
- </div>