blacklight 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +1 -0
  5. data/.travis.yml +14 -6
  6. data/Gemfile +2 -3
  7. data/README.md +3 -1
  8. data/VERSION +1 -1
  9. data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
  10. data/app/assets/stylesheets/blacklight/_dropdown.css.scss +2 -1
  11. data/app/assets/stylesheets/blacklight/_search_history.css.scss +1 -1
  12. data/app/assets/stylesheets/blacklight/blacklight.css.scss +2 -0
  13. data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +2 -0
  14. data/app/helpers/blacklight/blacklight_helper_behavior.rb +199 -48
  15. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
  16. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
  17. data/app/views/catalog/_document_header.html.erb +1 -1
  18. data/app/views/catalog/_index_default.html.erb +3 -3
  19. data/app/views/catalog/_per_page_widget.html.erb +1 -1
  20. data/app/views/catalog/_show_default.html.erb +3 -3
  21. data/app/views/catalog/_sort_widget.html.erb +1 -1
  22. data/app/views/catalog/show.html.erb +29 -32
  23. data/app/views/layouts/blacklight.html.erb +1 -1
  24. data/blacklight.gemspec +1 -1
  25. data/config/locales/blacklight.fr.yml +236 -0
  26. data/gemfiles/rails3.gemfile +9 -0
  27. data/gemfiles/rails4.gemfile +10 -0
  28. data/lib/blacklight/catalog.rb +22 -10
  29. data/lib/blacklight/configurable.rb +2 -3
  30. data/lib/blacklight/configuration/fields.rb +5 -4
  31. data/lib/blacklight/mash.rb +7 -139
  32. data/lib/blacklight/routes.rb +19 -18
  33. data/lib/blacklight/solr_helper.rb +14 -11
  34. data/lib/blacklight/solr_response.rb +1 -1
  35. data/lib/generators/blacklight/blacklight_generator.rb +9 -1
  36. data/lib/generators/blacklight/test_support_generator.rb +15 -0
  37. data/test_support/bin/setup-test-app.sh +8 -12
  38. data/test_support/bin/test.sh +20 -24
  39. data/test_support/features/search.feature +0 -3
  40. data/test_support/features/search_pagination.feature +53 -0
  41. data/test_support/features/step_definitions/search_pagination_steps.rb +29 -0
  42. data/test_support/features/step_definitions/search_steps.rb +0 -11
  43. data/test_support/spec/controllers/catalog_controller_spec.rb +15 -80
  44. data/test_support/spec/helpers/blacklight_helper_spec.rb +75 -22
  45. data/test_support/spec/helpers/catalog_helper_spec.rb +8 -1
  46. data/test_support/spec/helpers/html_head_helper_spec.rb +21 -7
  47. data/test_support/spec/lib/blacklight_configurable_spec.rb +18 -4
  48. data/test_support/spec/lib/blacklight_configuration_spec.rb +28 -0
  49. data/test_support/spec/lib/solr_helper_spec.rb +14 -4
  50. data/test_support/spec/routing/catalog_routing_spec.rb +67 -0
  51. data/test_support/spec/views/catalog/index.atom.builder_spec.rb +3 -7
  52. metadata +42 -15
  53. metadata.gz.sig +0 -0
@@ -104,7 +104,7 @@ module Blacklight::CatalogHelperBehavior
104
104
 
105
105
  def show_sort_and_per_page? response = nil
106
106
  response ||= @response
107
- response.response['numFound'] > 1
107
+ response.total > 1
108
108
  end
109
109
 
110
110
  end
@@ -32,7 +32,7 @@ module Blacklight::SearchHistoryConstraintsHelperBehavior
32
32
  render_search_to_s_element(blacklight_config.facet_fields[facet_field].label,
33
33
  value_list.collect do |value|
34
34
  render_filter_value(value)
35
- end.join(content_tag(:span, t('blacklight.and'), :class =>'label')).html_safe
35
+ end.join(content_tag(:span, " #{t('blacklight.and')} ", :class =>'filterSeparator')).html_safe
36
36
  )
