arclight 0.5.0 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +11 -4
  3. data/.github/workflows/ruby.yml +24 -11
  4. data/.rspec +0 -1
  5. data/.rubocop.yml +286 -2
  6. data/.rubocop_todo.yml +18 -195
  7. data/CONTRIBUTING.md +5 -5
  8. data/Gemfile +12 -12
  9. data/README.md +18 -12
  10. data/app/assets/javascripts/arclight/arclight.js +3 -7
  11. data/app/assets/javascripts/arclight/oembed_viewer.js +64 -39
  12. data/app/assets/javascripts/arclight/truncate_controller.js +27 -0
  13. data/app/assets/stylesheets/arclight/application.scss +1 -5
  14. data/app/assets/stylesheets/arclight/modules/hierarchy_and_online_contents.scss +104 -130
  15. data/app/assets/stylesheets/arclight/modules/icons.scss +14 -3
  16. data/app/assets/stylesheets/arclight/modules/layout.scss +120 -100
  17. data/app/assets/stylesheets/arclight/modules/mastheads.scss +15 -57
  18. data/app/assets/stylesheets/arclight/modules/repositories.scss +2 -2
  19. data/app/assets/stylesheets/arclight/modules/repository_card.scss +4 -48
  20. data/app/assets/stylesheets/arclight/modules/search_results.scss +86 -35
  21. data/app/assets/stylesheets/arclight/modules/show_collection.scss +5 -32
  22. data/app/assets/stylesheets/arclight/modules/truncator.scss +56 -0
  23. data/app/assets/stylesheets/arclight/variables.scss +7 -4
  24. data/app/components/arclight/access_component.html.erb +14 -0
  25. data/app/components/arclight/access_component.rb +25 -0
  26. data/app/components/arclight/bookmark_component.html.erb +25 -0
  27. data/app/components/arclight/bookmark_component.rb +9 -0
  28. data/app/components/arclight/breadcrumb_component.rb +40 -0
  29. data/app/components/arclight/breadcrumbs_hierarchy_component.html.erb +34 -0
  30. data/app/components/arclight/breadcrumbs_hierarchy_component.rb +25 -0
  31. data/app/components/arclight/collection_context_component.html.erb +12 -0
  32. data/app/components/arclight/collection_context_component.rb +27 -0
  33. data/app/components/arclight/collection_info_component.html.erb +28 -0
  34. data/app/components/arclight/collection_info_component.rb +26 -0
  35. data/app/components/arclight/collection_sidebar_component.html.erb +15 -0
  36. data/app/components/arclight/collection_sidebar_component.rb +41 -0
  37. data/app/{views/catalog/_search_results_repository.html.erb → components/arclight/constraints_component.html.erb} +2 -1
  38. data/app/components/arclight/constraints_component.rb +17 -0
  39. data/app/components/arclight/document_collection_context_component.html.erb +29 -0
  40. data/app/components/arclight/document_collection_context_component.rb +28 -0
  41. data/app/components/arclight/document_collection_hierarchy_component.html.erb +46 -0
  42. data/app/components/arclight/document_collection_hierarchy_component.rb +62 -0
  43. data/app/components/arclight/document_component.html.erb +39 -0
  44. data/app/components/arclight/document_component.rb +49 -0
  45. data/app/components/arclight/document_components_hierarchy_component.html.erb +32 -0
  46. data/app/components/arclight/document_components_hierarchy_component.rb +28 -0
  47. data/app/components/arclight/document_download_component.html.erb +24 -0
  48. data/app/components/arclight/document_download_component.rb +71 -0
  49. data/app/components/arclight/embed_component.html.erb +10 -0
  50. data/app/components/arclight/embed_component.rb +43 -0
  51. data/app/components/arclight/group_component.html.erb +30 -0
  52. data/app/components/arclight/group_component.rb +23 -0
  53. data/app/components/arclight/header_component.html.erb +5 -0
  54. data/app/components/arclight/header_component.rb +10 -0
  55. data/app/components/arclight/index_metadata_field_component.html.erb +17 -0
  56. data/app/components/arclight/index_metadata_field_component.rb +20 -0
  57. data/app/components/arclight/masthead_component.html.erb +15 -0
  58. data/app/components/arclight/masthead_component.rb +10 -0
  59. data/app/components/arclight/metadata_section_component.html.erb +13 -0
  60. data/app/components/arclight/metadata_section_component.rb +22 -0
  61. data/app/components/arclight/oembed_viewer_component.html.erb +5 -0
  62. data/app/components/arclight/oembed_viewer_component.rb +16 -0
  63. data/app/components/arclight/online_content_filter_component.html.erb +15 -0
  64. data/app/components/arclight/online_content_filter_component.rb +19 -0
  65. data/app/components/arclight/online_status_indicator_component.rb +19 -0
  66. data/app/components/arclight/repository_breadcrumb_component.html.erb +10 -0
  67. data/app/components/arclight/repository_breadcrumb_component.rb +17 -0
  68. data/app/components/arclight/repository_location_component.html.erb +20 -0
  69. data/app/components/arclight/repository_location_component.rb +10 -0
  70. data/app/components/arclight/search_bar_component.html.erb +25 -0
  71. data/app/components/arclight/search_bar_component.rb +32 -0
  72. data/app/components/arclight/search_result_breadcrumbs_component.html.erb +3 -0
  73. data/app/components/arclight/search_result_breadcrumbs_component.rb +37 -0
  74. data/app/components/arclight/search_result_component.html.erb +20 -0
  75. data/app/components/arclight/search_result_component.rb +24 -0
  76. data/app/components/arclight/search_result_title_component.html.erb +13 -0
  77. data/app/components/arclight/search_result_title_component.rb +15 -0
  78. data/app/components/arclight/sidebar_component.html.erb +9 -0
  79. data/app/components/arclight/sidebar_component.rb +19 -0
  80. data/app/components/arclight/upper_metadata_layout_component.rb +10 -0
  81. data/app/components/blacklight/icons/bookmark_component.rb +12 -0
  82. data/app/components/blacklight/icons/collection_component.rb +14 -0
  83. data/app/components/blacklight/icons/compact_component.rb +12 -0
  84. data/app/components/blacklight/icons/container_component.rb +14 -0
  85. data/app/components/blacklight/icons/ead_component.rb +12 -0
  86. data/app/components/blacklight/icons/file_component.rb +14 -0
  87. data/app/components/blacklight/icons/folder_component.rb +12 -0
  88. data/app/components/blacklight/icons/online_component.rb +15 -0
  89. data/app/components/blacklight/icons/pdf_component.rb +12 -0
  90. data/app/components/blacklight/icons/repository_component.rb +12 -0
  91. data/app/controllers/arclight/repositories_controller.rb +4 -4
  92. data/app/{controllers/concerns → helpers}/arclight/ead_format_helpers.rb +4 -7
  93. data/app/helpers/arclight/field_config_helpers.rb +26 -0
  94. data/app/helpers/arclight_helper.rb +15 -253
  95. data/app/models/arclight/document_downloads.rb +12 -15
  96. data/app/models/arclight/parent.rb +5 -0
  97. data/app/models/arclight/parents.rb +2 -1
  98. data/app/models/arclight/requests/aeon_external_request.rb +1 -1
  99. data/app/models/arclight/requests/aeon_web_ead.rb +8 -3
  100. data/app/models/arclight/requests/google_form.rb +8 -3
  101. data/app/models/concerns/arclight/catalog.rb +25 -15
  102. data/app/models/concerns/arclight/search_behavior.rb +12 -26
  103. data/app/models/concerns/arclight/solr_document.rb +70 -73
  104. data/app/presenters/arclight/show_presenter.rb +34 -7
  105. data/app/views/arclight/_requests.html.erb +2 -2
  106. data/app/views/arclight/repositories/_repository.html.erb +21 -40
  107. data/app/views/arclight/repositories/index.html.erb +3 -1
  108. data/app/views/arclight/repositories/show.html.erb +4 -6
  109. data/app/views/arclight/requests/_aeon_external_request_endpoint.html.erb +4 -5
  110. data/app/views/arclight/requests/_aeon_web_ead.html.erb +2 -3
  111. data/app/views/arclight/requests/_google_form.html.erb +4 -6
  112. data/app/views/catalog/_group.html.erb +1 -18
  113. data/app/views/catalog/_group_toggle.html.erb +1 -1
  114. data/app/views/catalog/_search_results_header.html.erb +3 -0
  115. data/app/views/catalog/hierarchy.html.erb +19 -0
  116. data/app/views/catalog/index.html.erb +16 -7
  117. data/app/views/shared/_breadcrumbs.html.erb +2 -14
  118. data/app/views/shared/_main_menu_links.html.erb +1 -1
  119. data/arclight.gemspec +7 -6
  120. data/config/breadcrumbs.rb +24 -0
  121. data/config/i18n-tasks.yml +9 -8
  122. data/config/importmap.rb +3 -0
  123. data/config/locales/arclight.en.yml +31 -30
  124. data/config/routes.rb +1 -1
  125. data/docker-compose.yml +16 -0
  126. data/lib/arclight/digital_object.rb +2 -1
  127. data/lib/arclight/engine.rb +18 -31
  128. data/lib/arclight/exceptions.rb +1 -0
  129. data/lib/arclight/hash_absolute_xpath.rb +2 -1
  130. data/lib/arclight/normalized_id.rb +2 -0
  131. data/lib/arclight/normalized_title.rb +2 -0
  132. data/lib/arclight/repository.rb +43 -54
  133. data/lib/arclight/routes/hierarchy.rb +19 -0
  134. data/lib/arclight/routes.rb +8 -0
  135. data/lib/arclight/traject/ead2_component_config.rb +292 -0
  136. data/lib/arclight/traject/ead2_config.rb +66 -287
  137. data/lib/arclight/version.rb +1 -1
  138. data/lib/arclight/year_range.rb +4 -3
  139. data/lib/arclight.rb +6 -1
  140. data/lib/generators/arclight/install_generator.rb +59 -21
  141. data/lib/generators/arclight/templates/arclight.scss +4 -3
  142. data/lib/generators/arclight/templates/catalog_controller.rb +150 -169
  143. data/lib/generators/arclight/templates/config/locales/arclight.en.yml +53 -0
  144. data/lib/generators/arclight/templates/config/repositories.yml +20 -27
  145. data/lib/tasks/index.rake +14 -17
  146. data/package.json +11 -13
  147. data/solr/conf/schema.xml +40 -36
  148. data/solr/conf/solrconfig.xml +33 -31
  149. data/tasks/arclight.rake +8 -7
  150. data/template.rb +0 -1
  151. metadata +111 -104
  152. data/.babelrc +0 -3
  153. data/app/assets/javascripts/arclight/collection_navigation.js +0 -100
  154. data/app/assets/javascripts/arclight/collection_scrollspy.js +0 -6
  155. data/app/assets/javascripts/arclight/context_navigation.js +0 -351
  156. data/app/assets/javascripts/arclight/truncator.js.erb +0 -29
  157. data/app/assets/stylesheets/arclight/bootstrap_overrides.scss +0 -26
  158. data/app/assets/stylesheets/arclight/modules/context_navigation.scss +0 -75
  159. data/app/controllers/concerns/arclight/field_config_helpers.rb +0 -102
  160. data/app/factories/blacklight_field_configuration_factory.rb +0 -30
  161. data/app/views/arclight/repositories/_in_person_repository.html.erb +0 -19
  162. data/app/views/arclight/repositories/_repository_contact.html.erb +0 -9
  163. data/app/views/arclight/viewers/_oembed.html.erb +0 -8
  164. data/app/views/catalog/_access_contents.html.erb +0 -15
  165. data/app/views/catalog/_arclight_abstract_or_scope.html.erb +0 -5
  166. data/app/views/catalog/_arclight_bookmark_control.html.erb +0 -38
  167. data/app/views/catalog/_arclight_document_header_icon.html.erb +0 -1
  168. data/app/views/catalog/_arclight_document_index_header.html.erb +0 -13
  169. data/app/views/catalog/_arclight_document_index_header_hierarchy_default.html.erb +0 -0
  170. data/app/views/catalog/_arclight_document_index_header_online_contents_default.html.erb +0 -0
  171. data/app/views/catalog/_arclight_index_compact_default.html.erb +0 -22
  172. data/app/views/catalog/_arclight_index_default.html.erb +0 -45
  173. data/app/views/catalog/_arclight_index_group_document_compact_default.html.erb +0 -19
  174. data/app/views/catalog/_arclight_index_group_document_default.html.erb +0 -18
  175. data/app/views/catalog/_arclight_online_content_indicator.html.erb +0 -3
  176. data/app/views/catalog/_arclight_rangelimit.html.erb +0 -24
  177. data/app/views/catalog/_arclight_viewer_default.html.erb +0 -1
  178. data/app/views/catalog/_collection_contents.html.erb +0 -4
  179. data/app/views/catalog/_collection_context.html.erb +0 -15
  180. data/app/views/catalog/_collection_context_nav.html.erb +0 -12
  181. data/app/views/catalog/_collection_online_contents.html.erb +0 -17
  182. data/app/views/catalog/_component_context.html.erb +0 -5
  183. data/app/views/catalog/_containers.html.erb +0 -3
  184. data/app/views/catalog/_context_card.html.erb +0 -27
  185. data/app/views/catalog/_context_sidebar.html.erb +0 -8
  186. data/app/views/catalog/_custom_metadata.html.erb +0 -16
  187. data/app/views/catalog/_document_downloads.html.erb +0 -14
  188. data/app/views/catalog/_group_header_compact_default.html.erb +0 -15
  189. data/app/views/catalog/_group_header_default.html.erb +0 -20
  190. data/app/views/catalog/_home.html.erb +0 -1
  191. data/app/views/catalog/_index_breadcrumb_default.html.erb +0 -6
  192. data/app/views/catalog/_index_collection_context_default.html.erb +0 -53
  193. data/app/views/catalog/_index_default.html.erb +0 -17
  194. data/app/views/catalog/_index_header.html.erb +0 -7
  195. data/app/views/catalog/_index_header_online_contents_default.html.erb +0 -1
  196. data/app/views/catalog/_index_online_contents_default.html.erb +0 -6
  197. data/app/views/catalog/_online_content_label.html.erb +0 -5
  198. data/app/views/catalog/_search_form.html.erb +0 -38
  199. data/app/views/catalog/_search_results.html.erb +0 -28
  200. data/app/views/catalog/_show_actions_box_default.html.erb +0 -27
  201. data/app/views/catalog/_show_breadcrumbs_default.html.erb +0 -6
  202. data/app/views/catalog/_show_collection.html.erb +0 -66
  203. data/app/views/catalog/_show_default.html.erb +0 -70
  204. data/app/views/catalog/_show_upper_metadata_collection.html.erb +0 -1
  205. data/app/views/catalog/_show_upper_metadata_default.html.erb +0 -14
  206. data/app/views/catalog/_sort_and_per_page.html.erb +0 -8
  207. data/app/views/catalog/_within_collection_dropdown.html.erb +0 -26
  208. data/app/views/layouts/catalog_result.html.erb +0 -7
  209. data/app/views/shared/_context_sidebar.html.erb +0 -8
  210. data/app/views/shared/_header_navbar.html.erb +0 -61
  211. data/app/views/shared/_show_breadcrumbs.html.erb +0 -27
  212. data/lib/arclight/viewer.rb +0 -45
  213. data/lib/arclight/viewers/oembed.rb +0 -57
  214. data/solr/conf/scripts.conf +0 -24
  215. data/vendor/assets/javascripts/responsiveTruncator.js +0 -69
  216. data/vendor/assets/javascripts/stickyfill.js +0 -480
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arclight
4
+ ##
5
+ # A module to add configuration helpers for certain fields used by Arclight
6
+ module FieldConfigHelpers
7
+ include Arclight::EadFormatHelpers
8
+
9
+ def item_requestable?(document)
10
+ document.requestable?
11
+ end
12
+ Arclight.deprecation.deprecate_methods(self, item_requestable?: 'Call e.g. `document.requestable?` instead')
13
+
14
+ def link_to_name_facet(args)
15
+ options = args[:config]&.separator_options || {}
16
+ values = args[:value] || []
17
+
18
+ values.map do |value|
19
+ link_to(
20
+ value,
21
+ search_action_path(f: { names: [value] })
22
+ )
23
+ end.to_sentence(options).html_safe
24
+ end
25
+ end
26
+ end
@@ -3,94 +3,15 @@
3
3
  ##
