blacklight 8.0.0.beta5 → 8.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +0 -4
  4. data/README.md +1 -1
  5. data/Rakefile +18 -0
  6. data/VERSION +1 -1
  7. data/app/assets/config/blacklight/manifest.js +3 -0
  8. data/app/assets/stylesheets/blacklight/_facets.scss +32 -5
  9. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +1 -1
  10. data/app/components/blacklight/document_component.rb +21 -2
  11. data/app/components/blacklight/response/facet_group_component.html.erb +2 -1
  12. data/app/helpers/blacklight/blacklight_helper_behavior.rb +0 -5
  13. data/app/javascript/blacklight/bookmark_toggle.js +8 -15
  14. data/app/javascript/blacklight/button_focus.js +10 -10
  15. data/app/javascript/blacklight/index.js +5 -5
  16. data/app/javascript/blacklight/modal.js +6 -11
  17. data/app/javascript/blacklight/search_context.js +51 -57
  18. data/app/models/concerns/blacklight/document.rb +11 -0
  19. data/app/views/catalog/_document.html.erb +2 -2
  20. data/app/views/layouts/blacklight/base.html.erb +4 -4
  21. data/blacklight.gemspec +1 -1
  22. data/config/importmap.rb +1 -1
  23. data/config/locales/blacklight.ar.yml +209 -226
  24. data/config/locales/blacklight.de.yml +197 -209
  25. data/config/locales/blacklight.en.yml +2 -0
  26. data/config/locales/blacklight.es.yml +196 -209
  27. data/config/locales/blacklight.fr.yml +196 -213
  28. data/config/locales/blacklight.hu.yml +193 -206
  29. data/config/locales/blacklight.it.yml +197 -209
  30. data/config/locales/blacklight.nl.yml +193 -206
  31. data/config/locales/blacklight.pt-BR.yml +195 -209
  32. data/config/locales/blacklight.sq.yml +193 -206
  33. data/config/locales/blacklight.zh.yml +194 -207
  34. data/lib/blacklight/configuration/view_config.rb +0 -4
  35. data/lib/blacklight/engine.rb +6 -7
  36. data/lib/generators/blacklight/assets/importmap_generator.rb +9 -2
  37. data/lib/generators/blacklight/assets/propshaft_generator.rb +11 -2
  38. data/lib/generators/blacklight/assets/sprockets_generator.rb +2 -0
  39. data/package.json +7 -4
  40. data/rollup.config.js +11 -1
  41. data/spec/features/sitelinks_search_box_spec.rb +13 -0
  42. data/spec/models/blacklight/icon_spec.rb +0 -2
  43. data/spec/spec_helper.rb +1 -1
  44. data/spec/support/view_component_test_helpers.rb +21 -0
  45. data/spec/test_app_templates/Gemfile.extra +4 -0
  46. data/spec/views/catalog/_document.html.erb_spec.rb +21 -0
  47. data/tasks/blacklight.rake +1 -1
  48. metadata +7 -10
  49. data/app/assets/javascripts/blacklight/blacklight.esm.js +0 -390
  50. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +0 -1
  51. data/app/assets/javascripts/blacklight/blacklight.js +0 -398
  52. data/app/assets/javascripts/blacklight/blacklight.js.map +0 -1
  53. data/spec/features/sitelinks_search_box.rb +0 -13
  54. data/spec/support/view_component_capybara_test_helpers.rb +0 -8
@@ -1,234 +1,221 @@
1
+ ---
1
2
  zh:
2
- views:
3
- pagination:
4
- first: '« 首页'
5
- last: '末页 »'
6
- previous: '« 上一页'
7
- next: '下一页 »'
8
- truncate: '…'
9
- aria:
10
- container_label: 分页链接
11
- current_page: 当前页面,页面%{page}
12
- go_to_page: 前往页面%{page}
13
- go_to_previous_page: 转到上一页
14
- go_to_next_page: 转到下一页
15
- go_to_first_page: 转到第一页
16
- go_to_last_page: 转到最后一页
17
-
18
- pagination_compact:
19
- previous: '« 上一页'
20
- next: '下一页 »'
21
-
22
3
  blacklight:
