blacklight 3.1.2 → 3.2.0pre1

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 (121) hide show
  1. data/.gitignore +5 -2
  2. data/README.md +7 -2
  3. data/VERSION +1 -1
  4. data/app/assets/images/favicon.ico +0 -0
  5. data/app/assets/javascripts/blacklight/blacklight.js +23 -1
  6. data/app/assets/stylesheets/blacklight/_catalog.css.scss +369 -0
  7. data/app/assets/stylesheets/blacklight/_facets.css.scss +117 -0
  8. data/app/assets/stylesheets/blacklight/_folder.css.scss +38 -0
  9. data/app/assets/stylesheets/blacklight/_formatting.css.scss +164 -0
  10. data/app/assets/stylesheets/blacklight/_header.css.scss +36 -0
  11. data/app/assets/stylesheets/blacklight/_layout.css.scss +79 -0
  12. data/app/assets/stylesheets/blacklight/_print.css.scss +54 -0
  13. data/app/assets/stylesheets/blacklight/_search_history.css.scss +44 -0
  14. data/app/assets/stylesheets/blacklight/_susy_framework.css.scss +228 -0
  15. data/app/assets/stylesheets/blacklight/blacklight.css.scss +27 -0
  16. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +48 -0
  17. data/app/controllers/bookmarks_controller.rb +2 -1
  18. data/app/controllers/folder_controller.rb +4 -0
  19. data/app/controllers/saved_searches_controller.rb +4 -0
  20. data/app/controllers/search_history_controller.rb +4 -0
  21. data/app/helpers/blacklight/blacklight_helper_behavior.rb +64 -104
  22. data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -4
  23. data/app/helpers/blacklight/facets_helper_behavior.rb +52 -5
  24. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +14 -59
  25. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +56 -0
  26. data/app/helpers/search_history_constraints_helper.rb +3 -0
  27. data/app/models/record_mailer.rb +1 -2
  28. data/app/views/_flash_msg.html.erb +4 -5
  29. data/app/views/_user_util_links.html.erb +3 -1
  30. data/app/views/bookmarks/index.html.erb +2 -2
  31. data/app/views/catalog/_bookmark_control.html.erb +6 -6
  32. data/app/views/catalog/_facet_layout.html.erb +4 -0
  33. data/app/views/catalog/_facet_limit.html.erb +20 -33
  34. data/app/views/catalog/_facets.html.erb +1 -5
  35. data/app/views/catalog/_folder_control.html.erb +5 -5
  36. data/app/views/catalog/_index_default.html.erb +1 -1
  37. data/app/views/catalog/_search_form.html.erb +4 -3
  38. data/app/views/catalog/_show_default.html.erb +1 -1
  39. data/app/views/catalog/_show_tools.html.erb +6 -6
  40. data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
  41. data/app/views/catalog/index.atom.builder +2 -2
  42. data/app/views/catalog/index.rss.builder +1 -1
  43. data/app/views/catalog/opensearch.xml.builder +10 -0
  44. data/app/views/catalog/show.html.erb +1 -1
  45. data/app/views/folder/_tools.html.erb +4 -4
  46. data/app/views/layouts/blacklight.html.erb +25 -37
  47. data/app/views/record_mailer/email_record.text.erb +1 -1
  48. data/app/views/record_mailer/sms_record.text.erb +2 -2
  49. data/app/views/search_history/index.html.erb +1 -1
  50. data/blacklight.gemspec +11 -9
  51. data/lib/{generators/blacklight/templates/SolrMarc.jar → SolrMarc.jar} +0 -0
  52. data/lib/blacklight.rb +5 -3
  53. data/lib/blacklight/catalog.rb +3 -4
  54. data/lib/blacklight/configurable.rb +54 -39
  55. data/lib/blacklight/configuration.rb +126 -0
  56. data/lib/blacklight/configuration/fields.rb +142 -0
  57. data/lib/blacklight/configuration/search_field.rb +12 -0
  58. data/lib/blacklight/configuration/solr_field.rb +12 -0
  59. data/lib/blacklight/configuration/sort_field.rb +17 -0
  60. data/lib/blacklight/controller.rb +16 -14
  61. data/lib/blacklight/engine.rb +1 -1
  62. data/lib/blacklight/global_configurable.rb +46 -0
  63. data/lib/blacklight/search_fields.rb +21 -54
  64. data/lib/blacklight/solr/document.rb +13 -3
  65. data/lib/blacklight/solr_helper.rb +88 -52
  66. data/lib/blacklight/utils.rb +18 -0
  67. data/lib/generators/blacklight/assets_generator.rb +14 -20
  68. data/lib/generators/blacklight/blacklight_generator.rb +14 -6
  69. data/lib/generators/blacklight/jetty_generator.rb +1 -1
  70. data/lib/generators/blacklight/templates/assets/standard.css.scss +51 -0
  71. data/lib/generators/blacklight/templates/catalog_controller.rb +148 -0
  72. data/lib/generators/blacklight/templates/config/blacklight_config.rb +2 -239
  73. data/lib/generators/blacklight/templates/config/sass.rb +5 -0
  74. data/lib/generators/blacklight/templates/solr_conf/schema.xml +514 -164
  75. data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +1591 -323
  76. data/lib/generators/blacklight/templates/solr_document.rb +2 -0
  77. data/lib/railties/all_tests.rake +36 -3
  78. data/lib/railties/blacklight_cucumber.rake +6 -4
  79. data/lib/railties/blacklight_rspec.rake +5 -4
  80. data/test_support/bin/run-tests.sh +2 -13
  81. data/test_support/bin/test.sh +30 -23
  82. data/test_support/features/did_you_mean.feature +14 -13
  83. data/test_support/features/step_definitions/saved_searches_steps.rb +1 -1
  84. data/test_support/features/step_definitions/search_steps.rb +4 -4
  85. data/test_support/spec/controllers/application_controller_spec.rb +3 -13
  86. data/test_support/spec/controllers/catalog_controller_spec.rb +102 -24
  87. data/test_support/spec/controllers/folder_controller_spec.rb +7 -1
  88. data/test_support/spec/helpers/blacklight_helper_spec.rb +45 -34
  89. data/test_support/spec/helpers/facets_helper_spec.rb +68 -0
  90. data/test_support/spec/helpers/html_head_helper_spec.rb +37 -0
  91. data/test_support/spec/helpers/{render_constraints_helper_spec.rb → search_history_constraints_helper_spec.rb} +26 -7
  92. data/test_support/spec/lib/blacklight_configurable_spec.rb +92 -0
  93. data/test_support/spec/lib/blacklight_configuration_spec.rb +295 -0
  94. data/test_support/spec/lib/{configurable_spec.rb → global_configurable_spec.rb} +2 -2
  95. data/test_support/spec/lib/search_fields_spec.rb +26 -29
  96. data/test_support/spec/{helpers → lib}/solr_helper_spec.rb +268 -287
  97. data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +1 -1
  98. data/test_support/spec/lib/utils_spec.rb +58 -0
  99. data/test_support/spec/models/solr_docment_spec.rb +4 -8
  100. data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +27 -170
  101. data/test_support/spec/views/catalog/_index_default.erb_spec.rb +38 -20
  102. data/test_support/spec/views/catalog/_show_default.erb_spec.rb +38 -19
  103. data/test_support/spec/views/catalog/index.atom.builder_spec.rb +19 -1
  104. metadata +148 -145
  105. data/app/assets/stylesheets/blacklight/blacklight.css +0 -493
  106. data/app/assets/stylesheets/yui.css +0 -31
  107. data/app/views/catalog/opensearch.xml.erb +0 -11
  108. data/doc/Atom-Responses.md +0 -90
  109. data/doc/CUSTOMIZING.md +0 -121
  110. data/doc/Extending-blacklight-with-the-document-extension-framework.md +0 -1
  111. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -131
  112. data/doc/Features.md +0 -147
  113. data/doc/Integration-with-Rails-Footnotes.md +0 -20
  114. data/doc/Pagination.md +0 -38
  115. data/doc/Quickstart.md +0 -97
  116. data/doc/Upgrading-Guide.md +0 -98
  117. data/doc/User-Authentication.md +0 -54
  118. data/doc/Using-a-custom-solr-uniquekey-field.md +0 -36
  119. data/lib/blacklight/comma_link_renderer.rb +0 -28
  120. data/lib/railties/jetty_solr_server.rb +0 -108
  121. data/test_support/spec/views/catalog/show.html.erb_spec.rb +0 -101