37
37
  end.join(" \n ").html_safe
38
38
  end
@@ -3,7 +3,7 @@
3
3
  <div class="documentHeader clearfix">
4
4
 
5
5
  <% # main title container for doc partial view -%>
6
- <h5 class="index_title"><%= t('blacklight.search.documents.counter', :counter => (document_counter + 1 + @response.params[:start].to_i)) %><%= link_to_document document, :label=>document_show_link_field, :counter => (document_counter + 1 + @response.params[:start].to_i) %></h5>
6
+ <h5 class="index_title"><%= t('blacklight.search.documents.counter', :counter => (document_counter + 1 + @response.params[:start].to_i)) %><%= link_to_document document, :label=>document_show_link_field(document), :counter => (document_counter + 1 + @response.params[:start].to_i) %></h5>
7
7
 
8
8
 
9
9
  <% # bookmark functions for items/docs -%>
@@ -1,10 +1,10 @@
1
1
  <%# default partial to display solr document fields in catalog index view -%>
2
2
  <dl class="dl-horizontal dl-invert">
3
3
 
4
- <% index_fields.each do |solr_fname, field| -%>
4
+ <% index_fields(document).each do |solr_fname, field| -%>
5
5
  <% if should_render_index_field? document, field %>
6
- <dt class="blacklight-<%= solr_fname.parameterize %>"><%= render_index_field_label :field => solr_fname %></dt>
7
- <dd class="blacklight-<%= solr_fname.parameterize %>"><%= render_index_field_value :document => document, :field => solr_fname %></dd>
6
+ <dt class="blacklight-<%= solr_fname.parameterize %>"><%= render_index_field_label document, :field => solr_fname %></dt>
7
+ <dd class="blacklight-<%= solr_fname.parameterize %>"><%= render_index_field_value document, :field => solr_fname %></dd>
8
8
  <% end -%>
9
9
  <% end -%>
10
10
 
@@ -6,7 +6,7 @@
6
6
  <%= link_to(t(:'blacklight.search.per_page.button_label', :count => current_per_page), "#") %> <span class="caret"></span>
7
7
  <ul>
8
8
  <%- blacklight_config.per_page.each do |count| %>
9
- <li><%= link_to(t(:'blacklight.search.per_page.label', :count => count).html_safe, url_for(params_for_search.merge(:per_page => count))) %></li>
9
+ <li><%= link_to(t(:'blacklight.search.per_page.label', :count => count).html_safe, url_for(params_for_search(:per_page => count))) %></li>
10
10
  <%- end -%>
11
11
  </ul>
12
12
  </li>
@@ -1,9 +1,9 @@
1
1
  <%# default partial to display solr document fields in catalog show view -%>
2
2
  <dl class="dl-horizontal dl-invert">
3
- <% document_show_fields.each do |solr_fname, field| -%>
3
+ <% document_show_fields(document).each do |solr_fname, field| -%>
4
4
  <% if should_render_show_field? document, field %>
5
- <dt class="blacklight-<%= solr_fname.parameterize %>"><%= render_document_show_field_label :field => solr_fname %></dt>
6
- <dd class="blacklight-<%= solr_fname.parameterize %>"><%= render_document_show_field_value :document => document, :field => solr_fname %></dd>
5
+ <dt class="blacklight-<%= solr_fname.parameterize %>"><%= render_document_show_field_label document, :field => solr_fname %></dt>
6
+ <dd class="blacklight-<%= solr_fname.parameterize %>"><%= render_document_show_field_value document, :field => solr_fname %></dd>
7
7
  <% end -%>
8
8
  <% end -%>
9
9
  </dl>
@@ -5,7 +5,7 @@
5
5
  <%= link_to(t('blacklight.search.sort.label', :field =>current_sort_field.label), "#") %> <span class="caret"></span>
6
6
  <ul>
7
7
  <%- blacklight_config.sort_fields.each do |sort_key, field| %>