23
- application_name: 'Blacklight'
24
- skip_links:
25
- label: '跳过链接'
26
- main_content: '转到主要内容'
27
- search_field: '转到搜索'
28
- first_result: '转到第一个搜索结果'
29
- header_links:
30
- login: '登陆'
31
- logout: '注销'
32
- bookmarks: '书签'
33
- search_history: '搜索历史'
34
-
35
- welcome: '欢迎!'
36
- and: '和'
37
- or: '或'
38
-
39
- modal:
40
- close: "关闭"
41
-
4
+ and:
5
+ application_name: Blacklight
6
+ back_to_bookmarks: 返回书签页面
7
+ back_to_search: 返回搜索页面
42
8
  bookmarks:
43
- title: '书签'
44
- page_title: '书签 - %{application_name}'
45
- no_bookmarks: '你还没有任何书签'
46
9
  add:
47
- button: '书签'
10
+ button: 书签
11
+ failure: 抱歉,保存书签时出错。
48
12
  success:
49
- one: '成功添加书签。'
50
- other: '成功添加书签。'
51
- failure: '抱歉,保存书签时出错。'
52
- remove:
53
- button: '删除书签'
54
- success: '成功删除书签。'
55
- failure: '抱歉,删除书签时出错。'
56
- action_confirm: '删除这个书签?'
57
- clear:
58
- action_title: '清除书签'
59
- action_confirm: '清除所有书签?'
60
- success: '已经清除了所有书签。'
61
- failure: '抱歉,清除书签时出错。'
62
- need_login: '登陆后才能访问你的书签功能。'
63
- list_title: '你的书签'
64
- delete: '删除'
65
-
66
- search_history:
13
+ one: 成功添加书签。
14
+ other: 成功添加书签。
67
15
  clear:
68
- action_title: '清除搜索历史'
69
- action_confirm: '清除搜索历史?'
70
- success: '已经清除搜索历史。'
71
- failure: '清除搜索历史时出错。'
72
- title: ''
73
- page_title: '搜索历史 - %{application_name}'
74
- no_history: '你没有任何搜索历史'
75
- recent: '你最近搜索历史'
76
- forget: '去除'
77
- save: '保存'
78
-
79
- tools:
80
- title: '工具'
81
- citation: '引用'
82
- email: '电子邮件'
83
- sms: '发送短信'
84
- clear: '清除'
85
-
16
+ action_confirm: 清除所有书签?
17
+ action_title: 清除书签
18
+ failure: 抱歉,清除书签时出错。
19
+ success: 已经清除了所有书签。
20
+ delete: 删除
21
+ list_title: 你的书签
22
+ need_login: 登陆后才能访问你的书签功能。
23
+ no_bookmarks: 你还没有任何书签
24
+ page_title: 书签 - %{application_name}
25
+ remove:
26
+ action_confirm: 删除这个书签?
27
+ button: 删除书签
28
+ failure: 抱歉,删除书签时出错。
29
+ success: 成功删除书签。
30
+ title: 书签
86
31
  citation:
87
- mla: 'MLA'
88
- apa: 'APA'
89
- chicago: 'Chicago'
90
-
32
+ apa: APA
33
+ chicago: Chicago
34
+ mla: MLA
35
+ did_you_mean: 你是要输入: %{options} 吗?
91
36
  email:
37
+ errors:
38
+ to:
39
+ blank: 请输入电子邮件接收人才能发送
40
+ invalid: 请输入合法电子邮件地址
92
41
  form:
93
- title: '通过电子邮件发送'
94
- to: '电子邮件:'
95
- message: '正文:'
96
- submit: '发送'
42
+ message: 正文:
43
+ submit: 发送
44
+ title: 通过电子邮件发送
45
+ to: 电子邮件:
46
+ success: 已发送电子邮件
97
47
  text:
98
- default_title: ''
48
+ default_title: 无
49
+ message: 正文: %{message}
99
50
  subject:
100
51
  one: '记录: %{title}'
101
- other: '记录'
52
+ other: 记录
102
53
  url: '网址: %{url}'