@@ -0,0 +1,27 @@
1
+ /* This file is generated by Blacklight. You probably don't want to edit
2
+ this file directly, or you'll have to manually merge your changes if later
3
+ versions of Blacklight change this file. Instead, use your own CSS file
4
+ which over-rides things in this file. Or of course you can choose
5
+ not to use the Blacklight CSS file at all in your local app. */
6
+
7
+
8
+ @import "compass";
9
+ @import "compass/reset";
10
+
11
+ @import 'blacklight/blacklight_defaults';
12
+
13
+ /* Import this to maintain the old YUI font styles */
14
+ @import "blacklight/layout";
15
+ @import "blacklight/formatting";
16
+ @import "blacklight/header";
17
+ @import "blacklight/catalog";
18
+ @import "blacklight/facets";
19
+ @import "blacklight/folder";
20
+ @import "blacklight/search_history";
21
+ @import "blacklight/print";
22
+
23
+
24
+ /* IE 6 Adjustments */
25
+ * html #hd .yui-g .yui-u {margin-top: -5em;}
26
+ * html #hd .yui-g .first {margin-top: 2em;}
27
+ * html #search {left: -1.8em;}
@@ -0,0 +1,48 @@
1
+ /* Warning! If you want to change these, just copy them into your own theme css. But you want to remove the !default, which only will set them if not already set. */
2
+
3
+ /* Grid parameters */
4
+ /* changing total cols is not recommended unless you're going to redo blacklight/_layout.css.sass */
5
+ $total-cols: 24 !default;
6
+
7
+ /* But the widths are changeable to px, em. */
8
+ $col-width: 2.5em !default;
9
+ $gutter-width: .5em !default;
10
+ $side-gutter-width: 2em !default;
11
+
12
+
13
+ $logo_url: 'blacklight/logo.png' !default;
14
+
15
+ /* Various elements of search customization share these colors */
16
+
17
+ $search_ui_border_color: #AAAAAA !default;
18
+ $search_ui_bg_color: #F0F0F0 !default;
19
+
20
+ /* separates documents, facets */
21
+ $dotted_border_color: #CCC !default;
22
+
23
+ /* background color of page */
24
+ $page_bg_color: #2E4F81 !default;
25
+
26
+
27
+ /* label (field names) */
28
+ $field_name_color: #888 !default;
29
+
30
+
31
+ /* constraint (you searched for:) details: */
32
+
33
+ $constraint_bg_color: #E2EDFE !default;
34
+
35
+ $constraint_border_color: #C4DAFE !default;
36
+ $constraint_border_active_color: #FFD27A !default;
37
+
38
+ /* dialog that pops up when you pick more on facets */
39
+ $facet_extended_button_bg_color: #F6F6F6 !default;
40
+ $facet_extended_button_border_color: #CCC !default;
41
+ $facet_extended_disabled_button_bg_color: #E2EDFE !default;
42
+ $facet_extended_disabled_border_color: #C4DAFE !default;
43
+ $facet_extended_button_hover_bg_color: #DADADA !default;
44
+ $facet_extended_button_hover_border_color: #999 !default;
45
+ $facet_extended_button_hover_color: #212121 !default;
46
+
47
+ /* border between items on marc view */
48
+ $marc_item_separator: 1px solid #CCC !default;
@@ -2,7 +2,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
4
  class BookmarksController < ApplicationController
