blacklight 5.0.0.pre4 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +225 -123
- data/app/helpers/blacklight/catalog_helper_behavior.rb +87 -14
- data/app/helpers/blacklight/configuration_helper_behavior.rb +61 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +67 -22
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +4 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +33 -10
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +8 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +7 -0
- data/app/helpers/blacklight_configuration_helper.rb +3 -0
- data/app/views/catalog/_constraints_element.html.erb +4 -6
- data/lib/blacklight/solr/document.rb +1 -1
- data/lib/blacklight/utils.rb +1 -1
- data/lib/generators/blacklight/install_generator.rb +4 -0
- data/lib/generators/blacklight/templates/blacklight.en.yml +3 -0
- data/solr/sample_solr_documents.yml +2120 -70
- data/spec/helpers/configuration_helper_spec.rb +61 -0
- data/spec/helpers/url_helper_spec.rb +7 -0
- data/spec/lib/blacklight/solr/document_spec.rb +8 -0
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c8f10c08ef2255599634c398a2e28201f7bbbf6
|
4
|
+
data.tar.gz: 1275af21c316d9b9c4f723eaecac370298e0b10a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 204052b9659c971b75293272467b192a7026d7284a74ee91a971f4e0147fcce6144d5d831caca2e62f61c4a3611612e24119c73b6ecb126f2e7b16950eb737b1
|
7
|
+
data.tar.gz: e91a0333a881eab6272d99c151d469cf9ee2c88098a83e488c58217a71e9d9ada6fab25c813926f9d3d3e0ab313d9900a5e7d07ba332ae5732237965681bae10
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.0.0
|
1
|
+
5.0.0
|
@@ -5,25 +5,35 @@
|
|
5
5
|
#
|
6
6
|
module Blacklight::BlacklightHelperBehavior
|
7
7
|
include BlacklightUrlHelper
|
8
|
+
include BlacklightConfigurationHelper
|
8
9
|
include HashAsHiddenFieldsHelper
|
9
10
|
include RenderConstraintsHelper
|
10
11
|
include FacetsHelper
|
11
12
|
|
13
|
+
##
|
14
|
+
# Get the name of this application, from either:
|
15
|
+
# - the Rails configuration
|
16
|
+
# - an i18n string (key: blacklight.application_name; preferred)
|
17
|
+
#
|
18
|
+
# @return [String] the application named
|
12
19
|
def application_name
|
13
20
|
return Rails.application.config.application_name if Rails.application.config.respond_to? :application_name
|
14
21
|
|
15
22
|
t('blacklight.application_name')
|
16
23
|
end
|
17
24
|
|
25
|
+
##
|
18
26
|
# Create <link rel="alternate"> links from a documents dynamically
|
19
27
|
# provided export formats. Currently not used by standard BL layouts,
|
20
28
|
# but available for your custom layouts to provide link rel alternates.
|
21
29
|
#
|
22
30
|
# Returns empty string if no links available.
|
23
31
|
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
32
|
+
# @params [SolrDocument] document
|
33
|
+
# @params [Hash] options
|
34
|
+
# @option options [Boolean] :unique ensures only one link is output for every
|
35
|
+
# content type, e.g. as required by atom
|
36
|
+
# @option options [Array<String>] :exclude array of format shortnames to not include in the output
|
27
37
|
def render_link_rel_alternates(document=@document, options = {})
|
28
38
|
options = {:unique => false, :exclude => []}.merge(options)
|
29
39
|
|
@@ -44,28 +54,43 @@ module Blacklight::BlacklightHelperBehavior
|
|
44
54
|
return html.html_safe
|
45
55
|
end
|
46
56
|
|
57
|
+
##
|
58
|
+
# Render OpenSearch headers for this search
|
59
|
+
# @return [String]
|
47
60
|
def render_opensearch_response_metadata
|
48
61
|
render :partial => 'catalog/opensearch_response_metadata'
|
49
62
|
end
|
50
63
|
|
64
|
+
##
|
65
|
+
# Render classes for the <body> element
|
66
|
+
# @return [String]
|
51
67
|
def render_body_class
|
52
68
|
extra_body_classes.join " "
|
53
69
|
end
|
54
70
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
71
|
+
##
|
72
|
+
# List of classes to be applied to the <body> element
|
73
|
+
# @see render_body_class
|
74
|
+
# @return [Array<String>]
|
59
75
|
def extra_body_classes
|
60
76
|
@extra_body_classes ||= ['blacklight-' + controller.controller_name, 'blacklight-' + [controller.controller_name, controller.action_name].join('-')]
|
61
77
|
end
|
62
78
|
|
63
|
-
|
64
|
-
|
79
|
+
##
|
80
|
+
# Render the search navbar
|
81
|
+
# @return [String]
|
82
|
+
def render_search_bar
|
83
|
+
render :partial=>'catalog/search_form'
|
65
84
|
end
|
66
85
|
|
67
|
-
|
68
|
-
#
|
86
|
+
##
|
87
|
+
# Render "docuemnt actions" area for search results view
|
88
|
+
# (normally renders next to title in the list view)
|
89
|
+
#
|
90
|
+
# @param [SolrDocument] document
|
91
|
+
# @param [Hash] options
|
92
|
+
# @option options [String] :wrapping_class
|
93
|
+
# @return [String]
|
69
94
|
def render_index_doc_actions(document, options={})
|
70
95
|
wrapping_class = options.delete(:wrapping_class) || "index-document-functions"
|
71
96
|
|
@@ -75,12 +100,18 @@ module Blacklight::BlacklightHelperBehavior
|
|
75
100
|
content_tag("div", safe_join(content, "\n"), :class=> wrapping_class)
|
76
101
|
end
|
77
102
|
|
78
|
-
|
79
|
-
#
|
103
|
+
##
|
104
|
+
# Render "docuemnt actions" for the item detail 'show' view.
|
105
|
+
# (this normally renders next to title)
|
106
|
+
#
|
107
|
+
# By default includes 'Bookmarks'
|
108
|
+
#
|
109
|
+
# @param [SolrDocument] document
|
110
|
+
# @param [Hash] options
|
111
|
+
# @option options [String] :wrapping_class
|
112
|
+
# @return [String]
|
80
113
|
def render_show_doc_actions(document=@document, options={})
|
81
|
-
|
82
|
-
# TODO: remove documentFunctions key in Blacklight 5.x
|
83
|
-
wrapping_class = options.delete(:documentFunctions) || options.delete(:wrapping_class) || "documentFunctions"
|
114
|
+
wrapping_class = options.delete(:wrapping_class) || "documentFunctions"
|
84
115
|
|
85
116
|
content = []
|
86
117
|
content << render(:partial => 'catalog/bookmark_control', :locals => {:document=> document}.merge(options)) if render_bookmarks_control?
|
@@ -89,17 +120,34 @@ module Blacklight::BlacklightHelperBehavior
|
|
89
120
|
end
|
90
121
|
|
91
122
|
##
|
92
|
-
#
|
93
|
-
|
94
|
-
|
123
|
+
# Determine whether to render a given field in the index view.
|
124
|
+
#
|
125
|
+
# @param [SolrDocument] document
|
126
|
+
# @param [Blacklight::Solr::Configuration::SolrField] solr_field
|
127
|
+
# @return [Boolean]
|
128
|
+
def should_render_index_field? document, solr_field
|
129
|
+
document.has?(solr_field.field) ||
|
130
|
+
(document.has_highlight_field? solr_field.field if solr_field.highlight) ||
|
131
|
+
solr_field.accessor
|
95
132
|
end
|
96
133
|
|
97
|
-
|
134
|
+
##
|
135
|
+
# Determine whether to render a given field in the show view
|
136
|
+
#
|
137
|
+
# @param [SolrDocument] document
|
138
|
+
# @param [Blacklight::Solr::Configuration::SolrField] solr_field
|
139
|
+
# @return [Boolean]
|
140
|
+
def should_render_show_field? document, solr_field
|
98
141
|
document.has?(solr_field.field) ||
|
99
142
|
(document.has_highlight_field? solr_field.field if solr_field.highlight) ||
|
100
143
|
solr_field.accessor
|
101
144
|
end
|
102
145
|
|
146
|
+
##
|
147
|
+
# Determine whether to display spellcheck suggestions
|
148
|
+
#
|
149
|
+
# @param [Blacklight::SolrResponse] response
|
150
|
+
# @return [Boolean]
|
103
151
|
def should_show_spellcheck_suggestions? response
|
104
152
|
response.total <= spell_check_max and response.spelling.words.size > 0
|
105
153
|
end
|
@@ -156,69 +204,9 @@ module Blacklight::BlacklightHelperBehavior
|
|
156
204
|
field_config = index_fields(document)[field]
|
157
205
|
value = options[:value] || get_field_values(document, field, field_config, options)
|
158
206
|
|
159
|
-
|
160
207
|
render_field_value value, field_config
|
161
208
|
end
|
162
209
|
|
163
|
-
# Used in the show view for displaying the main solr document heading
|
164
|
-
def document_heading document=nil
|
165
|
-
document ||= @document
|
166
|
-
render_field_value document[blacklight_config.view_config(:show).title_field] || document.id
|
167
|
-
end
|
168
|
-
|
169
|
-
# Used in the show view for setting the main html document title
|
170
|
-
def document_show_html_title document=nil
|
171
|
-
document ||= @document
|
172
|
-
|
173
|
-
if blacklight_config.view_config(:show).html_title_field
|
174
|
-
render_field_value(document[blacklight_config.view_config(:show).html_title_field])
|
175
|
-
else
|
176
|
-
document_heading document
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
##
|
181
|
-
# Render the document "heading" (title) in a content tag
|
182
|
-
# @overload render_document_heading(tag)
|
183
|
-
# @overload render_document_heading(document, options)
|
184
|
-
# @params [SolrDocument] document
|
185
|
-
# @params [Hash] options
|
186
|
-
# @options options [Symbol] :tag
|
187
|
-
def render_document_heading(*args)
|
188
|
-
options = args.extract_options!
|
189
|
-
if args.first.is_a? SolrDocument
|
190
|
-
document = args.shift
|
191
|
-
tag = options[:tag]
|
192
|
-
else
|
193
|
-
document = nil
|
194
|
-
tag = args.first || options[:tag]
|
195
|
-
end
|
196
|
-
|
197
|
-
tag ||= :h4
|
198
|
-
|
199
|
-
content_tag(tag, render_field_value(document_heading(document)), :itemprop => "name")
|
200
|
-
end
|
201
|
-
|
202
|
-
# Used in the document_list partial (search view) for building a select element
|
203
|
-
def sort_fields
|
204
|
-
blacklight_config.sort_fields.map { |key, x| [x.label, x.key] }
|
205
|
-
end
|
206
|
-
|
207
|
-
# Used in the document list partial (search view) for creating a link to the document show action
|
208
|
-
def document_show_link_field document=nil
|
209
|
-
blacklight_config.view_config(document_index_view_type).title_field.to_sym
|
210
|
-
end
|
211
|
-
|
212
|
-
# Used in the search form partial for building a select tag
|
213
|
-
def search_fields
|
214
|
-
search_field_options_for_select
|
215
|
-
end
|
216
|
-
|
217
|
-
# used in the catalog/_show/_default partial
|
218
|
-
def document_show_fields document=nil
|
219
|
-
blacklight_config.show_fields
|
220
|
-
end
|
221
|
-
|
222
210
|
##
|
223
211
|
# Render the show field label for a document
|
224
212
|
#
|
@@ -265,7 +253,6 @@ module Blacklight::BlacklightHelperBehavior
|
|
265
253
|
# @param [Hash] opts
|
266
254
|
# @options opts [String] :value
|
267
255
|
def render_document_show_field_value *args
|
268
|
-
|
269
256
|
options = args.extract_options!
|
270
257
|
document = args.shift || options[:document]
|
271
258
|
|
@@ -276,6 +263,56 @@ module Blacklight::BlacklightHelperBehavior
|
|
276
263
|
render_field_value value, field_config
|
277
264
|
end
|
278
265
|
|
266
|
+
##
|
267
|
+
# Get the value of the document's "title" field, or a placeholder
|
268
|
+
# value (if empty)
|
269
|
+
#
|
270
|
+
# @param [SolrDocument] document
|
271
|
+
# @return [String]
|
272
|
+
def document_heading document=nil
|
273
|
+
document ||= @document
|
274
|
+
render_field_value(document[blacklight_config.view_config(:show).title_field] || document.id)
|
275
|
+
end
|
276
|
+
|
277
|
+
##
|
278
|
+
# Get the document's "title" to display in the <title> element.
|
279
|
+
# (by default, use the #document_heading)
|
280
|
+
#
|
281
|
+
# @see #document_heading
|
282
|
+
# @param [SolrDocument] document
|
283
|
+
# @return [String]
|
284
|
+
def document_show_html_title document=nil
|
285
|
+
document ||= @document
|
286
|
+
|
287
|
+
if blacklight_config.view_config(:show).html_title_field
|
288
|
+
render_field_value(document[blacklight_config.view_config(:show).html_title_field])
|
289
|
+
else
|
290
|
+
document_heading document
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
##
|
295
|
+
# Render the document "heading" (title) in a content tag
|
296
|
+
# @overload render_document_heading(tag)
|
297
|
+
# @overload render_document_heading(document, options)
|
298
|
+
# @params [SolrDocument] document
|
299
|
+
# @params [Hash] options
|
300
|
+
# @options options [Symbol] :tag
|
301
|
+
def render_document_heading(*args)
|
302
|
+
options = args.extract_options!
|
303
|
+
if args.first.is_a? SolrDocument
|
304
|
+
document = args.shift
|
305
|
+
tag = options[:tag]
|
306
|
+
else
|
307
|
+
document = nil
|
308
|
+
tag = args.first || options[:tag]
|
309
|
+
end
|
310
|
+
|
311
|
+
tag ||= :h4
|
312
|
+
|
313
|
+
content_tag(tag, render_field_value(document_heading(document)), :itemprop => "name")
|
314
|
+
end
|
315
|
+
|
279
316
|
##
|
280
317
|
# Get the value for a document's field, and prepare to render it.
|
281
318
|
# - highlight_field
|
@@ -287,8 +324,12 @@ module Blacklight::BlacklightHelperBehavior
|
|
287
324
|
# - link_to_search
|
288
325
|
# TODO : maybe this should be merged with render_field_value, and the ugly signature
|
289
326
|
# simplified by pushing some of this logic into the "model"
|
327
|
+
# @param [SolrDocument] document
|
328
|
+
# @param [String] field name
|
329
|
+
# @param [Blacklight::Solr::Configuration::SolrField] solr field configuration
|
330
|
+
# @param [Hash] options additional options to pass to the rendering helpers
|
290
331
|
def get_field_values document, field, field_config, options = {}
|
291
|
-
#
|
332
|
+
# retrieving values
|
292
333
|
value = case
|
293
334
|
when (field_config and field_config.highlight)
|
294
335
|
# retrieve the document value from the highlighting response
|
@@ -311,7 +352,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
311
352
|
document.get(field, :sep => nil) if field
|
312
353
|
end
|
313
354
|
|
314
|
-
# rendering
|
355
|
+
# rendering values
|
315
356
|
case
|
316
357
|
when (field_config and field_config.helper_method)
|
317
358
|
send(field_config.helper_method, options.merge(:document => document, :field => field, :value => value))
|
@@ -330,12 +371,12 @@ module Blacklight::BlacklightHelperBehavior
|
|
330
371
|
end
|
331
372
|
end
|
332
373
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
374
|
+
##
|
375
|
+
# Render a value (or array of values) from a field
|
376
|
+
#
|
377
|
+
# @param [String] value or list of values to display
|
378
|
+
# @param [Blacklight::Solr::Configuration::SolrField] solr field configuration
|
379
|
+
# @return [String]
|
339
380
|
def render_field_value value=nil, field_config=nil
|
340
381
|
safe_values = Array(value).collect { |x| x.respond_to?(:force_encoding) ? x.force_encoding("UTF-8") : x }
|
341
382
|
|
@@ -346,10 +387,19 @@ module Blacklight::BlacklightHelperBehavior
|
|
346
387
|
safe_join(safe_values, (field_config.separator if field_config) || field_value_separator)
|
347
388
|
end
|
348
389
|
|
390
|
+
##
|
391
|
+
# Default separator to use in #render_field_value
|
392
|
+
#
|
393
|
+
# @return [String]
|
349
394
|
def field_value_separator
|
350
395
|
', '
|
351
396
|
end
|
352
397
|
|
398
|
+
##
|
399
|
+
# Get the current "view type" (and ensure it is a valid type)
|
400
|
+
#
|
401
|
+
# @param [Hash] the query parameters to check
|
402
|
+
# @return [Symbol]
|
353
403
|
def document_index_view_type query_params=params
|
354
404
|
if query_params[:view] and blacklight_config.view.keys.include? query_params[:view].to_sym
|
355
405
|
query_params[:view].to_sym
|
@@ -358,21 +408,42 @@ module Blacklight::BlacklightHelperBehavior
|
|
358
408
|
end
|
359
409
|
end
|
360
410
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
411
|
+
##
|
412
|
+
# Render the document index view
|
413
|
+
#
|
414
|
+
# @param [Array<SolrDocument>] list of documents to render
|
415
|
+
# @param [Hash] locals to pass to the render call
|
416
|
+
# @return [String]
|
365
417
|
def render_document_index documents = nil, locals = {}
|
366
418
|
documents ||= @document_list
|
367
419
|
render_document_index_with_view(document_index_view_type, documents)
|
368
420
|
end
|
369
421
|
|
422
|
+
##
|
423
|
+
# Render the document index for a grouped response
|
424
|
+
def render_grouped_document_index
|
425
|
+
render :partial => 'catalog/group_default'
|
426
|
+
end
|
427
|
+
|
428
|
+
##
|
429
|
+
# Render the document index for the given view type with the
|
430
|
+
# list of documents.
|
431
|
+
#
|
432
|
+
# This method will interpolate the list of templates with
|
433
|
+
# the current view, and gracefully handles missing templates.
|
434
|
+
#
|
435
|
+
# @see #document_index_path_templates
|
436
|
+
#
|
437
|
+
# @param [String] view type
|
438
|
+
# @param [Array<SolrDocument>] list of documents to render
|
439
|
+
# @param [Hash] locals to pass to the render call
|
440
|
+
# @return [String]
|
370
441
|
def render_document_index_with_view view, documents, locals = {}
|
371
442
|
document_index_path_templates.each do |str|
|
372
443
|
# XXX rather than handling this logic through exceptions, maybe there's a Rails internals method
|
373
444
|
# for determining if a partial template exists..
|
374
445
|
begin
|
375
|
-
return render(:partial => (str % { :index_view_type => view }), :locals =>
|
446
|
+
return render(:partial => (str % { :index_view_type => view }), :locals => locals.merge(:documents => documents) )
|
376
447
|
rescue ActionView::MissingTemplate
|
377
448
|
nil
|
378
449
|
end
|
@@ -381,7 +452,11 @@ module Blacklight::BlacklightHelperBehavior
|
|
381
452
|
return ""
|
382
453
|
end
|
383
454
|
|
384
|
-
|
455
|
+
##
|
456
|
+
# A list of document partial templates to attempt to render
|
457
|
+
#
|
458
|
+
# @see #render_document_index_with_view
|
459
|
+
# @return [Array<String>]
|
385
460
|
def document_index_path_templates
|
386
461
|
# first, the legacy template names for backwards compatbility
|
387
462
|
# followed by the new, inheritable style
|
@@ -389,37 +464,53 @@ module Blacklight::BlacklightHelperBehavior
|
|
389
464
|
@document_index_path_templates ||= ["document_%{index_view_type}", "catalog/document_%{index_view_type}", "catalog/document_list"]
|
390
465
|
end
|
391
466
|
|
392
|
-
|
467
|
+
##
|
468
|
+
# Return a normalized partial name for rendering a single document
|
469
|
+
#
|
470
|
+
# @param [SolrDocument]
|
471
|
+
# @return [String]
|
393
472
|
def document_partial_name(document)
|
394
|
-
# .to_s is necessary otherwise the default return value is not always a string
|
395
|
-
# using "_" as sep. to more closely follow the views file naming conventions
|
396
|
-
# parameterize uses "-" as the default sep. which throws errors
|
397
473
|
display_type = document[blacklight_config.view_config(:show).display_type_field]
|
398
474
|
|
399
475
|
return 'default' unless display_type
|
400
476
|
display_type = display_type.join(" ") if display_type.respond_to?(:join)
|
401
477
|
|
478
|
+
# .to_s is necessary otherwise the default return value is not always a string
|
479
|
+
# using "_" as sep. to more closely follow the views file naming conventions
|
480
|
+
# parameterize uses "-" as the default sep. which throws errors
|
402
481
|
"#{display_type.gsub("-"," ")}".parameterize("_").to_s
|
403
482
|
end
|
404
483
|
|
405
|
-
|
406
|
-
|
484
|
+
##
|
485
|
+
# Return the list of partials for a given solr document
|
486
|
+
# @param [SolrDocument]
|
487
|
+
# @return [String]
|
488
|
+
def render_document_partials(doc, partials = [], locals ={})
|
489
|
+
safe_join(partials.map do |action_name|
|
407
490
|
render_document_partial(doc, action_name, locals)
|
408
491
|
end, "\n")
|
409
492
|
end
|
410
493
|
|
411
|
-
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
|
494
|
+
##
|
495
|
+
# Given a doc and a base name for a partial, this method will attempt to render
|
496
|
+
# an appropriate partial based on the document format and view type.
|
497
|
+
#
|
498
|
+
# If a partial that matches the document format is not found,
|
499
|
+
# render a default partial for the base name.
|
500
|
+
#
|
501
|
+
# @see #document_partial_path_templates
|
502
|
+
#
|
503
|
+
# @param [SolrDocument] doc
|
504
|
+
# @param [String] base name for the partial
|
505
|
+
# @param [Hash] locales to pass through to the partials
|
506
|
+
def render_document_partial(doc, base_name, locals = {})
|
416
507
|
format = document_partial_name(doc)
|
417
508
|
|
418
509
|
document_partial_path_templates.each do |str|
|
419
510
|
# XXX rather than handling this logic through exceptions, maybe there's a Rails internals method
|
420
511
|
# for determining if a partial template exists..
|
421
512
|
begin
|
422
|
-
return render :partial => (str % { :action_name =>
|
513
|
+
return render :partial => (str % { :action_name => base_name, :format => format, :index_view_type => document_index_view_type }), :locals=>locals.merge(:document=>doc)
|
423
514
|
rescue ActionView::MissingTemplate
|
424
515
|
nil
|
425
516
|
end
|
@@ -428,7 +519,15 @@ module Blacklight::BlacklightHelperBehavior
|
|
428
519
|
return ''
|
429
520
|
end
|
430
521
|
|
431
|
-
|
522
|
+
##
|
523
|
+
# A list of document partial templates to try to render for a document
|
524
|
+
#
|
525
|
+
# The partial names will be interpolated with the following variables:
|
526
|
+
# - action_name: (e.g. index, show)
|
527
|
+
# - index_view_type: (the current view type, e.g. list, gallery)
|
528
|
+
# - format: the document's format (e.g. book)
|
529
|
+
#
|
530
|
+
# @see #render_document_partial
|
432
531
|
def document_partial_path_templates
|
433
532
|
# first, the legacy template names for backwards compatbility
|
434
533
|
# followed by the new, inheritable style
|
@@ -436,9 +535,15 @@ module Blacklight::BlacklightHelperBehavior
|
|
436
535
|
@partial_path_templates ||= ["%{action_name}_%{index_view_type}_%{format}", "%{action_name}_%{index_view_type}_default", "%{action_name}_%{format}", "%{action_name}_default", "catalog/%{action_name}_%{format}", "catalog/_%{action_name}_partials/%{format}", "catalog/_%{action_name}_partials/default"]
|
437
536
|
end
|
438
537
|
|
439
|
-
|
440
|
-
|
441
|
-
|
538
|
+
##
|
539
|
+
# Render the document index heading
|
540
|
+
#
|
541
|
+
# @param [SolrDocument] doc
|
542
|
+
# @param [Hash] opts
|
543
|
+
# @option opts [Symbol] :label Render the given field from the document
|
544
|
+
# @option opts [Proc] :label Evaluate the given proc
|
545
|
+
# @option opts [String] :label Render the given string
|
546
|
+
def render_document_index_label doc, opts = {}
|
442
547
|
label = nil
|
443
548
|
label ||= doc.get(opts[:label], :sep => nil) if opts[:label].instance_of? Symbol
|
444
549
|
label ||= opts[:label].call(doc, opts) if opts[:label].instance_of? Proc
|
@@ -447,10 +552,15 @@ module Blacklight::BlacklightHelperBehavior
|
|
447
552
|
render_field_value label
|
448
553
|
end
|
449
554
|
|
450
|
-
|
451
|
-
#
|
452
|
-
# a
|
555
|
+
##
|
556
|
+
# Render a partial of an arbitrary format inside a
|
557
|
+
# template of a different format. (e.g. render an HTML
|
558
|
+
# partial from an XML template)
|
559
|
+
# code taken from:
|
453
560
|
# http://stackoverflow.com/questions/339130/how-do-i-render-a-partial-of-a-different-format-in-rails (zgchurch)
|
561
|
+
#
|
562
|
+
# @param [String] format suffix
|
563
|
+
# @yield
|
454
564
|
def with_format(format, &block)
|
455
565
|
old_formats = formats
|
456
566
|
self.formats = [format]
|
@@ -467,17 +577,9 @@ module Blacklight::BlacklightHelperBehavior
|
|
467
577
|
end
|
468
578
|
|
469
579
|
##
|
470
|
-
#
|
471
|
-
def render_grouped_document_index grouped_key = nil
|
472
|
-
render :partial => 'catalog/group_default'
|
473
|
-
end
|
474
|
-
|
580
|
+
# Determine whether to render the bookmarks control
|
475
581
|
def render_bookmarks_control?
|
476
582
|
has_user_authentication_provider? and current_or_guest_user.present?
|
477
583
|
end
|
478
584
|
|
479
|
-
def spell_check_max
|
480
|
-
blacklight_config.spell_max
|
481
|
-
end
|
482
|
-
|
483
585
|
end
|