103
- message: '正文: %{message}'
104
-
105
- success: "已发送电子邮件"
106
-
107
- errors:
108
- to:
109
- invalid: '请输入合法电子邮件地址'
110
- blank: '请输入电子邮件接收人才能发送'
111
- sms:
112
- form:
113
- title: '通过短信发送'
114
- to: '电话号码:'
115
- carrier: '运营商'
116
- carrier_prompt: '请选择运营商'
117
- submit: '发送'
118
- text:
119
- url: '链接: %{url}'
120
- success: "已发送短信"
121
- errors:
122
- to:
123
- invalid: '请输入10位正确电话号码'
124
- blank: "请输入接收人电话号码才能发送短信"
125
- carrier:
126
- blank: '你必须选择一个运营商'
127
- invalid: "你必须输入一个运营商"
128
-
129
- back_to_search: '返回搜索页面'
130
- back_to_bookmarks: '返回书签页面'
131
-
54
+ entry_name:
55
+ default: 条目
56
+ grouped:
57
+ default: 分组结果
58
+ header_links:
59
+ bookmarks: 书签
60
+ login: 登陆
61
+ logout: 注销
62
+ search_history: 搜索历史
63
+ main:
64
+ aria:
65
+ main_container: 主要内容
66
+ modal:
67
+ close: 关闭
68
+ or:
132
69
  search:
133
- page_title:
134
- title: '%{constraints} - %{application_name} 搜索结果'
135
- constraint: '%{label}: %{value}'
136
- many_constraint_values: '%{values} 已选'
137
- header: '搜'
138
- search_constraints_header: '搜索条件'
139
- search_results: '搜索结果'
140
- errors:
141
- invalid_solr_id: "抱歉,你要找的结果不存在。"
142
- per_page:
143
- label: '%{count}<span class="sr-only visually-hidden"> 每页</span>'
144
- button_label: '%{count} 每页' # TODO: Remove during major release
145
- button_label_html: '%{count}<span class="d-none d-sm-inline"> 每页</span>'
146
- title: '每页显示结果数'
147
- submit: '更新'
148
- aria_label: '结果导航'
149
- sort:
150
- label: '按 %{field} 排序' # TODO: Remove during major release
151
- label_html: '<span class="d-none d-sm-inline">按 %{field} </span>排序'
152
- submit: '排序'
153
- form:
154
- search_field:
155
- label: '搜索字段'
156
- title: '设定的搜索选项'
157
- post_label: '为'
158
- search:
159
- label: '搜索'
160
- placeholder: '搜索...'
161
- submit: '搜索'
162
- pagination:
163
- title: '搜索结果导航'
164
- pagination_info:
165
- no_items_found: '没有找到 %{entry_name} '
166
- single_item_found: '找到 <strong>1</strong> %{entry_name}'
167
- pages:
168
- one: '<strong>%{start_num}</strong> - <strong>%{end_num}</strong> 共 <strong>%{total_num}</strong>'
169
- other: '<strong>%{start_num}</strong> - <strong>%{end_num}</strong> 共 <strong>%{total_num}</strong>'
170
- entry_pagination_info:
171
- one: '<strong>1 / 1</strong>'
172
- other: '<strong>%{current}</strong> / <strong>%{total}</strong>'
70
+ atom_feed: 搜索结果Atom
71
+ bookmarks:
72
+ absent: 加入书签
73
+ inprogress: 保存...
74
+ present: 在书签中
173
75
  documents:
174
76
  aria:
175
- search_results: '搜索结果'
176
- limit_search: '限定搜索'
177
- counter: '%{counter}. '
77
+ limit_search: 限定搜索
78
+ search_results: 搜索结果
79
+ counter: "%{counter}. "
80
+ entry_pagination_info:
81
+ one: "<strong>1 / 1</strong>"
82
+ other: "<strong>%{current}</strong> / <strong>%{total}</strong>"
83
+ errors:
84
+ invalid_solr_id: 抱歉,你要找的结果不存在。
178
85
  facets:
179
- title: '限定搜索'
180
- clear: '清除搜索条件'
181
- all: '皆'
182
- sort:
183
- count: '按数量排序'
184
- index: '按字母排序'
185
- count: '%{number}'
186
- more_html: '更多 <span class="sr-only visually-hidden">%{field_name}</span> »'
187
- selected:
188
- remove: '[删除]'
86
+ all:
87
+ clear: 清除搜索条件
88
+ count: "%{number}"
89
+ group:
90
+ close: 隐藏方面
91
+ open: 显示方面
92
+ toggle: 更多 »
189
93
  missing: "[未找到]"