5
-
5
+
6
+ before_filter :require_user_authentication_provider
6
7
  before_filter :verify_user
7
8
 
8
9
  # Beware, :id is the Solr document_id, not the actual Bookmark id.
@@ -1,6 +1,10 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class FolderController < ApplicationController
3
+ include Blacklight::Configurable
3
4
  include Blacklight::SolrHelper
5
+
6
+ copy_blacklight_config_from(CatalogController)
7
+
4
8
  helper CatalogHelper
5
9
 
6
10
  # fetch the documents that match the ids in the folder
@@ -1,5 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class SavedSearchesController < ApplicationController
3
+ include Blacklight::Configurable
4
+
5
+ copy_blacklight_config_from(CatalogController)
6
+ before_filter :require_user_authentication_provider
3
7
  before_filter :verify_user
4
8
 
5
9
  def index
@@ -1,5 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class SearchHistoryController < ApplicationController
3
+ include Blacklight::Configurable
4
+
5
+ copy_blacklight_config_from(CatalogController)
6
+
3
7
  def index
4
8
  @searches = searches_from_history
5
9
  end
@@ -11,9 +11,15 @@ module Blacklight::BlacklightHelperBehavior
11
11
 
12
12
 
13
13
  def application_name
14
+ return Rails.application.config.application_name if Rails.application.config.respond_to? :application_name
15
+
14
16
  'Blacklight'
