arclight 0.2.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/.all-contributorsrc +450 -0
  3. data/.codeclimate.yml +5 -0
  4. data/.eslintrc +14 -4
  5. data/.github/workflows/ruby.yml +51 -0
  6. data/.gitignore +1 -0
  7. data/.rspec +0 -1
  8. data/.rubocop.yml +504 -8
  9. data/.rubocop_todo.yml +62 -199
  10. data/.solr_wrapper +2 -1
  11. data/CONTRIBUTING.md +5 -5
  12. data/CONTRIBUTORS.md +79 -0
  13. data/Gemfile +15 -10
  14. data/README.md +36 -34
  15. data/Rakefile +0 -1
  16. data/app/assets/images/blacklight/bookmark.svg +1 -0
  17. data/app/assets/images/blacklight/collection.svg +5 -0
  18. data/app/assets/images/blacklight/compact.svg +1 -25
  19. data/app/assets/images/blacklight/container.svg +5 -0
  20. data/app/assets/images/blacklight/ead.svg +1 -0
  21. data/app/assets/images/blacklight/file.svg +5 -0
  22. data/app/assets/images/blacklight/folder.svg +1 -0
  23. data/app/assets/images/blacklight/list.svg +1 -0
  24. data/app/assets/images/blacklight/minus.svg +1 -0
  25. data/app/assets/images/blacklight/online.svg +5 -0
  26. data/app/assets/images/blacklight/pdf.svg +1 -0
  27. data/app/assets/images/blacklight/plus.svg +1 -0
  28. data/app/assets/images/blacklight/repository.svg +1 -0
  29. data/app/assets/javascripts/arclight/arclight.js +4 -10
  30. data/app/assets/javascripts/arclight/oembed_controller.js +58 -0
  31. data/app/assets/javascripts/arclight/truncate_controller.js +27 -0
  32. data/app/assets/stylesheets/arclight/application.scss +4 -4
  33. data/app/assets/stylesheets/arclight/build.scss +4 -0
  34. data/app/assets/stylesheets/arclight/modules/hierarchy_and_online_contents.scss +117 -146
  35. data/app/assets/stylesheets/arclight/modules/highlights.scss +2 -1
  36. data/app/assets/stylesheets/arclight/modules/icons.scss +20 -0
  37. data/app/assets/stylesheets/arclight/modules/layout.scss +183 -40
  38. data/app/assets/stylesheets/arclight/modules/mastheads.scss +24 -75
  39. data/app/assets/stylesheets/arclight/modules/repositories.scss +3 -7
  40. data/app/assets/stylesheets/arclight/modules/repository_card.scss +5 -50
  41. data/app/assets/stylesheets/arclight/modules/search_form.scss +9 -0
  42. data/app/assets/stylesheets/arclight/modules/search_results.scss +197 -26
  43. data/app/assets/stylesheets/arclight/modules/show_collection.scss +21 -69
  44. data/app/assets/stylesheets/arclight/modules/truncator.scss +58 -0
  45. data/app/assets/stylesheets/arclight/responsive.scss +13 -0
  46. data/app/assets/stylesheets/arclight/variables.scss +25 -2
  47. data/app/components/arclight/access_component.html.erb +14 -0
  48. data/app/components/arclight/access_component.rb +25 -0
  49. data/app/components/arclight/bookmark_component.html.erb +25 -0
  50. data/app/components/arclight/bookmark_component.rb +9 -0
  51. data/app/components/arclight/breadcrumb_component.rb +50 -0
  52. data/app/components/arclight/breadcrumbs_hierarchy_component.html.erb +34 -0
  53. data/app/components/arclight/breadcrumbs_hierarchy_component.rb +25 -0
  54. data/app/components/arclight/collection_context_component.html.erb +12 -0
  55. data/app/components/arclight/collection_context_component.rb +27 -0
  56. data/app/components/arclight/collection_info_component.html.erb +28 -0
  57. data/app/components/arclight/collection_info_component.rb +26 -0
  58. data/app/components/arclight/collection_sidebar_component.html.erb +15 -0
  59. data/app/components/arclight/collection_sidebar_component.rb +39 -0
  60. data/app/{views/catalog/_search_results_repository.html.erb → components/arclight/constraints_component.html.erb} +2 -1
  61. data/app/components/arclight/constraints_component.rb +17 -0
  62. data/app/components/arclight/document_collection_context_component.html.erb +29 -0
  63. data/app/components/arclight/document_collection_context_component.rb +28 -0
  64. data/app/components/arclight/document_collection_hierarchy_component.html.erb +50 -0
  65. data/app/components/arclight/document_collection_hierarchy_component.rb +62 -0
  66. data/app/components/arclight/document_component.html.erb +39 -0
  67. data/app/components/arclight/document_component.rb +49 -0
  68. data/app/components/arclight/document_components_hierarchy_component.html.erb +20 -0
  69. data/app/components/arclight/document_components_hierarchy_component.rb +34 -0
  70. data/app/components/arclight/document_download_component.html.erb +24 -0
  71. data/app/components/arclight/document_download_component.rb +71 -0
  72. data/app/components/arclight/embed_component.html.erb +10 -0
  73. data/app/components/arclight/embed_component.rb +43 -0
  74. data/app/components/arclight/expand_hierarchy_button_component.html.erb +5 -0
  75. data/app/components/arclight/expand_hierarchy_button_component.rb +16 -0
  76. data/app/components/arclight/group_component.html.erb +34 -0
  77. data/app/components/arclight/group_component.rb +23 -0
  78. data/app/components/arclight/header_component.html.erb +5 -0
  79. data/app/components/arclight/header_component.rb +10 -0
  80. data/app/components/arclight/index_metadata_field_component.html.erb +16 -0
  81. data/app/components/arclight/index_metadata_field_component.rb +20 -0
  82. data/app/components/arclight/masthead_component.html.erb +17 -0
  83. data/app/components/arclight/masthead_component.rb +10 -0
  84. data/app/components/arclight/metadata_section_component.html.erb +13 -0
  85. data/app/components/arclight/metadata_section_component.rb +22 -0
  86. data/app/components/arclight/oembed_viewer_component.html.erb +5 -0
  87. data/app/components/arclight/oembed_viewer_component.rb +16 -0
  88. data/app/components/arclight/online_content_filter_component.html.erb +15 -0
  89. data/app/components/arclight/online_content_filter_component.rb +17 -0
  90. data/app/components/arclight/online_status_indicator_component.rb +19 -0
  91. data/app/components/arclight/repository_breadcrumb_component.html.erb +10 -0
  92. data/app/components/arclight/repository_breadcrumb_component.rb +17 -0
  93. data/app/components/arclight/repository_location_component.html.erb +20 -0
  94. data/app/components/arclight/repository_location_component.rb +10 -0
  95. data/app/components/arclight/search_bar_component.html.erb +27 -0
  96. data/app/components/arclight/search_bar_component.rb +32 -0
  97. data/app/components/arclight/search_result_breadcrumbs_component.html.erb +6 -0
  98. data/app/components/arclight/search_result_breadcrumbs_component.rb +37 -0
  99. data/app/components/arclight/search_result_component.html.erb +20 -0
  100. data/app/components/arclight/search_result_component.rb +18 -0
  101. data/app/components/arclight/search_result_title_component.html.erb +15 -0
  102. data/app/components/arclight/search_result_title_component.rb +15 -0
  103. data/app/components/arclight/sidebar_component.html.erb +9 -0
  104. data/app/components/arclight/sidebar_component.rb +19 -0
  105. data/app/components/arclight/upper_metadata_layout_component.rb +10 -0
  106. data/app/components/blacklight/icons/bookmark_component.rb +12 -0
  107. data/app/components/blacklight/icons/collection_component.rb +14 -0
  108. data/app/components/blacklight/icons/compact_component.rb +12 -0
  109. data/app/components/blacklight/icons/container_component.rb +14 -0
  110. data/app/components/blacklight/icons/ead_component.rb +12 -0
  111. data/app/components/blacklight/icons/file_component.rb +14 -0
  112. data/app/components/blacklight/icons/folder_component.rb +12 -0
  113. data/app/components/blacklight/icons/online_component.rb +15 -0
  114. data/app/components/blacklight/icons/pdf_component.rb +12 -0
  115. data/app/components/blacklight/icons/repository_component.rb +12 -0
  116. data/app/controllers/arclight/repositories_controller.rb +4 -4
  117. data/app/helpers/arclight/ead_format_helpers.rb +309 -0
  118. data/app/helpers/arclight/field_config_helpers.rb +26 -0
  119. data/app/helpers/arclight_helper.rb +55 -120
  120. data/app/models/arclight/document_downloads.rb +122 -0
  121. data/app/models/arclight/parent.rb +9 -9
  122. data/app/models/arclight/parents.rb +9 -4
  123. data/app/models/arclight/requests/aeon_external_request.rb +42 -0
  124. data/app/models/arclight/requests/aeon_web_ead.rb +52 -0
  125. data/app/models/arclight/requests/google_form.rb +8 -3
  126. data/app/models/concerns/arclight/catalog.rb +33 -11
  127. data/app/models/concerns/arclight/search_behavior.rb +22 -21
  128. data/app/models/concerns/arclight/solr_document.rb +88 -59
  129. data/app/presenters/arclight/show_presenter.rb +34 -7
  130. data/app/views/arclight/_requests.html.erb +7 -0
  131. data/app/views/arclight/repositories/_repository.html.erb +22 -41
  132. data/app/views/arclight/repositories/index.html.erb +5 -0
  133. data/app/views/arclight/repositories/show.html.erb +7 -8
  134. data/app/views/arclight/requests/_aeon_external_request_endpoint.html.erb +8 -0
  135. data/app/views/arclight/requests/_aeon_web_ead.html.erb +6 -0
  136. data/app/views/arclight/requests/_google_form.html.erb +4 -5
  137. data/app/views/catalog/_document_list.html.erb +8 -0
  138. data/app/views/catalog/_group.html.erb +4 -0
  139. data/app/views/catalog/_group_toggle.html.erb +10 -0
  140. data/app/views/catalog/_search_results_header.html.erb +3 -0
  141. data/app/views/catalog/hierarchy.html.erb +19 -0
  142. data/app/views/catalog/index.html.erb +16 -7
  143. data/app/views/shared/_breadcrumbs.html.erb +3 -15
  144. data/app/views/shared/_main_menu_links.html.erb +1 -1
  145. data/arclight.gemspec +18 -17
  146. data/config/breadcrumbs.rb +24 -0
  147. data/config/i18n-tasks.yml +11 -9
  148. data/config/importmap.rb +3 -0
  149. data/config/locales/arclight.en.yml +68 -34
  150. data/config/routes.rb +1 -1
  151. data/docker-compose.yml +16 -0
  152. data/lib/arclight/digital_object.rb +2 -1
  153. data/lib/arclight/engine.rb +22 -31
  154. data/lib/arclight/exceptions.rb +1 -0
  155. data/lib/arclight/hash_absolute_xpath.rb +13 -8
  156. data/lib/arclight/level_label.rb +46 -0
  157. data/lib/arclight/normalized_date.rb +5 -10
  158. data/lib/arclight/normalized_id.rb +7 -2
  159. data/lib/arclight/normalized_title.rb +3 -0
  160. data/lib/arclight/repository.rb +70 -28
  161. data/lib/arclight/routes/hierarchy.rb +19 -0
  162. data/lib/arclight/routes.rb +8 -0
  163. data/lib/arclight/traject/ead2_component_config.rb +335 -0
  164. data/lib/arclight/traject/ead2_config.rb +172 -331
  165. data/lib/arclight/traject/nokogiri_namespaceless_reader.rb +22 -0
  166. data/lib/arclight/version.rb +1 -1
  167. data/lib/arclight/year_range.rb +13 -4
  168. data/lib/arclight.rb +6 -1
  169. data/lib/generators/arclight/install_generator.rb +100 -10
  170. data/lib/generators/arclight/templates/arclight.scss +6 -3
  171. data/lib/generators/arclight/templates/catalog_controller.rb +237 -179
  172. data/lib/generators/arclight/templates/config/downloads.yml +12 -0
  173. data/lib/generators/arclight/templates/config/locales/arclight.en.yml +61 -0
  174. data/lib/generators/arclight/templates/config/repositories.yml +42 -31
  175. data/lib/generators/arclight/update_generator.rb +1 -1
  176. data/lib/tasks/index.rake +25 -30
  177. data/package.json +15 -9
  178. data/solr/conf/schema.xml +97 -328
  179. data/solr/conf/solrconfig.xml +99 -164
  180. data/tasks/arclight.rake +18 -9
  181. data/template.rb +6 -7
  182. metadata +188 -129
  183. data/.travis.yml +0 -28
  184. data/app/assets/javascripts/arclight/collection_context.js +0 -18
  185. data/app/assets/javascripts/arclight/collection_navigation.js +0 -117
  186. data/app/assets/javascripts/arclight/collection_scrollspy.js +0 -6
  187. data/app/assets/javascripts/arclight/component_ancestors.js +0 -56
  188. data/app/assets/javascripts/arclight/oembed_viewer.js +0 -46
  189. data/app/assets/javascripts/arclight/search_results.js +0 -15
  190. data/app/assets/javascripts/arclight/truncator.js.erb +0 -23
  191. data/app/assets/stylesheets/arclight/bootstrap_overrides.scss +0 -3
  192. data/app/assets/stylesheets/arclight/modules/sidebar.scss +0 -21
  193. data/app/controllers/concerns/arclight/field_config_helpers.rb +0 -86
  194. data/app/factories/blacklight_field_configuration_factory.rb +0 -29
  195. data/app/views/arclight/repositories/_in_person_repository.html.erb +0 -19
  196. data/app/views/arclight/viewers/_oembed.html.erb +0 -7
  197. data/app/views/catalog/_arclight_document_index_header.html.erb +0 -13
  198. data/app/views/catalog/_arclight_document_index_header_online_contents_default.html.erb +0 -0
  199. data/app/views/catalog/_arclight_index_compact_default.html.erb +0 -15
  200. data/app/views/catalog/_arclight_online_content_indicator.html.erb +0 -5
  201. data/app/views/catalog/_arclight_rangelimit.html.erb +0 -24
  202. data/app/views/catalog/_arclight_viewer_default.html.erb +0 -1
  203. data/app/views/catalog/_collection_contents.html.erb +0 -12
  204. data/app/views/catalog/_collection_count.html.erb +0 -7
  205. data/app/views/catalog/_collection_downloads.html.erb +0 -15
  206. data/app/views/catalog/_collection_online_contents.html.erb +0 -17
  207. data/app/views/catalog/_collection_overview.html.erb +0 -7
  208. data/app/views/catalog/_component_contents.html.erb +0 -16
  209. data/app/views/catalog/_component_overview.html.erb +0 -40
  210. data/app/views/catalog/_context_card.html.erb +0 -27
  211. data/app/views/catalog/_context_sidebar.html.erb +0 -8
  212. data/app/views/catalog/_custom_metadata.html.erb +0 -16
  213. data/app/views/catalog/_home.html.erb +0 -1
  214. data/app/views/catalog/_index_breadcrumb_default.html.erb +0 -3
  215. data/app/views/catalog/_index_default.html.erb +0 -17
  216. data/app/views/catalog/_index_header.html.erb +0 -7
  217. data/app/views/catalog/_index_header_hierarchy_default.html.erb +0 -42
  218. data/app/views/catalog/_index_header_online_contents_default.html.erb +0 -1
  219. data/app/views/catalog/_index_hierarchy_default.html.erb +0 -28
  220. data/app/views/catalog/_index_online_contents_default.html.erb +0 -6
  221. data/app/views/catalog/_results_histogram.html.erb +0 -15
  222. data/app/views/catalog/_search_results.html.erb +0 -31
  223. data/app/views/catalog/_show_breadcrumbs_default.html.erb +0 -21
  224. data/app/views/catalog/_show_collection.html.erb +0 -48
  225. data/app/views/catalog/_show_component_sidebar.html.erb +0 -12
  226. data/app/views/catalog/_show_default.html.erb +0 -42
  227. data/app/views/catalog/_show_sidebar.html.erb +0 -22
  228. data/app/views/catalog/_show_upper_metadata_collection.html.erb +0 -1
  229. data/app/views/catalog/_show_upper_metadata_default.html.erb +0 -14
  230. data/app/views/layouts/catalog_result.html.erb +0 -7
  231. data/app/views/shared/_context_sidebar.html.erb +0 -8
  232. data/app/views/shared/_header_navbar.html.erb +0 -65
  233. data/lib/arclight/custom_component.rb +0 -99
  234. data/lib/arclight/custom_document.rb +0 -93
  235. data/lib/arclight/indexer.rb +0 -9
  236. data/lib/arclight/shared_indexing_behavior.rb +0 -97
  237. data/lib/arclight/shared_terminology_behavior.rb +0 -65
  238. data/lib/arclight/solr_ead_indexer_ext.rb +0 -155
  239. data/lib/arclight/viewer.rb +0 -45
  240. data/lib/arclight/viewers/oembed.rb +0 -56
  241. data/lib/generators/arclight/templates/arclight.js +0 -2
  242. data/solr/conf/scripts.conf +0 -24
  243. data/vendor/assets/javascripts/responsiveTruncator.js +0 -69
  244. data/vendor/assets/javascripts/stickyfill.js +0 -480
  245. /data/app/assets/images/{blacklight → arclight}/logo.png +0 -0
  246. /data/{app/views/catalog/_arclight_document_index_header_hierarchy_default.html.erb → config/repositories.yml} +0 -0