94
+ more_html: 更多 <span class="sr-only visually-hidden">%{field_name}</span> »
190
95
  pivot:
191
- show: 打开
192
96
  hide: 关
193
- group:
194
- toggle: '更多 »'
195
- group:
196
- more: '更多 »'
97
+ show: 打开
98
+ selected:
99
+ remove: "[删除]"
100
+ sort:
101
+ count: 按数量排序
102
+ index: 按字母排序
103
+ title: 限定搜索
197
104
  filters:
198
- title: '你在搜索:'
199
- label: '%{label}:'
105
+ label: "%{label}:"
200
106
  remove:
201
- value: '删除限定条件 %{value}'
202
107
  label_value: '删除限定条件 %{label}: %{value}'
203
- start_over: '重新开始'
108
+ value: 删除限定条件 %{value}
109
+ title: 你在搜索:
110
+ form:
111
+ search:
112
+ label: 搜索
113
+ placeholder: 搜索...
114
+ search_field:
115
+ label: 搜索字段
116
+ post_label: 为
117
+ title: 设定的搜索选项
118
+ submit: 搜索
119
+ group:
120
+ more: 更多 »
121
+ header: 搜
204
122
  index:
205
- label: '%{label}:'
123
+ label: "%{label}:"
124
+ page_title:
125
+ constraint: "%{label}: %{value}"
126
+ many_constraint_values: "%{values} 已选"
127
+ title: "%{constraints} - %{application_name} 搜索结果"
128
+ pagination:
129
+ title: 搜索结果导航
130
+ pagination_info:
131
+ no_items_found: '没有找到 %{entry_name} '
132
+ pages:
133
+ one: "<strong>%{start_num}</strong> - <strong>%{end_num}</strong> 共 <strong>%{total_num}</strong>"
134
+ other: "<strong>%{start_num}</strong> - <strong>%{end_num}</strong> 共 <strong>%{total_num}</strong>"
135
+ single_item_found: 找到 <strong>1</strong> %{entry_name}
136
+ per_page:
137
+ aria_label: 结果导航
138
+ button_label: "%{count} 每页"
139
+ button_label_html: '%{count}<span class="d-none d-sm-inline"> 每页</span>'
140
+ label: '%{count}<span class="sr-only visually-hidden"> 每页</span>'
141
+ submit: 更新
142
+ title: 每页显示结果数
143
+ rss_feed: 搜索结果RSS
144
+ search_constraints_header: 搜索条件
145
+ search_results: 搜索结果
206
146
  show:
207
- title: '%{document_title} - %{application_name}'
208
- label: '%{label}:'
209
- rss_feed: '搜索结果RSS'
210
- atom_feed: '搜索结果Atom'
211
- bookmarks:
212
- present: "在书签中"
213
- absent: "加入书签"
214
- inprogress: "保存..."
215
- zero_results:
216
- title: "未找到任何结果"
217
- modify_search: "请更改你的搜索条件"
218
- use_fewer_keywords: "使用更少的搜索条件,使用左边的链接来筛选搜索结果。"
219
- search_fields: "你在搜索如下字段 %{search_fields}"
220
- search_everything: "试一试搜索所有记录"
221
- view_title: "以如下方式察看搜索结果: "
147
+ label: "%{label}:"
148
+ title: "%{document_title} - %{application_name}"
149
+ sort:
150
+ label: 按 %{field} 排序
151
+ label_html: <span class="d-none d-sm-inline">按 %{field} </span>排序
152
+ submit: 排序
153
+ start_over: 重新开始
222
154
  view:
223
- list: "列表"
224
-
225
- entry_name:
226
- default: '条目'
227
- grouped:
228
- default: '分组结果'
229
-
230
- did_you_mean: '你是要输入: %{options} 吗?'
231
-
232
- main:
155
+ list: 列表
156
+ view_title: '以如下方式察看搜索结果: '
157
+ zero_results:
158
+ modify_search: 请更改你的搜索条件
159
+ search_everything: 试一试搜索所有记录
160
+ search_fields: 你在搜索如下字段 %{search_fields}
161
+ title: 未找到任何结果
162
+ use_fewer_keywords: 使用更少的搜索条件,使用左边的链接来筛选搜索结果。
163
+ search_history:
164
+ clear:
165
+ action_confirm: 清除搜索历史?
166
+ action_title: 清除搜索历史
167
+ failure: 清除搜索历史时出错。
168
+ success: 已经清除搜索历史。
169
+ forget: 去除
170
+ no_history: 你没有任何搜索历史
171
+ page_title: 搜索历史 - %{application_name}
172
+ recent: 你最近搜索历史
173
+ save: 保存
174
+ title: ''
175
+ skip_links:
176
+ first_result: 转到第一个搜索结果
177
+ label: 跳过链接
178
+ main_content: 转到主要内容
179
+ search_field: 转到搜索
180
+ sms:
181
+ errors:
182
+ carrier:
183
+ blank: 你必须选择一个运营商
184
+ invalid: 你必须输入一个运营商
185
+ to:
186
+ blank: 请输入接收人电话号码才能发送短信
187
+ invalid: 请输入10位正确电话号码
188
+ form:
189
+ carrier: 运营商
190
+ carrier_prompt: 请选择运营商
191
+ submit: 发送
192
+ title: 通过短信发送
193
+ to: '电话号码:'
194
+ success: 已发送短信
195
+ text:
196
+ url: '链接: %{url}'
197
+ tools:
198
+ citation: 引用
199
+ clear: 清除
200
+ email: 电子邮件
201
+ sms: 发送短信
202
+ title: 工具
203
+ welcome: 欢迎!
204
+ views:
205
+ pagination:
233
206
  aria:
234
- main_container: '主要内容'
207
+ container_label: 分页链接
208
+ current_page: 当前页面,页面%{page}
209
+ go_to_first_page: 转到第一页
210
+ go_to_last_page: 转到最后一页
211
+ go_to_next_page: 转到下一页
212
+ go_to_page: 前往页面%{page}
213
+ go_to_previous_page: 转到上一页
214
+ first: "&laquo; 首页"
215
+ last: 末页 &raquo;
216
+ next: 下一页 &raquo;
217
+ previous: "&laquo; 上一页"
218
+ truncate: "…"
219
+ pagination_compact:
220
+ next: 下一页 &raquo;
221
+ previous: "&laquo; 上一页"
@@ -26,10 +26,6 @@ class Blacklight::Configuration
26
26
  # @return [Class] component class used to render the search bar
27
27
  # @!attribute search_header_component
28
28
  # @return [Class] component class used to render the header above the documents
29
- def search_bar_presenter_class
30
- super || Blacklight::SearchBarPresenter
31
- end
32
-
33
29
  def display_label(**options)