15
17
  end
16
18
 
19
+ # Provide the full, absolute url for an image
20
+ def asset_url(*args)
21
+ "#{request.protocol}#{request.host_with_port}#{asset_path(*args)}"
22
+ end
17
23
 
18
24
  # Create <link rel="alternate"> links from a documents dynamically
19
25
  # provided export formats. Currently not used by standard BL layouts,
@@ -36,7 +42,7 @@ module Blacklight::BlacklightHelperBehavior
36
42
  unless( options[:exclude].include?(format) ||
37
43
  (options[:unique] && seen.include?(spec[:content_type]))
38
44
  )
39
- html << tag(:link, {:rel=>"alternate", :title=>format, :type => spec[:content_type], :href=> catalog_url(document.id, format)}) << "\n"
45
+ html << tag(:link, {:rel=>"alternate", :title=>format, :type => spec[:content_type], :href=> catalog_url(document, format)}) << "\n"
40
46
 
41
47
  seen.add(spec[:content_type]) if options[:unique]
42
48
  end
@@ -69,38 +75,45 @@ module Blacklight::BlacklightHelperBehavior
69
75
  # Save function area for search results 'index' view, normally
70
76
  # renders next to title. Includes just 'Folder' by default.
71
77
  def render_index_doc_actions(document, options={})
72
- content_tag("div", :class=>"documentFunctions") do
73
- raw("#{render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options))}
74
- #{render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))}")
75
- end
78
+ content = []
79
+ content << render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options)) if has_user_authentication_provider? and current_user
80
+ content << render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))
81
+
82
+ content_tag("div", content.join("\n").html_safe, :class=>"documentFunctions")
76
83
  end
77
84
 
78
85
  # Save function area for item detail 'show' view, normally
79
86
  # renders next to title. By default includes 'Folder' and 'Bookmarks'
80
87
  def render_show_doc_actions(document=@document, options={})
81
- content_tag("div", :class=>"documentFunctions") do
82
- raw("#{render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options))}
83
- #{render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))}")
84
- end
88
+ content = []
89
+ content << render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options)) if has_user_authentication_provider? and current_user
90
+ content << render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))
91
+
92
+ content_tag("div", content.join("\n").html_safe, :class=>"documentFunctions")
85
93
  end
86
94
 
87
95
  # used in the catalog/_index_partials/_default view
96
+ def index_fields
97
+ blacklight_config.index_fields
98
+ end
99
+
88
100
  def index_field_names
89
- Blacklight.config[:index_fields][:field_names]
101
+ index_fields.keys
90
102
  end