4
4
  # Generic Helpers used in Arclight
5
5
  module ArclightHelper
6
- def aria_hidden_breadcrumb_separator
7
- safe_join(
8
- [
9
- '<span aria-hidden="true">'.html_safe,
10
- t('arclight.breadcrumb_separator'),
11
- '</span>'.html_safe
12
- ]
13
- )
14
- end
15
-
16
- ##
17
- # @param [SolrDocument]
18
- def parents_to_links(document)
19
- breadcrumb_links = []
20
-
21
- breadcrumb_links << build_repository_link(document)
22
-
23
- breadcrumb_links << document_parents(document).map do |parent|
24
- link_to parent.label, solr_document_path(parent.global_id)
25
- end
26
-
27
- safe_join(breadcrumb_links, aria_hidden_breadcrumb_separator)
28
- end
29
-
30
- ##
31
- # For a non-grouped compact view, display the breadcrumbs with the following
32
- # algorithm:
33
- # - Display only the first two parts of the item breadcrumb: the repository
34
- # and the collection.
35
- # - After the collection and the breadcrumb divider icon, show an ellipses as
36
- # shown in the mockup above. The repository and the collection parts are
37
- # linked as usual; the ellipses is not linked.
38
- def regular_compact_breadcrumbs(document)
39
- breadcrumb_links = [build_repository_link(document)]
40
-
41
- parents = document_parents(document)
42
- breadcrumb_links << parents[0, 1].map do |parent|
43
- link_to parent.label, solr_document_path(parent.global_id)
44
- end
45
-
46
- breadcrumb_links << '&hellip;'.html_safe if parents.length > 1
47
-
48
- safe_join(
49
- breadcrumb_links,
50
- aria_hidden_breadcrumb_separator
51
- )
52
- end
53
-
54
- ##
55
- # @param [SolrDocument]
56
- def component_parents_to_links(document)
57
- parents = document_parents(document)
58
- return unless parents.length > 1
59
-
60
- safe_join(parents.slice(1, 999).map do |parent|
61
- link_to parent.label, solr_document_path(parent.global_id)
62
- end, aria_hidden_breadcrumb_separator)
63
- end
64
-
65
- ##
66
- # @param [SolrDocument]
67
- def component_top_level_parent_to_links(document)
68
- parents = document_parents(document)
69
- return unless parents.length > 1
70
-
71
- parent_link = link_to(parents[1].label, solr_document_path(parents[1].global_id))
72
- return parent_link if parents.length == 2
73
-
74
- safe_join(
75
- [
76
- parent_link,
77
- aria_hidden_breadcrumb_separator,
78
- '&hellip;'.html_safe
79
- ]
80
- )
81
- end
82
-
83
- ##
84
- # @param [SolrDocument]
85
- def document_parents(document)
86
- Arclight::Parents.from_solr_document(document).as_parents
87
- end
6
+ include Arclight::EadFormatHelpers
7
+ include Arclight::FieldConfigHelpers
8
+ include Blacklight::LayoutHelperBehavior
88
9
 
