geoblacklight 4.0.0.pre.alpha.2 → 4.0.0.pre.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +1 -1
  3. data/.github/workflows/ruby.yml +27 -103
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +6 -6
  6. data/.rubocop_todo.yml +0 -3
  7. data/.solr_wrapper +2 -0
  8. data/README.md +1 -4
  9. data/Rakefile +0 -1
  10. data/app/assets/images/blacklight/child-item.svg +3 -0
  11. data/app/assets/images/blacklight/collections.svg +4 -0
  12. data/app/assets/images/blacklight/datasets.svg +7 -0
  13. data/app/assets/images/blacklight/geoblacklight-icons.json +363 -332
  14. data/app/assets/images/blacklight/imagery.svg +4 -0
  15. data/app/assets/images/blacklight/maps.svg +4 -0
  16. data/app/assets/images/blacklight/parent-item.svg +3 -0
  17. data/app/assets/images/blacklight/university-of-colorado-boulder.svg +6 -0
  18. data/app/assets/images/blacklight/websites.svg +4 -0
  19. data/app/assets/javascripts/geoblacklight/controls/fullscreen.js +8 -0
  20. data/app/assets/javascripts/geoblacklight/geoblacklight.js +2 -1
  21. data/app/assets/javascripts/geoblacklight/viewers/esri.js +1 -0
  22. data/app/assets/javascripts/geoblacklight/viewers/index_map.js +1 -0
  23. data/app/assets/javascripts/geoblacklight/viewers/tilejson.js +33 -0
  24. data/app/assets/javascripts/geoblacklight/viewers/tms.js +2 -2
  25. data/app/assets/javascripts/geoblacklight/viewers/viewer.js +3 -0
  26. data/app/assets/javascripts/geoblacklight/viewers/wms.js +2 -2
  27. data/app/assets/javascripts/geoblacklight/viewers/wmts.js +85 -0
  28. data/app/assets/javascripts/geoblacklight/viewers/xyz.js +10 -0
  29. data/app/assets/stylesheets/geoblacklight/geoblacklight.scss +1 -0
  30. data/app/assets/stylesheets/geoblacklight/modules/_base.scss +0 -1
  31. data/app/assets/stylesheets/geoblacklight/modules/_styles.scss +5 -1
  32. data/app/assets/stylesheets/geoblacklight/modules/downloads.scss +20 -47
  33. data/app/assets/stylesheets/geoblacklight/modules/index_maps.scss +68 -0
  34. data/app/assets/stylesheets/geoblacklight/modules/item.scss +16 -0
  35. data/app/assets/stylesheets/geoblacklight/modules/modal.scss +6 -0
  36. data/app/assets/stylesheets/geoblacklight/modules/sidebar.scss +4 -0
  37. data/app/components/geoblacklight/icon_facet_item_component.rb +33 -0
  38. data/app/helpers/geoblacklight_helper.rb +6 -45
  39. data/app/models/concerns/geoblacklight/bbox_filter_field.rb +64 -0
  40. data/app/models/concerns/geoblacklight/bbox_filter_query.rb +50 -0
  41. data/app/models/concerns/geoblacklight/solr_document.rb +1 -1
  42. data/app/models/concerns/geoblacklight/suppressed_records_search_behavior.rb +31 -0
  43. data/app/presenters/geoblacklight/bbox_item_presenter.rb +9 -0
  44. data/app/views/catalog/_downloads_collapse.html.erb +27 -0
  45. data/app/views/catalog/_header_icons.html.erb +2 -2
  46. data/app/views/catalog/_index_split_default.html.erb +2 -2
  47. data/app/views/catalog/_show_default_viewer_container.html.erb +17 -0
  48. data/app/views/catalog/_show_downloads.html.erb +10 -21
  49. data/app/views/catalog/_show_sidebar.html.erb +3 -0
  50. data/app/views/catalog/_show_web_services.html.erb +11 -0
  51. data/app/views/catalog/_web_services.html.erb +3 -2
  52. data/app/views/catalog/web_services.html.erb +1 -1
  53. data/app/views/shared/_header_navbar.html.erb +13 -3
  54. data/config/locales/geoblacklight.en.yml +5 -1
  55. data/geoblacklight.gemspec +7 -7
  56. data/lib/generators/geoblacklight/install_generator.rb +1 -1
  57. data/lib/generators/geoblacklight/templates/assets/_customizations.scss +5 -4
  58. data/lib/generators/geoblacklight/templates/assets/application.scss +0 -3
  59. data/lib/generators/geoblacklight/templates/catalog_controller.rb +86 -57
  60. data/lib/generators/geoblacklight/templates/settings.gbl_v1.yml +5 -5
  61. data/lib/generators/geoblacklight/templates/settings.yml +43 -25
  62. data/lib/geoblacklight/bounding_box.rb +5 -1
  63. data/lib/geoblacklight/constants.rb +3 -0
  64. data/lib/geoblacklight/engine.rb +3 -2
  65. data/lib/geoblacklight/faraday_middleware/follow_redirects.rb +176 -0
  66. data/lib/geoblacklight/item_viewer.rb +13 -1
  67. data/lib/geoblacklight/metadata/base.rb +2 -1
  68. data/lib/geoblacklight/version.rb +1 -1
  69. data/lib/geoblacklight/view_helper_override.rb +2 -28
  70. data/lib/geoblacklight.rb +0 -10
  71. data/lib/tasks/geoblacklight.rake +1 -1
  72. data/schema/geoblacklight-schema-aardvark.json +3 -23
  73. data/solr/conf/schema.xml +37 -43
  74. data/solr/conf/solrconfig.xml +17 -17
  75. data/spec/components/geoblacklight/icon_facet_item_component_spec.rb +17 -0
  76. data/spec/config/initializers/rails_config_spec.rb +1 -1
  77. data/spec/controllers/catalog_controller_spec.rb +1 -1
  78. data/spec/controllers/wms_controller_spec.rb +1 -1
  79. data/spec/features/download_layer_spec.rb +31 -14
  80. data/spec/features/esri_viewer_spec.rb +5 -1
  81. data/spec/features/full_screen_controll_spec.rb +15 -0
  82. data/spec/features/home_page_spec.rb +2 -2
  83. data/spec/features/index_map_spec.rb +2 -2
  84. data/spec/features/missing_metadata_spec.rb +1 -1
  85. data/spec/features/multiple_downloads_spec.rb +2 -1
  86. data/spec/features/relations_spec.rb +12 -1
  87. data/spec/features/saved_searches_spec.rb +1 -1
  88. data/spec/features/search_results_complex_geometry_spec.rb +24 -0
  89. data/spec/features/search_results_icons_spec.rb +16 -0
  90. data/spec/features/search_results_map_spec.rb +2 -2
  91. data/spec/features/search_spec.rb +17 -0
  92. data/spec/features/show_page_download_spec.rb +29 -0
  93. data/spec/features/show_page_metadata_spec.rb +2 -2
  94. data/spec/features/split_view.html.erb_spec.rb +12 -1
  95. data/spec/features/tilejson_spec.rb +22 -0
  96. data/spec/features/tms_spec.rb +2 -2
  97. data/spec/features/web_services_modal_spec.rb +35 -2
  98. data/spec/features/wmts_spec.rb +34 -0
  99. data/spec/features/xyz_spec.rb +10 -0
  100. data/spec/fixtures/manifests/tilejson.json +21 -0
  101. data/spec/fixtures/manifests/wmts-multiple.xml +813 -0
  102. data/spec/fixtures/manifests/wmts-single.xml +126 -0
  103. data/spec/fixtures/solr_documents/README.md +46 -43
  104. data/spec/fixtures/solr_documents/actual-papermap1.json +2 -1
  105. data/spec/fixtures/solr_documents/actual-point1.json +2 -1
  106. data/spec/fixtures/solr_documents/actual-polygon1.json +2 -1
  107. data/spec/fixtures/solr_documents/actual-raster1.json +3 -2
  108. data/spec/fixtures/solr_documents/b1g_wabash_child_15.json +62 -0
  109. data/spec/fixtures/solr_documents/b1g_wabash_child_16.json +64 -0
  110. data/spec/fixtures/solr_documents/b1g_wabash_child_17.json +62 -0
  111. data/spec/fixtures/solr_documents/b1g_wabash_child_18.json +62 -0
  112. data/spec/fixtures/solr_documents/b1g_wabash_parent.json +59 -0
  113. data/spec/fixtures/solr_documents/baruch_ancestor1.json +2 -1
  114. data/spec/fixtures/solr_documents/baruch_ancestor2.json +2 -1
  115. data/spec/fixtures/solr_documents/baruch_documentation_download.json +1 -1
  116. data/spec/fixtures/solr_documents/bbox-spans-180.json +2 -1
  117. data/spec/fixtures/solr_documents/cornell_html_metadata.json +4 -3
  118. data/spec/fixtures/solr_documents/esri-dynamic-layer-all-layers.json +3 -2
  119. data/spec/fixtures/solr_documents/esri-dynamic-layer-single-layer.json +3 -2
  120. data/spec/fixtures/solr_documents/esri-feature-layer.json +2 -1
  121. data/spec/fixtures/solr_documents/esri-image-map-layer.json +3 -2
  122. data/spec/fixtures/solr_documents/esri-tiled_map_layer.json +2 -1
  123. data/spec/fixtures/solr_documents/esri-wms-layer.json +2 -1
  124. data/spec/fixtures/solr_documents/harvard_raster.json +3 -2
  125. data/spec/fixtures/solr_documents/iiif-eastern-hemisphere.json +3 -2
  126. data/spec/fixtures/solr_documents/index-map-polygon-no-downloadurl.json +2 -1
  127. data/spec/fixtures/solr_documents/index-map-polygon.json +2 -1
  128. data/spec/fixtures/solr_documents/index-map-stanford.json +2 -1
  129. data/spec/fixtures/solr_documents/index_map_point.json +3 -2
  130. data/spec/fixtures/solr_documents/metadata_no_provider.json +2 -1
  131. data/spec/fixtures/solr_documents/multiple-downloads.json +3 -2
  132. data/spec/fixtures/solr_documents/no_spatial.json +1 -4
  133. data/spec/fixtures/solr_documents/oembed.json +2 -1
  134. data/spec/fixtures/solr_documents/princeton-child1.json +3 -2
  135. data/spec/fixtures/solr_documents/princeton-child2.json +3 -2
  136. data/spec/fixtures/solr_documents/princeton-child3.json +2 -1
  137. data/spec/fixtures/solr_documents/princeton-child4.json +3 -2
  138. data/spec/fixtures/solr_documents/princeton-parent.json +5 -3
  139. data/spec/fixtures/solr_documents/public_direct_download.json +2 -1
  140. data/spec/fixtures/solr_documents/public_iiif_princeton.json +3 -2
  141. data/spec/fixtures/solr_documents/public_polygon_mit.json +2 -1
  142. data/spec/fixtures/solr_documents/restricted-line.json +2 -1
  143. data/spec/fixtures/solr_documents/tilejson.json +48 -0
  144. data/spec/fixtures/solr_documents/tms.json +15 -18
  145. data/spec/fixtures/solr_documents/umn_metro_result1.json +5 -3
  146. data/spec/fixtures/solr_documents/umn_state_result1.json +3 -2
  147. data/spec/fixtures/solr_documents/umn_state_result2.json +3 -5
  148. data/spec/fixtures/solr_documents/uva_slug_colon.json +2 -1
  149. data/spec/fixtures/solr_documents/wmts-multiple.json +41 -0
  150. data/spec/fixtures/solr_documents/wmts-single-layer.json +48 -0
  151. data/spec/fixtures/solr_documents/xyz.json +46 -0
  152. data/spec/helpers/geoblacklight_helper_spec.rb +12 -35
  153. data/spec/lib/geoblacklight/document_presenter_spec.rb +3 -3
  154. data/spec/lib/geoblacklight/download/geojson_download_spec.rb +1 -1
  155. data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +1 -1
  156. data/spec/lib/geoblacklight/download/kmz_download_spec.rb +1 -1
  157. data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +1 -1
  158. data/spec/lib/geoblacklight/download_spec.rb +2 -2
  159. data/spec/lib/geoblacklight/metadata/base_spec.rb +19 -1
  160. data/spec/lib/geoblacklight/metadata_transformer/fgdc_spec.rb +1 -1
  161. data/spec/lib/geoblacklight/metadata_transformer/iso19139_spec.rb +1 -1
  162. data/spec/lib/geoblacklight/references_spec.rb +5 -3
  163. data/spec/lib/geoblacklight/relation/relation_response_spec.rb +5 -0
  164. data/spec/lib/geoblacklight/view_helper_override_spec.rb +0 -10
  165. data/spec/lib/geoblacklight/wms_layer_spec.rb +1 -1
  166. data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +96 -0
  167. data/spec/models/concerns/geoblacklight/bbox_filter_query_spec.rb +105 -0
  168. data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +2 -1
  169. data/spec/models/concerns/geoblacklight/suppressed_records_search_behavior_spec.rb +31 -0
  170. data/spec/presenters/geoblacklight/bbox_item_presenter_spec.rb +36 -0
  171. data/spec/spec_helper.rb +8 -3
  172. data/spec/test_app_templates/Gemfile.extra +1 -0
  173. data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -4
  174. data/spec/views/catalog/_show_downloads.html.erb_spec.rb +5 -5
  175. data/template.rb +2 -4
  176. data/vendor/assets/images/fullscreen.png +0 -0
  177. data/vendor/assets/images/fullscreen@2x.png +0 -0
  178. data/vendor/assets/javascripts/Leaflet.fullscreen.js +152 -0
  179. data/vendor/assets/javascripts/esri-leaflet.js +10 -3
  180. data/vendor/assets/javascripts/esri-leaflet.js.map +1 -1
  181. data/vendor/assets/javascripts/leaflet-iiif.js +39 -18
  182. data/vendor/assets/javascripts/leaflet-src.js.erb +14126 -0
  183. data/vendor/assets/javascripts/leaflet-src.js.map +1 -1
  184. data/vendor/assets/stylesheets/leaflet.css +640 -634
  185. data/vendor/assets/stylesheets/leaflet.fullscreen.css +40 -0
  186. metadata +108 -53
  187. data/app/models/concerns/geoblacklight/spatial_search_behavior.rb +0 -71
  188. data/app/views/catalog/_download_generated_link.html.erb +0 -4
  189. data/app/views/catalog/_download_link.html.erb +0 -3
  190. data/app/views/catalog/_downloads_generated.html.erb +0 -6
  191. data/app/views/catalog/_downloads_primary.html.erb +0 -21
  192. data/app/views/catalog/_downloads_secondary.html.erb +0 -39
  193. data/app/views/catalog/_icon_facet.html.erb +0 -16
  194. data/bin/coverage.rb +0 -36
  195. data/lib/generators/geoblacklight/templates/Procfile +0 -3
  196. data/lib/generators/geoblacklight/templates/package.json +0 -14
  197. data/lib/generators/geoblacklight/templates/webpacker.yml +0 -67
  198. data/lib/generators/geoblacklight/webpacker_generator.rb +0 -36
  199. data/lib/geoblacklight/catalog_helper_override.rb +0 -14
  200. data/spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb +0 -97
  201. data/vendor/assets/javascripts/leaflet.js.erb +0 -13922
  202. data/vendor/assets/stylesheets/leaflet-label.css +0 -54