91
-
92
- # used in the _index_partials/_default view
103
+
104
+ # used in the catalog/_index_partials/_default partial
93
105
  def index_field_labels
94
- Blacklight.config[:index_fields][:labels]
106
+ # XXX DEPRECATED
107
+ Hash[*index_fields.map { |key, field| [key, field.label] }.flatten]
95
108
  end
96
-
109
+
97
110
  def spell_check_max
98
- Blacklight.config[:spell_max] || 0
111
+ blacklight_config.spell_max
99
112
  end
100
113
 
101
114
  def render_index_field_label args
102
115
  field = args[:field]
103
- html_escape index_field_labels[field]
116
+ html_escape index_fields[field].label
104
117
  end
105
118
 
106
119
  def render_index_field_value args
@@ -111,7 +124,7 @@ module Blacklight::BlacklightHelperBehavior
111
124
 
112
125
  # Used in the show view for displaying the main solr document heading
113
126
  def document_heading
114
- @document[Blacklight.config[:show][:heading]] || @document.id
127
+ @document[blacklight_config.show.heading] || @document.id
115
128
  end
116
129
  def render_document_heading
117
130
  content_tag(:h1, document_heading)
@@ -119,42 +132,43 @@ module Blacklight::BlacklightHelperBehavior
119
132
 
120
133
  # Used in the show view for setting the main html document title
121
134
  def document_show_html_title
122
- @document[Blacklight.config[:show][:html_title]]
135
+ @document[blacklight_config.show.html_title]
123
136
  end
124
137
 
125
138
  # Used in citation view for displaying the title
126
139
  def citation_title(document)
127
- document[Blacklight.config[:show][:html_title]]
140
+ document[blacklight_config.show.html_title]
128
141
  end
129
142
 
130
143
  # Used in the document_list partial (search view) for building a select element
131
144
  def sort_fields
132
- Blacklight.config[:sort_fields]
145
+ blacklight_config.sort_fields.map { |key, x| [x.label, x.key] }
133
146
  end
134
147
 
135
148
  # Used in the document list partial (search view) for creating a link to the document show action
136
149
  def document_show_link_field
137
- Blacklight.config[:index][:show_link].to_sym
150
+ blacklight_config.index.show_link.to_sym
138
151
  end
139
152
 
140
153
  # Used in the search form partial for building a select tag
141
154
  def search_fields
142
- Blacklight.search_field_options_for_select
155
+ search_field_options_for_select
143
156
  end
144
157
 
145
158
  # used in the catalog/_show/_default partial
146
159
  def document_show_fields
147
- Blacklight.config[:show_fields][:field_names]
160
+ blacklight_config.show_fields.keys
148
161
  end
149
162
 
150
163
  # used in the catalog/_show/_default partial
151
164
  def document_show_field_labels
152
- Blacklight.config[:show_fields][:labels]
165
+ # XXX DEPRECATED
166
+ Hash[*blacklight_config.show_fields.map { |key, field| [key, field.label] }.flatten]
153
167
  end
154
168
 
155
169
  def render_document_show_field_label args
156
170
  field = args[:field]
157
- html_escape document_show_field_labels[field]
171
+ html_escape blacklight_config.show_fields[field].label
158
172
  end
159
173
 
160
174
  def render_document_show_field_value args
@@ -178,7 +192,7 @@ module Blacklight::BlacklightHelperBehavior
178
192
  # .to_s is necessary otherwise the default return value is not always a string
179
193
  # using "_" as sep. to more closely follow the views file naming conventions
180
194
  # parameterize uses "-" as the default sep. which throws errors
181
- display_type = document[Blacklight.config[:show][:display_type]]
195
+ display_type = document[blacklight_config.show.display_type]
182
196
 
183
197
  return 'default' unless display_type
184
198
  display_type = display_type.join(" ") if display_type.respond_to?(:join)
@@ -250,13 +264,18 @@ module Blacklight::BlacklightHelperBehavior
250
264
  label ||= doc.id