89
10
  def repository_collections_path(repository)
90
11
  search_action_url(
91
12
  f: {
92
- repository_sim: [repository.name],
93
- level_sim: ['Collection']
13
+ repository: [repository.name],
14
+ level: ['Collection']
94
15
  }
95
16
  )
96
17
  end
@@ -108,26 +29,22 @@ module ArclightHelper
108
29
 
109
30
  ##
110
31
  # Classes used for customized show page in arclight
111
- def custom_show_content_classes
112
- 'col-md-12 show-document'
32
+ def show_content_classes
33
+ 'col-12 col-lg-8 show-document order-2'
113
34
  end
114
35
 
115
- def normalize_id(id)
116
- Arclight::NormalizedId.new(id).to_s
36
+ def show_sidebar_classes
37
+ 'col-lg-4 order-1 collection-sidebar'
117
38
  end
118
39
 
119
40
  def collection_active?
120
- respond_to?(:search_state) && search_state&.params_for_search&.dig('f', 'level_sim') == ['Collection']
41
+ search_state.filter('level').values == ['Collection']
121
42
  end
122
43
 
123
44
  def collection_active_class
124
45
  'active' if collection_active?
125
46
  end
126
47
 
127
- def collection_count
128
- @response.response['numFound']
129
- end
130
-
131
48
  def grouped?