34
30
  I18n.t(
35
31
  :"blacklight.search.view_title.#{key}",
@@ -19,15 +19,14 @@ module Blacklight
19
19
  end
20
20
  end
21
21
 
22
- initializer "blacklight.assets.precompile" do
23
- # rubocop:disable Lint/ConstantDefinitionInBlock
24
- PRECOMPILE_ASSETS = %w(favicon.ico blacklight/blacklight.js blacklight/blacklight.js.map blacklight/blacklight.esm.js blacklight/blacklight.esm.js.map).freeze
25
- # rubocop:enable Lint/ConstantDefinitionInBlock
22
+ PRECOMPILE_ASSETS = %w(favicon.ico blacklight/blacklight.js blacklight/blacklight.js.map blacklight/blacklight.esm.js blacklight/blacklight.esm.js.map).freeze
26
23
 
24
+ initializer "blacklight.assets.precompile" do |app|
27
25
  # When Rails has been generated in API mode, it does not have sprockets available
28
- if Rails.application.config.respond_to?(:assets)
29
- Rails.application.config.assets.precompile += PRECOMPILE_ASSETS
30
- end
26
+ next unless app.config.respond_to?(:assets)
27
+
28
+ app.config.assets.paths << Engine.root.join("app/javascript")
29
+ app.config.assets.precompile += Blacklight::Engine::PRECOMPILE_ASSETS
31
30
  end
32
31
 
33
32
  initializer "blacklight.importmap", before: "importmap" do |app|
@@ -14,9 +14,15 @@ module Blacklight
14
14
  def import_javascript_assets
15
15
  append_to_file 'config/importmap.rb' do
16
16
  <<~CONTENT
17
+ pin "@github/auto-complete-element", to: "https://cdn.skypack.dev/@github/auto-complete-element"
17
18
  pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/umd/popper.min.js"
18
19
  pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.2.2'}/dist/js/bootstrap.js"
19
- pin "blacklight", to: "blacklight/blacklight.js"
20
+ CONTENT
21
+ end
22
+
23
+ append_to_file 'app/assets/config/manifest.js' do
24
+ <<~CONTENT
25
+ //= link blacklight/manifest.js
20
26
  CONTENT
21
27
  end
22
28
  end
@@ -25,7 +31,8 @@ module Blacklight
25
31
  append_to_file 'app/javascript/application.js' do
26
32
  <<~CONTENT
27
33
  import bootstrap from "bootstrap"
28
- import "blacklight"
34
+ import githubAutoCompleteElement from "@github/auto-complete-element"
35
+ import Blacklight from "blacklight"
29
36
  CONTENT
30
37
  end
31
38
  end
@@ -4,7 +4,15 @@ module Blacklight
4
4
  module Assets
5
5
  class PropshaftGenerator < Rails::Generators::Base
6
6
  def add_package
7
- run 'yarn add blacklight-frontend'
7
+ if ENV['CI']
8
+ run "yarn add blacklight-frontend:#{Blacklight::Engine.root}"
9
+ else
10
+ run 'yarn add blacklight-frontend'
11
+ end
12
+ end
13
+
14
+ def add_third_party_packages
15
+ run 'yarn add @github/auto-complete-element'
8
16
  end
9
17
 
10
18
  def add_package_assets
@@ -16,7 +24,8 @@ module Blacklight
16
24
 
17
25
  append_to_file 'app/javascript/application.js' do
18
26
  <<~CONTENT
19
- import Blacklight from "blacklight-frontend/app/assets/javascripts/blacklight/blacklight.esm";
27
+ import Blacklight from "blacklight-frontend";
28
+ import githubAutoCompleteElement from "@github/auto-complete-element";
20
29
  CONTENT
21
30
  end
22
31
  end
@@ -18,6 +18,7 @@ module Blacklight
18
18
  return if Rails.version > '7' || Sprockets::VERSION < '4'
19
19
 
20
20
  append_to_file 'app/assets/config/manifest.js', "\n//= link application.js"
21
+ append_to_file 'app/assets/config/manifest.js', "\n//= link blacklight/manifest.js"
21
22
  empty_directory 'app/assets/images'
22
23
  end
23
24
 
@@ -42,6 +43,7 @@ module Blacklight
42
43
  // Required by Blacklight
43
44
  //= require popper
44
45
  //= require bootstrap
46
+ //= require blacklight/blacklight
45
47
  CONTENT
46
48
  end
47
49
  end
data/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "8.0.0-beta.5",
3
+ "version": "8.0.0-beta.6",
4
4
  "description": "[![Build Status](https://travis-ci.com/projectblacklight/blacklight.png?branch=main)](https://travis-ci.com/projectblacklight/blacklight) [![Gem Version](https://badge.fury.io/rb/blacklight.png)](http://badge.fury.io/rb/blacklight) [![Coverage Status](https://coveralls.io/repos/github/projectblacklight/blacklight/badge.svg?branch=main)](https://coveralls.io/github/projectblacklight/blacklight?branch=main)",
5
5
  "main": "app/assets/javascripts/blacklight",
6
+ "module": "app/assets/javascripts/blacklight/blacklight.esm.js",
6
7
  "scripts": {
7
- "js-compile-bundle": "rollup --config rollup.config.js --sourcemap && ESM=true rollup --config rollup.config.js --sourcemap"
8
+ "prepare": "rollup --config rollup.config.js --sourcemap && ESM=true rollup --config rollup.config.js --sourcemap"
8
9
  },
9
10
  "repository": {
10
11
  "type": "git",
11
12
  "url": "git+https://github.com/projectblacklight/blacklight.git"
12
13
  },
13
14
  "files": [
14
- "app/assets"
15
+ "app/assets",
16
+ "app/javascript"
15
17
  ],
16
18
  "author": "",
17
19
  "license": "Apache-2.0",
@@ -20,7 +22,8 @@
20
22
  },