@@ -3,58 +3,59 @@
3
3
  ##
4
4
  # Generic Helpers used in Arclight
5
5
  module ArclightHelper
6
- ##
7
- # @param [SolrDocument]
8
- def parents_to_links(document)
9
- safe_join(Arclight::Parents.from_solr_document(document).as_parents.map do |parent|
10
- link_to parent.label, solr_document_path(parent.global_id)
11
- end, t('arclight.breadcrumb_separator'))
12
- end
6
+ include Arclight::EadFormatHelpers
7
+ include Arclight::FieldConfigHelpers
8
+ include Blacklight::DocumentHelperBehavior
9
+ include Blacklight::LayoutHelperBehavior
13
10
 
14
11
  def repository_collections_path(repository)
15
12
  search_action_url(
16
13
  f: {
17
- repository_sim: [repository.name],
18
- level_sim: ['Collection']
14
+ repository: [repository.name],
15
+ level: ['Collection']
19
16
  }
20
17
  )
21
18
  end
22
19
 
20
+ # Returns the i18n-ed string to be used as the h1 in search results
21
+ def search_results_header_text
22
+ if (repo = repository_faceted_on).present?
23
+ t('arclight.search.repository_header', repository: repo.name)
24
+ elsif collection_active?
25
+ t('arclight.search.collections_header')
26
+ else
27
+ t('blacklight.search.header')
28
+ end
29
+ end
30
+
23
31
  ##