132
49
  respond_to?(:search_state) && search_state&.params_for_search&.dig('group') == 'true'
133
50
  end
@@ -140,14 +57,6 @@ module ArclightHelper
140
57
  search_state.params_for_search.except('group', 'page')
141
58
  end
142
59
 
143
- def search_within_collection(collection_name, search)
144
- search.merge(f: { collection_sim: [collection_name] })
145
- end
146
-
147
- def on_repositories_show?
148
- controller_name == 'repositories' && action_name == 'show'
149
- end
150
-
151
60
  def on_repositories_index?
152
61
  controller_name == 'repositories' && action_name == 'index'
153
62
  end
@@ -157,29 +66,14 @@ module ArclightHelper
157
66
  'active' if on_repositories_index?
158
67
  end
159
68
 
160
- def fields_have_content?(document, field_accessor)
161
- generic_document_fields(field_accessor).any? do |_, field|
162
- generic_should_render_field?(field_accessor, document, field)
163
- end
164
- end
165
-
166
69
  # If we have a facet on the repository, then return the Repository object for it
167
70
  #
168
71
  # @return [Repository]
169
72
  def repository_faceted_on
170
- return unless respond_to?(:search_state) && search_state && facet_field_in_params?('repository_sim')
171
-
172
- repos = Array(facet_params('repository_sim'))
173
- faceted = repos && repos.length == 1 && repos.first
174
- Arclight::Repository.find_by(name: repos.first) if faceted
175
- end
73
+ repos = search_state.filter('repository').values
74
+ return unless repos.one?
176
75
 