@@ -25,7 +25,7 @@ OVERLAP_RATIO_BOOST: '2'
25
25
  FIELDS:
26
26
  :ACCESS_RIGHTS: 'dc_rights_s'
27
27
  #:ALTERNATIVE_TITLE: 'dct_alternative_sm'
28
- #:CENTROID: 'dcat_centroid_ss'
28
+ #:CENTROID: 'dcat_centroid'
29
29
  :CREATOR: 'dc_creator_sm'
30
30
  :DATE_ISSUED: 'dct_issued_s'
31
31
  #:DATE_RANGE: 'gbl_dateRange_drsim'
@@ -57,7 +57,7 @@ FIELDS:
57
57
  #:RIGHTS_HOLDER: 'dct_rightsHolder_sm'
58
58
  :SOURCE: 'dc_source_sm'
59
59
  :SPATIAL_COVERAGE: 'dct_spatial_sm'
60
- :SPATIAL_EXTENT: 'solr_geom'
60
+ :GEOMETRY: 'solr_geom'
61
61
  :SUBJECT: 'dc_subject_sm'
62
62
  :SUPPRESSED: 'suppressed_b'
63
63
  :TEMPORAL_COVERAGE: 'dct_temporal_sm'
@@ -159,15 +159,15 @@ LEAFLET:
159
159
  DETECT_RETINA: true
