diff --git a/app/components/earthworks/alert_component.html.erb b/app/components/alert_component.html.erb
similarity index 100%
rename from app/components/earthworks/alert_component.html.erb
rename to app/components/alert_component.html.erb
diff --git a/app/components/alert_component.rb b/app/components/alert_component.rb
new file mode 100644
index 00000000..79261804
--- /dev/null
+++ b/app/components/alert_component.rb
@@ -0,0 +1,18 @@
+class AlertComponent < ViewComponent::Base
+ attr_reader :title, :body, :type, :icon
+
+ def initialize(body:, type:, title: nil)
+ super
+ @title = title
+ @body = body
+ @type = type
+ @icon = match_icon
+ end
+
+ def match_icon
+ icon_mapping = { 'info' => 'bi-info-circle-fill', 'warning' => 'bi-exclamation-triangle-fill',
+ 'danger' => 'bi-exclamation-triangle-fill', 'sucess' => 'bi-check-circle-fill',
+ 'note' => 'bi-exclamation-circle-fill' }
+ icon_mapping[type]
+ end
+end
diff --git a/app/components/earthworks/also_available_component.html.erb b/app/components/also_available_component.html.erb
similarity index 100%
rename from app/components/earthworks/also_available_component.html.erb
rename to app/components/also_available_component.html.erb
diff --git a/app/components/also_available_component.rb b/app/components/also_available_component.rb
new file mode 100644
index 00000000..8e24c97c
--- /dev/null
+++ b/app/components/also_available_component.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+# Display also available as links in sidebar
+class AlsoAvailableComponent < ViewComponent::Base
+ attr_reader :document
+
+ def initialize(document:)
+ @document = document
+ super
+ end
+
+ # a list of all the available other urls for the document
+ def also_available_links
+ { SearchWorks: document.searchworks_url }.compact_blank
+ end
+
+ def render?
+ also_available_links.present?
+ end
+end
diff --git a/app/components/earthworks/code_snippet_link_component.html.erb b/app/components/code_snippet_link_component.html.erb
similarity index 100%
rename from app/components/earthworks/code_snippet_link_component.html.erb
rename to app/components/code_snippet_link_component.html.erb
diff --git a/app/components/code_snippet_link_component.rb b/app/components/code_snippet_link_component.rb
new file mode 100644
index 00000000..35c2f956
--- /dev/null
+++ b/app/components/code_snippet_link_component.rb
@@ -0,0 +1,7 @@
+# Display link that triggers modal with code snippet content
+class CodeSnippetLinkComponent < ViewComponent::Base
+ # Do not display the link to code snippets if the document is restricted
+ def key
+ 'code_snippet_link'
+ end
+end
diff --git a/app/components/earthworks/code_snippet_modal_component.html.erb b/app/components/code_snippet_modal_component.html.erb
similarity index 100%
rename from app/components/earthworks/code_snippet_modal_component.html.erb
rename to app/components/code_snippet_modal_component.html.erb
diff --git a/app/components/code_snippet_modal_component.rb b/app/components/code_snippet_modal_component.rb
new file mode 100644
index 00000000..37cf7c01
--- /dev/null
+++ b/app/components/code_snippet_modal_component.rb
@@ -0,0 +1,130 @@
+# frozen_string_literal: true
+
+class CodeSnippetModalComponent < ViewComponent::Base
+ def initialize(document)
+ @document = document
+ @raster_data_type = raster_data?
+ @vector_data_type = vector_data?
+ super
+ end
+
+ def code_block(content)
+ sanitize "
#{h content}
"
+ end
+
+ def render_python
+ substitute_values(retrieve_text('Python'))
+ end
+
+ def render_r
+ substitute_values(retrieve_text('R'))
+ end
+
+ def render_leaflet
+ substitute_values(retrieve_text('Leaflet'))
+ end
+
+ # Incorporate
+ def substitute_values(content)
+ sub_content = content
+
+ # replace WXS_ID
+ sub_content = sub_content.gsub('<>',
+ substitute_id_value(@document.wxs_identifier, '[Insert Web Services ID]'))
+
+ # If layer id is required
+ sub_content = sub_content.gsub('<>',
+ substitute_id_value(layer_id, '[Insert Layer ID]'))
+
+ # replace WMS reference
+ sub_content = sub_content.gsub('<>',
+ substitute_webservice_value(@document.references.wms, '[Insert WMS endpoint]'))
+
+ # replace WFS reference
+ sub_content = sub_content.gsub('<>',
+ substitute_webservice_value(@document.references.wfs, '[Insert WFS endpoint]'))
+
+ # Replace Bounding box information
+ if @document.geom_field.blank? || @document.geometry.geom.blank?
+ # If geometry information is not available, subsitute the coordinates with placeholder text
+ sub_content = sub_content.gsub('<>', '[Insert bounding box min X value]')
+ sub_content = sub_content.gsub('<>', '[Insert bounding box min Y value]')
+ sub_content = sub_content.gsub('<>', '[Insert bounding box max X value]')
+ sub_content = sub_content.gsub('<>', '[Insert bounding box max Y value]')
+ else
+ geometry = @document.geometry.geom
+ bbox_array = geometry.split('ENVELOPE(')[1].split(')')[0].split(',').map(&:strip)
+
+ if bbox_array.length == 4
+ min_x = bbox_array[0]
+ max_x = bbox_array[1]
+ min_y = bbox_array[2]
+ max_y = bbox_array[3]
+
+ sub_content = sub_content.gsub('<>', min_x)
+ sub_content = sub_content.gsub('<>', min_y)
+ sub_content = sub_content.gsub('<>', max_x)
+ sub_content = sub_content.gsub('<>', max_y)
+ end
+ end
+ sub_content
+ end
+
+ def layer_id
+ # If the Solr document has a wxs_identifier field, handle two cases:
+ # if the string has 'druid:', return the portion after this prefix.
+ # Otherwise, return the whole string. The latter case is for other institutions' data.
+ if @document.wxs_identifier.present?
+ wxs_id = @document.wxs_identifier
+ return wxs_id.include?('druid:') ? wxs_id.split('druid:')[1] : wxs_id
+ end
+
+ nil
+ end
+
+ def substitute_id_value(value, placeholder_value)
+ value.presence || placeholder_value
+ end
+
+ def substitute_webservice_value(webservice, placeholder_value)
+ webservice.nil? || webservice.endpoint.nil? ? placeholder_value : webservice.endpoint
+ end
+
+ private
+
+ # Get the code sample text based on the data type and programming language
+ def retrieve_text(language)
+ file_name = code_sample_file_name(language)
+ return if file_name.empty?
+
+ File.read(Rails.root.join('config', 'code_samples', file_name).to_s).to_s
+ end
+
+ def vector_data?
+ return false unless @document.key?(Settings.FIELDS.RESOURCE_TYPE)
+
+ vector_types = ['polygon data', 'point data', 'line data', 'index maps',
+ 'vector data']
+
+ # If the intersection of these arrays is not empty, then there is at least one vector type value
+ !(@document[Settings.FIELDS.RESOURCE_TYPE].map(&:downcase) &
+ vector_types).empty?
+ end
+
+ def raster_data?
+ return false unless @document.key?(Settings.FIELDS.RESOURCE_TYPE)
+
+ @document[Settings.FIELDS.RESOURCE_TYPE].map(&:downcase).include?('raster data')
+ end
+
+ def code_sample_file_name(language)
+ case language
+ when 'Python'
+ @vector_data_type ? 'vector_python.txt' : 'raster_python.txt'
+ when 'Leaflet'
+ @vector_data_type ? 'vector_leaflet.txt' : 'raster_leaflet.txt'
+ when 'R'
+ @vector_data_type ? 'vector_r.txt' : 'raster_r.txt'
+ end
+ end
+end
diff --git a/app/components/earthworks/document/sidebar_component.html.erb b/app/components/document/sidebar_component.html.erb
similarity index 100%
rename from app/components/earthworks/document/sidebar_component.html.erb
rename to app/components/document/sidebar_component.html.erb
diff --git a/app/components/document/sidebar_component.rb b/app/components/document/sidebar_component.rb
new file mode 100644
index 00000000..8fae3645
--- /dev/null
+++ b/app/components/document/sidebar_component.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+# Render the sidebar on the show view
+module Document
+ class SidebarComponent < Geoblacklight::Document::SidebarComponent
+ def components
+ [
+ Geoblacklight::LoginLinkComponent.new(document: document),
+ Geoblacklight::StaticMapComponent.new(document: document),
+ DownloadLinksComponent.new(document: document),
+ AlsoAvailableComponent.new(document: document)
+ ]
+ end
+ end
+end
diff --git a/app/components/earthworks/document_component.html.erb b/app/components/document_component.html.erb
similarity index 87%
rename from app/components/earthworks/document_component.html.erb
rename to app/components/document_component.html.erb
index 77ddba64..003d1742 100644
--- a/app/components/earthworks/document_component.html.erb
+++ b/app/components/document_component.html.erb
@@ -1,6 +1,6 @@
<%= title %>
- <%= render Earthworks::HeaderIconsComponent.new(document: @document) %>
+ <%= render HeaderIconsComponent.new(document: @document) %>
<%= content_tag @component,
id: @id,
@@ -43,9 +43,9 @@
<% if (@document.image? || @document.item_viewer.iiif) && !@document[Settings.FIELDS[:GEOREFERENCED]] %>
- <%= render Earthworks::AlertComponent.new(type: 'info', body: t('earthworks.show.no_georeference_message')) %>
+ <%= render AlertComponent.new(type: 'info', body: t('earthworks.show.no_georeference_message')) %>
<% end %>
<%= render Geoblacklight::ViewerContainerComponent.new(document: @document) %>
<%= render Geoblacklight::AttributeTableComponent.new(document: @document) %>
<%= render Geoblacklight::IndexMapInspectComponent.new(document: @document) %>
-
\ No newline at end of file
+
diff --git a/app/components/document_component.rb b/app/components/document_component.rb
new file mode 100644
index 00000000..cf8431e5
--- /dev/null
+++ b/app/components/document_component.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class DocumentComponent < Geoblacklight::DocumentComponent
+end
diff --git a/app/components/earthworks/download_links_component.html.erb b/app/components/download_links_component.html.erb
similarity index 100%
rename from app/components/earthworks/download_links_component.html.erb
rename to app/components/download_links_component.html.erb
diff --git a/app/components/download_links_component.rb b/app/components/download_links_component.rb
new file mode 100644
index 00000000..d43a8520
--- /dev/null
+++ b/app/components/download_links_component.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+# Display expandable file download links in sidebar
+class DownloadLinksComponent < Geoblacklight::DownloadLinksComponent
+ def download_link_file(label, id, url)
+ link_to(
+ label,
+ url,
+ 'contentUrl' => url,
+ :class => 'btn btn-primary',
+ :data => {
+ download: 'trigger',
+ download_type: 'direct',
+ download_id: id
+ }
+ )
+ end
+
+ # Generates the link markup for the IIIF JPEG download
+ # @return [String]
+ def download_link_iiif
+ link_to(
+ download_text('JPG'),
+ iiif_jpg_url,
+ 'contentUrl' => iiif_jpg_url,
+ :class => 'btn btn-primary',
+ :data => {
+ download: 'trigger'
+ }
+ )
+ end
+end
diff --git a/app/components/earthworks/alert_component.rb b/app/components/earthworks/alert_component.rb
deleted file mode 100644
index 19dff49a..00000000
--- a/app/components/earthworks/alert_component.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-module Earthworks
- class AlertComponent < ViewComponent::Base
- attr_reader :title, :body, :type, :icon
-
- def initialize(body:, type:, title: nil)
- super
- @title = title
- @body = body
- @type = type
- @icon = match_icon
- end
-
- def match_icon
- icon_mapping = { 'info' => 'bi-info-circle-fill', 'warning' => 'bi-exclamation-triangle-fill',
- 'danger' => 'bi-exclamation-triangle-fill', 'sucess' => 'bi-check-circle-fill',
- 'note' => 'bi-exclamation-circle-fill' }
- icon_mapping[type]
- end
- end
-end
diff --git a/app/components/earthworks/also_available_component.rb b/app/components/earthworks/also_available_component.rb
deleted file mode 100644
index a394b03d..00000000
--- a/app/components/earthworks/also_available_component.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- # Display also available as links in sidebar
- class AlsoAvailableComponent < ViewComponent::Base
- attr_reader :document
-
- def initialize(document:)
- @document = document
- super
- end
-
- # a list of all the available other urls for the document
- def also_available_links
- { SearchWorks: document.searchworks_url }.compact_blank
- end
-
- def render?
- also_available_links.present?
- end
- end
-end
diff --git a/app/components/earthworks/code_snippet_link_component.rb b/app/components/earthworks/code_snippet_link_component.rb
deleted file mode 100644
index b1defa19..00000000
--- a/app/components/earthworks/code_snippet_link_component.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module Earthworks
- # Display link that triggers modal with code snippet content
- class CodeSnippetLinkComponent < ViewComponent::Base
- # Do not display the link to code snippets if the document is restricted
- def key
- 'code_snippet_link'
- end
- end
-end
diff --git a/app/components/earthworks/code_snippet_modal_component.rb b/app/components/earthworks/code_snippet_modal_component.rb
deleted file mode 100644
index 07785753..00000000
--- a/app/components/earthworks/code_snippet_modal_component.rb
+++ /dev/null
@@ -1,132 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- class CodeSnippetModalComponent < ViewComponent::Base
- def initialize(document)
- @document = document
- @raster_data_type = raster_data?
- @vector_data_type = vector_data?
- super
- end
-
- def code_block(content)
- sanitize "#{h content}
"
- end
-
- def render_python
- substitute_values(retrieve_text('Python'))
- end
-
- def render_r
- substitute_values(retrieve_text('R'))
- end
-
- def render_leaflet
- substitute_values(retrieve_text('Leaflet'))
- end
-
- # Incorporate
- def substitute_values(content)
- sub_content = content
-
- # replace WXS_ID
- sub_content = sub_content.gsub('<>',
- substitute_id_value(@document.wxs_identifier, '[Insert Web Services ID]'))
-
- # If layer id is required
- sub_content = sub_content.gsub('<>',
- substitute_id_value(layer_id, '[Insert Layer ID]'))
-
- # replace WMS reference
- sub_content = sub_content.gsub('<>',
- substitute_webservice_value(@document.references.wms, '[Insert WMS endpoint]'))
-
- # replace WFS reference
- sub_content = sub_content.gsub('<>',
- substitute_webservice_value(@document.references.wfs, '[Insert WFS endpoint]'))
-
- # Replace Bounding box information
- if @document.geom_field.blank? || @document.geometry.geom.blank?
- # If geometry information is not available, subsitute the coordinates with placeholder text
- sub_content = sub_content.gsub('<>', '[Insert bounding box min X value]')
- sub_content = sub_content.gsub('<>', '[Insert bounding box min Y value]')
- sub_content = sub_content.gsub('<>', '[Insert bounding box max X value]')
- sub_content = sub_content.gsub('<>', '[Insert bounding box max Y value]')
- else
- geometry = @document.geometry.geom
- bbox_array = geometry.split('ENVELOPE(')[1].split(')')[0].split(',').map(&:strip)
-
- if bbox_array.length == 4
- min_x = bbox_array[0]
- max_x = bbox_array[1]
- min_y = bbox_array[2]
- max_y = bbox_array[3]
-
- sub_content = sub_content.gsub('<>', min_x)
- sub_content = sub_content.gsub('<>', min_y)
- sub_content = sub_content.gsub('<>', max_x)
- sub_content = sub_content.gsub('<>', max_y)
- end
- end
- sub_content
- end
-
- def layer_id
- # If the Solr document has a wxs_identifier field, handle two cases:
- # if the string has 'druid:', return the portion after this prefix.
- # Otherwise, return the whole string. The latter case is for other institutions' data.
- if @document.wxs_identifier.present?
- wxs_id = @document.wxs_identifier
- return wxs_id.include?('druid:') ? wxs_id.split('druid:')[1] : wxs_id
- end
-
- nil
- end
-
- def substitute_id_value(value, placeholder_value)
- value.presence || placeholder_value
- end
-
- def substitute_webservice_value(webservice, placeholder_value)
- webservice.nil? || webservice.endpoint.nil? ? placeholder_value : webservice.endpoint
- end
-
- private
-
- # Get the code sample text based on the data type and programming language
- def retrieve_text(language)
- file_name = code_sample_file_name(language)
- return if file_name.empty?
-
- File.read(Rails.root.join('config', 'code_samples', file_name).to_s).to_s
- end
-
- def vector_data?
- return false unless @document.key?(Settings.FIELDS.RESOURCE_TYPE)
-
- vector_types = ['polygon data', 'point data', 'line data', 'index maps',
- 'vector data']
-
- # If the intersection of these arrays is not empty, then there is at least one vector type value
- !(@document[Settings.FIELDS.RESOURCE_TYPE].map(&:downcase) &
- vector_types).empty?
- end
-
- def raster_data?
- return false unless @document.key?(Settings.FIELDS.RESOURCE_TYPE)
-
- @document[Settings.FIELDS.RESOURCE_TYPE].map(&:downcase).include?('raster data')
- end
-
- def code_sample_file_name(language)
- case language
- when 'Python'
- @vector_data_type ? 'vector_python.txt' : 'raster_python.txt'
- when 'Leaflet'
- @vector_data_type ? 'vector_leaflet.txt' : 'raster_leaflet.txt'
- when 'R'
- @vector_data_type ? 'vector_r.txt' : 'raster_r.txt'
- end
- end
- end
-end
diff --git a/app/components/earthworks/document/sidebar_component.rb b/app/components/earthworks/document/sidebar_component.rb
deleted file mode 100644
index 6584b1ee..00000000
--- a/app/components/earthworks/document/sidebar_component.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- # Render the sidebar on the show view
- module Document
- class SidebarComponent < Geoblacklight::Document::SidebarComponent
- def components
- [
- Geoblacklight::LoginLinkComponent.new(document: document),
- Geoblacklight::StaticMapComponent.new(document: document),
- Earthworks::DownloadLinksComponent.new(document: document),
- Earthworks::AlsoAvailableComponent.new(document: document)
- ]
- end
- end
- end
-end
diff --git a/app/components/earthworks/document_component.rb b/app/components/earthworks/document_component.rb
deleted file mode 100644
index f82c3035..00000000
--- a/app/components/earthworks/document_component.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- class DocumentComponent < Geoblacklight::DocumentComponent
- def classes
- [
- @classes,
- helpers.render_document_class(@document),
- 'document',
- 'col-lg-6',
- ("document-position-#{@counter}" if @counter)
- ].compact.flatten
- end
- end
-end
diff --git a/app/components/earthworks/download_links_component.rb b/app/components/earthworks/download_links_component.rb
deleted file mode 100644
index 325bd36f..00000000
--- a/app/components/earthworks/download_links_component.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- # Display expandable file download links in sidebar
- class DownloadLinksComponent < Geoblacklight::DownloadLinksComponent
- def download_link_file(label, id, url)
- link_to(
- label,
- url,
- 'contentUrl' => url,
- :class => 'btn btn-primary',
- :data => {
- download: 'trigger',
- download_type: 'direct',
- download_id: id
- }
- )
- end
-
- # Generates the link markup for the IIIF JPEG download
- # @return [String]
- def download_link_iiif
- link_to(
- download_text('JPG'),
- iiif_jpg_url,
- 'contentUrl' => iiif_jpg_url,
- :class => 'btn btn-primary',
- :data => {
- download: 'trigger'
- }
- )
- end
- end
-end
diff --git a/app/components/earthworks/header_icons_component.rb b/app/components/earthworks/header_icons_component.rb
deleted file mode 100644
index eab4eee5..00000000
--- a/app/components/earthworks/header_icons_component.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- class HeaderIconsComponent < Geoblacklight::HeaderIconsComponent
- def get_icon(field)
- icon_name = @document[field]
- if icon_name&.include?('Datasets') && @document[Settings.FIELDS.RESOURCE_TYPE]
- specific_icon = @document[Settings.FIELDS.RESOURCE_TYPE]
- specific_icon = specific_icon.first if specific_icon.is_a?(Array)
- specific_icon = specific_icon&.gsub(' data', '')
- icon = geoblacklight_icon(specific_icon)
- return [icon, specific_icon] unless icon.include?('icon-missing')
- end
- icon_name = icon_name.first if icon_name.is_a?(Array)
- [geoblacklight_icon(icon_name), icon_name]
- end
- end
-end
diff --git a/app/components/earthworks/recently_added_list.rb b/app/components/earthworks/recently_added_list.rb
deleted file mode 100644
index df525ce5..00000000
--- a/app/components/earthworks/recently_added_list.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- class RecentlyAddedList < ViewComponent::Base
- attr_reader :count, :docs, :type, :field, :term
-
- def initialize(term:, additional_fq: '', rows: 4, field: 'gbl_resourceClass_sm')
- super
- @fq = ["#{field}:#{term}"] + [additional_fq]
- @field = field
- @rows = rows
- @sort = 'gbl_mdModified_dt desc'
- response = results['response']
- @docs = response['docs']
- @count = response['numFound']
- @term = term
- @type = term.downcase
- end
-
- def search_params
- {
- 'fq' => @fq,
- 'sort' => @sort,
- 'rows' => @rows,
- 'fl' => [Settings.FIELDS.TITLE, Settings.FIELDS.ID, Settings.FIELDS.RESOURCE_TYPE]
- }
- end
-
- def results
- solr = RSolr.connect url: Blacklight.connection_config[:url]
- @results = solr.get 'select', params: search_params
- end
- end
-end
diff --git a/app/components/earthworks/search_bar_component.rb b/app/components/earthworks/search_bar_component.rb
deleted file mode 100644
index acc15f5e..00000000
--- a/app/components/earthworks/search_bar_component.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- class SearchBarComponent < Blacklight::SearchBarComponent
- def search_button
- render Earthworks::SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit'))
- end
- end
-end
diff --git a/app/components/earthworks/search_button_component.rb b/app/components/earthworks/search_button_component.rb
deleted file mode 100644
index 762c50cf..00000000
--- a/app/components/earthworks/search_button_component.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- class SearchButtonComponent < Blacklight::SearchButtonComponent
- def call
- tag.button(class: 'btn btn-primary search-btn', type: 'submit', id: @id) do
- tag.span(@text, class: 'submit-search-text')
- end
- end
- end
-end
diff --git a/app/components/earthworks/search_result_component.rb b/app/components/earthworks/search_result_component.rb
deleted file mode 100644
index 4ab2a1fa..00000000
--- a/app/components/earthworks/search_result_component.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- class SearchResultComponent < Geoblacklight::SearchResultComponent
- def classes
- [
- @classes,
- helpers.render_document_class(@document),
- 'document',
- 'p-2',
- 'mt-0',
- ("document-position-#{@counter}" if @counter)
- ].compact.flatten
- end
- end
-end
diff --git a/app/components/earthworks/server_applied_params_component.rb b/app/components/earthworks/server_applied_params_component.rb
deleted file mode 100644
index d371d8a2..00000000
--- a/app/components/earthworks/server_applied_params_component.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-module Earthworks
- class ServerAppliedParamsComponent < Blacklight::SearchContext::ServerAppliedParamsComponent
- end
-end
diff --git a/app/components/earthworks/header_icons_component.html.erb b/app/components/header_icons_component.html.erb
similarity index 100%
rename from app/components/earthworks/header_icons_component.html.erb
rename to app/components/header_icons_component.html.erb
diff --git a/app/components/header_icons_component.rb b/app/components/header_icons_component.rb
new file mode 100644
index 00000000..481d130e
--- /dev/null
+++ b/app/components/header_icons_component.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class HeaderIconsComponent < Geoblacklight::HeaderIconsComponent
+ def get_icon(field)
+ icon_name = @document[field]
+ if icon_name&.include?('Datasets') && @document[Settings.FIELDS.RESOURCE_TYPE]
+ specific_icon = @document[Settings.FIELDS.RESOURCE_TYPE]
+ specific_icon = specific_icon.first if specific_icon.is_a?(Array)
+ specific_icon = specific_icon&.gsub(' data', '')
+ icon = geoblacklight_icon(specific_icon)
+ return [icon, specific_icon] unless icon.include?('icon-missing')
+ end
+ icon_name = icon_name.first if icon_name.is_a?(Array)
+ [geoblacklight_icon(icon_name), icon_name]
+ end
+end
diff --git a/app/components/earthworks/recently_added_list.html.erb b/app/components/recently_added_list.html.erb
similarity index 100%
rename from app/components/earthworks/recently_added_list.html.erb
rename to app/components/recently_added_list.html.erb
diff --git a/app/components/recently_added_list.rb b/app/components/recently_added_list.rb
new file mode 100644
index 00000000..d01961f2
--- /dev/null
+++ b/app/components/recently_added_list.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class RecentlyAddedList < ViewComponent::Base
+ attr_reader :count, :docs, :type, :field, :term
+
+ def initialize(term:, additional_fq: '', rows: 4, field: 'gbl_resourceClass_sm')
+ super
+ @fq = ["#{field}:#{term}"] + [additional_fq]
+ @field = field
+ @rows = rows
+ @sort = 'gbl_mdModified_dt desc'
+ response = results['response']
+ @docs = response['docs']
+ @count = response['numFound']
+ @term = term
+ @type = term.downcase
+ end
+
+ def search_params
+ {
+ 'fq' => @fq,
+ 'sort' => @sort,
+ 'rows' => @rows,
+ 'fl' => [Settings.FIELDS.TITLE, Settings.FIELDS.ID, Settings.FIELDS.RESOURCE_TYPE]
+ }
+ end
+
+ def results
+ solr = RSolr.connect url: Blacklight.connection_config[:url]
+ @results = solr.get 'select', params: search_params
+ end
+end
diff --git a/app/components/search_bar_component.rb b/app/components/search_bar_component.rb
new file mode 100644
index 00000000..2faefea5
--- /dev/null
+++ b/app/components/search_bar_component.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class SearchBarComponent < Blacklight::SearchBarComponent
+ def search_button
+ render SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit'))
+ end
+end
diff --git a/app/components/search_button_component.rb b/app/components/search_button_component.rb
new file mode 100644
index 00000000..ce3fd4cc
--- /dev/null
+++ b/app/components/search_button_component.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class SearchButtonComponent < Blacklight::SearchButtonComponent
+ def call
+ tag.button(class: 'btn btn-primary search-btn', type: 'submit', id: @id) do
+ tag.span(@text, class: 'submit-search-text')
+ end
+ end
+end
diff --git a/app/components/earthworks/search_result_component.html.erb b/app/components/search_result_component.html.erb
similarity index 91%
rename from app/components/earthworks/search_result_component.html.erb
rename to app/components/search_result_component.html.erb
index 864e512a..e1150111 100644
--- a/app/components/earthworks/search_result_component.html.erb
+++ b/app/components/search_result_component.html.erb
@@ -1,5 +1,5 @@
-<%# This template copies from Blacklight's components/document_component.html.erb
+<%# This template copies from Blacklight's components/document_component.html.erb
# for the wrapping `content_tag @component` structure
# and adds custom layout within for the document header, status-icons and more-info areas %>
@@ -17,7 +17,7 @@
<%= content_tag :div, class: 'row index-split d-flex flex-grow-1 flex-column me-2', data: { layer_id: @document.id, geom: @document.geometry.geojson } do %>
<%= title %>
- <%= render Earthworks::HeaderIconsComponent.new(document: @document) %>
+ <%= render HeaderIconsComponent.new(document: @document) %>
<% end %>
<% end %>
@@ -28,4 +28,4 @@
-
\ No newline at end of file
+
diff --git a/app/components/search_result_component.rb b/app/components/search_result_component.rb
new file mode 100644
index 00000000..a2b616d6
--- /dev/null
+++ b/app/components/search_result_component.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class SearchResultComponent < Geoblacklight::SearchResultComponent
+ def classes
+ [
+ @classes,
+ helpers.render_document_class(@document),
+ 'document',
+ 'p-2',
+ 'mt-0',
+ ("document-position-#{@counter}" if @counter)
+ ].compact.flatten
+ end
+end
diff --git a/app/components/earthworks/server_applied_params_component.html.erb b/app/components/server_applied_params_component.html.erb
similarity index 100%
rename from app/components/earthworks/server_applied_params_component.html.erb
rename to app/components/server_applied_params_component.html.erb
diff --git a/app/components/server_applied_params_component.rb b/app/components/server_applied_params_component.rb
new file mode 100644
index 00000000..5768b4ac
--- /dev/null
+++ b/app/components/server_applied_params_component.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class ServerAppliedParamsComponent < Blacklight::SearchContext::ServerAppliedParamsComponent
+end
diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb
index 09a9d18e..10e9ef78 100644
--- a/app/controllers/catalog_controller.rb
+++ b/app/controllers/catalog_controller.rb
@@ -38,21 +38,21 @@ class CatalogController < ApplicationController
# config.index.show_link = 'title_display'
# config.index.record_display_type = 'format'
- config.index.document_component = Earthworks::SearchResultComponent
+ config.index.document_component = SearchResultComponent
config.index.title_field = Settings.FIELDS.TITLE
- config.index.search_bar_component = Earthworks::SearchBarComponent
+ config.index.search_bar_component = SearchBarComponent
config.bookmark_icon_component = Blacklight::Icons::BookmarkIconComponent
- config.track_search_session.applied_params_component = Earthworks::ServerAppliedParamsComponent
+ config.track_search_session.applied_params_component = ServerAppliedParamsComponent
config.crawler_detector = ->(req) { req.env['HTTP_USER_AGENT']&.include?('bot') }
# solr field configuration for document/show views
config.show.display_type_field = 'format'
- config.show.sidebar_component = Earthworks::Document::SidebarComponent
- config.show.document_component = Earthworks::DocumentComponent
+ config.show.sidebar_component = Document::SidebarComponent
+ config.show.document_component = DocumentComponent
config.show.metadata_component = DocumentMetadataComponent
config.header_component = Geoblacklight::HeaderComponent
@@ -323,12 +323,11 @@ class CatalogController < ApplicationController
(Settings.METADATA_SHOWN &
options[:document].references.refs.map { |x| x.type.to_s }).any?
}
- config.add_show_tools_partial :code_snippet_link, component: Earthworks::CodeSnippetLinkComponent,
+ config.add_show_tools_partial :code_snippet_link, component: CodeSnippetLinkComponent,
if: proc { |_context, _config, options|
options[:document] &&
!options[:document].restricted?
}
-
config.show.document_actions.delete(:sms)
config.add_show_header_tools_partial(:bookmark, partial: 'bookmark_control', if: :render_bookmarks_control?)
diff --git a/app/views/catalog/_home_text.html.erb b/app/views/catalog/_home_text.html.erb
index 0231250a..def79a2c 100644
--- a/app/views/catalog/_home_text.html.erb
+++ b/app/views/catalog/_home_text.html.erb
@@ -8,12 +8,12 @@
autocomplete_path: suggest_index_catalog_path
) %>
- <%= render Earthworks::RecentlyAddedList.new(term: 'Datasets') %>
+ <%= render RecentlyAddedList.new(term: 'Datasets') %>
- <%= render Earthworks::RecentlyAddedList.new(additional_fq: '-gbl_resourceClass_sm: Datasets', term: 'Maps') %>
+ <%= render RecentlyAddedList.new(additional_fq: '-gbl_resourceClass_sm: Datasets', term: 'Maps') %>
<%= render(Geoblacklight::LocationLeafletMapComponent.new(page: 'home', geosearch: { dynamic: false })) %>
-
\ No newline at end of file
+
diff --git a/app/views/catalog/code_snippet.html.erb b/app/views/catalog/code_snippet.html.erb
index 748baae4..ad6195f4 100644
--- a/app/views/catalog/code_snippet.html.erb
+++ b/app/views/catalog/code_snippet.html.erb
@@ -1 +1 @@
-<%= render Earthworks::CodeSnippetModalComponent.new(@docs.first) %>
\ No newline at end of file
+<%= render CodeSnippetModalComponent.new(@docs.first) %>
diff --git a/app/views/layouts/catalog_result.html.erb b/app/views/layouts/catalog_result.html.erb
index 38ef7373..8dd1ca0f 100644
--- a/app/views/layouts/catalog_result.html.erb
+++ b/app/views/layouts/catalog_result.html.erb
@@ -5,10 +5,10 @@
-
+
<% end %>
-<%= render template: "layouts/blacklight/base" %>
\ No newline at end of file
+<%= render template: "layouts/blacklight/base" %>
diff --git a/spec/components/earthworks/code_snippet_modal_component_spec.rb b/spec/components/code_snippet_modal_component_spec.rb
similarity index 98%
rename from spec/components/earthworks/code_snippet_modal_component_spec.rb
rename to spec/components/code_snippet_modal_component_spec.rb
index a9442d42..1ddfc8fe 100644
--- a/spec/components/earthworks/code_snippet_modal_component_spec.rb
+++ b/spec/components/code_snippet_modal_component_spec.rb
@@ -3,7 +3,7 @@
require 'rails_helper'
require 'spec_helper'
-RSpec.describe Earthworks::CodeSnippetModalComponent, type: :component do
+RSpec.describe CodeSnippetModalComponent, type: :component do
subject(:rendered) do
render_inline(described_class.new(document))
end