geoblacklight 2.4.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +142 -0
  3. data/.gitignore +8 -0
  4. data/.rubocop.yml +24 -23
  5. data/.rubocop_todo.yml +398 -12
  6. data/README.md +3 -3
  7. data/Rakefile +13 -4
  8. data/app/assets/images/favicon.ico +0 -0
  9. data/app/assets/javascripts/geoblacklight/downloaders/downloader.js +1 -1
  10. data/app/assets/javascripts/geoblacklight/geoblacklight.js +18 -1
  11. data/app/assets/javascripts/geoblacklight/modules/bookmarks.js +43 -0
  12. data/app/assets/javascripts/geoblacklight/modules/metadata_download_button.js +6 -1
  13. data/app/assets/javascripts/geoblacklight/modules/results.js +7 -8
  14. data/app/assets/javascripts/geoblacklight/modules/svg_tooltips.js +31 -0
  15. data/app/assets/javascripts/geoblacklight/modules/util.js +5 -0
  16. data/app/assets/javascripts/geoblacklight/viewers/esri.js +3 -3
  17. data/app/assets/javascripts/geoblacklight/viewers/esri/tiled_map_layer.js +1 -1
  18. data/app/assets/javascripts/geoblacklight/viewers/index_map.js +1 -1
  19. data/app/assets/javascripts/geoblacklight/viewers/map.js +12 -2
  20. data/app/assets/javascripts/geoblacklight/viewers/tms.js +10 -0
  21. data/app/assets/javascripts/geoblacklight/viewers/wms.js +3 -3
  22. data/app/assets/stylesheets/geoblacklight/geoblacklight.scss +2 -0
  23. data/app/assets/stylesheets/geoblacklight/modules/_base.scss +33 -0
  24. data/app/assets/stylesheets/geoblacklight/{_blacklight_overrides.scss → modules/_blacklight_overrides.scss} +1 -1
  25. data/app/assets/stylesheets/geoblacklight/{_styles.scss → modules/_styles.scss} +1 -0
  26. data/app/assets/stylesheets/geoblacklight/modules/downloads.scss +37 -54
  27. data/app/assets/stylesheets/geoblacklight/modules/item.scss +1 -0
  28. data/app/assets/stylesheets/geoblacklight/modules/results.scss +17 -29
  29. data/app/assets/stylesheets/geoblacklight/modules/sidebar.scss +12 -42
  30. data/app/assets/stylesheets/geoblacklight/modules/toolbar.scss +17 -59
  31. data/app/controllers/download_controller.rb +12 -12
  32. data/app/controllers/relation_controller.rb +1 -0
  33. data/app/controllers/wms_controller.rb +1 -0
  34. data/app/helpers/arcgis_helper.rb +1 -0
  35. data/app/helpers/blacklight_helper.rb +1 -0
  36. data/app/helpers/carto_helper.rb +1 -0
  37. data/app/helpers/geoblacklight_helper.rb +37 -72
  38. data/app/models/concerns/geoblacklight/solr_document.rb +15 -19
  39. data/app/models/concerns/geoblacklight/solr_document/arcgis.rb +2 -1
  40. data/app/models/concerns/geoblacklight/solr_document/carto.rb +1 -13
  41. data/app/models/concerns/geoblacklight/solr_document/citation.rb +1 -0
  42. data/app/models/concerns/geoblacklight/solr_document/finder.rb +1 -0
  43. data/app/models/concerns/geoblacklight/solr_document/inspection.rb +2 -1
  44. data/app/models/concerns/geoblacklight/spatial_search_behavior.rb +6 -4
  45. data/app/presenters/geoblacklight/document_presenter.rb +2 -1
  46. data/app/views/catalog/_arcgis.html.erb +4 -0
  47. data/app/views/catalog/_carto.html.erb +4 -0
  48. data/app/views/catalog/_document_split.html.erb +1 -1
  49. data/app/views/catalog/_downloads_primary.html.erb +8 -1
  50. data/app/views/catalog/_header_icons.html.erb +3 -3
  51. data/app/views/catalog/_home_text.html.erb +3 -0
  52. data/app/views/catalog/_index_split_default.html.erb +21 -21
  53. data/app/views/catalog/_show_default_viewer_container.html.erb +1 -1
  54. data/app/views/download/hgl.html.erb +13 -11
  55. data/app/views/relation/_ancestors.html.erb +3 -6
  56. data/app/views/relation/_descendants.html.erb +4 -7
  57. data/app/views/relation/index.html.erb +20 -8
  58. data/app/views/relation/index.json.jbuilder +2 -1
  59. data/app/views/shared/_header_navbar.html.erb +0 -2
  60. data/babel.config.json +4 -0
  61. data/bin/coverage.rb +36 -0
  62. data/config/initializers/new_gbl_settings_defaults_3_3.yml +10 -0
  63. data/config/initializers/rails_config.rb +5 -0
  64. data/config/locales/geoblacklight.en.yml +7 -2
  65. data/geoblacklight.gemspec +7 -9
  66. data/jest.config.js +25 -0
  67. data/lib/generators/geoblacklight/assets_generator.rb +46 -0
  68. data/lib/generators/geoblacklight/install_generator.rb +4 -10
  69. data/lib/generators/geoblacklight/templates/assets/_blacklight.scss +1 -0
  70. data/lib/generators/geoblacklight/templates/assets/_customizations.scss +28 -0
  71. data/{app/assets/stylesheets/geoblacklight/application.scss → lib/generators/geoblacklight/templates/assets/_geoblacklight.scss} +0 -1
  72. data/lib/generators/geoblacklight/templates/assets/application.scss +7 -0
  73. data/lib/generators/geoblacklight/templates/{geoblacklight.js → assets/geoblacklight.js} +0 -0
  74. data/lib/generators/geoblacklight/templates/catalog_controller.rb +5 -3
  75. data/lib/generators/geoblacklight/templates/settings.yml +20 -17
  76. data/lib/generators/geoblacklight/webpacker_generator.rb +1 -0
  77. data/lib/geoblacklight.rb +2 -2
  78. data/lib/geoblacklight/bounding_box.rb +2 -1
  79. data/lib/geoblacklight/catalog_helper_override.rb +1 -0
  80. data/lib/geoblacklight/constants.rb +2 -0
  81. data/lib/geoblacklight/download.rb +2 -1
  82. data/lib/geoblacklight/download/geojson_download.rb +1 -0
  83. data/lib/geoblacklight/download/geotiff_download.rb +1 -0
  84. data/lib/geoblacklight/download/hgl_download.rb +1 -0
  85. data/lib/geoblacklight/download/kmz_download.rb +3 -2
  86. data/lib/geoblacklight/download/shapefile_download.rb +1 -0
  87. data/lib/geoblacklight/engine.rb +2 -2
  88. data/lib/geoblacklight/exceptions.rb +1 -0
  89. data/lib/geoblacklight/geoblacklight_helper_behavior.rb +1 -0
  90. data/lib/geoblacklight/geometry.rb +70 -0
  91. data/lib/geoblacklight/item_viewer.rb +6 -1
  92. data/lib/geoblacklight/metadata.rb +1 -0
  93. data/lib/geoblacklight/metadata/base.rb +2 -7
  94. data/lib/geoblacklight/metadata/fgdc.rb +1 -0
  95. data/lib/geoblacklight/metadata/html.rb +2 -2
  96. data/lib/geoblacklight/metadata/iso19139.rb +1 -0
  97. data/lib/geoblacklight/metadata_transformer.rb +1 -0
  98. data/lib/geoblacklight/metadata_transformer/base.rb +1 -0
  99. data/lib/geoblacklight/metadata_transformer/fgdc.rb +1 -0
  100. data/lib/geoblacklight/metadata_transformer/iso19139.rb +1 -0
  101. data/lib/geoblacklight/reference.rb +1 -0
  102. data/lib/geoblacklight/references.rb +7 -3
  103. data/lib/geoblacklight/relation/ancestors.rb +3 -2
  104. data/lib/geoblacklight/relation/descendants.rb +2 -1
  105. data/lib/geoblacklight/relation/relation_response.rb +2 -1
  106. data/lib/geoblacklight/routes.rb +1 -0
  107. data/lib/geoblacklight/routes/downloadable.rb +1 -0
  108. data/lib/geoblacklight/routes/exportable.rb +1 -0
  109. data/lib/geoblacklight/routes/wms.rb +1 -0
  110. data/lib/geoblacklight/version.rb +2 -1
  111. data/lib/geoblacklight/view_helper_override.rb +1 -0
  112. data/lib/geoblacklight/wms_layer.rb +2 -4
  113. data/lib/geoblacklight/wms_layer/feature_info_response.rb +1 -0
  114. data/lib/tasks/geoblacklight.rake +38 -32
  115. data/package.json +17 -1
  116. data/setupJest.js +14 -0
  117. data/solr/conf/schema.xml +1 -3
  118. data/spec/config/initializers/rails_config_spec.rb +14 -0
  119. data/spec/controllers/catalog_controller_spec.rb +7 -6
  120. data/spec/controllers/download_controller_spec.rb +1 -0
  121. data/spec/controllers/relation_controller_spec.rb +1 -0
  122. data/spec/controllers/wms_controller_spec.rb +1 -0
  123. data/spec/factories/user.rb +1 -0
  124. data/spec/features/bookmarks_spec.rb +1 -0
  125. data/spec/features/configurable_basemap_spec.rb +1 -0
  126. data/spec/features/data_dictionary_download_spec.rb +1 -0
  127. data/spec/features/download_layer_spec.rb +2 -1
  128. data/spec/features/empty_search_spec.rb +1 -0
  129. data/spec/features/esri_viewer_spec.rb +1 -5
  130. data/spec/features/exports_spec.rb +4 -12
  131. data/spec/features/help_text_spec.rb +1 -0
  132. data/spec/features/home_page_spec.rb +6 -0
  133. data/spec/features/iiif_viewer_spec.rb +1 -0
  134. data/spec/features/index_map_spec.rb +1 -0
  135. data/spec/features/layer_inspection_spec.rb +1 -0
  136. data/spec/features/layer_opacity_spec.rb +1 -0
  137. data/spec/features/layer_preview_spec.rb +1 -0
  138. data/spec/features/layer_with_no_references_spec.rb +1 -0
  139. data/spec/features/linkified_attribute_table_spec.rb +1 -0
  140. data/spec/features/metadata_panel_spec.rb +1 -0
  141. data/spec/features/missing_metadata_spec.rb +1 -0
  142. data/spec/features/multiple_downloads_spec.rb +15 -0
  143. data/spec/features/oembed_spec.rb +1 -0
  144. data/spec/features/relations_spec.rb +10 -29
  145. data/spec/features/saved_searches_spec.rb +1 -0
  146. data/spec/features/search_bar_spec.rb +1 -0
  147. data/spec/features/search_results_map_spec.rb +1 -6
  148. data/spec/features/search_results_overlap_ratio_spec.rb +6 -5
  149. data/spec/features/search_spec.rb +1 -0
  150. data/spec/features/show_page_metadata_spec.rb +1 -0
  151. data/spec/features/sms_spec.rb +1 -0
  152. data/spec/features/split_view.html.erb_spec.rb +3 -2
  153. data/spec/features/suppressed_records_spec.rb +1 -0
  154. data/spec/features/tms_spec.rb +10 -0
  155. data/spec/features/web_services_modal_spec.rb +1 -0
  156. data/spec/fixtures/solr_documents/multiple-downloads.json +30 -0
  157. data/spec/fixtures/solr_documents/public_iiif_princeton.json +1 -1
  158. data/spec/fixtures/solr_documents/tms.json +29 -0
  159. data/spec/helpers/arcgis_helper_spec.rb +1 -0
  160. data/spec/helpers/carto_helper_spec.rb +1 -0
  161. data/spec/helpers/geoblacklight_helper_spec.rb +73 -14
  162. data/spec/javascripts/geoblacklight_spec.js +0 -6
  163. data/spec/javascripts/metadata_download_button_spec.js +5 -3
  164. data/spec/javascripts/util_spec.js +2 -4
  165. data/spec/lib/geoblacklight/bounding_box_spec.rb +1 -0
  166. data/spec/lib/geoblacklight/document_presenter_spec.rb +3 -2
  167. data/spec/lib/geoblacklight/download/geojson_download_spec.rb +1 -0
  168. data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +1 -0
  169. data/spec/lib/geoblacklight/download/hgl_download_spec.rb +1 -0
  170. data/spec/lib/geoblacklight/download/kmz_download_spec.rb +3 -2
  171. data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +1 -0
  172. data/spec/lib/geoblacklight/download_spec.rb +3 -2
  173. data/spec/lib/geoblacklight/geoblacklight_helper_behavior_spec.rb +1 -0
  174. data/spec/lib/geoblacklight/geometry_spec.rb +48 -0
  175. data/spec/lib/geoblacklight/item_viewer_spec.rb +13 -0
  176. data/spec/lib/geoblacklight/metadata/base_spec.rb +1 -0
  177. data/spec/lib/geoblacklight/metadata/html_spec.rb +1 -0
  178. data/spec/lib/geoblacklight/metadata_spec.rb +1 -0
  179. data/spec/lib/geoblacklight/metadata_transformer/base_spec.rb +3 -2
  180. data/spec/lib/geoblacklight/metadata_transformer/fgdc_spec.rb +3 -2
  181. data/spec/lib/geoblacklight/metadata_transformer/iso19139_spec.rb +3 -2
  182. data/spec/lib/geoblacklight/metadata_transformer_spec.rb +4 -3
  183. data/spec/lib/geoblacklight/reference_spec.rb +1 -0
  184. data/spec/lib/geoblacklight/references_spec.rb +3 -4
  185. data/spec/lib/geoblacklight/relation/ancestors_spec.rb +2 -1
  186. data/spec/lib/geoblacklight/relation/descendants_spec.rb +2 -1
  187. data/spec/lib/geoblacklight/relation/relation_response_spec.rb +1 -0
  188. data/spec/lib/geoblacklight/view_helper_override_spec.rb +1 -0
  189. data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +5 -4
  190. data/spec/lib/geoblacklight/wms_layer_spec.rb +1 -0
  191. data/spec/models/concerns/geoblacklight/solr_document/carto_spec.rb +1 -20
  192. data/spec/models/concerns/geoblacklight/solr_document/citation_spec.rb +1 -0
  193. data/spec/models/concerns/geoblacklight/solr_document/finder_spec.rb +1 -0
  194. data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +1 -0
  195. data/spec/models/concerns/geoblacklight/solr_document_spec.rb +1 -0
  196. data/spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb +15 -2
  197. data/spec/routing/catalog_routing_spec.rb +1 -0
  198. data/spec/spec_helper.rb +12 -9
  199. data/spec/support/backport_test_helpers.rb +1 -0
  200. data/spec/support/features.rb +1 -0
  201. data/spec/support/features/session_helpers.rb +1 -0
  202. data/spec/support/fixtures.rb +1 -0
  203. data/spec/tasks/geoblacklight_spec.rb +4 -3
  204. data/spec/test_app_templates/Gemfile.extra +1 -0
  205. data/spec/test_app_templates/lib/generators/test_app_generator.rb +2 -8
  206. data/spec/views/catalog/_document_split.html.erb_spec.rb +2 -1
  207. data/spec/views/catalog/_index_split.html.erb_spec.rb +2 -1
  208. data/spec/views/catalog/_results_pagination.html.erb_spec.rb +1 -0
  209. data/spec/views/catalog/_show_downloads.html.erb_spec.rb +1 -0
  210. data/spec/views/catalog/_show_tools.html.erb_spec.rb +3 -5
  211. data/template.rb +4 -2
  212. metadata +74 -78
  213. data/.circleci/config.yml +0 -164
  214. data/app/assets/stylesheets/geoblacklight/_geoblacklight.scss +0 -36
  215. data/app/assets/stylesheets/geoblacklight/modules/relations.scss +0 -15
  216. data/app/views/catalog/_exports.html.erb +0 -3
  217. data/app/views/catalog/_show_tools.html.erb +0 -25
  218. data/lib/generators/geoblacklight/templates/geoblacklight.scss +0 -4
  219. data/spec/javascripts/spec_helper.js +0 -32
  220. data/spec/lib/geoblacklight/controller_override_spec.rb +0 -1
  221. data/spec/teaspoon_env.rb +0 -213
  222. data/vendor/assets/javascripts/readmore.js +0 -0
  223. data/vendor/assets/javascripts/readmore.min.js +0 -0