160
160
  INDEX:
161
161
  DEFAULT: &default
162
- color: "#1eb300"
162
+ color: "#7FCDBB"
163
163
  weight: "1"
164
164
  radius: "4"
165
165
  UNAVAILABLE:
166
166
  <<: *default
167
- color: "#b3001e"
167
+ color: "#EDF8B1"
168
168
  SELECTED:
169
169
  <<: *default
170
- color: "#006bde"
170
+ color: "#2C7FB8"
171
171
  VIEWERS:
172
172
  WMS:
173
173
  <<: *opacity_control
@@ -10,9 +10,6 @@ ARCGIS_BASE_URL: 'https://www.arcgis.com/home/webmap/viewer.html'
10
10
  # Download path can be configured using this setting
11
11
  #DOWNLOAD_PATH: "./tmp/cache/downloads"
12
12
 
13
- # DEPRECATED Main Solr geometry field used for spatial search and bounding box. Should be type 'rpt'
14
- GEOMETRY_FIELD: 'solr_geom'
15
-
16
13
  # The bq boost value for spatial search matches within a bounding box
17
14
  BBOX_WITHIN_BOOST: '10'
18
15
 
@@ -29,7 +26,7 @@ HOMEPAGE_MAP_GEOM: null
29
26
  FIELDS:
30
27
  :ACCESS_RIGHTS: 'dct_accessRights_s'
31
28
  :ALTERNATIVE_TITLE: 'dct_alternative_sm'
32
- :CENTROID: 'dcat_centroid_ss'
29
+ :CENTROID: 'dcat_centroid'
33
30
  :CREATOR: 'dct_creator_sm'
34
31
  :DATE_ISSUED: 'dct_issued_s'
35
32
  :DATE_RANGE: 'gbl_dateRange_drsim'
@@ -42,9 +39,10 @@ FIELDS:
42
39
  :INDEX_YEAR: 'gbl_indexYear_im'
43
40
  :IS_PART_OF: 'dct_isPartOf_sm'
44
41
  :IS_REPLACED_BY: 'dct_isReplacedBy_sm'
45
- :ISO_TOPIC_CATEGORY: 'dcat_theme_sm'
42
+ :THEME: 'dcat_theme_sm'
46
43
  :KEYWORD: 'dcat_keyword_sm'
47
44
  :LANGUAGE: 'dct_language_sm'
45
+ :LAYER_MODIFIED: 'gbl_mdModified_dt'
48
46
  :LICENSE: 'dct_license_sm'
49
47
  :MEMBER_OF: 'pcdm_memberOf_sm'
50
48
  :METADATA_VERSION: 'gbl_mdVersion_s'
@@ -61,7 +59,7 @@ FIELDS:
61
59
  :RIGHTS_HOLDER: 'dct_rightsHolder_sm'
62
60
  :SOURCE: 'dct_source_sm'
63
61
  :SPATIAL_COVERAGE: 'dct_spatial_sm'