8
- <li><%= link_to(field.label, url_for(params_for_search.merge(:sort => sort_key))) %></li>
8
+ <li><%= link_to(field.label, url_for(params_for_search(:sort => sort_key))) %></li>
9
9
  <%- end -%>
10
10
  </ul>
11
11
  </li>
@@ -1,44 +1,41 @@
1
- <div class="row">
1
+ <div id="content" class="span9 show-document">
2
2
 
3
- <div id="content" class="span9 show-document">
3
+ <%= render 'previous_next_doc' %>
4
4
 
5
- <%= render 'previous_next_doc' %>
5
+
6
+ <% @page_title = t('blacklight.search.show.title', :document_title => document_show_html_title, :application_name => application_name) %>
7
+ <% extra_head_content << render_link_rel_alternates %>
8
+ <% sidebar_items << render_document_sidebar_partial %>
6
9
 
7
-
8
- <% @page_title = t('blacklight.search.show.title', :document_title => document_show_html_title, :application_name => application_name) %>
9
- <% extra_head_content << render_link_rel_alternates %>
10
- <% sidebar_items << render_document_sidebar_partial %>
10
+ <%# this should be in a partial -%>
11
+ <div id="document" class="<%= render_document_class %>">
12
+ <div id="doc_<%= @document.id.to_s.parameterize %>">
13
+
11
14
 
12
- <%# this should be in a partial -%>
13
- <div id="document" class="<%= render_document_class %>">
14
- <div id="doc_<%= @document.id.to_s.parameterize %>">
15
-
15
+ <% # bookmark/folder functions -%>
16
+ <%= render_document_heading(:h1).html_safe %>
16
17
 
17
- <% # bookmark/folder functions -%>
18
- <%= render_document_heading(:h1).html_safe %>
19
-
20
- <div class="document">
21
- <%= render_document_partial @document, :show %>
22
- </div>
23
-
24
-
18
+ <div class="document">
19
+ <%= render_document_partial @document, :show %>
25
20
  </div>
26
- </div>
27
21
 
22
+
23
+ </div>
24
+ </div>
28
25
 
29
26
 
30
- <% if @document.respond_to?(:export_as_openurl_ctx_kev) %>
31
- <!--
32
- // COinS, for Zotero among others.
33
- // This document_partial_name(@document) business is not quite right,
34
- // but has been there for a while.
35
- -->
36
- <span class="Z3988" title="<%= @document.export_as_openurl_ctx_kev(document_partial_name(@document)) %>"></span>
37
- <% end %>
38
27
 
39
- </div>
28
+ <% if @document.respond_to?(:export_as_openurl_ctx_kev) %>
29
+ <!--
30
+ // COinS, for Zotero among others.
31
+ // This document_partial_name(@document) business is not quite right,
32
+ // but has been there for a while.
33
+ -->
34
+ <span class="Z3988" title="<%= @document.export_as_openurl_ctx_kev(document_partial_name(@document)) %>"></span>
35
+ <% end %>
40
36
 
41
- <div id="sidebar" class="span3">
42
- <%= render_document_sidebar_partial %>
43
- </div><!--/span -->
44
37
  </div>
38
+
39
+ <div id="sidebar" class="span3">
40
+ <%= render_document_sidebar_partial %>
41
+ </div><!--/span -->
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html lang="en">
2
+ <html lang="en" class="no-js">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # PRODUCTION GEM REQUIREMENTS
22
22
  # ---------------------------------------
23
- s.add_dependency "rails", "~> 3.2"
23
+ s.add_dependency "rails", ">= 3.2"
24
24
  s.add_dependency "nokogiri", "~>1.5" # XML Parser
25
25
  # Let's allow future versions of marc, count on
26
26
  # them to be backwards compat until 1.1