177
- def hierarchy_component_context?
178
- params[:hierarchy_context] == 'component'
179
- end
180
-
181
- def online_contents_context?
182
- params[:view] == 'online_contents'
76
+ Arclight::Repository.find_by(name: repos.first)
183
77
  end
184
78
 
185
79
  # determine which icon to show in search results header
@@ -197,139 +91,7 @@ module ArclightHelper
197
91
  end
198
92
  end
199
93
 
200
- def render_grouped_documents(documents)
201
- safe_join(
202
- documents.each_with_index.map do |document, i|
203
- render_document_partial(document, :arclight_index_group_document, document_counter: i)
204
- end
205
- )
206
- end
207
-
208
- def ead_files(document)
209
- files = Arclight::DocumentDownloads.new(document, document.collection_unitid).files
210
- files.find do |file|
211
- file.type == 'ead'
212
- end
213
- end
214
-
215
- ##
216
- # Defines custom helpers used for creating unique metadata blocks to render
217
- Arclight::Engine.config.catalog_controller_field_accessors.each do |config_field|
218
- ##
219
- # Mimics what document_show_fields from Blacklight does
220
- # https://github.com/projectblacklight/blacklight/blob/dee8d794125306ec8d4ab834a6a45bcf9671c791/app/helpers/blacklight/configuration_helper_behavior.rb#L35-L38
221
- define_method(:"document_#{config_field}s") do |_document = nil|
222
- blacklight_config.send(:"#{config_field}s")
223
- end
224
-
225
- ##
226
- # Mimics what render_document_show_field_label from Blacklight does
227
- # https://github.com/projectblacklight/blacklight/blob/dee8d794125306ec8d4ab834a6a45bcf9671c791/app/helpers/blacklight/blacklight_helper_behavior.rb#L136-L156
228
- define_method(:"render_document_#{config_field}_label") do |*args|
229
- options = args.extract_options!
230
- document = args.first
231
-
232
- field = options[:field]
233
-
234
- t(:'blacklight.search.show.label', label: send(:"document_#{config_field}_label", document, field))
235
- end
236
-
237
- ##
238
- # Mimics what document_show_field_label from Blacklight does
239
- # https://github.com/projectblacklight/blacklight/blob/dee8d794125306ec8d4ab834a6a45bcf9671c791/app/helpers/blacklight/configuration_helper_behavior.rb#L67-L74
240
- define_method(:"document_#{config_field}_label") do |document, field|
241
- field_config = send(:"document_#{config_field}s", document)[field]
242
- field_config ||= Blacklight::Configuration::NullField.new(key: field)
243
-
244
- field_config.display_label('show')
245
- end
246
-
247
- ##
248
- # Mimics what should_render_show_field? from Blacklight does
249
- # https://github.com/projectblacklight/blacklight/blob/dee8d794125306ec8d4ab834a6a45bcf9671c791/app/helpers/blacklight/blacklight_helper_behavior.rb#L84-L92
250
- define_method(:"should_render_#{config_field}?") do |document, field_config|
251
- should_render_field?(field_config, document) && document_has_value?(document, field_config)
252
- end
253
- end
254
-
255
- ##
256
- # Calls the method for a configured field
257
- def generic_document_fields(config_field)
258
- send(:"document_#{config_field}s")
259
- end
260
-
261
- ##
262
- # Calls the method for a configured field
263
- def generic_should_render_field?(config_field, document, field)
264
- send(:"should_render_#{config_field}?", document, field)
265
- end
266
-
267
- ##
268
- # Calls the method for a configured field
269
- def generic_render_document_field_label(config_field, document, field: field_name)
270
- send(:"render_document_#{config_field}_label", document, field: field)
271
- end
272
-
273
- def show_expanded?(document)
274
- !original_document?(document) && within_original_tree?(document)
275
- end
276
-
277
- def within_original_tree?(document)
278
- Array.wrap(params['original_parents']).map do |parent|
279
- Arclight::Parent.new(id: parent, eadid: document.parent_ids.first, level: nil, label: nil).global_id
280
- end.include?(document.id)
281
- end
282
-
283
- def original_document?(document)
284
- document.id == params['original_document']
285
- end
286
-
287
- def generic_context_navigation(document, original_parents: document.parent_ids, component_level: 1)
288
- content_tag(
289
- :div,
290
- '',
291
- class: 'context-navigator',
292
- data: {
293
- collapse: I18n.t('arclight.views.show.collapse'),
294
- expand: I18n.t('arclight.views.show.expand'),
295
- arclight: {
296
- level: component_level,
297
- path: search_catalog_path(hierarchy_context: 'component'),
298
- name: document.collection_name,
299
- originalDocument: document.id,
300
- originalParents: original_parents,
301
- eadid: normalize_id(document.eadid)
302
- }
303
- }
304
- )
305
- end
306
-
307
- ##
308
- # Determine if the user is currently under a collection context
309
- # This is any record view (because it is either the collection or a component w/i a collection)
310
- # or in a result view where a collection facet has been selected
311
- def within_collection_context?
312
- return true if record_view?
313
-
314
- results_view? && params.dig(:f, 'collection_sim')
315
- end
316
-
317
- def results_view?
318
- controller_name == 'catalog' && action_name == 'index'
319
- end
320
-
321
- def record_view?
322
- controller_name == 'catalog' && action_name == 'show'
323
- end
324
-
325
- private
326
-
327
- def build_repository_link(document)
328
- repository_path = document.repository_config&.slug
329
- if repository_path.present?
330
- link_to(document.repository, arclight_engine.repository_path(repository_path))
331
- else
332
- content_tag(:span, document.repository)
333
- end
94
+ def current_context_document
95
+ @document
334
96
  end
