arclight 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.all-contributorsrc +450 -0
  3. data/.babelrc +3 -0
  4. data/.codeclimate.yml +5 -0
  5. data/.eslintrc +3 -0
  6. data/.rubocop.yml +19 -0
  7. data/.rubocop_todo.yml +15 -135
  8. data/.travis.yml +2 -2
  9. data/CONTRIBUTORS.md +79 -0
  10. data/README.md +21 -24
  11. data/Rakefile +0 -1
  12. data/app/assets/images/blacklight/bookmark.svg +1 -0
  13. data/app/assets/images/blacklight/collection.svg +5 -0
  14. data/app/assets/images/blacklight/compact.svg +1 -25
  15. data/app/assets/images/blacklight/container.svg +5 -0
  16. data/app/assets/images/blacklight/ead.svg +1 -0
  17. data/app/assets/images/blacklight/file.svg +5 -0
  18. data/app/assets/images/blacklight/folder.svg +1 -0
  19. data/app/assets/images/blacklight/list.svg +1 -0
  20. data/app/assets/images/blacklight/minus.svg +1 -0
  21. data/app/assets/images/blacklight/online.svg +5 -0
  22. data/app/assets/images/blacklight/pdf.svg +1 -0
  23. data/app/assets/images/blacklight/plus.svg +1 -0
  24. data/app/assets/images/blacklight/repository.svg +1 -0
  25. data/app/assets/javascripts/arclight/arclight.js +1 -3
  26. data/app/assets/javascripts/arclight/collection_navigation.js +36 -53
  27. data/app/assets/javascripts/arclight/collection_scrollspy.js +1 -1
  28. data/app/assets/javascripts/arclight/context_navigation.js +374 -0
  29. data/app/assets/javascripts/arclight/truncator.js.erb +8 -2
  30. data/app/assets/stylesheets/arclight/application.scss +3 -1
  31. data/app/assets/stylesheets/arclight/bootstrap_overrides.scss +23 -0
  32. data/app/assets/stylesheets/arclight/modules/context_navigation.scss +75 -0
  33. data/app/assets/stylesheets/arclight/modules/hierarchy_and_online_contents.scss +28 -35
  34. data/app/assets/stylesheets/arclight/modules/highlights.scss +2 -1
  35. data/app/assets/stylesheets/arclight/modules/layout.scss +128 -14
  36. data/app/assets/stylesheets/arclight/modules/mastheads.scss +27 -5
  37. data/app/assets/stylesheets/arclight/modules/repositories.scss +1 -5
  38. data/app/assets/stylesheets/arclight/modules/repository_card.scss +6 -7
  39. data/app/assets/stylesheets/arclight/modules/search_results.scss +145 -24
  40. data/app/assets/stylesheets/arclight/modules/show_collection.scss +38 -59
  41. data/app/assets/stylesheets/arclight/responsive.scss +13 -0
  42. data/app/assets/stylesheets/arclight/variables.scss +21 -1
  43. data/app/controllers/concerns/arclight/ead_format_helpers.rb +225 -0
  44. data/app/controllers/concerns/arclight/field_config_helpers.rb +23 -7
  45. data/app/factories/blacklight_field_configuration_factory.rb +1 -0
  46. data/app/helpers/arclight_helper.rb +197 -35
  47. data/app/models/arclight/document_downloads.rb +125 -0
  48. data/app/models/arclight/parent.rb +4 -2
  49. data/app/models/arclight/parents.rb +6 -4
  50. data/app/models/arclight/requests/aeon_external_request.rb +42 -0
  51. data/app/models/arclight/requests/aeon_web_ead.rb +47 -0
  52. data/app/models/arclight/requests/google_form.rb +2 -2
  53. data/app/models/concerns/arclight/catalog.rb +14 -2
  54. data/app/models/concerns/arclight/search_behavior.rb +27 -12
  55. data/app/models/concerns/arclight/solr_document.rb +29 -7
  56. data/app/views/arclight/_requests.html.erb +7 -0
  57. data/app/views/arclight/repositories/_in_person_repository.html.erb +1 -1
  58. data/app/views/arclight/repositories/_repository.html.erb +2 -2
  59. data/app/views/arclight/repositories/_repository_contact.html.erb +9 -0
  60. data/app/views/arclight/repositories/index.html.erb +3 -0
  61. data/app/views/arclight/repositories/show.html.erb +5 -4
  62. data/app/views/arclight/requests/_aeon_external_request_endpoint.html.erb +9 -0
  63. data/app/views/arclight/requests/_aeon_web_ead.html.erb +7 -0
  64. data/app/views/arclight/requests/_google_form.html.erb +2 -1
  65. data/app/views/arclight/viewers/_oembed.html.erb +2 -1
  66. data/app/views/catalog/_access_contents.html.erb +15 -0
  67. data/app/views/catalog/_arclight_abstract_or_scope.html.erb +5 -0
  68. data/app/views/catalog/_arclight_bookmark_control.html.erb +38 -0
  69. data/app/views/catalog/_arclight_document_header_icon.html.erb +1 -0
  70. data/app/views/catalog/_arclight_index_compact_default.html.erb +18 -11
  71. data/app/views/catalog/_arclight_index_default.html.erb +45 -0
  72. data/app/views/catalog/_arclight_index_group_document_compact_default.html.erb +19 -0
  73. data/app/views/catalog/_arclight_index_group_document_default.html.erb +18 -0
  74. data/app/views/catalog/_arclight_online_content_indicator.html.erb +1 -3
  75. data/app/views/catalog/_collection_contents.html.erb +2 -10
  76. data/app/views/catalog/_collection_context.html.erb +15 -0
  77. data/app/views/catalog/_collection_context_nav.html.erb +12 -0
  78. data/app/views/catalog/_collection_online_contents.html.erb +3 -3
  79. data/app/views/catalog/_component_context.html.erb +5 -0
  80. data/app/views/catalog/_containers.html.erb +3 -0
  81. data/app/views/catalog/_context_sidebar.html.erb +2 -2
  82. data/app/views/catalog/_document_downloads.html.erb +14 -0
  83. data/app/views/catalog/_group.html.erb +21 -0
  84. data/app/views/catalog/_group_header_compact_default.html.erb +15 -0
  85. data/app/views/catalog/_group_header_default.html.erb +20 -0
  86. data/app/views/catalog/_group_toggle.html.erb +10 -0
  87. data/app/views/catalog/_home.html.erb +1 -1
  88. data/app/views/catalog/_index_breadcrumb_default.html.erb +5 -2
  89. data/app/views/catalog/_index_collection_context_default.html.erb +53 -0
  90. data/app/views/catalog/_index_header.html.erb +3 -3
  91. data/app/views/catalog/_index_online_contents_default.html.erb +1 -1
  92. data/app/views/catalog/_online_content_label.html.erb +5 -0
  93. data/app/views/catalog/_search_form.html.erb +34 -0
  94. data/app/views/catalog/_search_results.html.erb +1 -4
  95. data/app/views/catalog/_show_actions_box_default.html.erb +27 -0
  96. data/app/views/catalog/_show_breadcrumbs_default.html.erb +5 -20
  97. data/app/views/catalog/_show_collection.html.erb +42 -24
  98. data/app/views/catalog/_show_default.html.erb +63 -35
  99. data/app/views/catalog/_show_upper_metadata_default.html.erb +1 -1
  100. data/app/views/catalog/_sort_and_per_page.html.erb +8 -0
  101. data/app/views/catalog/_within_collection_dropdown.html.erb +26 -0
  102. data/app/views/shared/_breadcrumbs.html.erb +4 -4
  103. data/app/views/shared/_context_sidebar.html.erb +2 -2
  104. data/app/views/shared/_header_navbar.html.erb +13 -17
  105. data/app/views/shared/_show_breadcrumbs.html.erb +27 -0
  106. data/arclight.gemspec +5 -6
  107. data/config/i18n-tasks.yml +2 -1
  108. data/config/locales/arclight.en.yml +54 -21
  109. data/config/repositories.yml +0 -0
  110. data/lib/arclight/engine.rb +22 -12
  111. data/lib/arclight/hash_absolute_xpath.rb +11 -7
  112. data/lib/arclight/level_label.rb +46 -0
  113. data/lib/arclight/normalized_date.rb +2 -2
  114. data/lib/arclight/normalized_id.rb +1 -0
  115. data/lib/arclight/normalized_title.rb +1 -0
  116. data/lib/arclight/repository.rb +58 -5
  117. data/lib/arclight/traject/ead2_config.rb +178 -159
  118. data/lib/arclight/traject/nokogiri_namespaceless_reader.rb +22 -0
  119. data/lib/arclight/version.rb +1 -1
  120. data/lib/arclight/viewers/oembed.rb +1 -0
  121. data/lib/arclight/year_range.rb +9 -1
  122. data/lib/generators/arclight/install_generator.rb +5 -1
  123. data/lib/generators/arclight/templates/catalog_controller.rb +128 -100
  124. data/lib/generators/arclight/templates/config/downloads.yml +12 -0
  125. data/lib/generators/arclight/templates/config/repositories.yml +20 -2
  126. data/lib/generators/arclight/update_generator.rb +1 -1
  127. data/lib/tasks/index.rake +18 -20
  128. data/package.json +8 -1
  129. data/solr/conf/schema.xml +51 -292
  130. data/solr/conf/solrconfig.xml +40 -125
  131. data/tasks/arclight.rake +1 -0
  132. data/vendor/assets/javascripts/responsiveTruncator.js +2 -2
  133. metadata +71 -44
  134. data/app/assets/javascripts/arclight/collection_context.js +0 -18
  135. data/app/assets/javascripts/arclight/component_ancestors.js +0 -56
  136. data/app/assets/javascripts/arclight/search_results.js +0 -15
  137. data/app/assets/stylesheets/arclight/modules/sidebar.scss +0 -21
  138. data/app/views/catalog/_collection_count.html.erb +0 -7
  139. data/app/views/catalog/_collection_downloads.html.erb +0 -15
  140. data/app/views/catalog/_collection_overview.html.erb +0 -7
  141. data/app/views/catalog/_component_contents.html.erb +0 -16
  142. data/app/views/catalog/_component_overview.html.erb +0 -40
  143. data/app/views/catalog/_index_header_hierarchy_default.html.erb +0 -42
  144. data/app/views/catalog/_index_hierarchy_default.html.erb +0 -28
  145. data/app/views/catalog/_results_histogram.html.erb +0 -15
  146. data/app/views/catalog/_show_component_sidebar.html.erb +0 -12
  147. data/app/views/catalog/_show_sidebar.html.erb +0 -22
  148. data/lib/arclight/custom_component.rb +0 -99
  149. data/lib/arclight/custom_document.rb +0 -93
  150. data/lib/arclight/indexer.rb +0 -9
  151. data/lib/arclight/shared_indexing_behavior.rb +0 -97
  152. data/lib/arclight/shared_terminology_behavior.rb +0 -65
  153. data/lib/arclight/solr_ead_indexer_ext.rb +0 -155