24
32
  # Classes used for customized show page in arclight
25
- def custom_show_content_classes
26
- 'col-md-12 show-document'
33
+ def show_content_classes
34
+ 'col-12 col-lg-8 show-document order-2'
27
35
  end
28
36
 
29
- def normalize_id(id)
30
- Arclight::NormalizedId.new(id).to_s
37
+ def show_sidebar_classes
38
+ 'col-lg-4 order-1 collection-sidebar'
31
39
  end
32
40
 
33
41
  def collection_active?
34
- try(:search_state) && search_state.params_for_search.try(:[], 'f').try(:[], 'level_sim') == ['Collection']
42
+ search_state.filter('level').values == ['Collection']
35
43
  end
36
44
 
37
45
  def collection_active_class
38
46
  'active' if collection_active?
39
47
  end
40
48
 
41
- def collection_count
42
- @response.response['numFound']
49
+ def grouped?
50
+ respond_to?(:search_state) && search_state&.params_for_search&.dig('group') == 'true'
43
51
  end
44
52
 
45
- ##
46
- # Looks for `document.unitid` in the downloads configuration
47
- # @param [SolrDocument] `document`
48
- # @param [Hash] `config` metadata for downloadable files
49
- # @return [Hash] with `:href` and `:size` keys
50
- def collection_downloads(document, config = load_download_config)
51
- config = config[document.unitid] if config.present?
52
- return {} if config.blank?
53
- parse_collection_downloads(config)
53
+ def search_with_group
54
+ search_state.params_for_search.merge('group' => 'true').except('page')
54
55
  end