335
97
  end
@@ -30,27 +30,23 @@ module Arclight
30
30
  end.compact
31
31
  end
32
32
 
33
- def to_partial_path
34
- 'catalog/document_downloads'
35
- end
36
-
37
33
  class << self
38
34
  def config
39
35
  @config ||= begin
40
- YAML.safe_load(::File.read(config_filename))
41
- rescue Errno::ENOENT
42
- {}
43
- end
36
+ YAML.safe_load(::File.read(config_filename))
37
+ rescue Errno::ENOENT
38
+ {}
39
+ end
44
40
  end
45
41
 
46
42
  def config_filename
47
- Rails.root.join('config', 'downloads.yml')
43
+ Rails.root.join('config/downloads.yml')
48
44
  end
49
45
 
50
46
  # Accessor for the File Class
51
47
  # @return [Class]
52
48
  def file_class
53
- File
49
+ Arclight::DocumentDownloads::File
54
50
  end
55
51
  end
56
52
 
@@ -58,6 +54,7 @@ module Arclight
58
54
  # Model a single file configured in downloads.yml
59
55
  class File
60
56
  attr_reader :type, :document
57
+
61
58
  def initialize(type:, data:, document:)
62
59
  @type = type
63
60
  @data = data
@@ -73,7 +70,7 @@ module Arclight
73
70
  def size
74
71
  return data['size'] if data['size']
75
72
 
76
- document.send(data['size_accessor'].to_sym) if data['size_accessor']
73
+ document.public_send(data['size_accessor'].to_sym) if data['size_accessor']
77
74
  end
78
75
 
79
76
  private
@@ -99,13 +96,13 @@ module Arclight
99
96
  end
100
97
 
101
98
  def template_variables
102
- data['template'].scan(/%{(\w+)}/).flatten.uniq
99
+ template.scan(Regexp.union(/%{(\w+)}/, /%<(\w+)>/)).flatten.compact.uniq
103
100
  end
104
101
 
105
102
  def escaped_document_interpolations
106
- non_custom_template_variables.map do |method_name|
107
- [method_name, escape_non_url_doc_value(document.send(method_name))]
108
- end.to_h
103
+ non_custom_template_variables.index_with do |method_name|
104
+ escape_non_url_doc_value(document.public_send(method_name))
105
+ end
109
106
  end
