geoblacklight 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/geoblacklight/document/sidebar_component.html.erb +3 -0
  3. data/app/components/geoblacklight/document/sidebar_component.rb +7 -0
  4. data/app/components/geoblacklight/download_links_component.html.erb +3 -0
  5. data/app/components/geoblacklight/download_links_component.rb +1 -1
  6. data/app/components/geoblacklight/item_map_viewer_component.rb +2 -2
  7. data/app/components/geoblacklight/location_leaflet_map_component.rb +2 -2
  8. data/app/components/geoblacklight/relations_component.html.erb +1 -1
  9. data/app/components/geoblacklight/static_map_component.rb +2 -2
  10. data/app/controllers/download_controller.rb +6 -0
  11. data/app/controllers/relation_controller.rb +1 -1
  12. data/app/helpers/geoblacklight_helper.rb +31 -3
  13. data/app/javascript/geoblacklight/controllers/leaflet_viewer_controller.js +18 -3
  14. data/app/javascript/geoblacklight/controllers/openlayers_viewer_controller.js +33 -2
  15. data/app/javascript/geoblacklight/leaflet/basemaps.js +0 -32
  16. data/app/javascript/geoblacklight/leaflet/inspection.js +5 -4
  17. data/app/javascript/geoblacklight/openlayers/basemaps.js +0 -20
  18. data/app/javascript/geoblacklight/openlayers/layers.js +1 -1
  19. data/app/models/concerns/geoblacklight/solr_document.rb +19 -2
  20. data/app/views/catalog/_metadata.html.erb +3 -0
  21. data/geoblacklight.gemspec +2 -2
  22. data/lib/generators/geoblacklight/templates/catalog_controller.rb +4 -5
  23. data/lib/generators/geoblacklight/templates/settings.yml +19 -0
  24. data/lib/geoblacklight/deprecated_configuration.rb +665 -0
  25. data/lib/geoblacklight/download.rb +3 -0
  26. data/lib/geoblacklight/engine.rb +13 -0
  27. data/lib/geoblacklight/references.rb +6 -1
  28. data/lib/geoblacklight/relation/ancestors.rb +3 -0
  29. data/lib/geoblacklight/relation/descendants.rb +3 -0
  30. data/lib/geoblacklight/relation/relation_response.rb +4 -1
  31. data/lib/geoblacklight/version.rb +1 -1
  32. data/lib/geoblacklight.rb +16 -0
  33. data/lib/tasks/geoblacklight.rake +9 -0
  34. data/package.json +1 -1
  35. data/solr/conf/solrconfig.xml +10 -10
  36. data/spec/features/configurable_basemap_spec.rb +68 -0
  37. data/spec/features/relations_spec.rb +2 -3
  38. data/spec/lib/geoblacklight/deprecated_configuration_spec.rb +680 -0
  39. data/spec/solr_config_spec.rb +41 -0
  40. data/spec/spec_helper.rb +24 -1
  41. metadata +12 -9
@@ -10,6 +10,19 @@ require "mime/types"
10
10
 
11
11
  module Geoblacklight
12
12
  class Engine < ::Rails::Engine
13
+ # Register GeoBlacklight's deprecator so that applications can configure it
14
+ # alongside Rails' own, e.g. `config.active_support.deprecation = :raise`.
15
+ initializer "geoblacklight.deprecator" do |app|
16
+ app.deprecators[:geoblacklight] = Geoblacklight.deprecation if app.respond_to?(:deprecators)
17
+ end
18
+
19
+ # Warn about application configuration that GeoBlacklight 6 removes. This runs
20
+ # once per boot rather than per request, because nothing in GeoBlacklight calls
21
+ # the deprecated templates or settings on the application's behalf.
22
+ config.after_initialize do
23
+ Geoblacklight::DeprecatedConfiguration.warn!
24
+ end
25
+
13
26
  # GeoblacklightHelper is needed by all helpers, so we inject it
14
27
  # into action view base here.
15
28
  initializer "geoblacklight.helpers" do
@@ -52,6 +52,7 @@ module Geoblacklight
52
52
  ##
53
53
  # Download hash based off of format type