55
56
 
56
- def on_repositories_show?
57
- controller_name == 'repositories' && action_name == 'show'
57
+ def search_without_group
58
+ search_state.params_for_search.except('group', 'page')
58
59
  end
59
60
 
60
61
  def on_repositories_index?
@@ -66,108 +67,42 @@ module ArclightHelper
66
67
  'active' if on_repositories_index?
67
68
  end
68
69
 
69
- def fields_have_content?(document, field_accessor)
70
- generic_document_fields(field_accessor).any? do |_, field|
71
- generic_should_render_field?(field_accessor, document, field)
72
- end
73
- end
74
-
75
70
  # If we have a facet on the repository, then return the Repository object for it
76
71
  #
77
72
  # @return [Repository]
78
73
  def repository_faceted_on
79
- return unless try(:search_state)
80
- repos = facets_from_request.find { |f| f.name == 'repository_sim' }.try(:items)
81
- faceted = repos && repos.length == 1 && repos.first.value
82
- Arclight::Repository.find_by(name: repos.first.value) if faceted
83
- end
84
-
85
- def hierarchy_component_context?
86
- params[:hierarchy_context] == 'component'
87
- end
88
-
89
- # @return [Hash] loaded from config/downloads.yml, or `{}` if missing file
90
- def load_download_config(filename = Rails.root.join('config', 'downloads.yml'))
91
- YAML.safe_load(File.read(filename))
92
- rescue Errno::ENOENT
93
- {}
94
- end
95
-
96
- # @return [Hash] the downloads for the given configuration using Hash symbols
97
- # @example `{ pdf: { href: 'http://...', size: '123 KB' } }`
98
- def parse_collection_downloads(config, results = {})
99
- %w[pdf ead].each do |type|
100
- next if config[type].blank?
101
- results[type.to_sym] = {
102
- href: config[type]['href'],
103
- size: display_size(config[type]['size'])
104
- }
74
+ repos = search_state.filter('repository').values
75
+ return unless repos.one?
76
+
77
+ Arclight::Repository.find_by(name: repos.first)
78
+ end
79
+
80
+ # determine which icon to show in search results header
81
+ # these icon names will need to be updated when the icons are determined
82
+ def document_or_parent_icon(document)
83
+ case document.level&.downcase
84
+ when 'collection'
85
+ 'collection'
86
+ when 'file'
87
+ 'file'
88
+ when 'series', 'subseries'
89
+ 'folder'
90
+ else
91
+ 'container'
105
92
  end