110
107
 
111
108
  def escape_non_url_doc_value(value)
@@ -6,6 +6,7 @@ module Arclight
6
6
  # https://github.com/awead/solr_ead/blob/8cf7ffaa66e0e4c9c0b12f5646d6c2e20984cd99/lib/solr_ead/behaviors.rb#L54-L57
7
7
  class Parent
8
8
  attr_reader :id, :label, :eadid, :level
9
+
9
10
  def initialize(id:, label:, eadid:, level:)
10
11
  @id = id
11
12
  @label = label
@@ -13,6 +14,10 @@ module Arclight
13
14
  @level = level
14
15
  end
15
16
 
17
+ def collection?
18
+ level == 'collection'
19
+ end
20
+
16
21
  ##
17
22
  # Concatenates the eadid and the id, to return an "id" in the context of
18
23
  # Blacklight and Solr
@@ -6,6 +6,7 @@ module Arclight
6
6
  # https://github.com/awead/solr_ead/blob/8cf7ffaa66e0e4c9c0b12f5646d6c2e20984cd99/lib/solr_ead/behaviors.rb#L54-L57
7
7
  class Parents
8
8
  attr_reader :ids, :labels, :levels
9
+
9
10
  def initialize(ids:, labels:, eadid:, levels:)
10
11
  @ids = ids
11
12
  @labels = labels
@@ -20,7 +21,7 @@ module Arclight
20
21
  ##
21
22
  # @return [Array[Arclight::Parent]]
22
23
  def as_parents
23
- ids.map.with_index { |_id, idx| Arclight::Parent.new(id: ids[idx], label: labels[idx], eadid: eadid, level: levels[idx]) }
24
+ ids.map.with_index { |id, idx| Arclight::Parent.new(id: id, label: labels[idx], eadid: eadid, level: levels[idx]) }
24
25
  end
25
26
 
26
27
  ##
@@ -30,7 +30,7 @@ module Arclight
30
30
 
31
31
  def dynamic_mappings
32
32
  config['request_mappings']['accessor'].transform_values do |v|
33
- @document.send(v.to_sym)
33
+ @document.public_send(v.to_sym)
34
34
  end
35
35
  end
36
36
 
@@ -7,8 +7,9 @@ module Arclight
7
7
  # query parameters from the form mapping configuration
8
8
  class AeonWebEad
9
9
  attr_reader :document, :ead_url
10
+
10
11
  ##
11
- # @param [Blacklight::SolrDocument] document
12
+ # @param [SolrDocument] document
12
13
  # @param [String] ead_url
13
14
  def initialize(document, ead_url)
14
15
  @document = document
@@ -18,7 +19,7 @@ module Arclight
18
19
  ##
19
20
  # Url target for Aeon request params
20
21
  def request_url
21
- document.repository_config.request_url_for_type('aeon_web_ead')
22
+ request_config['request_url']
22
23
  end
23
24
 
24
25
  ##
@@ -35,13 +36,17 @@ module Arclight
35
36
  # @return [Hash]
36
37
  def form_mapping
37
38
  form_hash = Rack::Utils.parse_nested_query(
38
- document.repository_config.request_mappings_for_type('aeon_web_ead')
39
+ request_config['request_mappings']
39
40
  )
40
41
  form_hash.each do |key, value|
41
42
  respond_to?(value) && form_hash[key] = send(value)
42
43
  end
43
44
  form_hash
44
45
  end
46
+
47
+ def request_config
48
+ document.repository_config.request_config_for_type('aeon_web_ead')
49
+ end
45
50
  end
46
51
  end
47
52
  end
@@ -7,10 +7,11 @@ module Arclight
7
7
  # query parameters from the form mapping configuratino
8
8
  class GoogleForm
9
9
  attr_reader :document, :presenter, :document_url
10
+
10
11
  delegate :collection_name, :collection_creator, :eadid, :containers, to: :document
11
12
 
12
13
  ##
13
- # @param [Blacklight::SolrDocument] document
14
+ # @param [SolrDocument] document
14
15
  # @param [Arclight::ShowPresenter] presenter
15
16
  # @param [String] document_url
16
17
  def initialize(document, presenter, document_url)
@@ -22,7 +23,7 @@ module Arclight
22
23
  ##
23
24
  # Url of form to fill
24
25
  def url
25
- document.repository_config&.request_url_for_type('google_form')
26
+ request_config['request_url']
26
27
  end
27
28
 
28
29
  ##
@@ -32,13 +33,17 @@ module Arclight
32
33
  # @return [Hash]
33
34
  def form_mapping
34
35
  Rack::Utils.parse_nested_query(
35
- document.repository_config&.request_mappings_for_type('google_form')
36
+ request_config['request_mappings']
36
37
  )
37
38
  end
38
39
 
39
40
  def title
40
41
  presenter.heading
41
42
  end
43
+
44
+ def request_config
45
+ document.repository_config&.request_config_for_type('google_form')
46
+ end
42
47
  end
43
48
  end
44
49
  end
@@ -8,27 +8,37 @@ module Arclight
8
8
 
9
9
  included do
10
10
  before_action only: :index do
