From 5fcfb478ba7f4fe0823a5d8091eac2f095dc90a8 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Mon, 4 Nov 2024 10:00:02 -0600 Subject: [PATCH] JS: fix customized viewer initialization error (#624) * JS: fix customized viewer initialization error by adding all GBL viewers locally Fixes #623 * Gems: bump GBLSCI to latest --- Gemfile | 2 +- Gemfile.lock | 10 ++++---- app/assets/javascripts/application.js | 5 ++-- .../javascripts/geoportal/viewers/cog.js | 5 ++++ .../javascripts/geoportal/viewers/iiif.js | 25 +++++++++++++++++++ .../javascripts/geoportal/viewers/oembed.js | 13 ++++++++++ .../javascripts/geoportal/viewers/pmtiles.js | 5 ++++ 7 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 app/assets/javascripts/geoportal/viewers/cog.js create mode 100644 app/assets/javascripts/geoportal/viewers/iiif.js create mode 100644 app/assets/javascripts/geoportal/viewers/oembed.js create mode 100644 app/assets/javascripts/geoportal/viewers/pmtiles.js diff --git a/Gemfile b/Gemfile index c6b3f53fe..18087d27a 100644 --- a/Gemfile +++ b/Gemfile @@ -100,7 +100,7 @@ gem 'noticed' gem 'paper_trail' # Image migration -gem 'geoblacklight_sidecar_images', git: "https://github.com/geoblacklight/geoblacklight_sidecar_images.git", branch: "feature/statesman-update" +gem 'geoblacklight_sidecar_images', git: "https://github.com/geoblacklight/geoblacklight_sidecar_images.git", branch: "develop" gem 'mini_magick', '~> 4.9.4' gem "image_processing", ">= 1.2" diff --git a/Gemfile.lock b/Gemfile.lock index 93f4ac296..f626c61fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,17 +27,17 @@ GIT GIT remote: https://github.com/geoblacklight/geoblacklight_sidecar_images.git - revision: 089e2a4a677a5d522b9d88fef0ef46cfa69961a0 - branch: feature/statesman-update + revision: ca23e5ef8eb4fa90d5c9cb955943deeb0dcba6f5 + branch: develop specs: - geoblacklight_sidecar_images (1.0.0) + geoblacklight_sidecar_images (1.1.0) faraday (>= 2.0) geoblacklight (~> 4.0) image_processing (~> 1.6) mimemagic (~> 0.3) mini_magick (~> 4.9.4) - rails (>= 5.2, < 7.1) - statesman (~> 10.0.0) + rails (>= 5.2, < 8.0) + statesman (>= 3.4) GIT remote: https://github.com/geobtaa/geoblacklight_admin.git diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 5cf3ccc07..b9d596114 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -40,6 +40,7 @@ //= require geoblacklight/viewers/viewer //= require ./geoportal/viewers/map //= require ./geoportal/viewers/b1g_image +//= require ./geoportal/viewers/cog //= require ./geoportal/viewers/download //= require ./geoportal/viewers/esri //= require ./geoportal/viewers/esri/dynamic_map_layer @@ -50,10 +51,10 @@ //= require ./geoportal/viewers/iiif_manifest //= require ./geoportal/viewers/index_map //= require geoblacklight/viewers/oembed - -//= require ./geoportal/viewers/wms +//= require ./geoportal/viewers/pmtiles //= require ./geoportal/viewers/tilejson //= require ./geoportal/viewers/tms +//= require ./geoportal/viewers/wms //= require ./geoportal/viewers/wmts //= require ./geoportal/viewers/xyz diff --git a/app/assets/javascripts/geoportal/viewers/cog.js b/app/assets/javascripts/geoportal/viewers/cog.js new file mode 100644 index 000000000..639d33e88 --- /dev/null +++ b/app/assets/javascripts/geoportal/viewers/cog.js @@ -0,0 +1,5 @@ +//= require geoblacklight/viewers/viewer + +GeoBlacklight.Viewer.Cog = GeoBlacklight.Viewer.extend({ + load: function() {} +}); \ No newline at end of file diff --git a/app/assets/javascripts/geoportal/viewers/iiif.js b/app/assets/javascripts/geoportal/viewers/iiif.js new file mode 100644 index 000000000..e50ca262b --- /dev/null +++ b/app/assets/javascripts/geoportal/viewers/iiif.js @@ -0,0 +1,25 @@ +//= require geoblacklight/viewers/viewer + +GeoBlacklight.Viewer.Iiif = GeoBlacklight.Viewer.extend({ + load: function() { + this.adjustLayout(); + + this.map = L.map(this.element, { + center: [0, 0], + crs: L.CRS.Simple, + zoom: 0 + }); + this.loadControls(); + this.iiifLayer = L.tileLayer.iiif(this.data.url) + .addTo(this.map); + }, + + adjustLayout: function() { + + // hide attribute table + $('#table-container').hide(); + + // expand viewer element + $(this.element).parent().attr('class', 'col-md-12'); + } +}); diff --git a/app/assets/javascripts/geoportal/viewers/oembed.js b/app/assets/javascripts/geoportal/viewers/oembed.js new file mode 100644 index 000000000..004d6d371 --- /dev/null +++ b/app/assets/javascripts/geoportal/viewers/oembed.js @@ -0,0 +1,13 @@ +//= require geoblacklight/viewers/viewer + +GeoBlacklight.Viewer.Oembed = GeoBlacklight.Viewer.extend({ + load: function() { + var $el = $(this.element); + $.getJSON(this.data.url, function(data){ + if (data === null){ + return; + } + $el.html(data.html); + }); + }, +}); diff --git a/app/assets/javascripts/geoportal/viewers/pmtiles.js b/app/assets/javascripts/geoportal/viewers/pmtiles.js new file mode 100644 index 000000000..359a0bbc4 --- /dev/null +++ b/app/assets/javascripts/geoportal/viewers/pmtiles.js @@ -0,0 +1,5 @@ +//= require geoblacklight/viewers/viewer + +GeoBlacklight.Viewer.Pmtiles = GeoBlacklight.Viewer.extend({ + load: function() {} +}); \ No newline at end of file