106
- results
107
- end
108
-
109
- # Show a human readable size, or if it's already a string, show that
110
- # @return [String] human readable siz
111
- def display_size(size)
112
- size = number_to_human_size(size.to_i + 1) if size.is_a?(Numeric) || size =~ /^[0-9]+$/ # assumes bytes
113
- size.to_s
114
93
  end
115
94
 
116
95
  ##
117
- # Defines custom helpers used for creating unique metadata blocks to render
118
- Arclight::Engine.config.catalog_controller_field_accessors.each do |config_field|
119
- ##
120
- # Mimics what document_show_fields from Blacklight does
121
- # https://github.com/projectblacklight/blacklight/blob/dee8d794125306ec8d4ab834a6a45bcf9671c791/app/helpers/blacklight/configuration_helper_behavior.rb#L35-L38
122
- define_method(:"document_#{config_field}s") do |_document = nil|
123
- blacklight_config.send(:"#{config_field}s")
124
- end
125
-
126
- ##
127
- # Mimics what render_document_show_field_label from Blacklight does
128
- # https://github.com/projectblacklight/blacklight/blob/dee8d794125306ec8d4ab834a6a45bcf9671c791/app/helpers/blacklight/blacklight_helper_behavior.rb#L136-L156
129
- define_method(:"render_document_#{config_field}_label") do |*args|
130
- options = args.extract_options!
131
- document = args.first
132
-
133
- field = options[:field]
134
-
135
- t(:'blacklight.search.show.label', label: send(:"document_#{config_field}_label", document, field))
136
- end
137
-
138
- ##
139
- # Mimics what document_show_field_label from Blacklight does
140
- # https://github.com/projectblacklight/blacklight/blob/dee8d794125306ec8d4ab834a6a45bcf9671c791/app/helpers/blacklight/configuration_helper_behavior.rb#L67-L74
141
- define_method(:"document_#{config_field}_label") do |document, field|
142
- field_config = send(:"document_#{config_field}s", document)[field]
143
- field_config ||= Blacklight::Configuration::NullField.new(key: field)
144
-
145
- field_config.display_label('show')
146
- end
147
-
148
- ##
149
- # Mimics what should_render_show_field? from Blacklight does
150
- # https://github.com/projectblacklight/blacklight/blob/dee8d794125306ec8d4ab834a6a45bcf9671c791/app/helpers/blacklight/blacklight_helper_behavior.rb#L84-L92
151
- define_method(:"should_render_#{config_field}?") do |document, field_config|
152
- should_render_field?(field_config, document) && document_has_value?(document, field_config)
153
- end
154
- end
155
-
156
- ##
157
- # Calls the method for a configured field
158
- def generic_document_fields(config_field)
159
- send(:"document_#{config_field}s")
96
+ # Override of BL core https://github.com/projectblacklight/blacklight/blob/v8.1.0/app/helpers/blacklight/document_helper_behavior.rb#L55
97
+ # Remove document_type check. It isn't a method on arclight documents
98
+ # Check if the document is in the user's bookmarks
99
+ # @param [Blacklight::Document] document
100
+ # @return [Boolean]
101
+ def bookmarked?(document)
102
+ current_bookmarks.any? { |x| x.document_id == document.id }
160
103
  end
