blacklight 5.19.2 → 6.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/.hound.yml +2 -0
- data/.jshintrc +67 -0
- data/.rubocop_hound.yml +4 -0
- data/.travis.yml +11 -8
- data/Gemfile +11 -21
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +1 -0
- data/app/assets/javascripts/blacklight/core.js +5 -19
- data/app/assets/javascripts/blacklight/facet_load.js +23 -0
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +18 -0
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +5 -1
- data/app/assets/stylesheets/blacklight/_bookmark.scss +14 -6
- data/app/assets/stylesheets/blacklight/_constraints.scss +52 -0
- data/app/assets/stylesheets/blacklight/_controls.scss +61 -0
- data/app/assets/stylesheets/blacklight/_facets.scss +31 -4
- data/app/assets/stylesheets/blacklight/_header.scss +17 -3
- data/app/assets/stylesheets/blacklight/_pagination.scss +21 -0
- data/app/assets/stylesheets/blacklight/_search_results.scss +28 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -3
- data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +3 -45
- data/app/controllers/concerns/blacklight/controller.rb +29 -18
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +4 -3
- data/app/controllers/concerns/blacklight/facet.rb +1 -0
- data/app/controllers/concerns/blacklight/request_builders.rb +4 -107
- data/app/controllers/concerns/blacklight/search_fields.rb +1 -1
- data/app/controllers/concerns/blacklight/search_helper.rb +8 -160
- data/app/controllers/saved_searches_controller.rb +1 -1
- data/app/controllers/search_history_controller.rb +18 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +17 -85
- data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -48
- data/app/helpers/blacklight/component_helper_behavior.rb +9 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +3 -43
- data/app/helpers/blacklight/facets_helper_behavior.rb +10 -6
- data/app/helpers/blacklight/layout_helper_behavior.rb +0 -8
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -10
- data/app/helpers/blacklight/render_partials_helper.rb +1 -3
- data/app/helpers/blacklight/url_helper_behavior.rb +15 -187
- data/{lib → app/models}/blacklight/abstract_repository.rb +0 -15
- data/{lib → app/models}/blacklight/configuration.rb +22 -59
- data/app/models/blacklight/configuration/context.rb +47 -0
- data/{lib → app/models}/blacklight/configuration/facet_field.rb +1 -0
- data/{lib → app/models}/blacklight/configuration/field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/fields.rb +2 -6
- data/{lib → app/models}/blacklight/configuration/search_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/solr_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/sort_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/tool_config.rb +0 -0
- data/app/models/blacklight/configuration/view_config.rb +9 -0
- data/app/models/blacklight/facet_paginator.rb +14 -28
- data/{lib → app/models}/blacklight/search_builder.rb +16 -24
- data/app/models/blacklight/solr/facet_paginator.rb +6 -2
- data/{lib → app/models}/blacklight/solr/repository.rb +0 -21
- data/{lib → app/models}/blacklight/solr/request.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response.rb +9 -8
- data/{lib → app/models}/blacklight/solr/response/facets.rb +37 -29
- data/{lib → app/models}/blacklight/solr/response/group.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/group_response.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/more_like_this.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/pagination_methods.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/response.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/spelling.rb +2 -1
- data/{lib → app/models}/blacklight/solr/search_builder.rb +0 -0
- data/app/models/concerns/blacklight/document.rb +11 -27
- data/app/models/concerns/blacklight/document/active_model_shim.rb +8 -0
- data/app/models/concerns/blacklight/solr/document.rb +8 -3
- data/{lib → app/models/concerns}/blacklight/solr/search_builder_behavior.rb +21 -33
- data/app/models/concerns/blacklight/user.rb +0 -9
- data/app/models/record_mailer.rb +0 -1
- data/app/presenters/blacklight/document_presenter.rb +23 -13
- data/app/views/blacklight/nav/_saved_searches.html.erb +1 -1
- data/app/views/blacklight/nav/_search_history.html.erb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -2
- data/app/views/bookmarks/index.html.erb +2 -2
- data/app/views/catalog/_document_default.atom.builder +4 -2
- data/app/views/catalog/_facet_index_navigation.html.erb +9 -0
- data/app/views/catalog/_facet_layout.html.erb +2 -3
- data/app/views/catalog/_facet_pagination.html.erb +19 -21
- data/app/views/catalog/_facets.html.erb +2 -3
- data/app/views/catalog/_home_text.html.erb +2 -3
- data/app/views/catalog/_index_header_default.html.erb +2 -2
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +21 -18
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/app/views/catalog/_zero_results.html.erb +2 -2
- data/app/views/catalog/facet.html.erb +3 -0
- data/app/views/catalog/index.atom.builder +1 -1
- data/app/views/layouts/blacklight.html.erb +2 -2
- data/app/views/saved_searches/index.html.erb +6 -7
- data/app/views/search_history/index.html.erb +5 -5
- data/app/views/shared/_header_navbar.html.erb +2 -2
- data/blacklight.gemspec +5 -5
- data/config/locales/blacklight.de.yml +1 -4
- data/config/locales/blacklight.en.yml +2 -7
- data/config/locales/blacklight.es.yml +1 -4
- data/config/locales/blacklight.fr.yml +1 -4
- data/config/locales/blacklight.it.yml +1 -4
- data/config/locales/blacklight.pt-BR.yml +1 -4
- data/config/routes.rb +9 -0
- data/db/migrate/20140202020201_create_searches.rb +1 -1
- data/db/migrate/20140202020202_create_bookmarks.rb +1 -1
- data/lib/blacklight.rb +5 -82
- data/lib/blacklight/engine.rb +0 -5
- data/lib/blacklight/parameters.rb +13 -0
- data/lib/blacklight/path.rb +143 -0
- data/lib/blacklight/routes.rb +3 -134
- data/lib/blacklight/routes/exportable.rb +25 -0
- data/lib/blacklight/routes/searchable.rb +20 -0
- data/lib/blacklight/solr.rb +1 -9
- data/lib/blacklight/utils.rb +2 -44
- data/lib/generators/blacklight/controller_generator.rb +7 -4
- data/lib/generators/blacklight/install_generator.rb +16 -9
- data/lib/generators/blacklight/models_generator.rb +18 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +85 -91
- data/lib/generators/blacklight/test_support_generator.rb +22 -15
- data/solr/conf/_rest_managed.json +3 -0
- data/solr/conf/admin-extra.html +31 -0
- data/solr/conf/elevate.xml +36 -0
- data/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/solr/conf/protwords.txt +21 -0
- data/solr/conf/schema.xml +621 -0
- data/solr/conf/scripts.conf +24 -0
- data/solr/conf/solrconfig.xml +391 -0
- data/solr/conf/spellings.txt +2 -0
- data/solr/conf/stopwords.txt +58 -0
- data/solr/conf/stopwords_en.txt +58 -0
- data/solr/conf/synonyms.txt +31 -0
- data/solr/conf/xslt/example.xsl +132 -0
- data/solr/conf/xslt/example_atom.xsl +67 -0
- data/solr/conf/xslt/example_rss.xsl +66 -0
- data/solr/conf/xslt/luke.xsl +337 -0
- data/solr/sample_solr_documents.yml +1 -0
- data/spec/controllers/blacklight/base_spec.rb +17 -0
- data/spec/controllers/blacklight/search_helper_spec.rb +25 -297
- data/spec/controllers/catalog_controller_spec.rb +7 -6
- data/spec/controllers/saved_searches_controller_spec.rb +1 -0
- data/spec/controllers/search_history_controller_spec.rb +1 -0
- data/spec/features/alternate_controller_spec.rb +10 -10
- data/spec/features/bookmarks_spec.rb +8 -22
- data/spec/features/facets_spec.rb +27 -7
- data/spec/features/record_view_spec.rb +4 -13
- data/spec/features/search_formats_spec.rb +1 -26
- data/spec/features/sitelinks_search_box.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +8 -38
- data/spec/helpers/catalog_helper_spec.rb +0 -8
- data/spec/helpers/configuration_helper_spec.rb +0 -25
- data/spec/helpers/facets_helper_spec.rb +12 -11
- data/spec/helpers/hash_as_hidden_fields_spec.rb +7 -7
- data/spec/helpers/layout_helper_spec.rb +0 -7
- data/spec/helpers/render_constraints_helper_spec.rb +4 -2
- data/spec/helpers/url_helper_spec.rb +13 -254
- data/spec/lib/blacklight/parameters_spec.rb +22 -0
- data/spec/lib/blacklight/path_spec.rb +254 -0
- data/spec/lib/blacklight_spec.rb +6 -2
- data/spec/models/blacklight/configuration/context_spec.rb +33 -0
- data/spec/models/blacklight/document/active_model_shim_spec.rb +33 -0
- data/spec/models/blacklight/document_spec.rb +29 -1
- data/spec/models/blacklight/facet_paginator_spec.rb +14 -13
- data/spec/models/blacklight/search_builder_spec.rb +17 -23
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +11 -1
- data/spec/models/blacklight/solr/response/facets_spec.rb +19 -25
- data/spec/models/blacklight/solr/response/group_response_spec.rb +5 -5
- data/spec/models/blacklight/solr/response_spec.rb +0 -11
- data/spec/models/blacklight/solr/search_builder_spec.rb +49 -57
- data/spec/presenters/document_presenter_spec.rb +15 -42
- data/spec/routing/catalog_routing_spec.rb +7 -11
- data/spec/spec_helper.rb +4 -42
- data/spec/support/controller_level_helpers.rb +17 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -2
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +40 -0
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
- data/tasks/blacklight.rake +25 -30
- metadata +93 -71
- data/app/assets/stylesheets/blacklight/_catalog.scss +0 -229
- data/app/controllers/concerns/blacklight/search_history.rb +0 -31
- data/app/views/catalog/_refworks_form.html.erb +0 -6
- data/lib/blacklight/configuration/view_config.rb +0 -71
- data/lib/blacklight/rails/routes.rb +0 -29
- data/lib/blacklight/solr_helper.rb +0 -9
- data/lib/generators/blacklight/templates/config/initializers/blacklight_initializer.rb +0 -9
- data/spec/helpers/component_helper_spec.rb +0 -19
- data/spec/lib/blacklight/routes_spec.rb +0 -25
- data/spec/lib/blacklight/solr_helper_spec.rb +0 -12
- data/spec/routing/routes_spec.rb +0 -20
- data/spec/views/catalog/_document_action.html.erb_spec.rb +0 -21
@@ -166,8 +166,6 @@ es:
|
|
166
166
|
label: 'Buscar en'
|
167
167
|
title: 'Opciones de Búsqueda temática'
|
168
168
|
post_label: 'para'
|
169
|
-
# i18n key 'q' is deprecated and will be removed in Blacklight 6.0, use 'search.label' and 'search.placeholder'
|
170
|
-
q: 'Buscar...'
|
171
169
|
search:
|
172
170
|
label: 'buscar'
|
173
171
|
placeholder: 'Buscar...'
|
@@ -187,12 +185,11 @@ es:
|
|
187
185
|
counter: '%{counter}.'
|
188
186
|
facets:
|
189
187
|
title: 'Limite su búsqueda'
|
188
|
+
clear: 'Borrar'
|
190
189
|
sort:
|
191
190
|
count: 'Ordenación numérica'
|
192
191
|
index: 'Ordenación A-Z'
|
193
192
|
count: '%{number}'
|
194
|
-
# i18n key 'more' is deprecated and will be removed in Blacklight 6.0
|
195
|
-
more: 'más »'
|
196
193
|
more_html: 'más <span class="sr-only">%{field_name}</span> »'
|
197
194
|
selected:
|
198
195
|
remove: '[borrar]'
|
@@ -169,8 +169,6 @@ fr:
|
|
169
169
|
label: 'dans'
|
170
170
|
title: 'Options de recherche'
|
171
171
|
post_label: 'pour'
|
172
|
-
# i18n key 'q' is deprecated and will be removed in Blacklight 6.0, use 'search.label' and 'search.placeholder'
|
173
|
-
q: 'Rechercher '
|
174
172
|
search:
|
175
173
|
label: 'Rechercher'
|
176
174
|
placeholder: 'Rechercher'
|
@@ -193,12 +191,11 @@ fr:
|
|
193
191
|
unselect: 'Panier'
|
194
192
|
facets:
|
195
193
|
title: 'Limiter votre recherche'
|
194
|
+
clear: 'Effacer'
|
196
195
|
sort:
|
197
196
|
count: 'Du + au - fréquent'
|
198
197
|
index: 'Tri de A à Z'
|
199
198
|
count: '%{number}'
|
200
|
-
# i18n key 'more' is deprecated and will be removed in Blacklight 6.0
|
201
|
-
more: 'plus »'
|
202
199
|
more_html: 'plus <span class="sr-only">%{field_name}</span> »'
|
203
200
|
selected:
|
204
201
|
remove: '[ X ]'
|
@@ -166,8 +166,6 @@ it:
|
|
166
166
|
label: 'Cerca in'
|
167
167
|
title: 'Opzioni di ricerca mirate'
|
168
168
|
post_label: 'per'
|
169
|
-
# i18n key 'q' is deprecated and will be removed in Blacklight 6.0, use 'search.label' and 'search.placeholder'
|
170
|
-
q: 'Ricerca in corso...'
|
171
169
|
search:
|
172
170
|
label: 'cerca per'
|
173
171
|
placeholder: 'Ricerca in corso...'
|
@@ -187,12 +185,11 @@ it:
|
|
187
185
|
counter: '%{counter}. '
|
188
186
|
facets:
|
189
187
|
title: 'Affina la ricerca'
|
188
|
+
clear: 'Cancella'
|
190
189
|
sort:
|
191
190
|
count: 'Ordina per numero'
|
192
191
|
index: 'Ordina A-Z'
|
193
192
|
count: '%{number}'
|
194
|
-
# i18n key 'more' is deprecated and will be removed in Blacklight 6.0
|
195
|
-
more: 'altri »'
|
196
193
|
more_html: 'altri <span class="sr-only">%{field_name}</span> »'
|
197
194
|
selected:
|
198
195
|
remove: '[cancella]'
|
@@ -164,8 +164,6 @@ pt-BR:
|
|
164
164
|
label: 'Procurar em'
|
165
165
|
title: 'Opções da Busca'
|
166
166
|
post_label: 'por'
|
167
|
-
# i18n key 'q' is deprecated and will be removed in Blacklight 6.0, use 'search.label' and 'search.placeholder'
|
168
|
-
q: 'Busca...'
|
169
167
|
search:
|
170
168
|
label: 'busca'
|
171
169
|
placeholder: 'Busca...'
|
@@ -185,12 +183,11 @@ pt-BR:
|
|
185
183
|
counter: '%{counter}. '
|
186
184
|
facets:
|
187
185
|
title: 'Filtre sua busca'
|
186
|
+
clear: 'Limpar'
|
188
187
|
sort:
|
189
188
|
count: 'Ordenar por Número'
|
190
189
|
index: 'Ordem Alfabética A-Z'
|
191
190
|
count: '%{number}'
|
192
|
-
# i18n key 'more' is deprecated and will be removed in Blacklight 6.0
|
193
|
-
more: 'mais »'
|
194
191
|
more_html: 'mais <span class="sr-only">%{field_name}</span> »'
|
195
192
|
selected:
|
196
193
|
remove: '[remover]'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Blacklight::Engine.routes.draw do
|
2
|
+
get "search_history", :to => "search_history#index", :as => "search_history"
|
3
|
+
delete "search_history/clear", :to => "search_history#clear", :as => "clear_search_history"
|
4
|
+
delete "saved_searches/clear", :to => "saved_searches#clear", :as => "clear_saved_searches"
|
5
|
+
get "saved_searches", :to => "saved_searches#index", :as => "saved_searches"
|
6
|
+
put "saved_searches/save/:id", :to => "saved_searches#save", :as => "save_search"
|
7
|
+
delete "saved_searches/forget/:id", :to => "saved_searches#forget", :as => "forget_search"
|
8
|
+
post "saved_searches/forget/:id", :to => "saved_searches#forget"
|
9
|
+
end
|
data/lib/blacklight.rb
CHANGED
@@ -5,74 +5,34 @@ require 'blacklight/utils'
|
|
5
5
|
|
6
6
|
module Blacklight
|
7
7
|
autoload :Exceptions, 'blacklight/exceptions'
|
8
|
+
autoload :Path, 'blacklight/path'
|
9
|
+
autoload :Parameters, 'blacklight/parameters'
|
8
10
|
autoload :Routes, 'blacklight/routes'
|
9
|
-
autoload :Solr, 'blacklight/solr'
|
10
|
-
|
11
|
-
autoload :SolrHelper, 'blacklight/solr_helper'
|
12
|
-
|
13
|
-
autoload :AbstractRepository, 'blacklight/abstract_repository'
|
14
|
-
autoload :Configuration, 'blacklight/configuration'
|
15
|
-
autoload :SearchBuilder, 'blacklight/search_builder'
|
16
11
|
|
17
12
|
extend Deprecation
|
18
13
|
|
19
14
|
require 'blacklight/version'
|
20
15
|
require 'blacklight/engine' if defined?(Rails)
|
21
|
-
|
16
|
+
|
22
17
|
class << self
|
23
18
|
attr_accessor :solr, :solr_config
|
24
19
|
end
|
25
20
|
|
26
|
-
class SolrRepository < Solr::Repository
|
27
|
-
extend Deprecation
|
28
|
-
def initialize blacklight_config
|
29
|
-
Deprecation.warn(self, 'Blacklight::SolrRepository is deprecated; use Blacklight::Solr::Repository instead')
|
30
|
-
super
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class SolrResponse < Solr::Response
|
35
|
-
extend Deprecation
|
36
|
-
def initialize(data, request_params, options = {})
|
37
|
-
Deprecation.warn(self, 'Blacklight::SolrResponse is deprecated; use Blacklight::Solr::Response instead')
|
38
|
-
super
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
21
|
# Secret key used to share session information with
|
43
22
|
# other services (e.g. refworks callback urls)
|
44
23
|
mattr_accessor :secret_key
|
45
24
|
@@secret_key = nil
|
46
25
|
|
47
|
-
# @deprecated
|
48
|
-
def self.solr_file
|
49
|
-
"#{::Rails.root}/config/solr.yml"
|
50
|
-
end
|
51
|
-
|
52
26
|
def self.blacklight_config_file
|
53
27
|
"#{::Rails.root}/config/blacklight.yml"
|
54
28
|
end
|
55
29
|
|
56
|
-
def self.add_routes(router, options = {})
|
57
|
-
Blacklight::Routes.new(router, options).draw
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.solr
|
61
|
-
Deprecation.warn Blacklight, "Blacklight.solr is deprecated and will be removed in 6.0.0. Use Blacklight.default_index.connection instead", caller
|
62
|
-
default_index.connection
|
63
|
-
end
|
64
|
-
|
65
30
|
##
|
66
31
|
# The default index connection for the search index
|
67
32
|
def self.default_index
|
68
33
|
@default_index ||= repository_class.new(default_configuration)
|
69
34
|
end
|
70
35
|
|
71
|
-
def self.solr_config
|
72
|
-
Deprecation.warn Blacklight, "Blacklight.solr_config is deprecated and will be removed in 6.0.0. Use Blacklight.connection_config instead", caller
|
73
|
-
connection_config
|
74
|
-
end
|
75
|
-
|
76
36
|
##
|
77
37
|
# The configured repository class. By convention, this is
|
78
38
|
# the class Blacklight::{name of the adapter}::Repository, e.g.
|
@@ -83,12 +43,8 @@ module Blacklight
|
|
83
43
|
Blacklight::Solr::Repository
|
84
44
|
when /::/
|
85
45
|
connection_config[:adapter].constantize
|
86
|
-
when nil, ''
|
87
|
-
Rails.logger.warn "The value for :adapter was not found in the blacklight.yml config, and will be required in Blacklight 6.0.0"
|
88
|
-
|
89
|
-
Blacklight::Solr::Repository
|
90
46
|
else
|
91
|
-
"
|
47
|
+
Blacklight.const_get("#{connection_config[:adapter]}/Repository".classify)
|
92
48
|
end
|
93
49
|
end
|
94
50
|
|
@@ -111,12 +67,7 @@ module Blacklight
|
|
111
67
|
|
112
68
|
return @blacklight_yml if @blacklight_yml
|
113
69
|
unless File.exists?(blacklight_config_file)
|
114
|
-
|
115
|
-
Deprecation.warn Blacklight, "Configuration is now done via blacklight.yml. Suppport for solr.yml will be removed in blacklight 6.0.0"
|
116
|
-
return solr_yml
|
117
|
-
else
|
118
|
-
raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?"
|
119
|
-
end
|
70
|
+
raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?"
|
120
71
|
end
|
121
72
|
|
122
73
|
begin
|
@@ -138,34 +89,6 @@ module Blacklight
|
|
138
89
|
return @blacklight_yml
|
139
90
|
end
|
140
91
|
|
141
|
-
def self.solr_yml
|
142
|
-
require 'erb'
|
143
|
-
require 'yaml'
|
144
|
-
|
145
|
-
return @solr_yml if @solr_yml
|
146
|
-
unless File.exists?(solr_file)
|
147
|
-
raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight:install\"?"
|
148
|
-
end
|
149
|
-
|
150
|
-
begin
|
151
|
-
@solr_erb = ERB.new(IO.read(solr_file)).result(binding)
|
152
|
-
rescue StandardError, SyntaxError => e
|
153
|
-
raise("solr.yml was found, but could not be parsed with ERB. \n#{e.inspect}")
|
154
|
-
end
|
155
|
-
|
156
|
-
begin
|
157
|
-
@solr_yml = YAML::load(@solr_erb)
|
158
|
-
rescue => e
|
159
|
-
raise("solr.yml was found, but could not be parsed.\n#{e.inspect}")
|
160
|
-
end
|
161
|
-
|
162
|
-
if @solr_yml.nil? || !@solr_yml.is_a?(Hash)
|
163
|
-
raise("solr.yml was found, but was blank or malformed.\n")
|
164
|
-
end
|
165
|
-
|
166
|
-
return @solr_yml
|
167
|
-
end
|
168
|
-
|
169
92
|
def self.logger
|
170
93
|
@logger ||= begin
|
171
94
|
::Rails.logger if defined? Rails and Rails.respond_to? :logger
|
data/lib/blacklight/engine.rb
CHANGED
@@ -3,7 +3,6 @@ module Blacklight
|
|
3
3
|
engine_name "blacklight"
|
4
4
|
|
5
5
|
require 'bootstrap-sass'
|
6
|
-
require 'blacklight/rails/routes'
|
7
6
|
|
8
7
|
# BlacklightHelper is needed by all helpers, so we inject it
|
9
8
|
# into action view base here.
|
@@ -34,10 +33,6 @@ module Blacklight
|
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
|
-
initializer "blacklight.assets.precompile" do |app|
|
38
|
-
app.config.assets.precompile += %w(favicon.ico)
|
39
|
-
end
|
40
|
-
|
41
36
|
Blacklight::Engine.config.sms_mappings = {
|
42
37
|
'Virgin' => 'vmobl.com',
|
43
38
|
'AT&T' => 'txt.att.net',
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Blacklight
|
2
|
+
module Parameters
|
3
|
+
##
|
4
|
+
# Sanitize the search parameters by removing unnecessary parameters
|
5
|
+
# from the provided parameters
|
6
|
+
# @param [Hash] source_params parameters
|
7
|
+
def self.sanitize params
|
8
|
+
params
|
9
|
+
.reject { |k,v| v.nil? }
|
10
|
+
.except(:action, :controller, :id, :commit, :utf8)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module Blacklight
|
2
|
+
# This class encapsulates the search state as represented by the query
|
3
|
+
# parameters namely: :f, :q, :page, :per_page and, :sort
|
4
|
+
class Path
|
5
|
+
include Blacklight::Facet
|
6
|
+
attr_reader :blacklight_config # Must be called blacklight_config, because Blacklight::Facet calls blacklight_config.
|
7
|
+
attr_reader :params
|
8
|
+
|
9
|
+
def initialize(params, blacklight_config)
|
10
|
+
@params = params
|
11
|
+
@blacklight_config = blacklight_config
|
12
|
+
end
|
13
|
+
|
14
|
+
def url_for_document(doc, options = {})
|
15
|
+
if respond_to?(:blacklight_config) and
|
16
|
+
blacklight_config.show.route and
|
17
|
+
(!doc.respond_to?(:to_model) or doc.to_model.is_a? SolrDocument)
|
18
|
+
route = blacklight_config.show.route.merge(action: :show, id: doc).merge(options)
|
19
|
+
route[:controller] = params[:controller] if route[:controller] == :current
|
20
|
+
route
|
21
|
+
else
|
22
|
+
doc
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# adds the value and/or field to params[:f]
|
27
|
+
# Does NOT remove request keys and otherwise ensure that the hash
|
28
|
+
# is suitable for a redirect. See
|
29
|
+
# add_facet_params_and_redirect
|
30
|
+
def add_facet_params(field, item, source_params=params)
|
31
|
+
|
32
|
+
if item.respond_to? :field
|
33
|
+
field = item.field
|
34
|
+
end
|
35
|
+
|
36
|
+
facet_config = facet_configuration_for_field(field)
|
37
|
+
|
38
|
+
url_field = facet_config.key
|
39
|
+
|
40
|
+
value = facet_value_for_facet_item(item)
|
41
|
+
|
42
|
+
p = reset_search_params(source_params)
|
43
|
+
p[:f] = (p[:f] || {}).dup # the command above is not deep in rails3, !@#$!@#$
|
44
|
+
p[:f][url_field] = (p[:f][url_field] || []).dup
|
45
|
+
|
46
|
+
if facet_config.single and not p[:f][url_field].empty?
|
47
|
+
p[:f][url_field] = []
|
48
|
+
end
|
49
|
+
|
50
|
+
p[:f][url_field].push(value)
|
51
|
+
|
52
|
+
if item and item.respond_to?(:fq) and item.fq
|
53
|
+
Array(item.fq).each do |f,v|
|
54
|
+
p = add_facet_params(f, v, p)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
p
|
59
|
+
end
|
60
|
+
|
61
|
+
# Used in catalog/facet action, facets.rb view, for a click
|
62
|
+
# on a facet value. Add on the facet params to existing
|
63
|
+
# search constraints. Remove any paginator-specific request
|
64
|
+
# params, or other request params that should be removed
|
65
|
+
# for a 'fresh' display.
|
66
|
+
# Change the action to 'index' to send them back to
|
67
|
+
# catalog/index with their new facet choice.
|
68
|
+
def add_facet_params_and_redirect(field, item)
|
69
|
+
new_params = add_facet_params(field, item)
|
70
|
+
|
71
|
+
# Delete any request params from facet-specific action, needed
|
72
|
+
# to redir to index action properly.
|
73
|
+
request_keys = blacklight_config.facet_paginator_class.request_keys
|
74
|
+
new_params.except! *request_keys.values
|
75
|
+
|
76
|
+
new_params
|
77
|
+
end
|
78
|
+
|
79
|
+
# copies the current params (or whatever is passed in as the 3rd arg)
|
80
|
+
# removes the field value from params[:f]
|
81
|
+
# removes the field if there are no more values in params[:f][field]
|
82
|
+
# removes additional params (page, id, etc..)
|
83
|
+
def remove_facet_params(field, item)
|
84
|
+
if item.respond_to? :field
|
85
|
+
field = item.field
|
86
|
+
end
|
87
|
+
|
88
|
+
facet_config = facet_configuration_for_field(field)
|
89
|
+
|
90
|
+
url_field = facet_config.key
|
91
|
+
|
92
|
+
value = facet_value_for_facet_item(item)
|
93
|
+
|
94
|
+
p = reset_search_params(params)
|
95
|
+
# need to dup the facet values too,
|
96
|
+
# if the values aren't dup'd, then the values
|
97
|
+
# from the session will get remove in the show view...
|
98
|
+
p[:f] = (p[:f] || {}).dup
|
99
|
+
p[:f][url_field] = (p[:f][url_field] || []).dup
|
100
|
+
p[:f][url_field] = p[:f][url_field] - [value]
|
101
|
+
p[:f].delete(url_field) if p[:f][url_field].size == 0
|
102
|
+
p.delete(:f) if p[:f].empty?
|
103
|
+
p
|
104
|
+
end
|
105
|
+
|
106
|
+
# Merge the source params with the params_to_merge hash
|
107
|
+
# @param [Hash] params_to_merge to merge into above
|
108
|
+
# @return the current search parameters after being sanitized by Blacklight::Parameters.sanitize
|
109
|
+
# @yield [params] The merged parameters hash before being sanitized
|
110
|
+
def params_for_search(params_to_merge={}, &block)
|
111
|
+
# params hash we'll return
|
112
|
+
my_params = params.dup.merge(params_to_merge.dup)
|
113
|
+
|
114
|
+
if block_given?
|
115
|
+
yield my_params
|
116
|
+
end
|
117
|
+
|
118
|
+
if my_params[:page] and (my_params[:per_page] != params[:per_page] or my_params[:sort] != params[:sort] )
|
119
|
+
my_params[:page] = 1
|
120
|
+
end
|
121
|
+
|
122
|
+
Parameters.sanitize(my_params)
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
|
127
|
+
##
|
128
|
+
# Reset any search parameters that store search context
|
129
|
+
# and need to be reset when e.g. constraints change
|
130
|
+
def reset_search_params source_params
|
131
|
+
Parameters.sanitize(source_params).except(:page, :counter).with_indifferent_access
|
132
|
+
end
|
133
|
+
|
134
|
+
# TODO: this code is duplicated in Blacklight::FacetsHelperBehavior
|
135
|
+
def facet_value_for_facet_item item
|
136
|
+
if item.respond_to? :value
|
137
|
+
item.value
|
138
|
+
else
|
139
|
+
item
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
data/lib/blacklight/routes.rb
CHANGED
@@ -1,138 +1,7 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require 'deprecation'
|
3
2
|
module Blacklight
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
attr_reader :resources
|
8
|
-
|
9
|
-
# adds as class and instance level accessors, default_route_sets
|
10
|
-
# returns an array of symbols for method names that define routes.
|
11
|
-
# Order is important:. (e.g. /catalog/email precedes /catalog/:id)
|
12
|
-
#
|
13
|
-
# Add-ons that want to add routes into default routing might
|
14
|
-
# monkey-patch Blacklight::Routes, say:
|
15
|
-
#
|
16
|
-
# module MyWidget::Routes
|
17
|
-
# extend ActiveSupport::Concern
|
18
|
-
# included do |klass|
|
19
|
-
# klass.default_route_sets += [:widget_routing]
|
20
|
-
# end
|
21
|
-
# def widget_routing(primary_resource)
|
22
|
-
# add_routes do |options|
|
23
|
-
# get "#{primary_resource}/widget", "#{primary_resource}#widget"
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
# end
|
27
|
-
# Blacklight::Routes.send(:include, MyWidget::Routes)
|
28
|
-
class_attribute :default_route_sets
|
29
|
-
self.default_route_sets = [:bookmarks, :search_history, :saved_searches, :export, :solr_document]
|
30
|
-
|
31
|
-
def initialize(router, options)
|
32
|
-
@router = router
|
33
|
-
@options = options
|
34
|
-
@resources = options.fetch(:resources, [:catalog])
|
35
|
-
end
|
36
|
-
|
37
|
-
def draw
|
38
|
-
route_sets.each do |r|
|
39
|
-
self.send(r, primary_resource)
|
40
|
-
end
|
41
|
-
resources.each do |r|
|
42
|
-
self.map_resource(r)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
protected
|
47
|
-
|
48
|
-
def primary_resource
|
49
|
-
resources.first
|
50
|
-
end
|
51
|
-
|
52
|
-
def add_routes &blk
|
53
|
-
@router.instance_exec(@options, &blk)
|
54
|
-
end
|
55
|
-
|
56
|
-
def route_sets
|
57
|
-
(@options[:only] || default_route_sets) - (@options[:except] || [])
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
module RouteSets
|
63
|
-
def bookmarks(_)
|
64
|
-
add_routes do |options|
|
65
|
-
delete "bookmarks/clear", :to => "bookmarks#clear", :as => "clear_bookmarks"
|
66
|
-
get "bookmarks/email", :as => "email_bookmarks"
|
67
|
-
post "bookmarks/email"
|
68
|
-
get "bookmarks/sms", :as => "sms_bookmarks"
|
69
|
-
post "bookmarks/sms"
|
70
|
-
get "bookmarks/citation", :as => "citation_bookmarks"
|
71
|
-
|
72
|
-
args = {}
|
73
|
-
args[:constraints] = options[:constraints] if options[:constraints]
|
74
|
-
resources :bookmarks, args
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def search_history(_)
|
79
|
-
add_routes do |options|
|
80
|
-
get "search_history", :to => "search_history#index", :as => "search_history"
|
81
|
-
delete "search_history/clear", :to => "search_history#clear", :as => "clear_search_history"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
def saved_searches(_)
|
87
|
-
add_routes do |options|
|
88
|
-
delete "saved_searches/clear", :to => "saved_searches#clear", :as => "clear_saved_searches"
|
89
|
-
get "saved_searches", :to => "saved_searches#index", :as => "saved_searches"
|
90
|
-
put "saved_searches/save/:id", :to => "saved_searches#save", :as => "save_search"
|
91
|
-
delete "saved_searches/forget/:id", :to => "saved_searches#forget", :as => "forget_search"
|
92
|
-
post "saved_searches/forget/:id", :to => "saved_searches#forget"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def catalog(_=nil)
|
97
|
-
map_resource(:catalog)
|
98
|
-
end
|
99
|
-
deprecation_deprecate catalog: "use Blacklight::Routes.map_resource(:catalog) instead"
|
100
|
-
|
101
|
-
def map_resource(key)
|
102
|
-
add_routes do |options|
|
103
|
-
get "#{key}/facet/:id", :to => "#{key}#facet", :as => "#{key}_facet"
|
104
|
-
get "#{key}", :to => "#{key}#index", :as => "#{key}_index"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def export(primary_resource)
|
109
|
-
add_routes do |options|
|
110
|
-
get "#{primary_resource}/opensearch", :as => "opensearch_#{primary_resource}"
|
111
|
-
get "#{primary_resource}/citation", :as => "citation_#{primary_resource}"
|
112
|
-
get "#{primary_resource}/email", :as => "email_#{primary_resource}"
|
113
|
-
post "#{primary_resource}/email"
|
114
|
-
get "#{primary_resource}/sms", :as => "sms_#{primary_resource}"
|
115
|
-
post "#{primary_resource}/sms"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def solr_document(primary_resource)
|
120
|
-
add_routes do |options|
|
121
|
-
|
122
|
-
args = {only: [:show]}
|
123
|
-
args[:constraints] = options[:constraints] if options[:constraints]
|
124
|
-
|
125
|
-
resources :solr_document, args.merge(path: primary_resource, controller: primary_resource) do
|
126
|
-
member do
|
127
|
-
post "track"
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
# :show and :update are for backwards-compatibility with catalog_url named routes
|
132
|
-
resources primary_resource, args
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
include RouteSets
|
3
|
+
module Routes
|
4
|
+
require 'blacklight/routes/exportable'
|
5
|
+
require 'blacklight/routes/searchable'
|
137
6
|
end
|
138
7
|
end
|