Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ docker compose logs updater db solr

# Rerun initialization when needed
docker compose run --rm updater

# Run db setup in test ENV
docker compose run --rm -e RAILS_ENV=test app rails db:setup
```

### Accessing services
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ task setup: %w[db:setup]
# Check (setup + coverage)

desc 'Set up, check test coverage'
task check: %w[setup geodata:index:seed spec]
task check: %w[setup geoblacklight:index:seed spec]

# clear rspec/rails default :spec task
Expand Down
7 changes: 0 additions & 7 deletions app/javascript/controllers/hello_controller.js

This file was deleted.

47 changes: 47 additions & 0 deletions app/javascript/geoblacklight/initializers/metadata_download.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intended to be different from the initializer javascript shipped with GeoBlacklight 5.3.0? why do we need to override it?

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export class GeoBlacklightMetadataDownloadButton {
constructor(el, i, options = {}) {
this.options = options
this.el = typeof el === "string" ? document.querySelector(el) : el
this.download = document.querySelector(this.options.target || this.el.getAttribute("data-ref-download"))
// On initialization only do this for the first one.
if (i === 0) {
this.setRefUrl()
}
this.configureHandler()
}

configureHandler() {
this.el.addEventListener("click", () => this.setRefUrl())
}

setRefUrl() {
const refUrl = this.el.getAttribute("data-ref-endpoint")
if (!refUrl) {
this.download.style.display = "none"
} else {
this.download.style.display = ""
this.download.setAttribute("href", refUrl)
}
}
}

export default function initializeMetadataDownload() {
const modal = document.getElementById("blacklight-modal")

// Use Blacklight's dialog-based modal dispatches these custom events
modal.addEventListener("show.blacklight.blacklight-modal", (e) => {
e.target.querySelectorAll(".metadata-body").forEach((el) => {
el.closest(".modal-content").classList.add("metadata-modal")
})

e.target.querySelectorAll(".pill-metadata").forEach((element, i) => {
new GeoBlacklightMetadataDownloadButton(element, i)
})
})

modal.addEventListener("hide.blacklight.blacklight-modal", (e) => {
e.target.querySelectorAll(".metadata-body").forEach((el) => {
el.closest(".modal-content").classList.remove("metadata-modal")
})
})
}
14 changes: 14 additions & 0 deletions app/views/catalog/metadata.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%= render Blacklight::System::ModalComponent.new do |component| %>
<% component.with_title do %>
<%= t('geoblacklight.metadata.view_metadata') %>
<% end %>
<% component.with_body do %>
<div class="modal-body metadata-body">
<%= render partial: 'metadata' %>
</div>
<% end %>
<% component.with_footer do %>
<a href="#" target="_blank" rel="noopener noreferrer" id="btn-metadata-download" class="btn btn-primary" aria-label="<%= t('geoblacklight.download.download_metadata_new_tab') %>">Download</a>
<button type="button" class="btn btn-secondary" data-bl-dismiss="modal"><%= t('blacklight.modal.close') %></button>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ services:

updater:
<<: *app
command: ["rails", "db:prepare", "css:build", "geoblacklight:index:seed"]
command: ["rails", "db:prepare", "css:build", "geodata:index:seed", "geoblacklight:index:seed"]
depends_on:
db:
condition: service_healthy
Expand Down
1 change: 1 addition & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
pin '@github/auto-complete-element', to: 'https://cdn.skypack.dev/@github/auto-complete-element'
pin '@popperjs/core', to: 'https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/esm/popper.js'
pin 'bootstrap', to: 'https://ga.jspm.io/npm:bootstrap@5.3.2/dist/js/bootstrap.esm.js'
pin 'geoblacklight/initializers/metadata_download', to: 'geoblacklight/initializers/metadata_download.js'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this adequate to pull in all the dependencies needed by geoblacklight?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anarchivist

The metadata link is not displayed when a record does not include ISO 19139 metadata.

The default Solr sample records from GeoBlacklight are outdated. Most records either lack metadata or contain incorrectly formatted ISO metadata. As a result, the metadata link may not appear, or the metadata modal may display incorrect ISO information.

I ingested a record with valid ISO 19139 metadata from GeoCombine, which allows me to properly test the metadata modal and its buttons locally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you give me an example record? i'm going based on the fixture data that is used for testing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yzhoubk OK, I pulled some sample records and indexed them locally. I can confirm that the downloads work for me now.

Has a bug been filed upstream for the 5.3.0 download button issue?

4 changes: 3 additions & 1 deletion config/locales/geoblacklight.en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
en:
geoblacklight:
download:
download_metadata_new_tab: 'Download metadata (opens in a new tab)'
home:
headline: 'Explore and discover...'
search_heading: 'Find the maps and data you need'
Expand All @@ -10,4 +12,4 @@ en:
resource_class: 'Resource Class'
subject: 'Subject'
theme: 'Theme'
version: 'GeoBlacklight version %{version}'
version: 'GeoBlacklight version %{version}'
15 changes: 15 additions & 0 deletions lib/tasks/geodata_index_seed.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace :geodata do
namespace :index do
desc 'Index app fixture metadata into Solr'
task seed: :environment do
fixtures_pattern = ENV.fetch('SOLR_FIXTURES_PATH', Rails.root.join('spec', 'fixtures', 'solr_documents', '*.json').to_s)
docs = Dir[fixtures_pattern].flat_map { |f| JSON.parse(File.read(f)) }

abort("No Solr fixtures found for pattern: #{fixtures_pattern}") if docs.empty?

puts "Indexing #{docs.size} fixture document(s) from #{fixtures_pattern}"
Blacklight.default_index.connection.add(docs)
Blacklight.default_index.connection.commit
end
end
end
4 changes: 2 additions & 2 deletions spec/fixtures/solr_documents/berkeley_public.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dct_accessRights_s": "Public",
"dct_format_s": "Shapefile",
"gbl_wxsIdentifier_s": "s7038h",
"dct_references_s": "{\"http://www.opengis.net/def/serviceType/ogc/wfs\":\"https://geoservices.lib.berkeley.edu/geoserver/wfs\",\"http://www.opengis.net/def/serviceType/ogc/wms\":\"https://geoservices.lib.berkeley.edu/geoserver/wms\",\"http://www.isotc211.org/schemas/2005/gmd/\":\"https://spatial.lib.berkeley.edu/metadata/berkeley-s7038h/iso19139.xml\",\"http://schema.org/downloadUrl\":\"https://spatial.lib.berkeley.edu/public/berkeley-s7038h/data.zip\"}",
"dct_references_s": "{\"http://www.opengis.net/def/serviceType/ogc/wfs\":\"https://geoservices.lib.berkeley.edu/geoserver/wfs\",\"http://www.opengis.net/def/serviceType/ogc/wms\":\"https://geoservices.lib.berkeley.edu/geoserver/wms\",\"http://www.isotc211.org/schemas/2005/gmd/\":\"https://spatial.lib.berkeley.edu/metadata/berkeley-s7038h/iso19139.xml\",\"http://www.opengis.net/cat/csw/csdgm\":\"https://spatial.lib.berkeley.edu/metadata/berkeley-s7d67w/fgdc.xml\",\"http://schema.org/downloadUrl\":\"https://spatial.lib.berkeley.edu/public/berkeley-s7038h/data.zip\"}",
"id": "berkeley-s7038h",
"dct_identifier_sm": [
"https://spatial.lib.berkeley.edu/viewpublic/berkeley-s7038h"
Expand All @@ -49,4 +49,4 @@
"This is text without a tag and it will be assigned the default 'note' style"
],
"gbl_fileSize_s": "1500MB"
}
}
4 changes: 3 additions & 1 deletion spec/system/public_result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
it 'clicking the metadata link, triggers the modal', js: true do
find('#metadataLink').click

expect(page).to have_css('.metadata-view a.pill-metadata.nav-link', visible: true)
find('a.pill-metadata.nav-link', text: 'ISO 19139', visible: true).click

expect(page).to have_css('a.pill-metadata.nav-link.active',
text: 'ISO 19139',
visible: true)

expect(page).to have_css('a.pill-metadata.nav-link.active[data-ref-endpoint="https://spatial.lib.berkeley.edu/metadata/berkeley-s7038h/iso19139.xml"]')
expect(page).to have_css('a.pill-metadata.nav-link.active[data-bs-toggle="pill"]')
end
Expand Down
Loading