54
54
  # @return [Hash, nil]
55
+ # @deprecated
55
56
  def downloads_by_format
56
57
  case format
57
58
  when "Shapefile"
@@ -66,8 +67,9 @@ module Geoblacklight
66
67
  ##
67
68
  # Generated download types from wxs services
68
69
  # @return (see #downloads_by_format)
70
+ # @deprecated
69
71
  def download_types
70
- downloads_by_format
72
+ Geoblacklight.deprecation.silence { downloads_by_format }
71
73
  end
72
74
 
73
75
  ##
@@ -156,5 +158,8 @@ module Geoblacklight
156
158
  def respond_to_missing?(m, *args, &b)
157
159
  Geoblacklight::Constants::URI.key?(m) || super
158
160
  end
161
+ Geoblacklight.deprecation.deprecate_methods(Geoblacklight::References,
162
+ downloads_by_format: "GeoBlacklight 6 removes the generated download subsystem: downloads are direct links only, rendered by Geoblacklight::Document::DownloadLinksComponent",
163
+ download_types: "GeoBlacklight 6 removes the generated download subsystem: downloads are direct links only, rendered by Geoblacklight::Document::DownloadLinksComponent")
159
164
  end
160
165
  end
@@ -4,6 +4,9 @@ module Geoblacklight
4
4
  module Relation
5
5
  class Ancestors
6
6
  def initialize(id, field, repository)
7
+ Geoblacklight.deprecation.warn(
8
+ "GeoBlacklight 6 renames the Geoblacklight::Relation namespace to Geoblacklight::Relations, and RelationController to RelationsController, so update any reference to Geoblacklight::Relation::Ancestors"
9
+ )
7
10
  @search_id = id
8
11
  @field = field
9
12
  @repository = repository
@@ -4,6 +4,9 @@ module Geoblacklight
4
4
  module Relation
5
5
  class Descendants
6
6
  def initialize(id, field, repository)
7
+ Geoblacklight.deprecation.warn(
8
+ "GeoBlacklight 6 renames the Geoblacklight::Relation namespace to Geoblacklight::Relations, and RelationController to RelationsController, so update any reference to Geoblacklight::Relation::Descendants"
9
+ )
7
10
  @search_id = id
8
11
  @field = field
9
12
  @repository = repository
@@ -5,6 +5,9 @@ module Geoblacklight
5
5
  class RelationResponse
6
6
  attr_reader :search_id, :link_id
7
7
  def initialize(id, repository)
8
+ Geoblacklight.deprecation.warn(
9
+ "GeoBlacklight 6 renames the Geoblacklight::Relation namespace to Geoblacklight::Relations, and RelationController to RelationsController, so update any reference to Geoblacklight::Relation::RelationResponse"
10
+ )
8
11
  @link_id = id
9
12
  @search_id = RSolr.solr_escape(id)
10
13
  @repository = repository
@@ -14,7 +17,7 @@ module Geoblacklight
14
17
  if Settings.RELATIONSHIPS_SHOWN.key?(method)
15
18
  field = Settings.RELATIONSHIPS_SHOWN[method].field
16
19
  query_type = query_type(Settings.RELATIONSHIPS_SHOWN[method])
17
- @results = query_type.new(@search_id, field, @repository).results
20
+ @results = Geoblacklight.deprecation.silence { query_type.new(@search_id, field, @repository) }.results
18
21
  else
19
22
  super
20
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Geoblacklight
4
- VERSION = "5.3.0"
4
+ VERSION = "5.4.0"
5
5
  end
data/lib/geoblacklight.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/dependencies"
4
+ require "active_support/deprecation"
4
5
  require "geoblacklight/engine"
5
6
  require "zeitwerk"
6
7
  loader = Zeitwerk::Loader.for_gem
@@ -13,4 +14,19 @@ module Geoblacklight
13
14
  def self.logger
14
15
  ::Rails.logger
15
16
  end
