diff --git a/.env b/.env index 05662c30..7cd4c90c 100644 --- a/.env +++ b/.env @@ -9,8 +9,10 @@ POSTGRES_PASSWORD=DatabaseFTW POSTGRES_USER=postgres REGISTRY_HOST=ghcr.io REGISTRY_URI=/scientist-softserv/arce -SITE_URI=web.oh.staging.notch8network.com +SITE_URI=https://arce-staging.notch8.cloud SOLR_URL=http://solr:8983/solr/blacklight-core TAG=dev TEST_DB=arce_test -IIIF_URL=http://web.arce.staging.notch8network.com \ No newline at end of file +IIIF_URL=http://web.arce.staging.notch8network.com +ROOT_URL=http://arce.test # need this for the URLs for related items. Will need to add to staging and prod envs +``` \ No newline at end of file diff --git a/.gitignore b/.gitignore index ead16aac..99cb7ce2 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ /public/packs-test /node_modules public/packs/* +public/assets/* .DS_Store .env.* .env.* diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index a50defae..47ea2ef9 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -133,9 +133,9 @@ class CatalogController < ApplicationController config.add_show_field 'copyright_status_t', label: 'Copyright Status', highlight: true config.add_show_field 'note_license_t', label: 'Creative Commons License', highlight: true, helper_method: 'external_link' config.add_show_field 'note_rights_t', label: 'Rights Statement', highlight: true - config.add_show_field 'file_name_t', label: 'Local ID', highlight: true config.add_show_field 'project_history_t', label: 'Project History' config.add_show_field 'note_funding_t', label: 'Funding Agency' + config.add_show_field 'related_items_t', label: 'Related Items' # config.add_show_field 'resource_preview_t', label: 'Image preview url' config.add_show_field 'resource_url_t', label: 'Resource url' diff --git a/app/models/arce_item.rb b/app/models/arce_item.rb index a026e163..89aa77ce 100644 --- a/app/models/arce_item.rb +++ b/app/models/arce_item.rb @@ -24,22 +24,22 @@ def self.index_logger end def self.client(args) - url = args[:url] || "https://dl.library.ucla.edu/oai2/" + url = args[:url] || "https://digital.library.ucla.edu/catalog/oai/" OAI::Client.new url, :headers => { "From" => "rob@notch8.com" }, :parser => 'rexml', - metadata_prefix: 'mods', + metadata_prefix: 'mods_arce', verb: 'ListRecords' end def self.fetch(args) - set = args[:set] || "arce_1" - response = client(args).list_records(set: set, metadata_prefix: 'mods') + set = args[:set] || "oai_set_ssim:arce" + response = client(args).list_records(set: set, metadata_prefix: 'mods_arce') response end def self.get(args) - response = client(args).get_record(identifier: args[:identifier], metadata_prefix: 'mods') + response = client(args).get_record(identifier: args[:identifier], metadata_prefix: 'mods_arce') response end @@ -125,9 +125,11 @@ def self.process_record(record) end # rubocop:disable Metrics/LineLength - history = ArceItem.find_or_new(record.header.identifier.split(':').last) # Digest::MD5.hexdigest(record.header.identifier).to_i(16)) + record_id = record.header.identifier.split(':').last[1..-1].gsub('/', '-') + history = ArceItem.find_or_new(record_id) # rubocop:enable Metrics/LineLength - history.attributes['id_t'] = record.header.identifier.split(':').last + history.attributes['id_t'] = record_id + if record.header.datestamp history.attributes[:timestamp] = Time.parse(record.header.datestamp) end @@ -137,29 +139,6 @@ def self.process_record(record) batch.children.each do |child| next if child.class == REXML::Text - - if child.attributes['displayLabel'] == 'File name' - file_name = child.text - history.attributes['file_name_t'] ||= [] - if !history.attributes['file_name_t'].include?(file_name) - history.attributes['file_name_t'] << file_name - end - end - if child.name == 'identifier' - if child.attributes['type'] == 'local' - if child.attributes['displayLabel'] == "Local ID" - child.children.each do |ch| - next if ch.class == REXML::Text - - file_name = ch.text - history.attributes['file_name_t'] ||= [] - if !history.attributes['file_name_t'].include?(file_name) - history.attributes['file_name_t'] << file_name - end - end - end - end - end if child.name == 'relatedItem' if child.attributes['type'] == 'host' child.children.each do |ch| @@ -167,12 +146,13 @@ def self.process_record(record) ch.children.each do |c| next if c.class == REXML::Text - + collections_to_skip = ["Africa Collections", "Middle East & North Africa Collections"] if c.name == 'title' - history.attributes['collection_display'] ||= c.text - history.attributes['collection_facet'] ||= c.text - history.attributes['collection_sort'] ||= c.text - history.attributes['collection_t'] ||= c.text + byebug + history.attributes['collection_display'] = c.text unless collections_to_skip.include?(c.text) + history.attributes['collection_facet'] = c.text unless collections_to_skip.include?(c.text) + history.attributes['collection_sort'] = c.text unless collections_to_skip.include?(c.text) + history.attributes['collection_t'] = c.text unless collections_to_skip.include?(c.text) end end end @@ -191,6 +171,31 @@ def self.process_record(record) end end end + + if child.attributes['otherType'] == 'relatedTo' + child.children.each do |ch| + next if ch.class == REXML::Text + + ch.children.each do |c| + next if c.class == REXML::Text + history.attributes['related_items_display'] ||= [] + history.attributes['related_items_t'] ||= [] + if c.name == 'title' + related_items = c.text + related_items.gsub("digital.library.ucla.edu/catalog/ark:", "archives.arce.org/catalog/") + # https://digital.library.ucla.edu/catalog/ark:/21198/z1bc8zr8 + # http://arce.test/catalog/%2F21198%2Fz1kh5nht + if !history.attributes['related_items_t'].include?(related_items) + history.attributes['related_items_t'] << related_items + end + if !history.attributes['related_items_display'].include?(related_items) + history.attributes['related_items_display'] << related_items + end + end + end + end + end + if child.attributes['type'] == 'series' child.children.each do |ch| next if ch.class == REXML::Text diff --git a/app/views/catalog/_uv.html.erb b/app/views/catalog/_uv.html.erb index 44ab3462..f0b788bb 100644 --- a/app/views/catalog/_uv.html.erb +++ b/app/views/catalog/_uv.html.erb @@ -1,7 +1,7 @@