-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic_finding_aid_controller.rb
More file actions
258 lines (218 loc) · 13.1 KB
/
static_finding_aid_controller.rb
File metadata and controls
258 lines (218 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
require "oac/finding_aid_tree_node"
class StaticFindingAidController < ApplicationController
layout "static_catalog_result"
include Blacklight::Catalog
include Arclight::Catalog
include CacheControl
configure_blacklight do |config|
config.search_builder_class = StaticFindingAidSearchBuilder
config.header_component = BlankComponent
config.show.document_component = StaticFindingAid::DocumentComponent
config.show.access_component = StaticFindingAid::AccessComponent
config.track_search_session.storage = false
config.default_solr_params = {
rows: 10,
fl: "*,collection:[subquery]",
'collection.q': "{!terms f=id v=$row._root_}",
'collection.defType': "lucene",
'collection.fl': "*",
'collection.rows': 1,
fq: "preview_ssi:false"
}
config.default_document_solr_params = {
qt: "document",
fl: "*,collection:[subquery]",
'collection.q': "{!terms f=id v=$row._root_}",
'collection.defType': "lucene",
'collection.fl': "*",
'collection.rows': 1
}
config.add_results_document_tool(:online, component: Arclight::OnlineStatusIndicatorComponent)
# config.add_results_document_tool(:arclight_bookmark_control, component: Arclight::BookmarkComponent)
config.show.sidebar_component = Arclight::SidebarComponent
config.show.breadcrumb_component = Arclight::SimpleBreadcrumbsHierarchyComponent
config.show.embed_component = Arclight::EmbedComponent
config.show.online_status_component = Arclight::OnlineStatusIndicatorComponent
config.show.document_header_component = Arclight::BlankComponent
config.show.display_type_field = "level_ssm"
# config.show.thumbnail_field = 'thumbnail_path_ss'
config.show.document_presenter_class = Arclight::ShowPresenter
config.show.metadata_partials = %i[
summary_field
background_field
related_field
indexed_terms_field
access_field
]
config.show.collection_access_items = %i[
terms_field
cite_field
in_person_field
contact_field
]
config.show.component_metadata_partials = %i[
component_field
component_indexed_terms_field
]
config.show.component_access_items = %i[
component_terms_field
cite_field
in_person_field
contact_field
]
# These are the parameters passed through in search_state.params_for_search
config.search_state_fields += %i[id group hierarchy_context original_document]
config.search_state_fields << { original_parents: [] }
# ===========================
# COLLECTION SHOW PAGE FIELDS
# ===========================
# Collection Show Page - Summary Section
config.add_summary_field "creators", field: "creator_ssim", link_to_facet: false
config.add_summary_field "abstract", field: "abstract_html_tesm", helper_method: :render_html_tags
config.add_summary_field "extent", field: "extent_ssm"
config.add_summary_field "language", field: "language_ssim"
config.add_summary_field "prefercite", field: "prefercite_html_tesm", helper_method: :render_html_tags
# Collection Show Page - Background Section
config.add_background_field "scopecontent", field: "scopecontent_html_tesm", helper_method: :render_html_tags
config.add_background_field "bioghist", field: "bioghist_html_tesm", helper_method: :render_html_tags
config.add_background_field "acqinfo", field: "acqinfo_ssim", helper_method: :render_html_tags
config.add_background_field "appraisal", field: "appraisal_html_tesm", helper_method: :render_html_tags
config.add_background_field "custodhist", field: "custodhist_html_tesm", helper_method: :render_html_tags
config.add_background_field "processinfo", field: "processinfo_html_tesm", helper_method: :render_html_tags
config.add_background_field "arrangement", field: "arrangement_html_tesm", helper_method: :render_html_tags
config.add_background_field "accruals", field: "accruals_html_tesm", helper_method: :render_html_tags
config.add_background_field "phystech", field: "phystech_html_tesm", helper_method: :render_html_tags
config.add_background_field "physloc", field: "physloc_html_tesm", helper_method: :render_html_tags
config.add_background_field "physdesc", field: "physdesc_tesim", helper_method: :render_html_tags
config.add_background_field "physfacet", field: "physfacet_tesim", helper_method: :render_html_tags
config.add_background_field "dimensions", field: "dimensions_tesim", helper_method: :render_html_tags
config.add_background_field "materialspec", field: "materialspec_html_tesm", helper_method: :render_html_tags
config.add_background_field "fileplan", field: "fileplan_html_tesm", helper_method: :render_html_tags
config.add_background_field "descrules", field: "descrules_ssm", helper_method: :render_html_tags
config.add_background_field "note", field: "note_html_tesm", helper_method: :render_html_tags
# Collection Show Page - Related Section
config.add_related_field "relatedmaterial", field: "relatedmaterial_html_tesm", helper_method: :render_html_tags
config.add_related_field "separatedmaterial", field: "separatedmaterial_html_tesm", helper_method: :render_html_tags
config.add_related_field "otherfindaid", field: "otherfindaid_html_tesm", helper_method: :render_html_tags
config.add_related_field "altformavail", field: "altformavail_html_tesm", helper_method: :render_html_tags
config.add_related_field "originalsloc", field: "originalsloc_html_tesm", helper_method: :render_html_tags
config.add_related_field "odd", field: "odd_html_tesm", helper_method: :render_html_tags
# Collection Show Page - Indexed Terms Section
config.add_indexed_terms_field "access_subjects", field: "access_subjects_ssim", link_to_facet: false, separator_options: {
words_connector: "<br/>",
two_words_connector: "<br/>",
last_word_connector: "<br/>"
}
config.add_indexed_terms_field "names_coll", field: "names_coll_ssim", separator_options: {
words_connector: "<br/>",
two_words_connector: "<br/>",
last_word_connector: "<br/>"
}, link_to_facet: false
config.add_indexed_terms_field "places", field: "places_ssim", link_to_facet: false, separator_options: {
words_connector: "<br/>",
two_words_connector: "<br/>",
last_word_connector: "<br/>"
}
config.add_indexed_terms_field "indexes", field: "indexes_html_tesm",
helper_method: :render_html_tags
# ==========================
# COMPONENT SHOW PAGE FIELDS
# ==========================
# Component Show Page - Metadata Section
config.add_component_field "containers", accessor: "containers", separator_options: {
words_connector: ", ",
two_words_connector: ", ",
last_word_connector: ", "
}, if: lambda { |_context, _field_config, document|
document.containers.present?
}
config.add_component_field "creators", field: "creator_ssim", link_to_facet: false
config.add_component_field "abstract", field: "abstract_html_tesm", helper_method: :render_html_tags
config.add_component_field "extent", field: "extent_ssm"
config.add_component_field "scopecontent", field: "scopecontent_html_tesm", helper_method: :render_html_tags
config.add_component_field "language", field: "language_ssim"
config.add_component_field "acqinfo", field: "acqinfo_ssim", helper_method: :render_html_tags
config.add_component_field "bioghist", field: "bioghist_html_tesm", helper_method: :render_html_tags
config.add_component_field "appraisal", field: "appraisal_html_tesm", helper_method: :render_html_tags
config.add_component_field "custodhist", field: "custodhist_html_tesm", helper_method: :render_html_tags
config.add_component_field "processinfo", field: "processinfo_html_tesm", helper_method: :render_html_tags
config.add_component_field "arrangement", field: "arrangement_html_tesm", helper_method: :render_html_tags
config.add_component_field "accruals", field: "accruals_html_tesm", helper_method: :render_html_tags
config.add_component_field "phystech", field: "phystech_html_tesm", helper_method: :render_html_tags
config.add_component_field "materialspec", field: "materialspec_html_tesm", helper_method: :render_html_tags
config.add_component_field "physloc", field: "physloc_html_tesm", helper_method: :render_html_tags
config.add_component_field "physdesc", field: "physdesc_tesim", helper_method: :render_html_tags
config.add_component_field "physfacet", field: "physfacet_tesim", helper_method: :render_html_tags
config.add_component_field "dimensions", field: "dimensions_tesim", helper_method: :render_html_tags
config.add_component_field "fileplan", field: "fileplan_html_tesm", helper_method: :render_html_tags
config.add_component_field "altformavail", field: "altformavail_html_tesm", helper_method: :render_html_tags
config.add_component_field "otherfindaid", field: "otherfindaid_html_tesm", helper_method: :render_html_tags
config.add_component_field "odd", field: "odd_html_tesm", helper_method: :render_html_tags
config.add_component_field "relatedmaterial", field: "relatedmaterial_html_tesm", helper_method: :render_html_tags
config.add_component_field "separatedmaterial", field: "separatedmaterial_html_tesm", helper_method: :render_html_tags
config.add_component_field "originalsloc", field: "originalsloc_html_tesm", helper_method: :render_html_tags
config.add_component_field "note", field: "note_html_tesm", helper_method: :render_html_tags
# Component Show Page - Indexed Terms Section
config.add_component_indexed_terms_field "access_subjects", field: "access_subjects_ssim", link_to_facet: false, separator_options: {
words_connector: "<br/>",
two_words_connector: "<br/>",
last_word_connector: "<br/>"
}
config.add_component_indexed_terms_field "names", field: "names_ssim", separator_options: {
words_connector: "<br/>",
two_words_connector: "<br/>",
last_word_connector: "<br/>"
}, link_to_facet: false
config.add_component_indexed_terms_field "places", field: "places_ssim", link_to_facet: false, separator_options: {
words_connector: "<br/>",
two_words_connector: "<br/>",
last_word_connector: "<br/>"
}
config.add_component_indexed_terms_field "indexes", field: "indexes_html_tesm",
helper_method: :render_html_tags
# =================
# ACCESS TAB FIELDS
# =================
# Collection Show Page Access Tab - Terms and Conditions Section
config.add_terms_field "restrictions", field: "accessrestrict_html_tesm", helper_method: :render_html_tags
config.add_terms_field "terms", field: "userestrict_html_tesm", helper_method: :render_html_tags
# Component Show Page Access Tab - Terms and Condition Section
config.add_component_terms_field "restrictions", field: "accessrestrict_html_tesm", helper_method: :render_html_tags
config.add_component_terms_field "terms", field: "userestrict_html_tesm", helper_method: :render_html_tags
config.add_component_terms_field "parent_restrictions", field: "parent_access_restrict_tesm", helper_method: :render_html_tags
config.add_component_terms_field "parent_terms", field: "parent_access_terms_tesm", helper_method: :render_html_tags
# Collection and Component Show Page Access Tab - In Person Section
config.add_in_person_field "repository_location", values: ->(_, document, _) { document.repository_config }, component: Arclight::RepositoryLocationComponent
config.add_in_person_field "before_you_visit", values: ->(_, document, _) { document.repository_config&.visit_note }
# Collection and Component Show Page Access Tab - How to Cite Section
config.add_cite_field "prefercite", field: "prefercite_html_tesm", helper_method: :render_html_tags
# Collection and Component Show Page Access Tab - Contact Section
config.add_contact_field "repository_contact", values: ->(_, document, _) { document.repository_config&.contact }
# Group header values
config.add_group_header_field "abstract_or_scope", accessor: true, truncate: true, helper_method: :render_html_tags
end
def show
@document = search_service.fetch(::RSolr.solr_escape(params[:id]))
# get document's last indexed date and id
doc_id = @document.id
last_indexed = @document["timestamp"]
s3_key = "static_findaids/#{doc_id}"
s3 = Aws::S3::Client.new(region: "us-west-2")
bucket = ENV.fetch("S3_BUCKET")
begin
head = s3.head_object(bucket: bucket, key: s3_key)
s3_last_indexed = head.metadata["lastindexed"]
if s3_last_indexed == last_indexed
html_obj = s3.get_object(bucket: bucket, key: s3_key)
send_data html_obj.body.read, type: "text/html", disposition: "inline"
return
end
rescue Aws::S3::Errors::NotFound
# object does not exist, continue as normal
end
if !helpers.show_static_finding_aid_link?(@document)
redirect_to solr_document_path(@document), status: 302
end
@doc_tree = Oac::FindingAidTreeNode.new(self, params[:id])
end
end