161
104
 
162
- ##
163
- # Calls the method for a configured field
164
- def generic_should_render_field?(config_field, document, field)
165
- send(:"should_render_#{config_field}?", document, field)
166
- end
167
-
168
- ##
169
- # Calls the method for a configured field
170
- def generic_render_document_field_label(config_field, document, field: field_name)
171
- send(:"render_document_#{config_field}_label", document, field: field)
105
+ def current_context_document
106
+ @document
172
107
  end
173
108
  end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arclight
4
+ ##
5
+ # Model the Download links that can be configured (via YAML) for a collection
6
+ # or container
7
+ class DocumentDownloads
8
+ attr_reader :document
9
+
10
+ def initialize(document, id = nil)
11
+ @document = document
12
+ @id = id
13
+ end
14
+
15
+ # Accessor for the ID
16
+ # @return [String]
17
+ def id
18
+ @id || document.unitid
19
+ end
20
+
21
+ # Factory method for the File objects
22
+ # @return [Array<Arclight::DocumentDownloads::File>]
23
+ def files
24
+ data = self.class.config[id] || self.class.config['default']
25
+ disabled = data.delete('disabled')
26
+ return [] if disabled
27
+
28
+ @files ||= data.map do |file_type, file_data|
29
+ self.class.file_class.new(type: file_type, data: file_data, document: document)
30
+ end.compact
31
+ end
32
+
33
+ class << self
34
+ def config
35
+ @config ||= begin
36
+ YAML.safe_load_file(config_filename)
37
+ rescue Errno::ENOENT
38
+ {}
39
+ end
40
+ end
41
+
42
+ def config_filename
43
+ Rails.root.join('config/downloads.yml')
44
+ end
45
+
46
+ # Accessor for the File Class
47
+ # @return [Class]
48
+ def file_class
49
+ Arclight::DocumentDownloads::File
50
+ end
51
+ end
52
+
53
+ ##
54
+ # Model a single file configured in downloads.yml
55
+ class File
56
+ attr_reader :type, :document
57
+
58
+ def initialize(type:, data:, document:)
59
+ @type = type
60
+ @data = data
61
+ @document = document
62
+ end
63
+
64
+ def href
65
+ return data['href'] if data['href']
66
+
67
+ format_template
68
+ end
69
+
70
+ def size
71
+ return data['size'] if data['size']
72
+
73
+ document.public_send(data['size_accessor'].to_sym) if data['size_accessor']
74
+ end
75
+
76
+ private
77
+
78
+ attr_reader :data
79
+
80
+ def format_template
81
+ return unless template
82
+
83
+ template % template_interpolations
84
+ end
85
+
86
+ def template
87
+ data['template']
88
+ end
89
+
90
+ def template_interpolations
91
+ escaped_document_interpolations.merge(custom_interpolations).symbolize_keys
92
+ end
93
+
94
+ def custom_interpolations
95
+ { 'repository_id' => document.repository_config&.slug }
96
+ end
97
+
98
+ def template_variables
99
+ template.scan(Regexp.union(/%{(\w+)}/, /%<(\w+)>/)).flatten.compact.uniq
100
+ end
101
+
102
+ def escaped_document_interpolations
103
+ non_custom_template_variables.index_with do |method_name|
104
+ escape_non_url_doc_value(document.public_send(method_name))
105
+ end
106
+ end
107
+
108
+ def escape_non_url_doc_value(value)
109
+ value = Array.wrap(value).first || '' # Handle single values/arrays and nil
110
+ return value if value.start_with?(/https?:/)
111
+
112
+ CGI.escape(value)
113
+ end
114
+
115
+ def non_custom_template_variables
116
+ template_variables.reject do |v|
117
+ custom_interpolations.keys.include?(v)
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -5,20 +5,20 @@ module Arclight
5
5
  # Logic containing information about Solr_Ead "Parent"