@@ -0,0 +1,236 @@
1
+ fr:
2
+ active_record:
3
+ models:
4
+ feedback: 'Vos réactions'
5
+ attributes:
6
+ feedback:
7
+ name: 'Votre nom'
8
+ email: 'Votre courriel'
9
+ message: 'Votre message'
10
+ views:
11
+ pagination:
12
+ first: '&laquo; Première'
13
+ last: 'Dernière &raquo;'
14
+ previous: '&laquo; Précédente'
15
+ next: 'Suivante &raquo;'
16
+ truncate: '…'
17
+
18
+ pagination_compact:
19
+ previous: '&laquo; Précédente'
20
+ next: 'Suivante &raquo;'
21
+
22
+ blacklight:
23
+ application_name: 'Blacklight BCU'
24
+
25
+ header_links:
26
+ login: 'Mon compte'
27
+ logout: 'Me déconnecter'
28
+ bookmarks: 'Mon panier'
29
+ saved_searches: 'Mes recherches'
30
+ search_history: 'Historique de recherche'
31
+
32
+ welcome: 'Welcome!'
33
+ and: 'et'
34
+ or: 'ou'
35
+
36
+ bookmarks:
37
+ collection:
38
+ add:
39
+ button: 'Panier'
40
+ title: 'Favoris'
41
+ no_bookmarks: 'Accédez à votre compte pour conserver des références dans votre panier'
42
+ add:
43
+ button: 'Panier'
44
+ success:
45
+ one: 'Favori bien enregistré.'
46
+ other: 'Favoris bien enregistrés.'
47
+ failure: 'Pardon, un problème est survenu lors de l''ajout.'
48
+ remove:
49
+ button: 'Supprimer'
50
+ success: 'Favori supprimé.'
51
+ failure: 'Pardon, un problème est survenu lors de la suppression.'
52
+ action_confirm: 'Supprimer ce favori ?'
53
+ clear:
54
+ action_title: 'Effacer tout'
55
+ action_confirm: 'Effacer tous vos favoris ?'
56
+ success: 'Favoris effacés.'
57
+ failure: 'Pardon, un problème est survenu lors de la suppression.'
58
+ need_login: 'Veuillez vous connecter pour accéder à vos favoris.'
59
+ list_title: 'Vos favoris'
60
+ delete: 'Supprimer'
61
+
62
+ feedback:
63
+ valid_name: 'Vous devez saisir votre nom.'
64
+ valid_email: 'Vous devez saisir votre courriel.'
65
+ need_message: 'Vous devez saisir un message.'
66
+ submit: 'Envoyer'
67
+ errors:
68
+ title: 'Veuillez corriger les erreurs suivantes :'
69
+ complete:
70
+ title: 'Merci pour vos remarques.'
71
+
72
+ folder:
73
+ title: 'Panier'
74
+ add:
75
+ success: '%{title} a bien été sélectionné.'
76
+ remove:
77
+ success: '%{title} a bien été supprimé.'
78
+ clear:
79
+ success: 'Panier vide.'
80
+ no_folder: 'Votre panier est vide'
81
+
82
+ saved_searches:
83
+ add:
84
+ success: 'Votre recherche a bien été sauvegardée.'
85
+ failure: 'Un problème est survenu lors de l''enregistrement.'
86
+ remove:
87
+ success: 'Votre recherche a bien été supprimée.'
88
+ failure: 'Un problème est survenu lors de la suppression.'
89
+ clear:
90
+ action_title: 'Effacer tout'
91
+ action_confirm: 'Effacer toutes vos recherches ?'
92
+ success: 'Recherches effacées.'
93
+ failure: 'Un problème est survenu lors de la suppression.'
94
+ title: 'Recherches sauvegardées'
95
+ need_login: 'Veuillez vous connecter pour accéder à vos recherches.'
96
+ no_searches: 'Vous n''avez sauvegardé aucune recherche.'
97
+ list_title: 'Vos recherches'
98
+ delete: 'Supprimer'
99
+
100
+ search_history:
101
+ clear:
102
+ action_title: 'Effacer l''historique'
103
+ action_confirm: 'Effacer votre historique de recherche ?'
104
+ success: 'Votre historique de recherche a bien été effacé.'
105
+ failure: 'Un problème est survenu lors de la suppression.'
106
+ title: 'Historique de recherche'
107
+ no_history: 'Il n''y a aucun historique en cours.'
108
+ recent: 'Dernières recherches'
109
+ forget: 'Supprimer'
110
+ save: 'Sauvegarder'
111
+
112
+ tools:
113
+ title: 'Outils'
114
+ cite: 'Citer'
115
+ endnote: 'Exporter vers EndNote ou Zotero'
116
+ refworks: 'Exporter vers Refworks'
117
+ email: 'Envoyer'
118
+ sms: 'SMS'
119
+ librarian_view: 'Vue UNIMARC'
120
+ clear: 'Effacer'
121
+
122
+ citation:
123
+ mla: 'MLA'
124
+ apa: 'APA'
125
+ chicago: 'Chicago'
126
+
127
+ email:
128
+ form:
129
+ title: 'Envoyer par courriel'
130
+ to: 'Courriel :'
131
+ message: 'Message :'
132
+ submit: 'Envoyer'
133
+ text:
134
+ title: 'Titre : %{value}'
135
+ author: 'Auteur : %{value}'
136
+ format: 'Format : %{value}'
137
+ language: 'Langue : %{value}'
138
+ subject:
139
+ one: 'Une référence : %{title}'
140
+ other: 'Des références bibliographiques'
141
+ url: 'URL : %{url}'
142
+ message: 'Message : %{message}'
143
+
144
+ errors:
145
+ to:
146
+ invalid: 'Vous devez saisir une adresse correcte.'
147
+ blank: 'Vous devez saisir l''adresse de votre destinataire.'
148
+ sms:
149
+ form:
150
+ title: 'Envoyer par SMS'
151
+ to: 'Numéro de téléphone :'
152
+ carrier: 'Opérateur téléphonique'
153
+ carrier_prompt: 'Veuillez choisir votre opérateur'
154
+ submit: 'Envoyer'
155
+ text:
156
+ title: '%{value}'
157
+ author: ' by %{value}'
158
+ url: 'Lien : %{url}'
159
+ errors:
160
+ to:
161
+ invalid: 'Vous devez saisir un numéro de téléphone à 10 chiffres.'
162
+ blank: "Vous devez saisir le numéro de téléphone de votre destinataire."
163
+ carrier:
164
+ blank: 'Vous devez choisir un opérateur.'
165
+
166
+ back_to_search: 'Retour aux résultats'
167
+ back_to_bookmarks: 'Retour aux favoris'
168
+
169
+ search:
170
+ title: '%{application_name} Résultats de recherche'
171
+ search_results_header: 'Recherche'
172
+ search_results: 'Résultats de recherche'
173
+ errors:
174
+ request_error: "Pardon, nous n'avons pas compris votre recherche."
175
+ invalid_solr_id: "Vous avez demandé une notice qui n'existe pas."
176
+ per_page:
177
+ label: '%{count}<span class="hide-text"> par page</span>'
178
+ button_label: '%{count} par page'
179
+ title: 'Nombre de résultats à afficher par page'
180
+ submit: 'mettre à jour'
181
+ sort:
182
+ label: 'Trier par %{field}'
183
+ submit: 'trier les résultats'
184
+ form:
185
+ search_field:
186
+ label: 'dans'
187
+ title: 'Options de recherche'
188
+ post_label: 'pour'
189
+ q: 'Rechercher '
190
+ submit: 'Chercher'
191
+ pagination:
192
+ title: 'Navigation dans les résultats'
193
+ pagination_info:
194
+ no_items_found: 'Pas de %{entry_name}'
195
+ single_item_found: '<b>1</b> de <b>1</b> sur <b>1</b>'
196
+ pages:
197
+ one: '<b>%{start_num}</b> - <b>%{end_num}</b> sur <b>%{total_num}</b>'
198
+ other: '<b>%{start_num}</b> - <b>%{end_num}</b> sur <b>%{total_num}</b>'
199
+ entry_pagination_info:
200
+ one: '<b>1 sur 1</b>'
201
+ other: '<b>%{current}</b> sur <b>%{total}</b>'
202
+ documents:
203
+ counter: '%{counter}. '
204
+ folder:
205
+ select: 'Panier'
206
+ unselect: 'Panier'
207
+ facets:
208
+ title: 'Limiter votre recherche'
209
+ sort:
210
+ count: 'Du + au - fréquent'
211
+ index: 'Tri de A à Z'
212
+ count: '%{number}'
213
+ more: 'plus »'
214
+ selected:
215
+ remove: '[ X ]'
216
+ filters:
217
+ title: 'Vous avez demandé :'
218
+ label: '%{label}:'
219
+ remove:
220
+ value: 'Supprimer la restriction %{value}'
221
+ label_value: 'Supprimer la restriction %{label}: %{value}'
222
+ librarian_view:
223
+ title: 'Vue UNIMARC'
224
+ leader: 'LABEL %{leader}'
225
+ start_over: 'Accueil'
226
+ show:
227
+ title: '%{document_title} - %{application_name}'
228
+ rss_feed: 'RSS pour les résultats'
229
+ atom_feed: 'Atom pour les résultats'
230
+ fields:
231
+ default: 'Keyword'
232
+
233
+ entry_name:
234
+ default: 'résultat'
235
+
236
+ did_you_mean: 'Essayez peut-être avec : %{options}'
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Please see blacklight.gemspec for dependency information.
4
+ gemspec :path=>"../"
5
+
6
+ gem 'simplecov', :platform => :mri
7
+ gem 'simplecov-rcov', :platform => :mri
8
+
9
+ gem 'rails', "~> 3.2"
@@ -0,0 +1,10 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Please see blacklight.gemspec for dependency information.
4
+ gemspec :path=>"../"
5
+
6
+ gem 'simplecov', :platform => :mri
7
+ gem 'simplecov-rcov', :platform => :mri
8
+
9
+ gem 'rails', '4.0.0.beta1'
10
+ gem 'sass-rails', '4.0.0.beta1'
@@ -276,20 +276,24 @@ module Blacklight::Catalog
276
276
 