64
- :SPATIAL_EXTENT: 'locn_geometry'
62
+ :GEOMETRY: 'locn_geometry'
65
63
  :SUBJECT: 'dct_subject_sm'
66
64
  :SUPPRESSED: 'gbl_suppressed_b'
67
65
  :TEMPORAL_COVERAGE: 'dct_temporal_sm'
@@ -93,6 +91,9 @@ WEBSERVICES_SHOWN:
93
91
  - 'wms'
94
92
  - 'tms'
95
93
  - 'wfs'
94
+ - 'xyz'
95
+ - 'wmts'
96
+ - 'tilejson'
96
97
  - 'iiif'
97
98
  - 'feature_layer'
98
99
  - 'tiled_map_layer'
@@ -106,11 +107,16 @@ RELATIONSHIPS_SHOWN:
106
107
  query_type: ancestors
107
108
  icon: nil
108
109
  label: geoblacklight.relations.member_of
109
- PART_OF:
110
+ PART_OF_ANCESTORS:
110
111
  field: dct_isPartOf_sm
111
112
  query_type: ancestors
112
113
  icon: nil
113
- label: geoblacklight.relations.part_of
114
+ label: geoblacklight.relations.part_of_ancestors
115
+ PART_OF_DESCENDANTS:
116
+ field: dct_isPartOf_sm
117
+ query_type: descendants
118
+ icon: child-item
119
+ label: geoblacklight.relations.part_of_descendants
114
120
  RELATION:
115
121
  field: dct_relation_sm
116
122
  query_type: ancestors
@@ -129,12 +135,12 @@ RELATIONSHIPS_SHOWN:
129
135
  SOURCE_ANCESTORS:
130
136
  field: dct_source_sm
131
137
  query_type: ancestors
132
- icon: pagelines-brands
138
+ icon: parent-item
133
139
  label: geoblacklight.relations.ancestor
134
140
  SOURCE_DESCENDANTS:
135
141
  field: dct_source_sm
136
142
  query_type: descendants
137
- icon: leaf
143
+ icon: child-item
138
144
  label: geoblacklight.relations.descendant
139
145
  VERSION_OF:
140
146
  field: dct_isVersionOf_sm
@@ -153,36 +159,48 @@ WMS_PARAMS:
153
159
  :INFO_FORMAT: 'text/html'
154
160
 
155
161
  # Settings for leaflet
156
- OPACITY_CONTROL: &opacity_control
157
- CONTROLS:
158
- - 'Opacity'
159
-
160
162
  LEAFLET:
161
163
  MAP:
162
164
  LAYERS:
163
165
  DETECT_RETINA: true
164
166
  INDEX:
165
167
  DEFAULT: &default
166
- color: "#1eb300"
168
+ color: "#7FCDBB"
167
169
  weight: "1"
168
170
  radius: "4"
169
171
  UNAVAILABLE:
170
172
  <<: *default
171
- color: "#b3001e"
173
+ color: "#EDF8B1"
172
174
  SELECTED:
173
175
  <<: *default
174
- color: "#006bde"
176
+ color: "#2C7FB8"
175
177
  VIEWERS:
176
- WMS:
177
- <<: *opacity_control
178
- TILEDMAPLAYER:
179
- <<: *opacity_control
180
- FEATURELAYER:
181
- <<: *opacity_control
182
178
  DYNAMICMAPLAYER:
183
- <<: *opacity_control
179
+ CONTROLS:
180
+ - 'Opacity'
181
+ - 'Fullscreen'
182
+ FEATURELAYER:
183
+ CONTROLS:
184
+ - 'Opacity'
185
+ - 'Fullscreen'
186
+ IIIF:
187
+ CONTROLS:
188
+ - 'Fullscreen'
184
189
  IMAGEMAPLAYER:
185
- <<: *opacity_control
190
+ CONTROLS:
191
+ - 'Opacity'
192
+ - 'Fullscreen'
193
+ INDEXMAP:
194
+ CONTROLS:
195
+ - 'Fullscreen'
196
+ TILEDMAPLAYER:
197
+ CONTROLS:
198
+ - 'Opacity'
199
+ - 'Fullscreen'
200
+ WMS:
201
+ CONTROLS:
202
+ - 'Opacity'
203
+ - 'Fullscreen'
186
204
 
187
205
  # Toggle the help text feature that offers users context
188
206
  HELP_TEXT:
@@ -23,12 +23,16 @@ module Geoblacklight
23
23
  "ENVELOPE(#{west}, #{east}, #{north}, #{south})"
24
24
  end
25
25
 
26
+ def to_param
27
+ "#{west} #{south} #{east} #{north}"
28
+ end
29
+
26
30
  ##
27
31
  # Create a Geoblacklight::BoundingBox from a Solr rectangle syntax
28
32
  # @param [String] bbox as "W S E N"
29
33
  # @return [Geoblacklight::BoundingBox]
30
34
  def self.from_rectangle(rectangle)
31
- rectangle_array = rectangle.split
35
+ rectangle_array = rectangle.is_a?(String) ? rectangle.split : []
32
36
  message = 'Bounding box should be a string in Solr rectangle syntax e.g."W S E N"'