6
6
  # https://github.com/awead/solr_ead/blob/8cf7ffaa66e0e4c9c0b12f5646d6c2e20984cd99/lib/solr_ead/behaviors.rb#L54-L57
7
7
  class Parent
8
- attr_reader :id, :label, :eadid
9
- def initialize(id:, label:, eadid:)
8
+ attr_reader :id, :label, :eadid, :level
9
+
10
+ alias global_id id
11
+ Arclight.deprecation.deprecate_methods(self, global_id: 'Call `id` instead')
12
+
13
+ def initialize(id:, label:, eadid:, level:)
10
14
  @id = id
11
15
  @label = label
12
16
  @eadid = eadid
17
+ @level = level
13
18
  end
14
19
 
15
- ##
16
- # Concatenates the eadid and the id, to return an "id" in the context of
17
- # Blacklight and Solr
18
- # @return [String]
19
- def global_id
20
- return id if eadid == id
21
- "#{eadid}#{id}"
20
+ def collection?
21
+ level == 'collection'
22
22
  end
23
23
  end
24
24
  end
@@ -5,11 +5,14 @@ module Arclight
5
5
  # Object for parsing and formalizing Solr_Ead "Parents"
6
6
  # https://github.com/awead/solr_ead/blob/8cf7ffaa66e0e4c9c0b12f5646d6c2e20984cd99/lib/solr_ead/behaviors.rb#L54-L57
7
7
  class Parents
8
- attr_reader :ids, :labels
9
- def initialize(ids:, labels:, eadid:)
8
+ attr_reader :ids, :legacy_ids, :labels, :levels
9
+
10
+ def initialize(ids:, legacy_ids:, labels:, eadid:, levels:)
10
11
  @ids = ids
12
+ @legacy_ids = legacy_ids
11
13
  @labels = labels
12
14
  @eadid = eadid
15
+ @levels = levels
13
16
  end
14
17
 
15
18
  def eadid
@@ -19,16 +22,18 @@ module Arclight
19
22
  ##
20
23
  # @return [Array[Arclight::Parent]]
21
24
  def as_parents
22
- Hash[ids.zip(labels)].map { |k, v| Arclight::Parent.new(id: k, label: v, eadid: eadid) }
25
+ (ids.presence || legacy_ids).map.with_index { |id, idx| Arclight::Parent.new(id: id, label: labels[idx], eadid: eadid, level: levels[idx]) }
23
26
  end
24
27
 
25
28
  ##
26
29
  # @param [SolrDocument] document
27
30
  def self.from_solr_document(document)
28
31
  ids = document.parent_ids
32
+ legacy_ids = document.legacy_parent_ids.map { |legacy_id| document.root == legacy_id ? legacy_id : "#{document.root}#{legacy_id}" }
29
33
  labels = document.parent_labels
30
34
  eadid = document.eadid
31
- new(ids: ids, labels: labels, eadid: eadid)
35
+ levels = document.parent_levels
36
+ new(ids: ids, legacy_ids: legacy_ids, labels: labels, eadid: eadid, levels: levels)
32
37
  end
33
38
  end