277
277
  # when solr (RSolr) throws an error (RSolr::RequestError), this method is executed.
278
278
  def rsolr_request_error(exception)
279
- if Rails.env == "development"
279
+
280
+ if Rails.env.development?
280
281
  raise exception # Rails own code will catch and give usual Rails error page with stack trace
281
282
  else
283
+
282
284
  flash_notice = I18n.t('blacklight.search.errors.request_error')
283
- # Set the notice flag if the flash[:notice] is already set to the error that we are setting.
284
- # This is intended to stop the redirect loop error
285
- notice = flash[:notice] if flash[:notice] == flash_notice
286
- logger.error exception
287
- unless notice
288
- flash[:notice] = flash_notice
289
- redirect_to root_path, :status => 500
290
- else
291
- render :file => "#{Rails.root}/public/500.html", :status => 500
285
+
286
+ # If there are errors coming from the index page, we want to trap those sensibly
287
+
288
+ if flash[:notice] == flash_notice
289
+ logger.error "Cowardly aborting rsolr_request_error exception handling, because we redirected to a page that raises another exception"
290
+ raise exception
292
291
  end
292
+
293
+ logger.error exception
294
+
295
+ flash[:notice] = flash_notice
296
+ redirect_to root_path
293
297
  end
294
298
  end
295
299
 
@@ -304,4 +308,12 @@ module Blacklight::Catalog
304
308
  render "index", :status => 404
305
309
  end
306
310
  end
311
+
312
+ def blacklight_solr
313
+ @solr ||= RSolr.connect(blacklight_solr_config)
314
+ end
315
+
316
+ def blacklight_solr_config
317
+ Blacklight.solr_config
318
+ end
307
319
  end