arclight 0.4.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.
- checksums.yaml +4 -4
- data/.eslintrc +11 -4
- data/.github/workflows/ruby.yml +37 -15
- data/.gitignore +1 -0
- data/.rspec +0 -1
- data/.rubocop.yml +498 -21
- data/.rubocop_todo.yml +69 -86
- data/.solr_wrapper +2 -1
- data/CONTRIBUTING.md +5 -5
- data/CONTRIBUTORS.md +1 -1
- data/Gemfile +15 -10
- data/README.md +20 -16
- data/app/assets/javascripts/arclight/arclight.js +4 -8
- data/app/assets/javascripts/arclight/oembed_controller.js +58 -0
- data/app/assets/javascripts/arclight/truncate_controller.js +27 -0
- data/app/assets/stylesheets/arclight/application.scss +2 -5
- data/app/assets/stylesheets/arclight/build.scss +4 -0
- data/app/assets/stylesheets/arclight/modules/hierarchy_and_online_contents.scss +108 -130
- data/app/assets/stylesheets/arclight/modules/icons.scss +19 -3
- data/app/assets/stylesheets/arclight/modules/layout.scss +129 -99
- data/app/assets/stylesheets/arclight/modules/mastheads.scss +23 -96
- 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_form.scss +9 -0
- data/app/assets/stylesheets/arclight/modules/search_results.scss +95 -45
- data/app/assets/stylesheets/arclight/modules/show_collection.scss +5 -32
- data/app/assets/stylesheets/arclight/modules/truncator.scss +58 -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 +50 -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 +39 -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 +50 -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 +20 -0
- data/app/components/arclight/document_components_hierarchy_component.rb +34 -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/expand_hierarchy_button_component.html.erb +5 -0
- data/app/components/arclight/expand_hierarchy_button_component.rb +16 -0
- data/app/components/arclight/group_component.html.erb +34 -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 +16 -0
- data/app/components/arclight/index_metadata_field_component.rb +20 -0
- data/app/components/arclight/masthead_component.html.erb +17 -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 +17 -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 +27 -0
- data/app/components/arclight/search_bar_component.rb +32 -0
- data/app/components/arclight/search_result_breadcrumbs_component.html.erb +6 -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 +18 -0
- data/app/components/arclight/search_result_title_component.html.erb +15 -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 +91 -7
- data/app/helpers/arclight/field_config_helpers.rb +26 -0
- data/app/helpers/arclight_helper.rb +24 -251
- data/app/models/arclight/document_downloads.rb +12 -15
- data/app/models/arclight/parent.rb +6 -8
- data/app/models/arclight/parents.rb +7 -4
- 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 +80 -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/_document_list.html.erb +8 -0
- data/app/views/catalog/_group.html.erb +2 -19
- 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 +16 -14
- 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_date.rb +5 -10
- data/lib/arclight/normalized_id.rb +6 -2
- data/lib/arclight/normalized_title.rb +2 -0
- data/lib/arclight/repository.rb +46 -57
- data/lib/arclight/routes/hierarchy.rb +19 -0
- data/lib/arclight/routes.rb +8 -0
- data/lib/arclight/traject/ead2_component_config.rb +335 -0
- data/lib/arclight/traject/ead2_config.rb +120 -299
- 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 +94 -21
- data/lib/generators/arclight/templates/arclight.scss +6 -3
- data/lib/generators/arclight/templates/catalog_controller.rb +193 -165
- data/lib/generators/arclight/templates/config/locales/arclight.en.yml +61 -0
- data/lib/generators/arclight/templates/config/repositories.yml +22 -29
- data/lib/tasks/index.rake +14 -17
- data/package.json +13 -14
- data/solr/conf/schema.xml +49 -39
- data/solr/conf/solrconfig.xml +78 -58
- data/tasks/arclight.rake +17 -9
- data/template.rb +6 -7
- metadata +149 -123
- 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/oembed_viewer.js +0 -46
- 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
- /data/app/assets/images/{blacklight → arclight}/logo.png +0 -0
|
@@ -3,94 +3,16 @@
|
|
|
3
3
|
##
|
|
4
4
|
# Generic Helpers used in Arclight
|
|
5
5
|
module ArclightHelper
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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::DocumentHelperBehavior
|
|
9
|
+
include Blacklight::LayoutHelperBehavior
|
|
88
10
|
|
|
89
11
|
def repository_collections_path(repository)
|
|
90
12
|
search_action_url(
|
|
91
13
|
f: {
|
|
92
|
-
|
|
93
|
-
|
|
14
|
+
repository: [repository.name],
|
|
15
|
+
level: ['Collection']
|
|
94
16
|
}
|
|
95
17
|
)
|
|
96
18
|
end
|
|
@@ -108,28 +30,24 @@ module ArclightHelper
|
|
|
108
30
|
|
|
109
31
|
##
|
|
110
32
|
# Classes used for customized show page in arclight
|
|
111
|
-
def
|
|
112
|
-
'col-
|
|
33
|
+
def show_content_classes
|
|
34
|
+
'col-12 col-lg-8 show-document order-2'
|
|
113
35
|
end
|
|
114
36
|
|
|
115
|
-
def
|
|
116
|
-
|
|
37
|
+
def show_sidebar_classes
|
|
38
|
+
'col-lg-4 order-1 collection-sidebar'
|
|
117
39
|
end
|
|
118
40
|
|
|
119
41
|
def collection_active?
|
|
120
|
-
|
|
42
|
+
search_state.filter('level').values == ['Collection']
|
|
121
43
|
end
|
|
122
44
|
|
|
123
45
|
def collection_active_class
|
|
124
46
|
'active' if collection_active?
|
|
125
47
|
end
|
|
126
48
|
|
|
127
|
-
def collection_count
|
|
128
|
-
@response.response['numFound']
|
|
129
|
-
end
|
|
130
|
-
|
|
131
49
|
def grouped?
|
|
132
|
-
|
|
50
|
+
respond_to?(:search_state) && search_state&.params_for_search&.dig('group') == 'true'
|
|
133
51
|
end
|
|
134
52
|
|
|
135
53
|
def search_with_group
|
|
@@ -140,14 +58,6 @@ module ArclightHelper
|
|
|
140
58
|
search_state.params_for_search.except('group', 'page')
|
|
141
59
|
end
|
|
142
60
|
|
|
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
61
|
def on_repositories_index?
|
|
152
62
|
controller_name == 'repositories' && action_name == 'index'
|
|
153
63
|
end
|
|
@@ -157,29 +67,14 @@ module ArclightHelper
|
|
|
157
67
|
'active' if on_repositories_index?
|
|
158
68
|
end
|
|
159
69
|
|
|
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
70
|
# If we have a facet on the repository, then return the Repository object for it
|
|
167
71
|
#
|
|
168
72
|
# @return [Repository]
|
|
169
73
|
def repository_faceted_on
|
|
170
|
-
|
|
74
|
+
repos = search_state.filter('repository').values
|
|
75
|
+
return unless repos.one?
|
|
171
76
|
|
|
172
|
-
repos
|
|
173
|
-
faceted = repos && repos.length == 1 && repos.first
|
|
174
|
-
Arclight::Repository.find_by(name: repos.first) if faceted
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def hierarchy_component_context?
|
|
178
|
-
params[:hierarchy_context] == 'component'
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def online_contents_context?
|
|
182
|
-
params[:view] == 'online_contents'
|
|
77
|
+
Arclight::Repository.find_by(name: repos.first)
|
|
183
78
|
end
|
|
184
79
|
|
|
185
80
|
# determine which icon to show in search results header
|
|
@@ -197,139 +92,17 @@ module ArclightHelper
|
|
|
197
92
|
end
|
|
198
93
|
end
|
|
199
94
|
|
|
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
95
|
##
|
|
308
|
-
#
|
|
309
|
-
#
|
|
310
|
-
#
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
end
|
|
316
|
-
|
|
317
|
-
def results_view?
|
|
318
|
-
controller_name == 'catalog' && action_name == 'index'
|
|
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 }
|
|
319
103
|
end
|
|
320
104
|
|
|
321
|
-
def
|
|
322
|
-
|
|
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
|
|
105
|
+
def current_context_document
|
|
106
|
+
@document
|
|
334
107
|
end
|
|
335
108
|
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(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,10 @@ 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
|
+
|
|
10
|
+
alias global_id id
|
|
11
|
+
Arclight.deprecation.deprecate_methods(self, global_id: 'Call `id` instead')
|
|
12
|
+
|
|
9
13
|
def initialize(id:, label:, eadid:, level:)
|
|
10
14
|
@id = id
|
|
11
15
|
@label = label
|
|
@@ -13,14 +17,8 @@ module Arclight
|
|
|
13
17
|
@level = level
|
|
14
18
|
end
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Blacklight and Solr
|
|
19
|
-
# @return [String]
|
|
20
|
-
def global_id
|
|
21
|
-
return id if eadid == id
|
|
22
|
-
|
|
23
|
-
"#{eadid}#{id}"
|
|
20
|
+
def collection?
|
|
21
|
+
level == 'collection'
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
24
|
end
|
|
@@ -5,9 +5,11 @@ 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, :levels
|
|
9
|
-
|
|
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
|
|
13
15
|
@levels = levels
|
|
@@ -20,17 +22,18 @@ module Arclight
|
|
|
20
22
|
##
|
|
21
23
|
# @return [Array[Arclight::Parent]]
|
|
22
24
|
def as_parents
|
|
23
|
-
ids.map.with_index { |
|
|
25
|
+
(ids.presence || legacy_ids).map.with_index { |id, idx| Arclight::Parent.new(id: id, label: labels[idx], eadid: eadid, level: levels[idx]) }
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
##
|
|
27
29
|
# @param [SolrDocument] document
|
|
28
30
|
def self.from_solr_document(document)
|
|
29
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}" }
|
|
30
33
|
labels = document.parent_labels
|
|
31
34
|
eadid = document.eadid
|
|
32
35
|
levels = document.parent_levels
|
|
33
|
-
new(ids: ids, labels: labels, eadid: eadid, levels: levels)
|
|
36
|
+
new(ids: ids, legacy_ids: legacy_ids, labels: labels, eadid: eadid, levels: levels)
|
|
34
37
|
end
|
|
35
38
|
end
|
|
36
39
|
end
|
|
@@ -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
|