@@ -1,14 +1,15 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  class KmzDownload < Geoblacklight::Download
3
4
  KMZ_DOWNLOAD_PARAMS = { service: 'wms',
4
5
  version: '1.1.0',
5
6
  request: 'GetMap',
6
- srsName: 'EPSG:900913',
7
+ srsName: 'EPSG:3857',
7
8
  format: 'application/vnd.google-earth.kmz',
8
9
  width: 2000, height: 2000 }.freeze
9
10
 
10
11
  def initialize(document, options = {})
11
- bbox_wsen = document.bounding_box_as_wsen.split(' ').join(', ')
12
+ bbox_wsen = document.geometry.bounding_box
12
13
  request_params = KMZ_DOWNLOAD_PARAMS.merge(layers: document[:layer_id_s], bbox: bbox_wsen)
13
14
  super(document, {
14
15
  type: 'kmz',
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  class ShapefileDownload < Geoblacklight::Download
3
4
  SHAPEFILE_DOWNLOAD_PARAMS = { service: 'wfs',
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  require 'blacklight'
2
- require 'font-awesome-rails'
3
3
  require 'coderay'
4
4
  require 'config'
5
5
  require 'faraday'
6
6
  require 'faraday_middleware'
7
+ require 'geoblacklight/version'
7
8
  require 'nokogiri'
8
- require 'geoblacklight-icons'
9
9
  require 'mime/types'
10
10
  require 'handlebars_assets'
11
11
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Exceptions
3
4
  class ExternalDownloadFailed < StandardError
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  ##
3
4
  # Adds helper behavior logic for GeoBlacklight, to used alongside
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+ require 'rgeo'
3
+ require 'rgeo-geojson'
4
+
5
+ module Geoblacklight
6
+ # Transforms and parses geometry expressed in WKT or CSW WKT ENVELOPE syntax
7
+ class Geometry
8
+ attr_reader :geom
9
+
10
+ # @param [String] geom WKT or WKT ENVELOPE syntax formatted string
11
+ def initialize(geom)
12
+ @geom = geom
13
+ end
14
+
15
+ # Convert geometry to GeoJSON
16
+ # @return [String]
17
+ def geojson
18
+ obj = factory.parse_wkt(geometry_as_wkt)
19
+ RGeo::GeoJSON.encode(obj).to_json
20
+ rescue RGeo::Error::ParseError
21
+ ''
22
+ end
23
+
24
+ # Generate a wsen bounding box from the geometry
25
+ # @return [String] bounding box as comma delimited wsen "w, s, e, n"
26
+ def bounding_box
27
+ obj = factory.parse_wkt(geometry_as_wkt)
28
+
29
+ # Get the minimum bounding box for the geometry as a Polygon
30
+ bbox = obj.envelope
31
+
32
+ # Return as wsen string
33
+ minx = bbox.coordinates[0][0][0]
34
+ miny = bbox.coordinates[0][0][1]
35
+ maxx = bbox.coordinates[0][1][0]
36
+ maxy = bbox.coordinates[0][2][1]
37
+ "#{minx}, #{miny}, #{maxx}, #{maxy}"
38
+ rescue RGeo::Error::ParseError
39
+ ''
40
+ end
41
+
42
+ private
43
+
44
+ # Convert WKT ENVELOPE string to WKT POLYGON string
45
+ # @return [String]
46
+ def envelope_to_polygon
47
+ exp = /^\s*ENVELOPE\(
48
+ \s*([-.\d]+)\s*,
49
+ \s*([-.\d]+)\s*,
50
+ \s*([-.\d]+)\s*,
51
+ \s*([-.\d]+)\s*
52
+ \)\s*$/x # uses 'x' option for free-spacing mode
53
+ bbox_match = exp.match(geom)
54
+ minx, maxx, maxy, miny = bbox_match.captures
55
+ "POLYGON ((#{minx} #{maxy}, #{minx} #{miny}, #{maxx} #{miny}, #{maxx} #{maxy}, #{minx} #{maxy}))"
56
+ end
57
+
58
+ def factory
59
+ @factory ||= RGeo::Cartesian.factory
60
+ end
61
+
62
+ # Return geometry as valid WKT string
63
+ # @return [String]
64
+ def geometry_as_wkt
65
+ return geom unless geom.match?(/ENVELOPE/)
66
+
67
+ envelope_to_polygon
68
+ end
69
+ end
70
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  class ItemViewer
3
4
  def initialize(references)
@@ -46,8 +47,12 @@ module Geoblacklight
46
47
  @references.oembed
47
48
  end
48
49
 
50
+ def tms
51
+ @references.tms
52
+ end
53
+
49
54
  def viewer_preference
50
- [oembed, index_map, wms, iiif, tiled_map_layer, dynamic_map_layer,
55
+ [oembed, index_map, tms, wms, iiif, tiled_map_layer, dynamic_map_layer,
51
56
  image_map_layer, feature_layer].compact.map(&:to_hash).first
52
57
  end
53
58
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Metadata
3
4
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Metadata
3
4
  ##
@@ -54,13 +55,7 @@ module Geoblacklight
54
55
  return response.body unless response.nil? || response.status == 404
55
56
  Geoblacklight.logger.error "Could not reach #{@reference.endpoint}"
56
57
  ''
57
- rescue Faraday::ConnectionFailed => error
58
- Geoblacklight.logger.error error.inspect
59
- ''
60
- rescue Faraday::TimeoutError => error
61
- Geoblacklight.logger.error error.inspect
62
- ''
63
- rescue OpenSSL::SSL::SSLError => error
58
+ rescue Faraday::ConnectionFailed, Faraday::TimeoutError, OpenSSL::SSL::SSLError => error
64
59
  Geoblacklight.logger.error error.inspect
65
60
  ''
66
61
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Metadata
3
4
  class Fgdc < Base
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Metadata
3
4
  class Html < Base
4
5
  def transform
5
- ActionController::Base.helpers.content_tag(:iframe,
6
- '',
6
+ ActionController::Base.helpers.tag.iframe('',
7
7
  src: @reference.endpoint,
8
8
  scrolling: 'yes',
9
9
  frameborder: 0)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Metadata
3
4
  class Iso19139 < Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'geo_combine'
2
3
 
3
4
  module Geoblacklight
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module MetadataTransformer
3
4
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module MetadataTransformer
3
4
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module MetadataTransformer
3
4
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  ##
3
4
  # Parses an array of dct_references to create useful reference information
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  # References is a geoblacklight-schema dct:references parser
3
4
  class References
@@ -43,7 +44,7 @@ module Geoblacklight
43
44
  # Preferred download (should be a file download)
44
45
  # @return [Hash, nil]
45
46
  def preferred_download
46
- return file_download unless download.blank?
47
+ return file_download if download.present?
47
48
  end
48
49
 
49
50
  ##
@@ -100,9 +101,12 @@ module Geoblacklight
100
101
  # present
101
102
  # @return (see #downloads_by_format)
102
103
  def vector_download_formats
103
- { shapefile: wfs.to_hash,
104
+ return unless wms.present? && wfs.present?
105
+ {
106
+ shapefile: wfs.to_hash,
104
107
  kmz: wms.to_hash,
105
- geojson: wfs.to_hash } if wms.present? && wfs.present?
108
+ geojson: wfs.to_hash
109
+ }
106
110
  end
107
111
 
108
112
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Relation
3
4
  class Ancestors
@@ -7,8 +8,8 @@ module Geoblacklight
7
8
  end
8
9
 
9
10
  def create_search_params
10
- { fq: ["{!join from=#{Settings.FIELDS.SOURCE} to=layer_slug_s}layer_slug_s:#{@search_id}"],
11
- fl: [Settings.FIELDS.TITLE, 'layer_slug_s', Settings.FIELDS.GEOM_TYPE] }
11
+ { fq: ["{!join from=#{Settings.FIELDS.SOURCE} to=#{Settings.FIELDS.UNIQUE_KEY}}#{Settings.FIELDS.UNIQUE_KEY}:#{@search_id}"],
12
+ fl: [Settings.FIELDS.TITLE, Settings.FIELDS.UNIQUE_KEY, Settings.FIELDS.GEOM_TYPE] }
12
13
  end
13
14
 
14
15
  def execute_query
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Relation
3
4
  class Descendants
@@ -8,7 +9,7 @@ module Geoblacklight
8
9
 
9
10
  def create_search_params
10
11
  { fq: "#{Settings.FIELDS.SOURCE}:#{@search_id}",
11
- fl: [Settings.FIELDS.TITLE, 'layer_slug_s', Settings.FIELDS.GEOM_TYPE] }
12
+ fl: [Settings.FIELDS.TITLE, Settings.FIELDS.UNIQUE_KEY, Settings.FIELDS.GEOM_TYPE] }
12
13
  end
13
14
 
14
15
  def execute_query
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Relation
3
4
  class RelationResponse
@@ -17,7 +18,7 @@ module Geoblacklight
17
18
  end
18
19
 
19
20
  def empty?
20
- !(ancestors['numFound'] > 0 || descendants['numFound'] > 0)
21
+ !(ancestors['numFound'].positive? || descendants['numFound'].positive?)
21
22
  end
22
23
  end
23
24
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Routes
3
4
  require 'geoblacklight/routes/exportable'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Routes
3
4
  class Downloadable
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Routes
3
4
  class Exportable
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module Routes
3
4
  class Wms
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
- VERSION = '2.4.0'.freeze
3
+ VERSION = '3.3.0'
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  module ViewHelperOverride
3
4
  include CatalogHelperOverride
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  class WmsLayer
3
4
  def initialize(params)
@@ -24,10 +25,7 @@ module Geoblacklight
24
25
  request.options.timeout = Settings.TIMEOUT_WMS
25
26
  request.options.open_timeout = Settings.TIMEOUT_WMS
26
27
  end
27
- rescue Faraday::ConnectionFailed => error
28
- Geoblacklight.logger.error error.inspect
29
- { error: error.inspect }
30
- rescue Faraday::TimeoutError => error
28
+ rescue Faraday::ConnectionFailed, Faraday::TimeoutError => error
31
29
  Geoblacklight.logger.error error.inspect
32
30
  { error: error.inspect }
33
31
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Geoblacklight
2
3
  class FeatureInfoResponse
3
4
  def initialize(response)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators'
2
3
  require 'generators/geoblacklight/install_generator'
3
4
 
@@ -7,15 +8,15 @@ namespace :geoblacklight do
7
8
  require 'solr_wrapper'
8
9
  SolrWrapper.wrap(port: '8983') do |solr|
9
10
  solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path('../../', File.dirname(__FILE__)), 'solr', 'conf')) do
10
- puts "\nSolr server running: http://localhost:#{solr.port}/solr/#/blacklight-core"
11
- puts "\n^C to stop"
12
- puts ' '
13
- begin
14
- Rake::Task['geoblacklight:solr:seed'].invoke
15
- system "bundle exec rails s #{args[:rails_server_args]}"
16
- rescue Interrupt
17
- puts 'Shutting down...'
18
- end
11
+ puts "\nSolr server running: http://localhost:#{solr.port}/solr/#/blacklight-core"
12
+ puts "\n^C to stop"
13
+ puts ' '
14
+ begin
15
+ Rake::Task['geoblacklight:solr:seed'].invoke
16
+ system "bundle exec rails s #{args[:rails_server_args]}"
17
+ rescue Interrupt
18
+ puts 'Shutting down...'
19
+ end
19
20
  end
20
21
  end
21
22
  end
@@ -30,7 +31,7 @@ namespace :geoblacklight do
30
31
  puts ' '
31
32
  begin
32
33
  Rake::Task['geoblacklight:solr:seed'].invoke
33
- system "foreman start"
34
+ system 'foreman start'
34
35
  rescue Interrupt
35
36
  puts 'Shutting down...'
36
37
  end
@@ -39,23 +40,23 @@ namespace :geoblacklight do
39
40
  end
40
41
 
41
42
  namespace :index do
42
- desc "Put sample data into solr"
43
+ desc 'Put sample data into solr'
43
44
  task :seed => :environment do
44
45
  docs = Dir['spec/fixtures/solr_documents/*.json'].map { |f| JSON.parse File.read(f) }.flatten
45
46
  Blacklight.default_index.connection.add docs
46
47
  Blacklight.default_index.connection.commit
47
48
  end
48
49
 
49
- desc "Ingests a GeoHydra transformed.json"
50
+ desc 'Ingests a GeoHydra transformed.json'
50
51
  task :ingest_all => :environment do
51
- docs = JSON::parse(File.read("#{Rails.root}/tmp/transformed.json"))
52
+ docs = JSON.parse(File.read(Rails.root.join('tmp', 'transformed.json')))
52
53
  docs.each do |doc|
53
54
  Blacklight.default_index.connection.add doc
54
55
  Blacklight.default_index.connection.commit
55
56
  end
56
57
  end
57
58
 
58
- desc "Ingests a directory of geoblacklight.json files"
59
+ desc 'Ingests a directory of geoblacklight.json files'
59
60
  task :ingest, [:directory] => :environment do |_t, args|
60
61
  args.with_defaults(directory: 'data')
61
62
  Dir.glob(File.join(args[:directory], '**', 'geoblacklight.json')).each do |fn|
@@ -66,7 +67,7 @@ namespace :geoblacklight do
66
67
  puts "Failed to ingest #{fn}: #{e.inspect}"
67
68
  end
68
69
  end
69
- puts "Committing changes to Solr"
70
+ puts 'Committing changes to Solr'
70
71
  Blacklight.default_index.connection.commit
71
72
  end
72
73
  end
@@ -74,35 +75,40 @@ namespace :geoblacklight do
74
75
  namespace :downloads do
75
76
  desc 'Delete all cached downloads'
76
77
  task delete: :environment do
77
- FileUtils.rm_rf Dir.glob("#{Rails.root}/tmp/cache/downloads/*")
78
+ FileUtils.rm_rf Dir.glob(Rails.root.join('tmp', 'cache', 'downloads', '*'))
78
79
  end
79
80
  desc 'Create download directory'
80
81
  task mkdir: :environment do
81
- FileUtils.mkdir_p Rails.root.join('tmp/cache/downloads'), verbose: true
82
+ FileUtils.mkdir_p(Rails.root.join('tmp', 'cache', 'downloads'), verbose: true)
82
83
  end
83
84
  desc 'Precaches a download'
84
- task :precache, [:doc_id, :download_type, :timeout] => [:environment] do |t, args|
85
- begin
86
- fail 'Please supply required arguments [document_id, download_type and timeout]' unless args[:doc_id] && args[:download_type] && args[:timeout]
87
- document = Geoblacklight::SolrDocument.find(args[:doc_id])
88
- fail Blacklight::Exceptions::RecordNotFound if document[:layer_slug_s] != args[:doc_id]
89
- download = "Geoblacklight::#{args[:download_type].capitalize}Download"
90
- .constantize.new(document, timeout: args[:timeout].to_i)
91
- download.get
92
- Rails.logger.info "Successfully downloaded #{download.file_name}"
93
- Rails.logger.info "#{Geoblacklight::ShapefileDownload.file_path}"
94
- rescue Geoblacklight::Exceptions::ExternalDownloadFailed => error
95
- Rails.logger.error error.message + ' ' + error.url
96
- rescue NameError
97
- Rails.logger.error "Could not find that download type \"#{args[:download_type]}\""
85
+ task :precache, [:doc_id, :download_type, :timeout] => [:environment] do |_t, args|
86
+ unless args[:doc_id] && args[:download_type] && args[:timeout]
87
+ fail 'Please supply required arguments [document_id, download_type and timeout]'
98
88
  end
89
+ document = Geoblacklight::SolrDocument.find(args[:doc_id])
90
+ fail Blacklight::Exceptions::RecordNotFound if document[:layer_slug_s] != args[:doc_id]
91
+ download = "Geoblacklight::#{args[:download_type].capitalize}Download"
92
+ .constantize.new(document, timeout: args[:timeout].to_i)
93
+ download.get
94
+ Rails.logger.info "Successfully downloaded #{download.file_name}"
95
+ Rails.logger.info Geoblacklight::ShapefileDownload.file_path.to_s
96
+ rescue Geoblacklight::Exceptions::ExternalDownloadFailed => error
97
+ Rails.logger.error error.message + ' ' + error.url
98
+ rescue NameError
99
+ Rails.logger.error "Could not find that download type \"#{args[:download_type]}\""
99
100
  end
100
101
  end
101
102
 
102
103
  namespace :solr do
103
- desc "Put sample data into solr"
104
+ desc 'Put sample data into solr'
104
105
  task :seed => :environment do
105
106
  Rake::Task['geoblacklight:index:seed'].invoke
106
107
  end
107
108
  end
109
+
110
+ desc 'Stdout output asset paths'
111
+ task application_asset_paths: [:environment] do
112
+ puts Rails.application.config.assets.paths
113
+ end
108
114
  end