34
39
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arclight
4
+ module Requests
5
+ ##
6
+ # This class should be used to turn configuration into a URL and
7
+ # POST form specifically aimed at Aeon's external request
8
+ # endpoint (https://support.atlas-sys.com/hc/en-us/articles/360011820054-External-Request-Endpoint)
9
+ class AeonExternalRequest
10
+ def initialize(document, presenter)
11
+ @document = document
12
+ @presenter = presenter
13
+ end
14
+
15
+ def config
16
+ @config ||= @document.repository_config.request_config_for_type('aeon_external_request_endpoint')
17
+ end
18
+
19
+ def url
20
+ "#{config['request_url']}?#{url_params}"
21
+ end
22
+
23
+ def form_mapping
24
+ static_mappings.merge(dynamic_mappings)
25
+ end
26
+
27
+ def static_mappings
28
+ config['request_mappings']['static']
29
+ end
30
+
31
+ def dynamic_mappings
32
+ config['request_mappings']['accessor'].transform_values do |v|
33
+ @document.public_send(v.to_sym)
34
+ end
35
+ end
36
+
37
+ def url_params
38
+ config['request_mappings']['url_params'].to_query
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arclight
4
+ module Requests
5
+ ##
6
+ # This object relies on the ability to respond to attributes passed in as
7
+ # query parameters from the form mapping configuration
8
+ class AeonWebEad
9
+ attr_reader :document, :ead_url
10
+
11
+ ##
12
+ # @param [SolrDocument] document
13
+ # @param [String] ead_url
14
+ def initialize(document, ead_url)
15
+ @document = document
16
+ @ead_url = ead_url
17
+ end
18
+
19
+ ##
20
+ # Url target for Aeon request params
21
+ def request_url
22
+ request_config['request_url']
23
+ end
24
+
25
+ ##
26
+ # Constructed request URL
27
+ def url
28
+ "#{request_url}?#{form_mapping.to_query}"
29
+ end
30
+
31
+ ##
32
+ # Converts mappings as a query url param into a Hash used for sending
33
+ # messages
34
+ # If a defined method is provided as a value, that method will be invoked
35
+ # "collection_name=entry.123" => { "collection_name" => "entry.123" }
36
+ # @return [Hash]
37
+ def form_mapping
38
+ form_hash = Rack::Utils.parse_nested_query(
39
+ request_config['request_mappings']
40
+ )
41
+ form_hash.each do |key, value|
42
+ respond_to?(value) && form_hash[key] = send(value)
43
+ end
44
+ form_hash
45
+ end
46
+
47
+ def request_config
48
+ document.repository_config.request_config_for_type('aeon_web_ead')
49
+ end
50
+ end
51
+ end
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.google_request_url
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.google_request_mappings
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
@@ -4,19 +4,41 @@ module Arclight
4
4
  ##
5
5
  # Arclight specific methods for the Catalog
6
6
  module Catalog
7
- ##
8
- # Overriding the Blacklight method so that the hierarchy view does not start
9
- # a new search session
10
- def start_new_search_session?
11
- !%w[hierarchy online_contents].include?(params[:view]) && super
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ before_action only: :index do
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
+ end
15
+ end
16
+
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
33
+ end
34
+
35
+ def hierarchy
36
+ @response = search_service.search_results
12
37
  end
13
38
 
14
- ##
15
- # Overriding the Blacklight method so that hierarchy does not get stored as
16
- # the preferred view
17
- def store_preferred_view
18
- return if %w[hierarchy online_contents].include?(params[:view])
19
- 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)
20
42
  end
21
43
  end
22
44
  end
@@ -8,38 +8,39 @@ 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
12
+ add_grouping
13
+ add_hierarchy_behavior
14
14
  ]
15
15
  end
16
16
 
17
- ##
18
- # For the hierarchy view, set a higher (unlimited) maximum document return
19
- def add_hierarchy_max_rows(solr_params)
20
- if blacklight_params[:view] == 'hierarchy'
21
- solr_params[:rows] = 999_999_999
22
- end
23
- solr_params
17
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
18
+ def add_hierarchy_behavior(solr_parameters)
19
+ return unless search_state.controller&.action_name == 'hierarchy'
20
+
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
24
27
  end
28
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
25
29
 
26
30
  ##
27
- # For the hierarchy view, set the sort order to preserve the order of components
28
- def add_hierarchy_sort(solr_params)
29
- solr_params[:sort] = 'sort_ii asc' if %w[hierarchy online_contents].include? blacklight_params[:view]
31
+ # Add highlighting
32
+ def add_highlighting(solr_params)
33
+ solr_params['hl'] = true
34
+ solr_params['hl.fl'] = CatalogController.blacklight_config.highlight_field
35
+ solr_params['hl.snippets'] = 3
30
36
  solr_params
31
37
  end
32
38
 
33
39
  ##
34
- # Disable highlighting for hiearchy, and enable it for all other searches
35
- def add_highlighting(solr_params)
36
- if blacklight_params[:view] == 'hierarchy'
37
- solr_params['hl'] = false
38
- else
39
- solr_params['hl'] = true
40
- solr_params['hl.fl'] = 'text'
41
- solr_params['hl.snippets'] = 3
42
- end
40
+ # Adds grouping parameters for Solr if enabled
41
+ def add_grouping(solr_params)
42
+ solr_params.merge!(Arclight::Engine.config.catalog_controller_group_query_params) if blacklight_params[:group] == 'true'
43
+
43
44
  solr_params
44
45
  end
45
46
  end