11
- if (params.dig(:f, :collection_sim) || []).any?(&:blank?)
12
- params[:f][:collection_sim].delete_if(&:blank?)
13
- params[:f].delete(:collection_sim) if params[:f][:collection_sim].blank?
11
+ if (params.dig(:f, :collection) || []).any?(&:blank?)
12
+ params[:f][:collection].compact_blank!
13
+ params[:f].delete(:collection) if params[:f][:collection].blank?
14
14
  end
15
15
  end
16
- end
17
16
 
18
- ##
19
- # Overriding the Blacklight method so that the hierarchy view does not start
20
- # a new search session
21
- def start_new_search_session?
22
- !%w[online_contents collection_context].include?(params[:view]) && super
17
+ before_action only: :hierarchy do
18
+ blacklight_config.search_state_fields += %i[id limit offset]
19
+ end
20
+
21
+ Blacklight::Configuration.define_field_access :summary_field, Blacklight::Configuration::ShowField
22
+ Blacklight::Configuration.define_field_access :background_field, Blacklight::Configuration::ShowField
23
+ Blacklight::Configuration.define_field_access :related_field, Blacklight::Configuration::ShowField
24
+ Blacklight::Configuration.define_field_access :indexed_terms_field, Blacklight::Configuration::ShowField
25
+ Blacklight::Configuration.define_field_access :in_person_field, Blacklight::Configuration::ShowField
26
+ Blacklight::Configuration.define_field_access :cite_field, Blacklight::Configuration::ShowField
27
+ Blacklight::Configuration.define_field_access :contact_field, Blacklight::Configuration::ShowField
28
+ Blacklight::Configuration.define_field_access :component_field, Blacklight::Configuration::ShowField
29
+ Blacklight::Configuration.define_field_access :component_indexed_terms_field, Blacklight::Configuration::ShowField
30
+ Blacklight::Configuration.define_field_access :terms_field, Blacklight::Configuration::ShowField
31
+ Blacklight::Configuration.define_field_access :component_terms_field, Blacklight::Configuration::ShowField
32
+ Blacklight::Configuration.define_field_access :group_header_field, Blacklight::Configuration::IndexField
23
33
  end
24
34
 
25
- ##
26
- # Overriding the Blacklight method so that hierarchy does not get stored as
27
- # the preferred view
28
- def store_preferred_view
29
- return if %w[online_contents collection_context].include?(params[:view])
35
+ def hierarchy
36
+ @response = search_service.search_results
37
+ end
30
38
 
31
- super
39
+ # Overrides blacklight search state so we can exclude some parameters from being passed into the SearchState
40
+ def search_state
41
+ @search_state ||= search_state_class.new(params.except('hierarchy', 'nest_path'), blacklight_config, self)
32
42
  end
33
43
  end
34
44
  end
@@ -8,44 +8,30 @@ module Arclight
8
8
 
9
9
  included do
10
10
  self.default_processor_chain += %i[
11
- add_hierarchy_max_rows
12
- add_hierarchy_sort
13
11
  add_highlighting
14
12
  add_grouping
13
+ add_hierarchy_behavior
15
14
  ]
16
15
  end
17
16
 
18
- ##
19
- # Override Blacklight's method so that some views don't add Solr facets into the request.
20
- def add_facetting_to_solr(solr_params)
21
- if %w[collection_context online_contents].include? blacklight_params[:view]
22
- return solr_params
23
- end
24
-
25
- super(solr_params)
26
- end
17
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
18
+ def add_hierarchy_behavior(solr_parameters)
19
+ return unless search_state.controller&.action_name == 'hierarchy'
27
20
 
28
- ##
29
- # For the collection_context views, set a higher (unlimited) maximum document return
30
- def add_hierarchy_max_rows(solr_params)
31
- if %w[collection_context].include? blacklight_params[:view]
32
- solr_params[:rows] = 999_999_999
33
- end
34
- solr_params
35
- end
36
-
37
- ##
38
- # For the asynch views, set the sort order to preserve the order of components
39
- def add_hierarchy_sort(solr_params)
40
- solr_params[:sort] = 'sort_ii asc' if %w[online_contents collection_context].include? blacklight_params[:view]
41
- solr_params
21
+ solr_parameters[:fq] ||= []
22
+ solr_parameters[:fq] << "_nest_parent_:#{blacklight_params[:id]}"
23
+ solr_parameters[:rows] = blacklight_params[:per_page]&.to_i || blacklight_params[:limit]&.to_i || 999_999_999
24
+ solr_parameters[:start] = blacklight_params[:offset] if blacklight_params[:offset]
25
+ solr_parameters[:sort] = 'sort_isi asc'
26
+ solr_parameters[:facet] = false
42
27
  end
28
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
43
29
 
44
30
  ##
45
31
  # Add highlighting
46
32
  def add_highlighting(solr_params)
47
33
  solr_params['hl'] = true
48
- solr_params['hl.fl'] = 'text'
34
+ solr_params['hl.fl'] = CatalogController.blacklight_config.highlight_field
49
35
  solr_params['hl.snippets'] = 3
50
36
  solr_params
51
37
  end