33
37
  fail Geoblacklight::Exceptions::WrongBoundingBoxFormat, message if rectangle_array.count != 4
34
38
  new(
@@ -16,7 +16,10 @@ module Geoblacklight
16
16
  wcs: 'http://www.opengis.net/def/serviceType/ogc/wcs',
17
17
  wfs: 'http://www.opengis.net/def/serviceType/ogc/wfs',
18
18
  wms: 'http://www.opengis.net/def/serviceType/ogc/wms',
19
+ wmts: 'http://www.opengis.net/def/serviceType/ogc/wmts',
19
20
  tms: 'https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification',
21
+ tilejson: 'https://github.com/mapbox/tilejson-spec',
22
+ xyz: 'https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames',
20
23
  hgl: 'http://schema.org/DownloadAction',
21
24
  feature_layer: 'urn:x-esri:serviceType:ArcGIS#FeatureLayer',
22
25
  tiled_map_layer: 'urn:x-esri:serviceType:ArcGIS#TiledMapLayer',
@@ -3,7 +3,6 @@ require 'blacklight'
3
3
  require 'coderay'
4
4
  require 'config'
5
5
  require 'faraday'
6
- require 'faraday_middleware'
7
6
  require 'geoblacklight/version'
8
7
  require 'nokogiri'
9
8
  require 'mime/types'
@@ -19,7 +18,9 @@ module Geoblacklight
19
18
  end
20
19
 
21
20
  config.to_prepare do
22
- Geoblacklight.inject!
21
+ unless SearchHistoryController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
22
+ SearchHistoryController.send(:helper, Geoblacklight::ViewHelperOverride)
23
+ end
23
24
  end
24
25
  end
25
26
  end
@@ -0,0 +1,176 @@
1
+ # frozen_string_literal: true
2
+ # :nocov:
3
+ require 'faraday'
4
+ require 'set'
5
+
6
+ module Geoblacklight
7
+ # NOTE: We copied this class from faraday_middleware in order to support
8
+ # both Faraday 1 & 2. If this middleware is ever extracted from
9
+ # faraday_middleware into its own gem we should remove this and use that
10
+ # instead.
11
+ module FaradayMiddleware
12
+ # Exception thrown when the maximum amount of requests is
13
+ # exceeded.
14
+ class RedirectLimitReached < ::Faraday::ClientError
15
+ attr_reader :response
16
+
17
+ def initialize(response)
18
+ super "too many redirects; last one to: #{response['location']}"
19
+ @response = response
20
+ end
21
+ end
22
+
23
+ # Public: Follow HTTP 301, 302, 303, 307, and 308 redirects.
24
+ #
25
+ # For HTTP 301, 302, and 303, the original GET, POST, PUT, DELETE, or PATCH
26
+ # request gets converted into a GET. With `:standards_compliant => true`,
27
+ # however, the HTTP method after 301/302 remains unchanged. This allows you
28
+ # to opt into HTTP/1.1 compliance and act unlike the major web browsers.
29
+ #
30
+ # This middleware currently only works with synchronous requests; i.e. it
31
+ # doesn't support parallelism.
32
+ #
33
+ # If you wish to persist cookies across redirects, you could use
34
+ # the faraday-cookie_jar gem:
35
+ #
36
+ # Faraday.new(:url => url) do |faraday|
37
+ # faraday.use FaradayMiddleware::FollowRedirects
38
+ # faraday.use :cookie_jar
39
+ # faraday.adapter Faraday.default_adapter
40
+ # end
41
+ #
42
+ class FollowRedirects < ::Faraday::Middleware
43
+ # HTTP methods for which 30x redirects can be followed
44
+ ALLOWED_METHODS = Set.new [:head, :options, :get, :post, :put, :patch, :delete]
45
+ # HTTP redirect status codes that this middleware implements
46
+ REDIRECT_CODES = Set.new [301, 302, 303, 307, 308]
47
+ # Keys in env hash which will get cleared between requests
48
+ ENV_TO_CLEAR = Set.new [:status, :response, :response_headers]
49
+
50
+ # Default value for max redirects followed
51
+ FOLLOW_LIMIT = 3
52
+
53
+ # Regex that matches characters that need to be escaped in URLs, sans
54
+ # the "%" character which we assume already represents an escaped sequence.
55
+ URI_UNSAFE = %r{[^\-_.!~*'()a-zA-Z\d;/?:@&=+$,\[\]%]}.freeze
56
+
57
+ AUTH_HEADER = 'Authorization'
58
+
59
+ # Public: Initialize the middleware.
60
+ #
61
+ # options - An options Hash (default: {}):
62
+ # :limit - A Numeric redirect limit (default: 3)
63
+ # :standards_compliant - A Boolean indicating whether to respect
64
+ # the HTTP spec when following 301/302
65
+ # (default: false)
66
+ # :callback - A callable used on redirects
67
+ # with the old and new envs
68
+ # :cookies - An Array of Strings (e.g.
69
+ # ['cookie1', 'cookie2']) to choose
70
+ # cookies to be kept, or :all to keep
71
+ # all cookies (default: []).
72
+ # :clear_authorization_header - A Boolean indicating whether the request
73
+ # Authorization header should be cleared on
74
+ # redirects (default: true)
75
+ def initialize(app, options = {})
76
+ super(app)
77
+ @options = options
78
+
79
+ @convert_to_get = Set.new [303]
80
+ @convert_to_get << 301 << 302 unless standards_compliant?
81
+ end
82
+
83
+ def call(env)
84
+ perform_with_redirection(env, follow_limit)
85
+ end
86
+
87
+ private
88
+
89
+ def convert_to_get?(response)
90
+ [:head, :options].exclude?(response.env[:method]) &&
91
+ @convert_to_get.include?(response.status)
92
+ end
93
+
94
+ def perform_with_redirection(env, follows)
95
+ request_body = env[:body]
96
+ response = @app.call(env)
97
+
98
+ response.on_complete do |response_env|
99
+ if follow_redirect?(response_env, response)
100
+ fail RedirectLimitReached, response if follows.zero?
101
+
102
+ new_request_env = update_env(response_env.dup, request_body, response)
103
+ callback&.call(response_env, new_request_env)
104
+ response = perform_with_redirection(new_request_env, follows - 1)
105
+ end
106
+ end
107
+ response
108
+ end
109
+
110
+ def update_env(env, request_body, response)
111
+ redirect_from_url = env[:url].to_s
112
+ redirect_to_url = safe_escape(response['location'] || '')
113
+ env[:url] += redirect_to_url
114
+
115
+ ENV_TO_CLEAR.each { |key| env.delete key }
116
+
117
+ if convert_to_get?(response)
118
+ env[:method] = :get
119
+ env[:body] = nil
120
+ else
121
+ env[:body] = request_body
122
+ end
123
+
124
+ clear_authorization_header(env, redirect_from_url, redirect_to_url)
125
+
126
+ env
127
+ end
128
+
129
+ def follow_redirect?(env, response)
130
+ ALLOWED_METHODS.include?(env[:method]) &&
131
+ REDIRECT_CODES.include?(response.status)
132
+ end
133
+
134
+ def follow_limit
135
+ @options.fetch(:limit, FOLLOW_LIMIT)
136
+ end
137
+
138
+ def standards_compliant?
139
+ @options.fetch(:standards_compliant, false)
140
+ end
141
+
142
+ def callback
143
+ @options[:callback]
144
+ end
145
+
146
+ # Internal: escapes unsafe characters from an URL which might be a path
147
+ # component only or a fully qualified URI so that it can be joined onto an
148
+ # URI:HTTP using the `+` operator. Doesn't escape "%" characters so to not
149
+ # risk double-escaping.
150
+ def safe_escape(uri)
151
+ uri = uri.split('#')[0] # we want to remove the fragment if present
152
+ uri.to_s.gsub(URI_UNSAFE) do |match|
153
+ "%#{match.unpack('H2' * match.bytesize).join('%').upcase}"
154
+ end
155
+ end
156
+
157
+ def clear_authorization_header(env, from_url, to_url)
158
+ return env if redirect_to_same_host?(from_url, to_url)
159
+ return env unless @options.fetch(:clear_authorization_header, true)
160
+
161
+ env[:request_headers].delete(AUTH_HEADER)
162
+ end
163
+
164
+ def redirect_to_same_host?(from_url, to_url)
165
+ return true if to_url.start_with?('/')
166
+
167
+ from_uri = URI.parse(from_url)
168
+ to_uri = URI.parse(to_url)
169
+
170
+ [from_uri.scheme, from_uri.host, from_uri.port] ==
171
+ [to_uri.scheme, to_uri.host, to_uri.port]
172
+ end
173
+ end
174
+ end
175
+ end
176
+ # :nocov:
@@ -51,8 +51,20 @@ module Geoblacklight
51
51
  @references.tms
52
52
  end
53
53
 
54
+ def xyz
55
+ @references.xyz
56
+ end
57
+
58
+ def tilejson
59
+ @references.tilejson
60
+ end
61
+
62
+ def wmts
63
+ @references.wmts
64
+ end
65
+
54
66
  def viewer_preference
55
- [oembed, index_map, tms, wms, iiif, tiled_map_layer, dynamic_map_layer,
67
+ [oembed, index_map, tilejson, xyz, wmts, tms, wms, iiif, tiled_map_layer, dynamic_map_layer,
56
68
  image_map_layer, feature_layer].compact.map(&:to_hash).first
57
69
  end
58
70
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'geoblacklight/faraday_middleware/follow_redirects'
2
3
  module Geoblacklight
3
4
  module Metadata
4
5
  ##
@@ -47,7 +48,7 @@ module Geoblacklight
47
48
  # connection error
48
49
  def retrieve_metadata
49
50
  connection = Faraday.new(url: @reference.endpoint) do |conn|
50
- conn.use FaradayMiddleware::FollowRedirects
51
+ conn.use Geoblacklight::FaradayMiddleware::FollowRedirects
51
52
  conn.adapter Faraday.default_adapter
52
53
  end
53
54
  begin
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Geoblacklight
3
- VERSION = '4.0.0-alpha.2'
3
+ VERSION = '4.0.0-rc2'
4
4
  end
@@ -1,41 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
  module Geoblacklight
3
+ # Override Blacklight helpers to inject behavior
3
4
  module ViewHelperOverride
4
- include CatalogHelperOverride
5
-
6
- def spatial_parameters?
7
- params[:bbox]
8
- end
9
-
10
- # Overrides BL method to enable results for spatial only params
11
- def has_search_parameters?
12
- spatial_parameters? || super
13
- end
14
-
15
- def query_has_constraints?(localized_params = params)
16
- has_search_parameters? || super(localized_params)
17
- end
18
-
19
5
  def render_search_to_s(params)
20
6
  super + render_search_to_s_bbox(params)
21
7
  end
22
8
 
23
9
  def render_search_to_s_bbox(params)
24
10
  return ''.html_safe if params['bbox'].blank?
25
- render_search_to_s_element(t('geoblacklight.bbox_label'), render_filter_value(params['bbox']))
26
- end
27
11
 
28
- def render_constraints_filters(localized_params = params)
29
- content = super(localized_params)
30
- localized_params = localized_params.to_h if localized_params.respond_to?(:to_h)
31
-
32
- if localized_params[:bbox]
33
- path = search_action_path(remove_spatial_filter_group(:bbox, localized_params))
34
- content << render_constraint_element(t('geoblacklight.bbox_label'),
35
- localized_params[:bbox], remove: path)
36
- end
37
-
38
- content
12
+ render_search_to_s_element(t('geoblacklight.bbox_label'), render_filter_value(params['bbox']))
39
13
  end
40
14
  end
41
15
  end
data/lib/geoblacklight.rb CHANGED
@@ -4,7 +4,6 @@ require 'geoblacklight/engine'
4
4
 
5
5
  module Geoblacklight
6
6
  require 'geoblacklight/bounding_box'
7
- require 'geoblacklight/catalog_helper_override'
8
7
  require 'geoblacklight/constants'
9
8
  require 'geoblacklight/exceptions'
10
9
  require 'geoblacklight/geometry'
@@ -34,15 +33,6 @@ module Geoblacklight
34
33
  require 'geoblacklight/relation/ancestors'
35
34
  require 'geoblacklight/relation/relation_response'
36
35
 
37
- def self.inject!
38
- CatalogController.send(:include, Geoblacklight::CatalogHelperOverride)
39
- CatalogController.send(:include, Geoblacklight::ViewHelperOverride)
40
- CatalogController.send(:helper, Geoblacklight::ViewHelperOverride) unless
41
- CatalogController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
42
- SearchHistoryController.send(:helper, Geoblacklight::ViewHelperOverride) unless
43
- SearchHistoryController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
44
- end
45
-
46
36
  def self.logger
47
37
  ::Rails.logger
48
38
  end
@@ -87,7 +87,7 @@ namespace :geoblacklight do
87
87
  fail 'Please supply required arguments [document_id, download_type and timeout]'
88
88
  end
89
89
  document = Geoblacklight::SolrDocument.find(args[:doc_id])
90
- fail Blacklight::Exceptions::RecordNotFound if document[:layer_slug_s] != args[:doc_id]
90
+ fail Blacklight::Exceptions::RecordNotFound if document[:id] != args[:doc_id]
91
91
  download = "Geoblacklight::#{args[:download_type].capitalize}Download"
92
92
  .constantize.new(document, timeout: args[:timeout].to_i)
93
93
  download.get
@@ -67,28 +67,7 @@
67
67
  "dcat_theme_sm": {
68
68
  "type": "array",
69
69
  "items": {
70
- "type": "string",
71
- "enum": [
72
- "Farming",
73
- "Biota",
74
- "Boundaries",
75
- "Climatology, Meteorology and Atmosphere",
76
- "Economy",
77
- "Elevation",
78
- "Environment",
79
- "Geoscientific Information",
80
- "Health",
81
- "Imagery and Base Maps",
82
- "Intelligence and Military",
83
- "Inland Waters",
84
- "Location",
85
- "Oceans",
86
- "Planning and Cadastral",
87
- "Society",
88
- "Structure",
89
- "Transportation",
90
- "Utilities and Communications"
91
- ]
70
+ "type": "string"
92
71
  }
93
72
  },
94
73
  "dcat_keyword_sm": {
@@ -123,7 +102,8 @@
123
102
  }
124
103
  },
125
104
  "locn_geometry": { "type": "string" },
126
- "dcat_centroid_ss": { "type": "string" },
105
+ "dcat_bbox": { "type": "string" },
106
+ "dcat_centroid": { "type": "string" },
127
107
  "dct_relation_sm": {
128
108
  "type": "array",
129
109
  "items": {