251
265
  end
252
266
 
267
+
268
+ def solr_document_path(*args); catalog_path(*args); end
269
+ def solr_document_url(*args); catalog_url(*args); end
270
+
253
271
  # link_to_document(doc, :label=>'VIEW', :counter => 3)
254
272
  # Use the catalog_path RESTful route to create a link to the show page for a specific item.
255
273
  # catalog_path accepts a HashWithIndifferentAccess object. The solr query params are stored in the session,
256
274
  # so we only need the +counter+ param here. We also need to know if we are viewing to document as part of search results.
257
- def link_to_document(doc, opts={:label=>Blacklight.config[:index][:show_link].to_sym, :counter => nil, :results_view => true})
275
+ def link_to_document(doc, opts={:label=>nil, :counter => nil, :results_view => true})
276
+ label ||= blacklight_config.index.show_link.to_sym
258
277
  label = render_document_index_label doc, opts
259
- link_to_with_data(label, catalog_path(doc.id), {:method => :put, :class => label.parameterize, :data => opts}).html_safe
278
+ link_to label, doc, :'data-counter' => opts[:counter]
260
279
  end
261
280
 
262
281
  # link_back_to_catalog(:label=>'Back to Search')
@@ -278,7 +297,20 @@ module Blacklight::BlacklightHelperBehavior
278
297
 
279
298
  options = {:params => params, :omit_keys => [:page]}.merge(options)
280
299
  my_params = options[:params].dup
281
- options[:omit_keys].each {|omit_key| my_params.delete(omit_key)}
300
+ options[:omit_keys].each do |omit_key|
301
+ case omit_key
302
+ when Hash
303
+ omit_key.each do |key, values|
304
+ next unless my_params[key]
305
+ my_params[key] = my_params[key].dup
306
+
307
+ values = [values] unless values.respond_to? :each
308
+ values.each { |v| my_params[key].delete(v) }
309
+ end
310
+ else
311
+ my_params.delete(omit_key)
312
+ end
313
+ end
282
314
  # removing action and controller from duplicate params so that we don't get hidden fields for them.
283
315
  my_params.delete(:action)
284
316
  my_params.delete(:controller)
@@ -293,12 +325,12 @@ module Blacklight::BlacklightHelperBehavior
293
325
 
294
326
  def link_to_previous_document(previous_document)
295
327
  return if previous_document == nil
296
- link_to_document previous_document, :label=> Previous', :counter => session[:search][:counter].to_i - 1
328
+ link_to '« Previous', previous_document, :class => "previous", :'data-counter' => session[:search][:counter].to_i - 1
297
329
  end
298
330
 
299
331
  def link_to_next_document(next_document)
300
332
  return if next_document == nil
301
- link_to_document next_document, :label=>'Next »', :counter => session[:search][:counter].to_i + 1
333
+ link_to 'Next »', next_document, :class => "next", :'data-counter' => session[:search][:counter].to_i + 1
302
334
  end
303
335
 
304
336
  # Use case, you want to render an html partial from an XML (say, atom)
@@ -313,79 +345,6 @@ module Blacklight::BlacklightHelperBehavior
313
345
  return result
314
346
  end
315
347
 
