blacklight 5.1.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/search_context.js +38 -24
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +49 -70
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -8
- data/app/helpers/blacklight/configuration_helper_behavior.rb +10 -2
- data/app/helpers/blacklight/facets_helper_behavior.rb +4 -1
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/url_helper_behavior.rb +41 -7
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_per_page_widget.html.erb +4 -4
- data/app/views/catalog/_previous_next_doc.html.erb +1 -1
- data/app/views/catalog/_show_tools.html.erb +1 -1
- data/app/views/catalog/show.html.erb +1 -1
- data/app/views/layouts/blacklight.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/jetty.yml +3 -0
- data/config/locales/blacklight.es.yml +220 -0
- data/gemfiles/rails4.1.gemfile +10 -0
- data/lib/blacklight/base.rb +1 -1
- data/lib/blacklight/catalog/search_context.rb +15 -15
- data/lib/blacklight/catalog.rb +19 -6
- data/lib/blacklight/configuration.rb +126 -31
- data/lib/blacklight/document_presenter.rb +168 -0
- data/lib/blacklight/request_builders.rb +288 -0
- data/lib/blacklight/routes.rb +6 -2
- data/lib/blacklight/solr/request.rb +1 -1
- data/lib/blacklight/solr_helper.rb +50 -323
- data/lib/blacklight/solr_response/facets.rb +7 -3
- data/lib/blacklight/utils.rb +39 -7
- data/lib/blacklight.rb +5 -3
- data/lib/generators/blacklight/install_generator.rb +17 -5
- data/lib/generators/blacklight/models_generator.rb +0 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +6 -0
- data/lib/generators/blacklight/templates/config/jetty.yml +8 -4
- data/lib/generators/blacklight/templates/config/solr.yml +2 -0
- data/spec/controllers/catalog_controller_spec.rb +41 -22
- data/spec/features/alternate_controller_spec.rb +1 -1
- data/spec/features/search_filters_spec.rb +24 -24
- data/spec/features/search_results_spec.rb +9 -4
- data/spec/features/search_sort_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +87 -0
- data/spec/helpers/catalog_helper_spec.rb +5 -10
- data/spec/helpers/configuration_helper_spec.rb +22 -1
- data/spec/helpers/facets_helper_spec.rb +6 -0
- data/spec/helpers/render_constraints_helper_spec.rb +1 -2
- data/spec/helpers/url_helper_spec.rb +45 -2
- data/spec/lib/blacklight/routes_spec.rb +4 -4
- data/spec/lib/blacklight/solr_helper_spec.rb +364 -253
- data/spec/lib/blacklight/solr_response/facets_spec.rb +82 -0
- data/spec/lib/blacklight/solr_response_spec.rb +3 -1
- data/spec/lib/document_presenter_spec.rb +216 -0
- data/spec/lib/utils_spec.rb +8 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/catalog/index.html.erb_spec.rb +29 -21
- data/spec/views/catalog/show.html.erb_spec.rb +11 -7
- data/template.demo.rb +20 -0
- metadata +12 -4
- data/lib/generators/blacklight/jetty_generator.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fea671a4828e18416d64b657b46a176d12825b99
|
4
|
+
data.tar.gz: 559e98ff68f295b5f353eb50272eebf4b856443e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 665816f47ac58bbdff19053888a885fe2b4b682e56b59bcf390e859c0d2c4f8b2aac7dd07bdd269eb620ff2d5271bcd9e0527dba75423c920a83d08502bf24e8
|
7
|
+
data.tar.gz: 37756999f96379e3908381a2959e6437533a7f0c860ccd29479bac5e64a24f9ed0014b207169641d6de1368b8204b6bd81c52ae8e6a7bff58b4631cb4d624697
|
data/.travis.yml
CHANGED
@@ -2,6 +2,7 @@ notifications:
|
|
2
2
|
email: false
|
3
3
|
|
4
4
|
rvm:
|
5
|
+
- 2.1.1
|
5
6
|
- 2.1.0
|
6
7
|
- 2.0.0
|
7
8
|
- 1.9.3
|
@@ -13,6 +14,7 @@ before_install:
|
|
13
14
|
gemfile:
|
14
15
|
- gemfiles/rails3.gemfile
|
15
16
|
- gemfiles/rails4.gemfile
|
17
|
+
- gemfiles/rails4.1.gemfile
|
16
18
|
|
17
19
|
notifications:
|
18
20
|
irc: "irc.freenode.org#blacklight"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.2.0
|
@@ -1,28 +1,42 @@
|
|
1
1
|
//= require blacklight/core
|
2
2
|
(function($) {
|
3
3
|
Blacklight.do_search_context_behavior = function() {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
4
|
+
$('a[data-context-href]').on('click.search-context', Blacklight.handleSearchContextMethod);
|
5
|
+
};
|
6
|
+
|
7
|
+
// this is the $.rails.handleMethod with a couple adjustments, described inline:
|
8
|
+
// first, we're attaching this directly to the event handler, so we can check for meta-keys
|
9
|
+
Blacklight.handleSearchContextMethod = function(event) {
|
10
|
+
var link = $(this);
|
11
|
+
|
12
|
+
// instead of using the normal href, we need to use the context href instead
|
13
|
+
var href = link.data('context-href'),
|
14
|
+
method = 'post',
|
15
|
+
target = link.attr('target'),
|
16
|
+
csrfToken = $('meta[name=csrf-token]').attr('content'),
|
17
|
+
csrfParam = $('meta[name=csrf-param]').attr('content'),
|
18
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
19
|
+
metadataInput = '<input name="_method" value="' + method + '" type="hidden" />',
|
20
|
+
redirectHref = '<input name="redirect" value="' + link.attr('href') + '" type="hidden" />';
|
21
|
+
|
22
|
+
// check for meta keys.. if set, we should open in a new tab
|
23
|
+
if(event.metaKey || event.ctrlKey) {
|
24
|
+
target = '_blank';
|
25
|
+
}
|
26
|
+
|
27
|
+
if (csrfParam !== undefined && csrfToken !== undefined) {
|
28
|
+
metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />';
|
29
|
+
}
|
30
|
+
|
31
|
+
if (target) { form.attr('target', target); }
|
32
|
+
|
33
|
+
form.hide().append(metadataInput).append(redirectHref).appendTo('body');
|
34
|
+
form.submit();
|
35
|
+
|
36
|
+
return false;
|
37
|
+
};
|
38
|
+
|
39
|
+
Blacklight.onLoad(function() {
|
40
|
+
Blacklight.do_search_context_behavior();
|
41
|
+
});
|
28
42
|
})(jQuery);
|
@@ -15,13 +15,21 @@ module Blacklight::BlacklightHelperBehavior
|
|
15
15
|
# - the Rails configuration
|
16
16
|
# - an i18n string (key: blacklight.application_name; preferred)
|
17
17
|
#
|
18
|
-
# @return [String] the application
|
18
|
+
# @return [String] the application name
|
19
19
|
def application_name
|
20
20
|
return Rails.application.config.application_name if Rails.application.config.respond_to? :application_name
|
21
21
|
|
22
22
|
t('blacklight.application_name')
|
23
23
|
end
|
24
24
|
|
25
|
+
##
|
26
|
+
# Get the page's HTML title
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
def render_page_title
|
30
|
+
(content_for(:page_title) if content_for?(:page_title)) || @page_title || application_name
|
31
|
+
end
|
32
|
+
|
25
33
|
##
|
26
34
|
# Create <link rel="alternate"> links from a documents dynamically
|
27
35
|
# provided export formats. Currently not used by standard BL layouts,
|
@@ -201,10 +209,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
201
209
|
document = args.shift || options[:document]
|
202
210
|
|
203
211
|
field = args.shift || options[:field]
|
204
|
-
|
205
|
-
value = options[:value] || get_field_values(document, field, field_config, options)
|
206
|
-
|
207
|
-
render_field_value value, field_config
|
212
|
+
presenter(document).render_index_field_value field, options
|
208
213
|
end
|
209
214
|
|
210
215
|
##
|
@@ -226,7 +231,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
226
231
|
|
227
232
|
field = options[:field]
|
228
233
|
|
229
|
-
|
234
|
+
t(:'blacklight.search.show.label', label: document_show_field_label(document, field))
|
230
235
|
end
|
231
236
|
|
232
237
|
##
|
@@ -257,10 +262,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
257
262
|
document = args.shift || options[:document]
|
258
263
|
|
259
264
|
field = args.shift || options[:field]
|
260
|
-
|
261
|
-
value = options[:value] || get_field_values(document, field, field_config, options)
|
262
|
-
|
263
|
-
render_field_value value, field_config
|
265
|
+
presenter(document).render_document_show_field_value field, options
|
264
266
|
end
|
265
267
|
|
266
268
|
##
|
@@ -271,7 +273,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
271
273
|
# @return [String]
|
272
274
|
def document_heading document=nil
|
273
275
|
document ||= @document
|
274
|
-
|
276
|
+
presenter(document).document_heading
|
275
277
|
end
|
276
278
|
|
277
279
|
##
|
@@ -284,11 +286,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
284
286
|
def document_show_html_title document=nil
|
285
287
|
document ||= @document
|
286
288
|
|
287
|
-
|
288
|
-
render_field_value(document[blacklight_config.view_config(:show).html_title_field])
|
289
|
-
else
|
290
|
-
document_heading document
|
291
|
-
end
|
289
|
+
presenter(document).document_show_html_title
|
292
290
|
end
|
293
291
|
|
294
292
|
##
|
@@ -310,7 +308,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
310
308
|
|
311
309
|
tag ||= :h4
|
312
310
|
|
313
|
-
content_tag(tag,
|
311
|
+
content_tag(tag, presenter(document).document_heading, :itemprop => "name")
|
314
312
|
end
|
315
313
|
|
316
314
|
##
|
@@ -329,55 +327,18 @@ module Blacklight::BlacklightHelperBehavior
|
|
329
327
|
# @param [Blacklight::Solr::Configuration::SolrField] solr field configuration
|
330
328
|
# @param [Hash] options additional options to pass to the rendering helpers
|
331
329
|
def get_field_values document, field, field_config, options = {}
|
332
|
-
|
333
|
-
value = case
|
334
|
-
when (field_config and field_config.highlight)
|
335
|
-
# retrieve the document value from the highlighting response
|
336
|
-
document.highlight_field(field_config.field).map { |x| x.html_safe } if document.has_highlight_field? field_config.field
|
337
|
-
when (field_config and field_config.accessor)
|
338
|
-
# implicit method call
|
339
|
-
if field_config.accessor === true
|
340
|
-
document.send(field)
|
341
|
-
# arity-1 method call (include the field name in the call)
|
342
|
-
elsif !field_config.accessor.is_a?(Array) && document.method(field_config.accessor).arity != 0
|
343
|
-
document.send(field_config.accessor, field)
|
344
|
-
# chained method calls
|
345
|
-
else
|
346
|
-
Array(field_config.accessor).inject(document) do |result, method|
|
347
|
-
result.send(method)
|
348
|
-
end
|
349
|
-
end
|
350
|
-
else
|
351
|
-
# regular solr
|
352
|
-
document.get(field, :sep => nil) if field
|
353
|
-
end
|
354
|
-
|
355
|
-
# rendering values
|
356
|
-
case
|
357
|
-
when (field_config and field_config.helper_method)
|
358
|
-
send(field_config.helper_method, options.merge(:document => document, :field => field, :value => value))
|
359
|
-
when (field_config and field_config.link_to_search)
|
360
|
-
link_field = if field_config.link_to_search === true
|
361
|
-
field_config.field
|
362
|
-
else
|
363
|
-
field_config.link_to_search
|
364
|
-
end
|
365
|
-
|
366
|
-
Array(value).map do |v|
|
367
|
-
link_to render_field_value(v, field_config), search_action_path(add_facet_params(link_field, v, {}))
|
368
|
-
end if field
|
369
|
-
else
|
370
|
-
value
|
371
|
-
end
|
330
|
+
presenter(document).get_field_values field, field_config, options
|
372
331
|
end
|
373
332
|
|
374
333
|
##
|
375
334
|
# Render a value (or array of values) from a field
|
376
335
|
#
|
336
|
+
# @deprecated Use DocumentPresenter instead
|
377
337
|
# @param [String] value or list of values to display
|
378
338
|
# @param [Blacklight::Solr::Configuration::SolrField] solr field configuration
|
379
339
|
# @return [String]
|
380
340
|
def render_field_value value=nil, field_config=nil
|
341
|
+
Deprecation.warn self, "render_field_value is deprecated. Use DocumentPresenter.render_field_value instead"
|
381
342
|
safe_values = Array(value).collect { |x| x.respond_to?(:force_encoding) ? x.force_encoding("UTF-8") : x }
|
382
343
|
|
383
344
|
if field_config and field_config.itemprop
|
@@ -392,6 +353,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
392
353
|
#
|
393
354
|
# @return [String]
|
394
355
|
def field_value_separator
|
356
|
+
Deprecation.warn self, "field_value_separator is deprecated. Use DocumentPresenter.field_value_separator instead"
|
395
357
|
', '
|
396
358
|
end
|
397
359
|
|
@@ -466,19 +428,25 @@ module Blacklight::BlacklightHelperBehavior
|
|
466
428
|
|
467
429
|
##
|
468
430
|
# Return a normalized partial name for rendering a single document
|
469
|
-
#
|
431
|
+
#
|
470
432
|
# @param [SolrDocument]
|
433
|
+
# @param [Symbol] base name for the partial
|
471
434
|
# @return [String]
|
472
|
-
def document_partial_name(document)
|
473
|
-
|
435
|
+
def document_partial_name(document, base_name = nil)
|
436
|
+
view_config = blacklight_config.view_config(:show)
|
437
|
+
|
438
|
+
display_type = if base_name and view_config.has_key? :"#{base_name}_display_type_field"
|
439
|
+
document[view_config[:"#{base_name}_display_type_field"]]
|
440
|
+
end
|
441
|
+
|
442
|
+
display_type ||= document[view_config.display_type_field]
|
474
443
|
|
475
|
-
|
476
|
-
display_type = display_type.join(" ") if display_type.respond_to?(:join)
|
444
|
+
display_type ||= 'default'
|
477
445
|
|
478
446
|
# .to_s is necessary otherwise the default return value is not always a string
|
479
447
|
# using "_" as sep. to more closely follow the views file naming conventions
|
480
448
|
# parameterize uses "-" as the default sep. which throws errors
|
481
|
-
|
449
|
+
Array(display_type).join(" ").gsub("-","_").parameterize("_")
|
482
450
|
end
|
483
451
|
|
484
452
|
##
|
@@ -504,7 +472,12 @@ module Blacklight::BlacklightHelperBehavior
|
|
504
472
|
# @param [String] base name for the partial
|
505
473
|
# @param [Hash] locales to pass through to the partials
|
506
474
|
def render_document_partial(doc, base_name, locals = {})
|
507
|
-
format = document_partial_name
|
475
|
+
format = if method(:document_partial_name).arity == 1
|
476
|
+
Deprecation.warn self, "The #document_partial_name with a single argument is deprecated. Update your override to include a second argument for the 'base name'"
|
477
|
+
document_partial_name(doc)
|
478
|
+
else
|
479
|
+
document_partial_name(doc, base_name)
|
480
|
+
end
|
508
481
|
|
509
482
|
document_partial_path_templates.each do |str|
|
510
483
|
# XXX rather than handling this logic through exceptions, maybe there's a Rails internals method
|
@@ -544,12 +517,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
544
517
|
# @option opts [Proc] :label Evaluate the given proc
|
545
518
|
# @option opts [String] :label Render the given string
|
546
519
|
def render_document_index_label doc, opts = {}
|
547
|
-
|
548
|
-
label ||= doc.get(opts[:label], :sep => nil) if opts[:label].instance_of? Symbol
|
549
|
-
label ||= opts[:label].call(doc, opts) if opts[:label].instance_of? Proc
|
550
|
-
label ||= opts[:label] if opts[:label].is_a? String
|
551
|
-
label ||= doc.id
|
552
|
-
render_field_value label
|
520
|
+
presenter(doc).render_document_index_label opts
|
553
521
|
end
|
554
522
|
|
555
523
|
##
|
@@ -582,4 +550,15 @@ module Blacklight::BlacklightHelperBehavior
|
|
582
550
|
has_user_authentication_provider? and current_or_guest_user.present?
|
583
551
|
end
|
584
552
|
|
553
|
+
##
|
554
|
+
# Returns a document presenter for the given document
|
555
|
+
def presenter(document)
|
556
|
+
presenter_class.new(document, self)
|
557
|
+
end
|
558
|
+
|
559
|
+
##
|
560
|
+
# Override this method if you want to use a different presenter class
|
561
|
+
def presenter_class
|
562
|
+
Blacklight::DocumentPresenter
|
563
|
+
end
|
585
564
|
end
|
@@ -61,7 +61,7 @@ module Blacklight::CatalogHelperBehavior
|
|
61
61
|
# @see #page_entries_info
|
62
62
|
# @return [String]
|
63
63
|
def item_page_entry_info
|
64
|
-
t('blacklight.search.entry_pagination_info.other', :current => number_with_delimiter(search_session[
|
64
|
+
t('blacklight.search.entry_pagination_info.other', :current => number_with_delimiter(search_session['counter']), :total => number_with_delimiter(search_session['total']), :count => search_session['total'].to_i).html_safe
|
65
65
|
end
|
66
66
|
|
67
67
|
##
|
@@ -113,13 +113,6 @@ module Blacklight::CatalogHelperBehavior
|
|
113
113
|
render :partial => 'show_sidebar'
|
114
114
|
end
|
115
115
|
|
116
|
-
##
|
117
|
-
# Check if any search parameters have been set
|
118
|
-
# @return [Boolean]
|
119
|
-
def has_search_parameters?
|
120
|
-
!params[:q].blank? or !params[:f].blank? or !params[:search_field].blank?
|
121
|
-
end
|
122
|
-
|
123
116
|
##
|
124
117
|
# Should we display the sort and per page widget?
|
125
118
|
#
|
@@ -116,6 +116,14 @@ module Blacklight::ConfigurationHelperBehavior
|
|
116
116
|
##
|
117
117
|
# The default value for search results per page
|
118
118
|
def default_per_page
|
119
|
-
blacklight_config.
|
119
|
+
blacklight_config.default_per_page || blacklight_config.per_page.first
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
|
+
##
|
123
|
+
# The available options for results per page, in the style of #options_for_select
|
124
|
+
def per_page_options_for_select
|
125
|
+
blacklight_config.per_page.map do |count|
|
126
|
+
[t(:'blacklight.search.per_page.label', :count => count).html_safe, count]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -166,7 +166,7 @@ module Blacklight::FacetsHelperBehavior
|
|
166
166
|
|
167
167
|
value = facet_value_for_facet_item(item)
|
168
168
|
|
169
|
-
|
169
|
+
params[:f] and params[:f][field] and params[:f][field].include?(value)
|
170
170
|
end
|
171
171
|
|
172
172
|
##
|
@@ -198,6 +198,9 @@ module Blacklight::FacetsHelperBehavior
|
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
|
+
def facet_field_id facet_field
|
202
|
+
"facet-#{facet_field.field.parameterize}"
|
203
|
+
end
|
201
204
|
|
202
205
|
private
|
203
206
|
|
@@ -19,13 +19,13 @@ module Blacklight::SearchHistoryConstraintsHelperBehavior
|
|
19
19
|
##
|
20
20
|
# Render the search query constraint
|
21
21
|
def render_search_to_s_q(params)
|
22
|
-
return "".html_safe if params[
|
22
|
+
return "".html_safe if params['q'].blank?
|
23
23
|
|
24
24
|
label = (default_search_field && params[:search_field] == default_search_field[:key]) ?
|
25
25
|
nil :
|
26
26
|
label_for_search_field(params[:search_field])
|
27
27
|
|
28
|
-
render_search_to_s_element(label , render_filter_value(params[
|
28
|
+
render_search_to_s_element(label , render_filter_value(params['q']) )
|
29
29
|
end
|
30
30
|
|
31
31
|
##
|
@@ -1,11 +1,19 @@
|
|
1
|
+
require 'deprecation'
|
1
2
|
module Blacklight::UrlHelperBehavior
|
3
|
+
extend Deprecation
|
4
|
+
self.deprecation_horizon = 'blacklight 6.0'
|
2
5
|
|
3
6
|
##
|
4
7
|
# Extension point for downstream applications
|
5
|
-
# to provide more interesting routing to
|
8
|
+
# to provide more interesting routing to
|
6
9
|
# documents
|
7
10
|
def url_for_document doc
|
8
|
-
doc
|
11
|
+
if controller.is_a? Blacklight::Catalog and doc.is_a? SolrDocument and
|
12
|
+
(!doc.respond_to?(:to_model) or doc.to_model.is_a? SolrDocument)
|
13
|
+
{ controller: controller_name, action: :show, id: doc }
|
14
|
+
else
|
15
|
+
doc
|
16
|
+
end
|
9
17
|
end
|
10
18
|
|
11
19
|
# link_to_document(doc, :label=>'VIEW', :counter => 3)
|
@@ -15,13 +23,19 @@ module Blacklight::UrlHelperBehavior
|
|
15
23
|
def link_to_document(doc, opts={:label=>nil, :counter => nil})
|
16
24
|
opts[:label] ||= document_show_link_field(doc)
|
17
25
|
label = render_document_index_label doc, opts
|
18
|
-
link_to label, url_for_document(doc),
|
26
|
+
link_to label, url_for_document(doc), document_link_params(doc, opts)
|
19
27
|
end
|
20
28
|
|
29
|
+
def document_link_params(doc, opts)
|
30
|
+
session_tracking_params(doc, opts[:counter]).deep_merge(opts.except(:label, :counter))
|
31
|
+
end
|
32
|
+
protected :document_link_params
|
33
|
+
|
21
34
|
##
|
22
35
|
# Link to the previous document in the current search context
|
23
36
|
def link_to_previous_document(previous_document)
|
24
|
-
|
37
|
+
link_opts = session_tracking_params(previous_document, search_session['counter'].to_i - 1).merge(:class => "previous", :rel => 'prev')
|
38
|
+
link_to_unless previous_document.nil?, raw(t('views.pagination.previous')), url_for_document(previous_document), link_opts do
|
25
39
|
content_tag :span, raw(t('views.pagination.previous')), :class => 'previous'
|
26
40
|
end
|
27
41
|
end
|
@@ -29,16 +43,35 @@ module Blacklight::UrlHelperBehavior
|
|
29
43
|
##
|
30
44
|
# Link to the next document in the current search context
|
31
45
|
def link_to_next_document(next_document)
|
32
|
-
|
46
|
+
link_opts = session_tracking_params(next_document, search_session['counter'].to_i + 1).merge(:class => "next", :rel => 'next')
|
47
|
+
link_to_unless next_document.nil?, raw(t('views.pagination.next')), url_for_document(next_document), link_opts do
|
33
48
|
content_tag :span, raw(t('views.pagination.next')), :class => 'next'
|
34
49
|
end
|
35
50
|
end
|
36
51
|
|
37
52
|
##
|
38
53
|
# Current search context parameters
|
39
|
-
def search_session_params counter
|
54
|
+
def search_session_params counter
|
40
55
|
{ :'data-counter' => counter, :'data-search_id' => current_search_session.try(:id) }
|
41
56
|
end
|
57
|
+
deprecation_deprecate :search_session_params
|
58
|
+
|
59
|
+
##
|
60
|
+
# Attributes for a link that gives a URL we can use to track clicks for the current search session
|
61
|
+
# @param [SolrDocument] document
|
62
|
+
# @param [Integer] counter
|
63
|
+
# @example
|
64
|
+
# session_tracking_params(SolrDocument.new(id: 123), 7)
|
65
|
+
# => { data: { :'tracker-href' => '/catalog/123/track?counter=7&search_id=999' } }
|
66
|
+
def session_tracking_params document, counter
|
67
|
+
if document.nil?
|
68
|
+
return {}
|
69
|
+
end
|
70
|
+
|
71
|
+
{ :data => {:'context-href' => track_solr_document_path(document, counter: counter, search_id: current_search_session.try(:id))}}
|
72
|
+
end
|
73
|
+
protected :session_tracking_params
|
74
|
+
|
42
75
|
|
43
76
|
#
|
44
77
|
# link based helpers ->
|
@@ -140,7 +173,7 @@ module Blacklight::UrlHelperBehavior
|
|
140
173
|
# Reset any search parameters that store search context
|
141
174
|
# and need to be reset when e.g. constraints change
|
142
175
|
def reset_search_params source_params
|
143
|
-
sanitize_search_params(source_params).except
|
176
|
+
sanitize_search_params(source_params).except(:page, :counter).with_indifferent_access
|
144
177
|
end
|
145
178
|
|
146
179
|
# adds the value and/or field to params[:f]
|
@@ -212,6 +245,7 @@ module Blacklight::UrlHelperBehavior
|
|
212
245
|
p[:f][field] = (p[:f][field] || []).dup
|
213
246
|
p[:f][field] = p[:f][field] - [value]
|
214
247
|
p[:f].delete(field) if p[:f][field].size == 0
|
248
|
+
p.delete(:f) if p[:f].empty?
|
215
249
|
p
|
216
250
|
end
|
217
251
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<div class="panel panel-default facet_limit blacklight-<%= facet_field.field.parameterize %> <%= 'facet_limit-active' if facet_field_in_params?(facet_field.field) %>">
|
2
|
-
<div class="<%= "collapsed" if should_collapse_facet?(facet_field) %> collapse-toggle panel-heading" data-toggle="collapse" data-target="
|
2
|
+
<div class="<%= "collapsed" if should_collapse_facet?(facet_field) %> collapse-toggle panel-heading" data-toggle="collapse" data-target="#<%= facet_field_id(facet_field) %>">
|
3
3
|
<h5 class="panel-title">
|
4
4
|
<%= link_to facet_field_label(facet_field.field), "#", :"data-no-turbolink" => true %>
|
5
5
|
</h5>
|
6
6
|
</div>
|
7
|
-
<div id="
|
7
|
+
<div id="<%= facet_field_id(facet_field) %>" class="panel-collapse facet-content <%= should_collapse_facet?(facet_field) ? 'collapse' : 'in' %>">
|
8
8
|
<div class="panel-body">
|
9
9
|
<%= yield %>
|
10
10
|
</div>
|
@@ -4,9 +4,9 @@
|
|
4
4
|
<div id="per_page-dropdown" class="btn-group">
|
5
5
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><%= link_to(t(:'blacklight.search.per_page.button_label', :count => current_per_page), "#") %> <span class="caret"></span></button>
|
6
6
|
<ul class="dropdown-menu">
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
<%- per_page_options_for_select.each do |(label, count)| %>
|
8
|
+
<li><%= link_to(label, url_for(params_for_search(:per_page => count))) %></li>
|
9
|
+
<%- end -%>
|
10
10
|
</ul>
|
11
11
|
</div>
|
12
|
-
<% end %>
|
12
|
+
<% end %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<%= render 'previous_next_doc' %>
|
4
4
|
|
5
5
|
|
6
|
-
<% @page_title = t('blacklight.search.show.title', :document_title => document_show_html_title, :application_name => application_name) -%>
|
6
|
+
<% @page_title = t('blacklight.search.show.title', :document_title => document_show_html_title, :application_name => application_name).html_safe -%>
|
7
7
|
<% content_for(:head) { render_link_rel_alternates } -%>
|
8
8
|
<%# this should be in a partial -%>
|
9
9
|
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<meta http-equiv="cleartype" content="on">
|
14
14
|
<![endif]-->
|
15
15
|
|
16
|
-
<title><%=
|
16
|
+
<title><%= render_page_title %></title>
|
17
17
|
<link href="<%= opensearch_catalog_path(:format => 'xml', :only_path => false) %>" title="<%= application_name%>" type="application/opensearchdescription+xml" rel="search"/>
|
18
18
|
<%= favicon_link_tag asset_path('favicon.ico') %>
|
19
19
|
<%= stylesheet_link_tag "application" %>
|
data/blacklight.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency "bootstrap-sass", "~> 3.0"
|
25
25
|
s.add_dependency "deprecation"
|
26
26
|
|
27
|
-
s.add_development_dependency "jettywrapper", ">= 1.
|
27
|
+
s.add_development_dependency "jettywrapper", ">= 1.7.0"
|
28
28
|
s.add_development_dependency "blacklight-marc", "~> 5.0"
|
29
29
|
s.add_development_dependency "rspec-rails"
|
30
30
|
s.add_development_dependency "capybara"
|