17
+
18
+ # Deprecator for GeoBlacklight's own deprecations. Anything deprecated here is
19
+ # slated for removal in GeoBlacklight 6.0.
20
+ #
21
+ # Downstream applications can configure its behavior the same way they would any
22
+ # other Rails deprecator, e.g. in config/application.rb:
23
+ #
24
+ # config.active_support.deprecation = :raise
25
+ #
26
+ # or directly:
27
+ #
28
+ # Geoblacklight.deprecation.behavior = :silence
29
+ def self.deprecation
30
+ @deprecation ||= ActiveSupport::Deprecation.new("6.0", "GeoBlacklight")
31
+ end
16
32
  end
@@ -54,14 +54,23 @@ namespace :geoblacklight do
54
54
  namespace :downloads do
55
55
  desc "Delete all cached downloads"
56
56
  task delete: :environment do
57
+ Geoblacklight.deprecation.warn(
58
+ "The geoblacklight:downloads:delete rake task is deprecated; GeoBlacklight 6 removes the generated download subsystem: downloads are direct links only, rendered by Geoblacklight::Document::DownloadLinksComponent"
59
+ )
57
60
  FileUtils.rm_rf Dir.glob(Rails.root.join("tmp", "cache", "downloads", "*"))
58
61
  end
59
62
  desc "Create download directory"
60
63
  task mkdir: :environment do
64
+ Geoblacklight.deprecation.warn(
65
+ "The geoblacklight:downloads:mkdir rake task is deprecated; GeoBlacklight 6 removes the generated download subsystem: downloads are direct links only, rendered by Geoblacklight::Document::DownloadLinksComponent"
66
+ )
61
67
  FileUtils.mkdir_p(Rails.root.join("tmp", "cache", "downloads"), verbose: true)
62
68
  end
63
69
  desc "Precaches a download"
64
70
  task :precache, %i[doc_id download_type timeout] => [:environment] do |_t, args|
71
+ Geoblacklight.deprecation.warn(
72
+ "The geoblacklight:downloads:precache rake task is deprecated; GeoBlacklight 6 removes the generated download subsystem: downloads are direct links only, rendered by Geoblacklight::Document::DownloadLinksComponent"
73
+ )
65
74
  unless args[:doc_id] && args[:download_type] && args[:timeout]
66
75
  raise "Please supply required arguments [document_id, download_type and timeout]"
67
76
  end
data/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@geoblacklight/frontend",
3
3
  "type": "module",
4
- "version": "5.3.0",
4
+ "version": "5.4.0",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -117,9 +117,9 @@
117
117
  <str name="q.alt">*:*</str>
118
118
  <str name="qf">
119
119
  text^1
120
- dct_description_ti^2
120
+ dct_description_tmi^2
121
121
  dct_creator_tmi^3
122
- dct_publisher_ti^3
122
+ dct_publisher_tmi^3
123
123
  dct_isPartOf_tmi^4
124
124
  dct_subject_tmi^5
125
125
  dct_spatial_tmi^5
@@ -127,16 +127,16 @@
127
127
  dct_title_ti^6
128
128
  dct_accessRights_ti^7
129
129
  dct_provider_ti^8
130
- gbl_resourceClass_ti^9
131
- gbl_resourceType_ti^9
132
- dct_identifier_ti^10
130
+ gbl_resourceClass_tmi^9
131
+ gbl_resourceType_tmi^9
132
+ dct_identifier_tmi^10
133
133
  id_ti^10
134
134
  </str>
135
135
  <str name="pf"><!-- phrase boost within result set -->
136
136
  text^1
137
- dct_description_ti^2
137
+ dct_description_tmi^2
138
138
  dct_creator_tmi^3
139
- dct_publisher_ti^3
139
+ dct_publisher_tmi^3
140
140
  dct_isPartOf_tmi^4
141
141
  dct_subject_tmi^5
142
142
  dct_spatial_tmi^5
@@ -144,9 +144,9 @@
144
144
  dct_title_ti^6
145
145
  dct_accessRights_ti^7
146
146
  dct_provider_ti^8
147
- gbl_resourceClass_ti^9
148
- gbl_resourceType_ti^9
149
- dct_identifier_ti^10
147
+ gbl_resourceClass_tmi^9
148
+ gbl_resourceType_tmi^9
149
+ dct_identifier_tmi^10
150
150
  id_ti^10