316
-
317
- # This is an updated +link_to+ that allows you to pass a +data+ hash along with the +html_options+
318
- # which are then written to the generated form for non-GET requests. The key is the form element name
319
- # and the value is the value:
320
- #
321
- # link_to_with_data('Name', some_path(some_id), :method => :post, :html)
322
- def link_to_with_data(*args, &block)
323
- if block_given?
324
- options = args.first || {}
325
- html_options = args.second
326
- concat(link_to(capture(&block), options, html_options))
327
- else
328
- name = args.first
329
- options = args.second || {}
330
- html_options = args.third
331
-
332
- url = url_for(options)
333
-
334
- if html_options
335
- html_options = html_options.stringify_keys
336
- href = html_options['href']
337
- convert_options_to_javascript_with_data!(html_options, url)
338
- tag_options = tag_options(html_options)
339
- else
340
- tag_options = nil
341
- end
342
-
343
- href_attr = "href=\"#{url}\"" unless href
344
- "<a #{href_attr}#{tag_options}>#{h(name) || h(url)}</a>".html_safe
345
- end
346
- end
347
-
348
- # This is derived from +convert_options_to_javascript+ from module Blacklight::+UrlHelperBehavior+ in +url_helper.rb+
349
- def convert_options_to_javascript_with_data!(html_options, url = '')
350
- confirm, popup = html_options.delete("confirm"), html_options.delete("popup")
351
-
352
- method, href = html_options.delete("method"), html_options['href']
353
- data = html_options.delete("data")
354
- data = data.stringify_keys if data
355
-
356
- html_options["onclick"] = case
357
- when method
358
- "#{method_javascript_function_with_data(method, url, href, data)}return false;"
359
- else
360
- html_options["onclick"]
361
- end
362
- end
363
-
364
- # This is derived from +method_javascript_function+ from module Blacklight::+UrlHelperBehavior+ in +url_helper.rb+
365
- def method_javascript_function_with_data(method, url = '', href = nil, data=nil)
366
- action = (href && url.size > 0) ? "'#{url}'" : 'this.href'
367
- submit_function =
368
- "var f = document.createElement('form'); f.style.display = 'none'; " +
369
- "this.parentNode.appendChild(f); f.method = 'POST'; f.action = #{action};"+
370
- "if(event.metaKey || event.ctrlKey){f.target = '_blank';};" # if the command or control key is being held down while the link is clicked set the form's target to _blank
371
- if data
372
- data.each_pair do |key, value|
373
- submit_function << "var d = document.createElement('input'); d.setAttribute('type', 'hidden'); "
374
- submit_function << "d.setAttribute('name', '#{key}'); d.setAttribute('value', '#{escape_javascript(value.to_s)}'); f.appendChild(d);"
375
- end
376
- end
377
- unless method == :post
378
- submit_function << "var m = document.createElement('input'); m.setAttribute('type', 'hidden'); "
379
- submit_function << "m.setAttribute('name', '_method'); m.setAttribute('value', '#{method}'); f.appendChild(m);"
380
- end
381
-
382
- if protect_against_forgery?
383
- submit_function << "var s = document.createElement('input'); s.setAttribute('type', 'hidden'); "
384
- submit_function << "s.setAttribute('name', '#{request_forgery_protection_token}'); s.setAttribute('value', '#{escape_javascript form_authenticity_token}'); f.appendChild(s);"
385
- end
386
- submit_function << "f.submit();"
387
- end
388
-
389
348
  # determines if the given document id is in the folder
390
349
  def item_in_folder?(doc_id)
391
350
  session[:folder_document_ids] && session[:folder_document_ids].include?(doc_id) ? true : false
@@ -413,4 +372,5 @@ module Blacklight::BlacklightHelperBehavior
413
372
  val
414
373
  end
415
374
 
375
+
416
376
  end
@@ -63,18 +63,18 @@ module Blacklight::CatalogHelperBehavior
63
63
  end
64
64
 
65
65
  # Look up search field user-displayable label
66
- # based on params[:qt] and configuration.
66
+ # based on params[:qt] and blacklight_configuration.
67
67
  def search_field_label(params)
68
- h( Blacklight.label_for_search_field(params[:search_field]) )
68
+ h( label_for_search_field(params[:search_field]) )
69
69
  end
70
70
 
71
71
  # Export to Refworks URL, called in _show_tools
72
72
  def refworks_export_url(document = @document)
73
- "http://www.refworks.com/express/expressimport.asp?vendor=#{CGI.escape(application_name)}&filter=MARC%20Format&encoding=65001&url=#{CGI.escape(catalog_path(document.id, :format => 'refworks_marc_txt', :only_path => false))}"
73
+ "http://www.refworks.com/express/expressimport.asp?vendor=#{CGI.escape(application_name)}&filter=MARC%20Format&encoding=65001&url=#{CGI.escape(catalog_path(document, :format => 'refworks_marc_txt', :only_path => false))}"
74
74
  end