21
23
  "homepage": "https://github.com/projectblacklight/blacklight#readme",
22
24
  "devDependencies": {
23
- "rollup": "^2.60.0"
25
+ "rollup": "^2.60.0",
26
+ "rollup-plugin-includepaths": "^0.2.4"
24
27
  },
25
28
  "browserslist": [
26
29
  "defaults",
data/rollup.config.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ import includePaths from 'rollup-plugin-includepaths';
4
+
3
5
  const path = require('path')
4
6
 
5
7
  const BUNDLE = process.env.BUNDLE === 'true'
@@ -9,6 +11,13 @@ const fileDest = `blacklight${ESM ? '.esm' : ''}`
9
11
  const external = []
10
12
  const globals = {}
11
13
 
14
+ let includePathOptions = {
15
+ include: {},
16
+ paths: ['app/javascript'],
17
+ external: [],
18
+ extensions: ['.js']
19
+ };
20
+
12
21
  const rollupConfig = {
13
22
  input: path.resolve(__dirname, `app/javascript/blacklight/index.js`),
14
23
  output: {
@@ -17,7 +26,8 @@ const rollupConfig = {
17
26
  globals,
18
27
  generatedCode: 'es2015'
19
28
  },
20
- external
29
+ external,
30
+ plugins: [includePaths(includePathOptions)]
21
31
  }
22
32
 
23
33
  if (!ESM) {
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe 'Sitelinks search box' do
4
+ it 'is home page' do
5
+ visit root_path
6
+ expect(page).to have_selector 'script[type="application/ld+json"]', visible: :hidden
7
+ end
8
+
9
+ it 'on search page' do
10
+ visit search_catalog_path q: 'book'
11
+ expect(page).not_to have_selector 'script[type="application/ld+json"]', visible: :hidden
12
+ end
13
+ end
@@ -12,8 +12,6 @@ RSpec.describe Blacklight::Icon do
12
12
  elsif defined?(Propshaft)
13
13
  allow(Rails.application.assets.load_path).to receive(:find).and_return(asset)
14
14
  end
15
- # FileUtils.mkdir_p '.internal_test_app/app/assets/images/blacklight'
16
- # File.write '.internal_test_app/app/assets/images/blacklight/test.svg', Blacklight::Icons::SearchComponent.new.svg
17
15
  end
18
16
 
19
17
  describe '#svg' do
data/spec/spec_helper.rb CHANGED
@@ -68,7 +68,7 @@ RSpec.configure do |config|
68
68
  config.infer_spec_type_from_file_location!
69
69
  config.include PresenterTestHelpers, type: :presenter
70
70
  config.include ViewComponent::TestHelpers, type: :component
71
- config.include ViewComponentCapybaraTestHelpers, type: :component
71
+ config.include ViewComponentTestHelpers, type: :component
72
72
 
73
73
  config.include(ControllerLevelHelpers, type: :helper)
74
74
  config.before(:each, type: :helper) { initialize_controller_helpers(helper) }
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ViewComponentTestHelpers
4
+ # Work around for https://github.com/teamcapybara/capybara/issues/2466
5
+ def render_inline_to_capybara_node(component)
6
+ Capybara::Node::Simple.new(render_inline(component).to_s)
7
+ end
8
+
9
+ # Work-around for https://github.com/ViewComponent/view_component/pull/1661
10
+ # which made the component test's controller method (more) private. This makes
11
+ # it available so we can set up controller-level state for our tests.
12
+ def controller
13
+ # ViewComponent 2.x
14
+ return super if defined?(super)
15
+
16
+ # ViewComponent 3.x
17
+ return __vc_test_helpers_controller if defined?(__vc_test_helpers_controller)
18
+
19
+ ApplicationController.new.extend(Rails.application.routes.url_helpers)
20
+ end
21
+ end
@@ -1,2 +1,6 @@
1
1
  gem 'rails-controller-testing'
2
2
  gem 'thor', '~> 0.20' if /^5.[12]/.match?(ENV['RAILS_VERSION'])
3
+
4
+ unless ENV['VIEW_COMPONENT_VERSION'].to_s == ""
5
+ gem 'view_component', ENV.fetch('VIEW_COMPONENT_VERSION')
6
+ end