151
151
  </str>
152
152
  <bool name="facet">true</bool>
@@ -3,6 +3,15 @@
3
3
  require "spec_helper"
4
4
 
5
5
  feature "Configurable basemap", js: true do
6
+ # CatalogController.blacklight_config is memoized and shared by the whole suite,
7
+ # so a scenario that sets a basemap has to put the original back. An around hook
8
+ # wraps the nested before hooks that do the setting.
9
+ around do |example|
10
+ original = CatalogController.blacklight_config.basemap_provider
11
+ example.run
12
+ CatalogController.blacklight_config.basemap_provider = original
13
+ end
14
+
6
15
  scenario "defaults to positron" do
7
16
  visit root_path
8
17
  expect(page).to have_css "img[src*='carto']", visible: :all
@@ -37,4 +46,63 @@ feature "Configurable basemap", js: true do
37
46
  expect(page).to have_css "img[src*='hot']", visible: :all
38
47
  end
39
48
  end
49
+
50
+ feature "with a configured tile URL for a shipped basemap" do
51
+ before do
52
+ CatalogController.blacklight_config.basemap_provider = "positron"
53
+ Settings.LEAFLET.BASEMAPS = {
54
+ positron: {
55
+ url: "https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png?key=fake-carto-key"
56
+ }
57
+ }
58
+ end
59
+ after { Settings.LEAFLET.BASEMAPS = nil }
60
+
61
+ scenario "requests tiles from the configured URL" do
62
+ visit root_path
63
+ expect(page).to have_css "img[src*='key=fake-carto-key']", visible: :all
64
+ end
65
+ scenario "keeps the attribution from the shipped definition" do
66
+ visit root_path
67
+ expect(page).to have_css ".leaflet-control-attribution", text: "Carto"
68
+ end
69
+ end
70
+
71
+ feature "with a basemap the application defines itself" do
72
+ before do
73
+ CatalogController.blacklight_config.basemap_provider = "myBasemap"
74
+ Settings.LEAFLET.BASEMAPS = {
75
+ myBasemap: {
76
+ url: "/tiles/{z}/{x}/{y}.png",
77
+ attribution: "Tiles courtesy of Example University",
78
+ maxZoom: 18
79
+ }
80
+ }
81
+ end
82
+ after { Settings.LEAFLET.BASEMAPS = nil }
83
+
84
+ scenario "requests tiles from the application's basemap" do
85
+ visit root_path
86
+ # visible: :all because these tiles 404, so the images have no dimensions
87
+ expect(page).to have_css "img[src*='/tiles/']", visible: :all
88
+ end
89
+ scenario "credits the application's basemap" do
90
+ visit root_path
91
+ expect(page).to have_css ".leaflet-control-attribution",
92
+ text: "Tiles courtesy of Example University"
93
+ end
94
+ end
95
+
96
+ feature "using a basemap GeoBlacklight no longer ships" do
97
+ before do
98
+ # worldEco was one of the CARTO basemaps served from the retired
99
+ # cartocdn fastly endpoints; applications still naming one should get a
100
+ # working basemap rather than none
101
+ CatalogController.blacklight_config.basemap_provider = "worldEco"
102
+ end
103
+ scenario "falls back to positron rather than drawing no basemap" do
104
+ visit root_path
105
+ expect(page).to have_css "img[src*='light_all']", visible: :all
106
+ end
107
+ end
40
108
  end
@@ -33,10 +33,9 @@ feature "Display related documents" do
33
33
  end
34
34
 
35
35
  scenario "Relationship browse link returns relationship-scoped results", js: true do
36
- # Wabash Topo parent record
37
- visit solr_document_path("eee6150b-ce2f-4837-9d17-ce72a0c1c26f")
36
+ visit solr_document_path("princeton-1r66j405w")
38
37
 
39
- expect(page).to have_content(:all, "Has part...")
38
+ expect(page).to have_content(:all, "Derived records...")
40
39
  expect(page).to have_link("Browse all 4 records...", visible: :all)
41
40
  click_link("Browse all 4 records...", visible: :all)
42
41