75
75
 
76
76
  def render_document_class(document = @document)
77
- 'blacklight-' + document.get(Blacklight.config[:index][:record_display_type]).parameterize rescue nil
77
+ 'blacklight-' + document.get(blacklight_config.index.record_display_type).parameterize rescue nil
78
78
  end
79
79
 
80
80
  def render_document_sidebar_partial(document = @document)
@@ -1,25 +1,72 @@
1
1
  module Blacklight::FacetsHelperBehavior
2
2
 
3
3
  #
4
- # Blacklight.config based helpers ->
4
+ # blacklight_config based helpers ->
5
5
  #
6
6
 
7
+ def facet_configuration_for_field(field)
8
+ blacklight_config.facet_fields[field] || Blacklight::Configuration::FacetField.new(:field => field)
9
+ end
10
+
7
11
  # used in the catalog/_facets partial
8
12
  def facet_field_labels
9
- Blacklight.config[:facet][:labels]
13
+ # DEPRECATED
14
+ Hash[*blacklight_config.facet_fields.map { |key, facet| [key, facet.label] }.flatten]
10
15
  end
11
16
 
12
17
  # used in the catalog/_facets partial
13
18
  def facet_field_names
14
- Blacklight.config[:facet][:field_names]
19
+ blacklight_config.facet_fields.keys
20
+ end
21
+
22
+ # Render a collection of facet fields
23
+ def render_facet_partials fields = facet_field_names, options = {}
24
+ solr_fields = fields.map do |solr_field|
25
+ case solr_field
26
+ when String, Symbol
27
+ @response.facet_by_field_name(solr_field)
28
+ when Blacklight::Configuration::FacetField
29
+ @response.facet_by_field_name(solr_field.field)
30
+ else
31
+ solr_field
32
+ end
33
+ end.compact
34
+
35
+ solr_fields.map do |display_facet|
36
+ next if display_facet.items.blank?
37
+ render_facet_limit(display_facet, options)
38
+ end.compact.join("\n").html_safe
15
39
  end
16
40
 
17
41
  # used in the catalog/_facets partial and elsewhere
18
42
  # Renders a single section for facet limit with a specified
19
43
  # solr field used for faceting. Can be over-ridden for custom
20
44
  # display on a per-facet basis.
21
- def render_facet_limit(solr_field)
22
- render( :partial => "catalog/facet_limit", :locals => {:solr_field =>solr_field })
45
+ #
46
+ # @param [RSolr::Ext::Response::Facets::FacetField] facet_field
47
+ # @param [Hash] options parameters to use for rendering the facet limit partial
48
+ #
49
+ def render_facet_limit(display_facet, options = {})
50
+ if display_facet.is_a? String or display_facet.is_a? Symbol
51
+ $stderr.puts "DEPRECATION WARNING: Blacklight::FacetsHelper#render_facet_limit: use #render_facet_partials to render facets by field name"
52
+ return render_facet_partials([display_facet])
53
+ end
54
+ options = options.dup
55
+ options[:partial] ||= facet_partial_name(display_facet)
56
+ options[:layout] ||= "facet_layout"
57
+ options[:locals] ||= {}
58
+ options[:locals][:solr_field] ||= display_facet.name
59
+ options[:locals][:facet_field] ||= facet_configuration_for_field(display_facet.name)
60
+ options[:locals][:display_facet] ||= display_facet
61
+
62
+ render(options)
63
+ end
64
+
65
+ # the name of the partial to use to render a facet field. Can be over-ridden for custom
66
+ # display on a per-facet basis.
67
+ def facet_partial_name(display_facet = nil)
68
+ name = facet_configuration_for_field(display_facet.name).try(:partial)
69
+ name ||= "facet_limit"
23
70
  end
24
71
 
25
72
  #