@@ -1,18 +0,0 @@
1
- Blacklight.onLoad(function () {
2
- 'use strict';
3
-
4
- $('[data-arclight-collection-context="true"]').each(function (i, element) {
5
- var $el = $(element);
6
- var data = $el.data();
7
- $.ajax({
8
- url: data.arclightCollectionContextUrl
9
- }).done(function (response) {
10
- var resp = $.parseHTML(response);
11
- var $doc = $(resp);
12
- var link = $('<a></a>').attr('href', data.arclightCollectionContextUrl);
13
- var addedSection = $doc.find('.al-show-header-section');
14
- addedSection.find('h1').wrapInner(link);
15
- $el.hide().html(addedSection).fadeIn(500);
16
- });
17
- });
18
- });
@@ -1,56 +0,0 @@
1
- (function (global) {
2
- var ComponentAncestors = {
3
- init: function (el) {
4
- var $el = $(el);
5
- var data = $el.data();
6
- var ancestors = $('<div>');
7
- var collectionId = data.arclightAncestors.shift();
8
- var allDone = $.Deferred();
9
-
10
- data.arclightAncestors.forEach(function (id, i) {
11
- var requestId = collectionId + id;
12
- var currentDiv = $('<div class="documents-hierarchy extra-indent al-hierarchy-level-' + (i) + '">');
13
- ancestors.append(currentDiv);
14
-
15
- $.ajax({
16
- url: data.arclightPath,
17
- data: {
18
- q: 'id:' + requestId,
19
- search_field: 'all_fields',
20
- view: 'hierarchy'
21
- }
22
- }).done(function (response) {
23
- var resp = $.parseHTML(response);
24
- var $doc = $(resp);
25
- var thisAncestor = $doc.find('article.document-position-0');
26
-
27
- // Remove collapsible stuff
28
- thisAncestor.find('.al-toggle-view-more').remove();
29
- thisAncestor.find('.collapse').remove();
30
- thisAncestor.find('hr').remove();
31
-
32
- currentDiv.append(thisAncestor);
33
- if (i + 1 === data.arclightAncestors.length) {
34
- allDone.resolve();
35
- }
36
- });
37
- });
38
-
39
- // Wait for all requests to finish
40
- allDone.done(function () {
41
- $el.html(ancestors);
42
- });
43
- }
44
- };
45
-
46
- global.ComponentAncestors = ComponentAncestors;
47
- }(this));
48
-
49
-
50
- Blacklight.onLoad(function () {
51
- 'use strict';
52
-
53
- $('[data-arclight-ancestors]').each(function (i, e) {
54
- ComponentAncestors.init(e); // eslint-disable-line no-undef
55
- });
56
- });
@@ -1,15 +0,0 @@
1
- Blacklight.onLoad(function () {
2
- 'use strict';
3
-
4
- var histogramContent = $('#al-date-range-histogram-content');
5
- var showSpan = $('#al-date-range-histogram-show');
6
- var hideSpan = $('#al-date-range-histogram-hide');
7
- histogramContent.on('show.bs.collapse', function () {
8
- showSpan.attr('hidden', 'hidden');
9
- hideSpan.removeAttr('hidden');
10
- });
11
- histogramContent.on('hide.bs.collapse', function () {
12
- hideSpan.attr('hidden', 'hidden');
13
- showSpan.removeAttr('hidden');
14
- });
15
- });
@@ -1,21 +0,0 @@
1
- .al-in-person-repository-location {
2
- clear: left;
3
- }
4
-
5
- .al-digital-object {
6
- margin-bottom: $spacer;
7
-
8
- .al-digital-object-label {
9
- margin-bottom: ($spacer / 2);
10
- }
11
- }
12
-
13
- // Hiding this from display since we don't need it.
14
- dt.blacklight-digital_objects_ssm {
15
- display: none;
16
- }
17
-
18
- .al-sticky-sidebar .al-request-button {
19
- border: 0;
20
- padding-left: 0;
21
- }
@@ -1,7 +0,0 @@
1
- <% if collection_active? %>
2
- <div class='al-collection-count'>
3
- <p class='lead'>
4
- <%= pluralize(number_with_delimiter(collection_count), t('arclight.views.index.collection_search.count')) %>
5
- </p>
6
- </div>
7
- <% end %>
@@ -1,15 +0,0 @@
1
- <% if downloads.present? && (downloads[:pdf].present? || downloads[:ead].present?) %>
2
- <div class='dropdown al-collection-actions-menu'>
3
- <button class='btn btn-secondary btn-sm dropdown-toggle' type="button" id="download-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
4
- <%= t 'arclight.views.show.download.default' %>
5
- </button>
6
- <div class="dropdown-menu dropdown-menu-right" aria-labelledby="download-dropdown">
7
- <% if downloads[:pdf].present? %>
8
- <a class="dropdown-item" href="<%= downloads[:pdf][:href] %>"><%= t('arclight.views.show.download.pdf', size: downloads[:pdf][:size]) %></a>
9
- <% end %>
10
- <% if downloads[:ead].present? %>
11
- <a class="dropdown-item" href="<%= downloads[:ead][:href] %>"><%= t('arclight.views.show.download.ead', size: downloads[:ead][:size]) %></a>
12
- <% end %>
13
- </div>
14
- </div>
15
- <% end %>
@@ -1,7 +0,0 @@
1
- <h2 class="sr-only">Collection description</h2>
2
- <% unless blacklight_config.show.metadata_partials.nil? %>
3
- <% blacklight_config.show.metadata_partials.each do |metadata| %>
4
- <% next unless fields_have_content?(@document, metadata) %>
5
- <%= render partial: 'custom_metadata', locals: { document: @document, field_accessor: metadata } %>
6
- <% end %>
7
- <% end %>
@@ -1,16 +0,0 @@
1
- <% document ||= @document %>
2
- <% @sub_level ||= document.component_level + 1 %>
3
-
4
-
5
- <h2 class="sr-only">Component inventory</h2>
6
- <div class="component-level-only">
7
- <%= content_tag(
8
- :div, '',
9
- class: 'al-contents',
10
- data: {
11
- arclight: {
12
- hierarchy: true, level: @sub_level, path: search_catalog_path, name: document.collection_name, parent: document.reference
13
- }
14
- }
15
- ) %>
16
- </div>
@@ -1,40 +0,0 @@
1
- <h2 class="sr-only">Component description</h2>
2
- <!-- Section below will be moved into its own partial later -->
3
- <%= content_tag(:div, id: t("arclight.views.show.sections.collection_context_field").parameterize) do %>
4
- <h3 class='al-show-sub-heading'>
5
- <%= t("arclight.views.show.sections.collection_context_field") %>
6
- </h3>
7
- <%= content_tag(
8
- :div, '',
9
- class: 'al-context',
10
- data: {
11
- arclight_collection_context: true,
12
- arclight_collection_context_url: solr_document_path(
13
- normalize_id(@document.eadid)
14
- )
15
- }
16
- ) %>
17
- <%= content_tag(
18
- :div, '',
19
- class: 'al-ancestors',
20
- data: {
21
- arclight_ancestors: @document.parent_ids,
22
- arclight_path: search_catalog_path(hierarchy_context: 'component')
23
- }
24
- ) %>
25
- <%= content_tag(
26
- :div, '',
27
- class: "al-contents al-hierarchy-level-#{@document.component_level} extra-indent documents-hierarchy",
28
- data: {
29
- arclight: {
30
- hierarchy: true,
31
- level: @document.component_level,
32
- path: search_catalog_path(hierarchy_context: 'component'),
33
- name: @document.collection_name,
34
- parent: @document.parent_ids.last,
35
- highlightId: @document.id
36
- }
37
- }
38
- ) %>
39
-
40
- <% end %>
@@ -1,42 +0,0 @@
1
- <div class="documentHeader row" data-document-id="<%= document.id %>">
2
- <% requestable = item_requestable?('', { document: document }) %>
3
- <h3 class="index_title document-title-heading col-md-8">
4
- <% if document.containers.present? %>
5
- <span class="document-title-containers">
6
- <%= document.containers.join(', ') %>:
7
- </span>
8
- <% end %>
9
- <% counter = document_counter_with_offset(document_counter) %>
10
- <%= link_to_document document, document_show_link_field(document), counter: counter %>
11
- <%= render_document_partial(document, 'arclight_online_content_indicator') %>
12
- <% if document.children? %>
13
- <div class='al-hierarchy-children-status'>
14
- <span class='badge badge-default al-number-of-children-badge'>
15
- <%= t(:'arclight.views.index.number_of_children', count: document.number_of_children) %>
16
- <% unless hierarchy_component_context? %>
17
- <%= link_to(
18
- t('arclight.hierarchy.view_all'),
19
- "##{document.reference}-collapsible-hierarchy",
20
- class: 'al-toggle-view-all',
21
- data: {
22
- toggle: 'collapse'
23
- }
24
- )
25
- %>
26
- <% end %>
27
- </span>
28
- </div>
29
- <% end %>
30
- </h3>
31
-
32
- <div class="al-hierarchy-side-content float-right col">
33
- <% unless hierarchy_component_context? %>
34
- <div class="index-document-functions">
35
- <%= render partial: 'catalog/bookmark_control', locals: { document: document } %>
36
- </div>
37
- <% end %>
38
- <% if requestable %>
39
- <%= render partial: 'arclight/requests/google_form', locals: { document: document } %>
40
- <% end %>
41
- </div>
42
- </div>
@@ -1,28 +0,0 @@
1
- <%= content_tag('div', class: 'al-document-abstract-or-scope') do %>
2
- <%= content_tag(:h4, I18n.t('arclight.hierarchy.scope_and_contents'), class: 'al-hierarchy-sub-heading') %>
3
- <%= content_tag('div', 'data-arclight-truncate' => true) do %>
4
- <%= document.abstract_or_scope %>
5
- <% end %>
6
- <% end if document.abstract_or_scope %>
7
-
8
- <% if document.number_of_children > 0 %>
9
- <%= content_tag(:div, id: "#{document.reference}-collapsible-hierarchy",
10
- class: "collapse al-hierarchy-level-#{document.component_level}",
11
- ) do %>
12
-
13
- <%= content_tag(
14
- :div, '',
15
- class: 'al-contents',
16
- data: {
17
- arclight: {
18
- hierarchy: true,
19
- level: document.component_level + 1,
20
- path: search_catalog_path,
21
- name: document.collection_name,
22
- parent: document.reference
23
- }
24
- }
25
- ) %>
26
-
27
- <% end %>
28
- <% end %>
@@ -1,15 +0,0 @@
1
- <div class='al-data-range-histogram row'>
2
- <div class='col-md-12'>
3
- <div id='al-date-range-histogram-content' class='collapse facet-content'>
4
- <%= render partial: 'arclight_rangelimit', locals: { field_name: :date_range_sim, solr_field: :date_range_sim } %>
5
- </div>
6
- <a class='float-right' data-toggle='collapse' href='#al-date-range-histogram-content' aria-expanded='false' aria-controls='al-date-range-histogram-content'>
7
- <span id="al-date-range-histogram-show">
8
- <%= t('arclight.date_range_histogram.show') %>
9
- </span>
10
- <span id="al-date-range-histogram-hide" hidden="hidden">
11
- <%= t('arclight.date_range_histogram.hide') %>
12
- </span>
13
- </a>
14
- </div>
15
- </div>
@@ -1,12 +0,0 @@
1
- <div class='al-sticky-sidebar'>
2
- <h2 class="sr-only">Sidebar</h2>
3
-
4
- <% unless blacklight_config.show.component_sidebar_items.nil? %>
5
- <div id="accordion" role="tablist" aria-multiselectable="true">
6
- <% items = blacklight_config.show.component_sidebar_items.select { |i| fields_have_content?(@document, i) } %>
7
- <% items.each_with_index do |item, index| %>
8
- <%= render partial: 'context_card', locals: { document: @document, field_accessor: item, card_index: index} %>
9
- <% end %>
10
- </div>
11
- <% end %>
12
- </div>
@@ -1,22 +0,0 @@
1
- <div class='al-sticky-sidebar'>
2
- <h2 class="sr-only">Sidebar</h2>
3
- <div class='al-sidebar-navigation-overview card'>
4
- <div class='card-header'>
5
- <h3 class="mb-0"><%= t('arclight.views.show.navigation_sidebar.title') %></h3>
6
- </div>
7
- <div class='card-body'>
8
- <ul class='nav nav-pills flex-column'>
9
- <% unless blacklight_config.show.metadata_partials.nil? %>
10
- <% blacklight_config.show.metadata_partials.each do |item| %>
11
- <% next unless fields_have_content?(@document, item) %>
12
- <li class='nav-item'>
13
- <%= link_to t("arclight.views.show.sections.#{item}"), "##{t("arclight.views.show.sections.#{item}").parameterize}", class: 'nav-link' %>
14
- </li>
15
- <% end %>
16
- <% end %>
17
- </ul>
18
- </div>
19
- </div>
20
-
21
- <%= render 'shared/context_sidebar' %>
22
- </div>
@@ -1,99 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Arclight
4
- ##
5
- # An Arclight custom component indexing code
6
- class CustomComponent < SolrEad::Component
7
- extend Arclight::SharedTerminologyBehavior
8
- include Arclight::SharedIndexingBehavior
9
- use_terminology SolrEad::Component
10
-
11
- # we extend the terminology to provide additional fields and/or indexing strategies
12
- # than `solr_ead` provides as-is. in many cases we're doing redundant indexing, but
13
- # we're trying to modify the `solr_ead` gem as little as possible
14
- extend_terminology do |t|
15
- # identifiers
16
- t.level(path: 'c/@level', index_as: %i[displayable]) # machine-readable for string `level_ssm`
17
- t.otherlevel(path: 'c/@otherlevel', index_as: %i[displayable])
18
- t.ref_(path: '/c/@id', index_as: %i[displayable])
19
-
20
- # facets
21
- t.creator(path: "c/did/origination[@label='creator']/*/text()", index_as: %i[displayable facetable symbol])
22
- t.places(path: 'c/controlaccess/geogname/text()', index_as: %i[displayable facetable symbol])
23
-
24
- add_unitid(t, 'c/')
25
- add_extent(t, 'c/')
26
- add_dates(t, 'c/')
27
- add_searchable_notes(t, 'c/')
28
- end
29
-
30
- def to_solr(solr_doc = {})
31
- super
32
- solr_doc['id'] = Arclight::NormalizedId.new(solr_doc['id']).to_s
33
- solr_doc['creator_sort'] = creator.to_a.join(', ') if creator.present?
34
- add_component_fields(solr_doc)
35
- solr_doc
36
- end
37
-
38
- private
39
-
40
- def add_component_fields(solr_doc)
41
- component_field_definitions.each do |field|
42
- # we want to use `set_field` rather than `insert_field` since we may be overriding fields
43
- Solrizer.set_field(solr_doc, field[:name], field[:value], field[:index_as])
44
- end
45
- add_date_ranges(solr_doc)
46
- add_normalized_title(solr_doc)
47
- resolve_repository(solr_doc)
48
- add_digital_content(prefix: 'c', solr_doc: solr_doc)
49
- add_digital_content(prefix: 'c/did', solr_doc: solr_doc)
50
- end
51
-
52
- def component_field_definitions
53
- [
54
- { name: 'level', value: formatted_level, index_as: :facetable },
55
- { name: 'names', value: names, index_as: :symbol },
56
- { name: 'access_subjects', value: access_subjects, index_as: :symbol },
57
- { name: 'containers', value: containers, index_as: :symbol },
58
- { name: 'has_online_content', value: online_content?, index_as: :symbol }
59
- ]
60
- end
61
-
62
- def resolve_repository(solr_doc)
63
- repository = solr_doc[Solrizer.solr_name('repository', :displayable)]
64
- %i[displayable facetable].each do |index_as|
65
- Solrizer.set_field(solr_doc, 'repository', repository_as_configured(repository), index_as)
66
- end
67
- end
68
-
69
- # @see http://eadiva.com/2/c/
70
- def formatted_level
71
- # terminology definitions for level yield Arrays and in this case single values
72
- # TODO: OM changes the behavior of `level = level.first` such that it always returns `nil`
73
- # so need our own local variable here
74
- actual_level = level.first.to_s if level.respond_to? :first
75
-
76
- if actual_level == 'otherlevel'
77
- alternative_level = otherlevel.first.to_s if otherlevel.respond_to? :first
78
- alternative_level.present? ? alternative_level : 'Other'
79
- elsif actual_level.present?
80
- actual_level.capitalize
81
- end
82
- end
83
-
84
- def names
85
- names_array(%w[corpname famname name persname], parent: 'c')
86
- end
87
-
88
- def access_subjects
89
- subjects_array(%w[subject function occupation genreform], parent: 'c')
90
- end
91
-
92
- def containers
93
- contains = search('//container').to_a
94
- contains.map do |c|
95
- "#{c.attributes['type'].try(:value)} #{c.text}".strip
96
- end
97
- end
98
- end
99
- end
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Arclight
4
- ##
5
- # An Arclight custom document indexing code
6
- class CustomDocument < SolrEad::Document
7
- extend Arclight::SharedTerminologyBehavior
8
- include Arclight::SharedIndexingBehavior
9
- use_terminology SolrEad::Document
10
-
11
- # we extend the terminology to provide additional fields and/or indexing strategies
12
- # than `solr_ead` provides as-is. in many cases we're doing redundant indexing, but
13
- # we're trying to modify the `solr_ead` gem as little as possible
14
- extend_terminology do |t|
15
- # facets
16
- t.repository(path: 'archdesc/did/repository/corpname/text() | archdesc/did/repository/name/text()', index_as: %i[displayable facetable])
17
- t.creator(path: "archdesc/did/origination[@label='creator']/*/text()", index_as: %i[displayable facetable symbol])
18
- t.creator_persname(path: "archdesc/did/origination[@label='creator']/persname/text()", index_as: %i[displayable facetable symbol])
19
- t.creator_corpname(path: "archdesc/did/origination[@label='creator']/corpname/text()", index_as: %i[displayable facetable symbol])
20
- t.creator_famname(path: "archdesc/did/origination[@label='creator']/famname/text()", index_as: %i[displayable facetable symbol])
21
- t.function(path: 'archdesc/controlaccess/function/text()', index_as: %i[displayable facetable])
22
- t.occupation(path: 'archdesc/controlaccess/occupation/text()', index_as: %i[displayable facetable])
23
- t.places(path: 'archdesc/controlaccess/geogname/text()', index_as: %i[displayable facetable symbol])
24
-
25
- add_unitid(t, 'archdesc/')
26
- add_extent(t, 'archdesc/')
27
- add_dates(t, 'archdesc/')
28
- add_searchable_notes(t, 'archdesc/')
29
- end
30
-
31
- def to_solr(solr_doc = {})
32
- super
33
- solr_doc['id'] = Arclight::NormalizedId.new(eadid.first).to_s
34
- solr_doc['creator_sort'] = creator.to_a.join(', ') if creator.present?
35
- add_document_fields(solr_doc)
36
- solr_doc
37
- end
38
-
39
- private
40
-
41
- def add_document_fields(solr_doc)
42
- arclight_field_definitions.each do |field|
43
- # we want to use `set_field` rather than `insert_field` since we may be overriding fields
44
- Solrizer.set_field(solr_doc, field[:name], field[:value], field[:index_as])
45
- end
46
-
47
- add_date_ranges(solr_doc)
48
- add_digital_content(prefix: 'ead/archdesc', solr_doc: solr_doc)
49
- add_normalized_titles(solr_doc)
50
- end
51
-
52
- def add_normalized_titles(solr_doc)
53
- title = add_normalized_title(solr_doc)
54
- Solrizer.set_field(solr_doc, 'collection', title, :facetable)
55
- Solrizer.set_field(solr_doc, 'collection', title, :displayable)
56
- end
57
-
58
- def arclight_field_definitions
59
- [
60
- { name: 'level', value: 'collection', index_as: :displayable },
61
- { name: 'level', value: 'Collection', index_as: :facetable },
62
- { name: 'names', value: names, index_as: :symbol },
63
- { name: 'access_subjects', value: access_subjects, index_as: :symbol },
64
- { name: 'creators', value: creators, index_as: :symbol },
65
- { name: 'has_online_content', value: online_content?, index_as: :symbol },
66
- { name: 'repository', value: repository_as_configured(repository), index_as: :displayable },
67
- { name: 'repository', value: repository_as_configured(repository), index_as: :facetable },
68
- { name: 'names_coll', value: names_coll, index_as: :symbol }
69
- ]
70
- end
71
-
72
- def names
73
- [corpname, famname, name, persname].flatten.compact.uniq - repository
74
- end
75
-
76
- def names_coll
77
- names_array(%w[corpname famname name persname], parent: 'archdesc')
78
- end
79
-
80
- def creators
81
- [creator_persname, creator_corpname, creator_famname].flatten.compact.uniq - repository
82
- end
83
-
84
- # Combine subjets into one group from
85
- # <controlaccess/><subject></subject>
86
- # <controlaccess/><function></function>
87
- # <controlaccess/><genreform></genreform>
88
- # <controlaccess/><occupation></occupation>
89
- def access_subjects
90
- subjects_array(%w[subject function occupation genreform], parent: 'archdesc')
91
- end
92
- end
93
- end