arclight 0.4.0 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc +11 -4
- data/.github/workflows/ruby.yml +24 -8
- data/.rspec +0 -1
- data/.rubocop.yml +289 -3
- data/.rubocop_todo.yml +64 -76
- data/CONTRIBUTING.md +5 -5
- data/Gemfile +15 -10
- data/README.md +18 -12
- data/app/assets/javascripts/arclight/arclight.js +3 -7
- data/app/assets/javascripts/arclight/oembed_viewer.js +64 -39
- data/app/assets/javascripts/arclight/truncate_controller.js +27 -0
- data/app/assets/stylesheets/arclight/application.scss +1 -5
- data/app/assets/stylesheets/arclight/modules/hierarchy_and_online_contents.scss +104 -130
- data/app/assets/stylesheets/arclight/modules/icons.scss +14 -3
- data/app/assets/stylesheets/arclight/modules/layout.scss +121 -100
- data/app/assets/stylesheets/arclight/modules/mastheads.scss +15 -57
- data/app/assets/stylesheets/arclight/modules/repositories.scss +2 -2
- data/app/assets/stylesheets/arclight/modules/repository_card.scss +4 -48
- data/app/assets/stylesheets/arclight/modules/search_results.scss +86 -35
- data/app/assets/stylesheets/arclight/modules/show_collection.scss +5 -32
- data/app/assets/stylesheets/arclight/modules/truncator.scss +56 -0
- data/app/assets/stylesheets/arclight/variables.scss +7 -4
- data/app/components/arclight/access_component.html.erb +14 -0
- data/app/components/arclight/access_component.rb +25 -0
- data/app/components/arclight/bookmark_component.html.erb +25 -0
- data/app/components/arclight/bookmark_component.rb +9 -0
- data/app/components/arclight/breadcrumb_component.rb +40 -0
- data/app/components/arclight/breadcrumbs_hierarchy_component.html.erb +34 -0
- data/app/components/arclight/breadcrumbs_hierarchy_component.rb +25 -0
- data/app/components/arclight/collection_context_component.html.erb +12 -0
- data/app/components/arclight/collection_context_component.rb +27 -0
- data/app/components/arclight/collection_info_component.html.erb +28 -0
- data/app/components/arclight/collection_info_component.rb +26 -0
- data/app/components/arclight/collection_sidebar_component.html.erb +15 -0
- data/app/components/arclight/collection_sidebar_component.rb +41 -0
- data/app/{views/catalog/_search_results_repository.html.erb → components/arclight/constraints_component.html.erb} +2 -1
- data/app/components/arclight/constraints_component.rb +17 -0
- data/app/components/arclight/document_collection_context_component.html.erb +29 -0
- data/app/components/arclight/document_collection_context_component.rb +28 -0
- data/app/components/arclight/document_collection_hierarchy_component.html.erb +46 -0
- data/app/components/arclight/document_collection_hierarchy_component.rb +62 -0
- data/app/components/arclight/document_component.html.erb +39 -0
- data/app/components/arclight/document_component.rb +49 -0
- data/app/components/arclight/document_components_hierarchy_component.html.erb +32 -0
- data/app/components/arclight/document_components_hierarchy_component.rb +28 -0
- data/app/components/arclight/document_download_component.html.erb +24 -0
- data/app/components/arclight/document_download_component.rb +71 -0
- data/app/components/arclight/embed_component.html.erb +10 -0
- data/app/components/arclight/embed_component.rb +43 -0
- data/app/components/arclight/group_component.html.erb +30 -0
- data/app/components/arclight/group_component.rb +23 -0
- data/app/components/arclight/header_component.html.erb +5 -0
- data/app/components/arclight/header_component.rb +10 -0
- data/app/components/arclight/index_metadata_field_component.html.erb +17 -0
- data/app/components/arclight/index_metadata_field_component.rb +20 -0
- data/app/components/arclight/masthead_component.html.erb +15 -0
- data/app/components/arclight/masthead_component.rb +10 -0
- data/app/components/arclight/metadata_section_component.html.erb +13 -0
- data/app/components/arclight/metadata_section_component.rb +22 -0
- data/app/components/arclight/oembed_viewer_component.html.erb +5 -0
- data/app/components/arclight/oembed_viewer_component.rb +16 -0
- data/app/components/arclight/online_content_filter_component.html.erb +15 -0
- data/app/components/arclight/online_content_filter_component.rb +19 -0
- data/app/components/arclight/online_status_indicator_component.rb +19 -0
- data/app/components/arclight/repository_breadcrumb_component.html.erb +10 -0
- data/app/components/arclight/repository_breadcrumb_component.rb +17 -0
- data/app/components/arclight/repository_location_component.html.erb +20 -0
- data/app/components/arclight/repository_location_component.rb +10 -0
- data/app/components/arclight/search_bar_component.html.erb +25 -0
- data/app/components/arclight/search_bar_component.rb +32 -0
- data/app/components/arclight/search_result_breadcrumbs_component.html.erb +3 -0
- data/app/components/arclight/search_result_breadcrumbs_component.rb +37 -0
- data/app/components/arclight/search_result_component.html.erb +20 -0
- data/app/components/arclight/search_result_component.rb +24 -0
- data/app/components/arclight/search_result_title_component.html.erb +13 -0
- data/app/components/arclight/search_result_title_component.rb +15 -0
- data/app/components/arclight/sidebar_component.html.erb +9 -0
- data/app/components/arclight/sidebar_component.rb +19 -0
- data/app/components/arclight/upper_metadata_layout_component.rb +10 -0
- data/app/components/blacklight/icons/bookmark_component.rb +12 -0
- data/app/components/blacklight/icons/collection_component.rb +14 -0
- data/app/components/blacklight/icons/compact_component.rb +12 -0
- data/app/components/blacklight/icons/container_component.rb +14 -0
- data/app/components/blacklight/icons/ead_component.rb +12 -0
- data/app/components/blacklight/icons/file_component.rb +14 -0
- data/app/components/blacklight/icons/folder_component.rb +12 -0
- data/app/components/blacklight/icons/online_component.rb +15 -0
- data/app/components/blacklight/icons/pdf_component.rb +12 -0
- data/app/components/blacklight/icons/repository_component.rb +12 -0
- data/app/controllers/arclight/repositories_controller.rb +4 -4
- data/app/{controllers/concerns → helpers}/arclight/ead_format_helpers.rb +4 -7
- data/app/helpers/arclight/field_config_helpers.rb +26 -0
- data/app/helpers/arclight_helper.rb +16 -254
- data/app/models/arclight/document_downloads.rb +12 -15
- data/app/models/arclight/parent.rb +5 -0
- data/app/models/arclight/parents.rb +2 -1
- data/app/models/arclight/requests/aeon_external_request.rb +1 -1
- data/app/models/arclight/requests/aeon_web_ead.rb +8 -3
- data/app/models/arclight/requests/google_form.rb +8 -3
- data/app/models/concerns/arclight/catalog.rb +25 -15
- data/app/models/concerns/arclight/search_behavior.rb +12 -26
- data/app/models/concerns/arclight/solr_document.rb +70 -73
- data/app/presenters/arclight/show_presenter.rb +34 -7
- data/app/views/arclight/_requests.html.erb +2 -2
- data/app/views/arclight/repositories/_repository.html.erb +21 -40
- data/app/views/arclight/repositories/index.html.erb +3 -1
- data/app/views/arclight/repositories/show.html.erb +4 -6
- data/app/views/arclight/requests/_aeon_external_request_endpoint.html.erb +4 -5
- data/app/views/arclight/requests/_aeon_web_ead.html.erb +3 -4
- data/app/views/arclight/requests/_google_form.html.erb +4 -6
- data/app/views/catalog/_group.html.erb +1 -18
- data/app/views/catalog/_group_toggle.html.erb +1 -1
- data/app/views/catalog/_search_results_header.html.erb +3 -0
- data/app/views/catalog/hierarchy.html.erb +19 -0
- data/app/views/catalog/index.html.erb +16 -7
- data/app/views/shared/_breadcrumbs.html.erb +2 -14
- data/app/views/shared/_main_menu_links.html.erb +1 -1
- data/arclight.gemspec +13 -11
- data/config/breadcrumbs.rb +24 -0
- data/config/i18n-tasks.yml +9 -8
- data/config/importmap.rb +3 -0
- data/config/locales/arclight.en.yml +31 -30
- data/config/routes.rb +1 -1
- data/docker-compose.yml +16 -0
- data/lib/arclight/digital_object.rb +2 -1
- data/lib/arclight/engine.rb +18 -37
- data/lib/arclight/exceptions.rb +1 -0
- data/lib/arclight/hash_absolute_xpath.rb +2 -1
- data/lib/arclight/normalized_id.rb +2 -0
- data/lib/arclight/normalized_title.rb +2 -0
- data/lib/arclight/repository.rb +45 -56
- data/lib/arclight/routes/hierarchy.rb +19 -0
- data/lib/arclight/routes.rb +8 -0
- data/lib/arclight/traject/ead2_component_config.rb +292 -0
- data/lib/arclight/traject/ead2_config.rb +66 -287
- data/lib/arclight/version.rb +1 -1
- data/lib/arclight/year_range.rb +4 -3
- data/lib/arclight.rb +6 -1
- data/lib/generators/arclight/install_generator.rb +59 -21
- data/lib/generators/arclight/templates/arclight.scss +4 -3
- data/lib/generators/arclight/templates/catalog_controller.rb +150 -165
- data/lib/generators/arclight/templates/config/locales/arclight.en.yml +53 -0
- data/lib/generators/arclight/templates/config/repositories.yml +20 -27
- data/lib/tasks/index.rake +14 -17
- data/package.json +11 -13
- data/solr/conf/schema.xml +42 -38
- data/solr/conf/solrconfig.xml +34 -31
- data/tasks/arclight.rake +8 -7
- data/template.rb +1 -2
- metadata +147 -120
- data/.babelrc +0 -3
- data/app/assets/javascripts/arclight/collection_navigation.js +0 -100
- data/app/assets/javascripts/arclight/collection_scrollspy.js +0 -6
- data/app/assets/javascripts/arclight/context_navigation.js +0 -351
- data/app/assets/javascripts/arclight/truncator.js.erb +0 -29
- data/app/assets/stylesheets/arclight/bootstrap_overrides.scss +0 -26
- data/app/assets/stylesheets/arclight/modules/context_navigation.scss +0 -75
- data/app/controllers/concerns/arclight/field_config_helpers.rb +0 -102
- data/app/factories/blacklight_field_configuration_factory.rb +0 -30
- data/app/views/arclight/repositories/_in_person_repository.html.erb +0 -19
- data/app/views/arclight/repositories/_repository_contact.html.erb +0 -9
- data/app/views/arclight/viewers/_oembed.html.erb +0 -8
- data/app/views/catalog/_access_contents.html.erb +0 -15
- data/app/views/catalog/_arclight_abstract_or_scope.html.erb +0 -5
- data/app/views/catalog/_arclight_bookmark_control.html.erb +0 -38
- data/app/views/catalog/_arclight_document_header_icon.html.erb +0 -1
- data/app/views/catalog/_arclight_document_index_header.html.erb +0 -13
- data/app/views/catalog/_arclight_document_index_header_hierarchy_default.html.erb +0 -0
- data/app/views/catalog/_arclight_document_index_header_online_contents_default.html.erb +0 -0
- data/app/views/catalog/_arclight_index_compact_default.html.erb +0 -22
- data/app/views/catalog/_arclight_index_default.html.erb +0 -45
- data/app/views/catalog/_arclight_index_group_document_compact_default.html.erb +0 -19
- data/app/views/catalog/_arclight_index_group_document_default.html.erb +0 -18
- data/app/views/catalog/_arclight_online_content_indicator.html.erb +0 -3
- data/app/views/catalog/_arclight_rangelimit.html.erb +0 -24
- data/app/views/catalog/_arclight_viewer_default.html.erb +0 -1
- data/app/views/catalog/_collection_contents.html.erb +0 -4
- data/app/views/catalog/_collection_context.html.erb +0 -15
- data/app/views/catalog/_collection_context_nav.html.erb +0 -12
- data/app/views/catalog/_collection_online_contents.html.erb +0 -17
- data/app/views/catalog/_component_context.html.erb +0 -5
- data/app/views/catalog/_containers.html.erb +0 -3
- data/app/views/catalog/_context_card.html.erb +0 -27
- data/app/views/catalog/_context_sidebar.html.erb +0 -8
- data/app/views/catalog/_custom_metadata.html.erb +0 -16
- data/app/views/catalog/_document_downloads.html.erb +0 -14
- data/app/views/catalog/_group_header_compact_default.html.erb +0 -15
- data/app/views/catalog/_group_header_default.html.erb +0 -20
- data/app/views/catalog/_home.html.erb +0 -1
- data/app/views/catalog/_index_breadcrumb_default.html.erb +0 -6
- data/app/views/catalog/_index_collection_context_default.html.erb +0 -53
- data/app/views/catalog/_index_default.html.erb +0 -17
- data/app/views/catalog/_index_header.html.erb +0 -7
- data/app/views/catalog/_index_header_online_contents_default.html.erb +0 -1
- data/app/views/catalog/_index_online_contents_default.html.erb +0 -6
- data/app/views/catalog/_online_content_label.html.erb +0 -5
- data/app/views/catalog/_search_form.html.erb +0 -34
- data/app/views/catalog/_search_results.html.erb +0 -28
- data/app/views/catalog/_show_actions_box_default.html.erb +0 -27
- data/app/views/catalog/_show_breadcrumbs_default.html.erb +0 -6
- data/app/views/catalog/_show_collection.html.erb +0 -66
- data/app/views/catalog/_show_default.html.erb +0 -70
- data/app/views/catalog/_show_upper_metadata_collection.html.erb +0 -1
- data/app/views/catalog/_show_upper_metadata_default.html.erb +0 -14
- data/app/views/catalog/_sort_and_per_page.html.erb +0 -8
- data/app/views/catalog/_within_collection_dropdown.html.erb +0 -26
- data/app/views/layouts/catalog_result.html.erb +0 -7
- data/app/views/shared/_context_sidebar.html.erb +0 -8
- data/app/views/shared/_header_navbar.html.erb +0 -61
- data/app/views/shared/_show_breadcrumbs.html.erb +0 -27
- data/lib/arclight/viewer.rb +0 -45
- data/lib/arclight/viewers/oembed.rb +0 -57
- data/solr/conf/scripts.conf +0 -24
- data/vendor/assets/javascripts/responsiveTruncator.js +0 -69
- data/vendor/assets/javascripts/stickyfill.js +0 -480
@@ -3,94 +3,15 @@
|
|
3
3
|
##
|
4
4
|
# Generic Helpers used in Arclight
|
5
5
|
module ArclightHelper
|
6
|
-
|
7
|
-
|
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 << '…'.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
|
-
'…'.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
|
-
|
93
|
-
|
13
|
+
repository: [repository.name],
|
14
|
+
level: ['Collection']
|
94
15
|
}
|
95
16
|
)
|
96
17
|
end
|
@@ -108,28 +29,24 @@ module ArclightHelper
|
|
108
29
|
|
109
30
|
##
|
110
31
|
# Classes used for customized show page in arclight
|
111
|
-
def
|
112
|
-
'col-
|
32
|
+
def show_content_classes
|
33
|
+
'col-12 col-lg-8 show-document order-2'
|
113
34
|
end
|
114
35
|
|
115
|
-
def
|
116
|
-
|
36
|
+
def show_sidebar_classes
|
37
|
+
'col-lg-4 order-1 collection-sidebar'
|
117
38
|
end
|
118
39
|
|
119
40
|
def collection_active?
|
120
|
-
|
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
|
134
51
|
|
135
52
|
def search_with_group
|
@@ -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
|
-
|
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
|
-
|
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
|
201
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
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.
|
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
|
-
|
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.
|
107
|
-
|
108
|
-
end
|
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 { |
|
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
|
##
|
@@ -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 [
|
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
|
-
|
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
|
-
|
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 [
|
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
|
-
|
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
|
-
|
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, :
|
12
|
-
params[:f][:
|
13
|
-
params[:f].delete(:
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
27
|
-
|
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
|
-
|
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
|
-
|
20
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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'] =
|
34
|
+
solr_params['hl.fl'] = CatalogController.blacklight_config.highlight_field
|
49
35
|
solr_params['hl.snippets'] = 3
|
50
36
|
solr_params
|
51
37
|
end
|