geoblacklight 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +21 -6
- data/.solr_wrapper +1 -0
- data/.standard.yml +1 -0
- data/Gemfile +13 -11
- data/README.md +1 -1
- data/Rakefile +42 -50
- data/app/assets/images/blacklight/american-geographical-society-library-uwm-libraries.svg +26 -0
- data/app/assets/images/blacklight/arizona.svg +4 -0
- data/app/assets/images/blacklight/circle-info-solid.svg +1 -0
- data/app/assets/images/blacklight/fire-solid.svg +1 -0
- data/app/assets/images/blacklight/lightbulb-solid.svg +1 -0
- data/app/assets/images/blacklight/nebraska.svg +4 -0
- data/app/assets/images/blacklight/rutgers.svg +5 -0
- data/app/assets/images/blacklight/triangle-exclamation-solid.svg +1 -0
- data/app/assets/stylesheets/geoblacklight/modules/sidebar.scss +8 -0
- data/app/components/geoblacklight/display_note_component.html.erb +1 -0
- data/app/components/geoblacklight/display_note_component.rb +47 -0
- data/app/components/geoblacklight/icon_facet_item_component.rb +2 -2
- data/app/controllers/download_controller.rb +36 -37
- data/app/controllers/relation_controller.rb +1 -0
- data/app/controllers/wms_controller.rb +1 -0
- data/app/helpers/arcgis_helper.rb +2 -1
- data/app/helpers/blacklight_helper.rb +2 -1
- data/app/helpers/carto_helper.rb +3 -2
- data/app/helpers/geoblacklight/geoblacklight_helper_behavior.rb +2 -1
- data/app/helpers/geoblacklight_helper.rb +44 -36
- data/app/models/concerns/geoblacklight/bbox_filter_query.rb +1 -1
- data/app/models/concerns/geoblacklight/solr_document/arcgis.rb +1 -0
- data/app/models/concerns/geoblacklight/solr_document/carto.rb +1 -0
- data/app/models/concerns/geoblacklight/solr_document/citation.rb +3 -2
- data/app/models/concerns/geoblacklight/solr_document/finder.rb +1 -0
- data/app/models/concerns/geoblacklight/solr_document/inspection.rb +1 -0
- data/app/models/concerns/geoblacklight/solr_document.rb +17 -9
- data/app/models/concerns/geoblacklight/suppressed_records_search_behavior.rb +2 -1
- data/app/presenters/geoblacklight/document_presenter.rb +3 -2
- data/app/views/catalog/_show_default_display_note.html.erb +7 -0
- data/app/views/catalog/_show_sidebar.html.erb +1 -0
- data/app/views/catalog/_show_sidebar_static_map.html.erb +10 -0
- data/app/views/relation/index.json.jbuilder +1 -1
- data/config/initializers/new_gbl_settings_defaults_4.1.yml +104 -0
- data/config/initializers/rails_config.rb +5 -1
- data/config/locales/geoblacklight.en.yml +18 -10
- data/geoblacklight.gemspec +36 -40
- data/lib/generators/geoblacklight/assets_generator.rb +15 -15
- data/lib/generators/geoblacklight/install_generator.rb +24 -23
- data/lib/generators/geoblacklight/templates/catalog_controller.rb +66 -71
- data/lib/generators/geoblacklight/templates/settings.yml +74 -22
- data/lib/geoblacklight/bounding_box.rb +1 -0
- data/lib/geoblacklight/constants.rb +26 -25
- data/lib/geoblacklight/download/geojson_download.rb +10 -9
- data/lib/geoblacklight/download/geotiff_download.rb +6 -5
- data/lib/geoblacklight/download/hgl_download.rb +4 -3
- data/lib/geoblacklight/download/kmz_download.rb +11 -10
- data/lib/geoblacklight/download/shapefile_download.rb +10 -9
- data/lib/geoblacklight/download.rb +12 -11
- data/lib/geoblacklight/engine.rb +10 -9
- data/lib/geoblacklight/exceptions.rb +3 -0
- data/lib/geoblacklight/faraday_middleware/follow_redirects.rb +12 -11
- data/lib/geoblacklight/geometry.rb +6 -5
- data/lib/geoblacklight/item_viewer.rb +4 -3
- data/lib/geoblacklight/metadata/base.rb +4 -3
- data/lib/geoblacklight/metadata/fgdc.rb +1 -0
- data/lib/geoblacklight/metadata/html.rb +5 -4
- data/lib/geoblacklight/metadata/iso19139.rb +1 -0
- data/lib/geoblacklight/metadata.rb +1 -0
- data/lib/geoblacklight/metadata_transformer/base.rb +5 -4
- data/lib/geoblacklight/metadata_transformer/fgdc.rb +1 -0
- data/lib/geoblacklight/metadata_transformer/iso19139.rb +1 -0
- data/lib/geoblacklight/metadata_transformer.rb +6 -2
- data/lib/geoblacklight/reference.rb +3 -2
- data/lib/geoblacklight/references.rb +11 -6
- data/lib/geoblacklight/relation/ancestors.rb +4 -3
- data/lib/geoblacklight/relation/descendants.rb +4 -3
- data/lib/geoblacklight/relation/relation_response.rb +3 -2
- data/lib/geoblacklight/routes/downloadable.rb +3 -2
- data/lib/geoblacklight/routes/exportable.rb +4 -3
- data/lib/geoblacklight/routes/wms.rb +2 -1
- data/lib/geoblacklight/routes.rb +4 -3
- data/lib/geoblacklight/version.rb +2 -1
- data/lib/geoblacklight/view_helper_override.rb +3 -2
- data/lib/geoblacklight/wms_layer/feature_info_response.rb +5 -4
- data/lib/geoblacklight/wms_layer.rb +4 -3
- data/lib/geoblacklight.rb +32 -31
- data/lib/tasks/geoblacklight.rake +45 -44
- data/schema/geoblacklight-schema-aardvark.json +6 -0
- data/spec/components/geoblacklight/display_note_component_spec.rb +27 -0
- data/spec/components/geoblacklight/homepage_feature_facet_component_spec.rb +11 -10
- data/spec/components/geoblacklight/icon_facet_item_component_spec.rb +8 -7
- data/spec/config/initializers/rails_config_spec.rb +10 -9
- data/spec/controllers/catalog_controller_spec.rb +27 -26
- data/spec/controllers/download_controller_spec.rb +50 -49
- data/spec/controllers/relation_controller_spec.rb +5 -4
- data/spec/controllers/wms_controller_spec.rb +10 -9
- data/spec/factories/user.rb +3 -2
- data/spec/features/bookmarks_spec.rb +7 -6
- data/spec/features/configurable_basemap_spec.rb +12 -11
- data/spec/features/data_dictionary_download_spec.rb +11 -10
- data/spec/features/download_layer_spec.rb +64 -63
- data/spec/features/empty_search_spec.rb +6 -5
- data/spec/features/esri_viewer_spec.rb +33 -32
- data/spec/features/exports_spec.rb +18 -17
- data/spec/features/full_screen_controll_spec.rb +8 -8
- data/spec/features/help_text_spec.rb +6 -5
- data/spec/features/home_page_spec.rb +30 -29
- data/spec/features/iiif_viewer_spec.rb +6 -5
- data/spec/features/index_map_spec.rb +17 -16
- data/spec/features/layer_inspection_spec.rb +8 -7
- data/spec/features/layer_opacity_spec.rb +15 -14
- data/spec/features/layer_preview_spec.rb +11 -10
- data/spec/features/layer_with_no_references_spec.rb +5 -4
- data/spec/features/linkified_attribute_table_spec.rb +8 -7
- data/spec/features/metadata_panel_spec.rb +32 -31
- data/spec/features/missing_metadata_spec.rb +18 -17
- data/spec/features/multiple_downloads_spec.rb +11 -10
- data/spec/features/oembed_spec.rb +6 -5
- data/spec/features/relations_spec.rb +51 -26
- data/spec/features/saved_searches_spec.rb +7 -6
- data/spec/features/search_bar_spec.rb +9 -8
- data/spec/features/search_results_complex_geometry_spec.rb +12 -11
- data/spec/features/search_results_icons_spec.rb +10 -9
- data/spec/features/search_results_map_spec.rb +21 -20
- data/spec/features/search_results_overlap_ratio_spec.rb +17 -16
- data/spec/features/search_spec.rb +19 -18
- data/spec/features/show_page_download_spec.rb +15 -14
- data/spec/features/show_page_metadata_spec.rb +9 -8
- data/spec/features/show_page_sidebar_static_map_spec.rb +21 -0
- data/spec/features/sms_spec.rb +12 -11
- data/spec/features/split_view.html.erb_spec.rb +56 -55
- data/spec/features/suppressed_records_spec.rb +10 -9
- data/spec/features/tilejson_spec.rb +9 -8
- data/spec/features/tms_spec.rb +6 -5
- data/spec/features/web_services_modal_spec.rb +37 -36
- data/spec/features/wmts_spec.rb +16 -15
- data/spec/features/xyz_spec.rb +6 -5
- data/spec/fixtures/solr_documents/actual-papermap1.json +1 -1
- data/spec/fixtures/solr_documents/actual-point1.json +1 -1
- data/spec/fixtures/solr_documents/actual-polygon1.json +1 -1
- data/spec/fixtures/solr_documents/actual-raster1.json +1 -1
- data/spec/fixtures/solr_documents/baruch_ancestor1.json +1 -1
- data/spec/fixtures/solr_documents/baruch_ancestor2.json +1 -1
- data/spec/fixtures/solr_documents/baruch_documentation_download.json +2 -2
- data/spec/fixtures/solr_documents/cornell_html_metadata.json +1 -1
- data/spec/fixtures/solr_documents/display-note.json +52 -0
- data/spec/fixtures/solr_documents/esri-dynamic-layer-all-layers.json +1 -1
- data/spec/fixtures/solr_documents/esri-dynamic-layer-single-layer.json +1 -1
- data/spec/fixtures/solr_documents/esri-feature-layer.json +1 -1
- data/spec/fixtures/solr_documents/esri-image-map-layer.json +1 -1
- data/spec/fixtures/solr_documents/esri-tiled_map_layer.json +1 -1
- data/spec/fixtures/solr_documents/esri-wms-layer.json +1 -1
- data/spec/fixtures/solr_documents/harvard_raster.json +1 -1
- data/spec/fixtures/solr_documents/iiif-eastern-hemisphere.json +1 -1
- data/spec/fixtures/solr_documents/index-map-polygon-no-downloadurl.json +1 -1
- data/spec/fixtures/solr_documents/index-map-polygon.json +1 -1
- data/spec/fixtures/solr_documents/index-map-stanford.json +1 -1
- data/spec/fixtures/solr_documents/index_map_point.json +1 -1
- data/spec/fixtures/solr_documents/princeton-parent.json +1 -1
- data/spec/fixtures/solr_documents/public_direct_download.json +1 -1
- data/spec/fixtures/solr_documents/public_iiif_princeton.json +1 -1
- data/spec/fixtures/solr_documents/restricted-line.json +1 -1
- data/spec/fixtures/solr_documents/tilejson.json +2 -2
- data/spec/fixtures/solr_documents/umn_metro_result1.json +2 -2
- data/spec/fixtures/solr_documents/umn_state_result1.json +1 -1
- data/spec/fixtures/solr_documents/umn_state_result2.json +1 -1
- data/spec/fixtures/solr_documents/uva_slug_colon.json +1 -1
- data/spec/fixtures/solr_documents/wmts-multiple.json +1 -1
- data/spec/fixtures/solr_documents/wmts-single-layer.json +6 -6
- data/spec/fixtures/solr_documents/xyz.json +3 -3
- data/spec/helpers/arcgis_helper_spec.rb +8 -7
- data/spec/helpers/carto_helper_spec.rb +6 -5
- data/spec/helpers/geoblacklight/geoblacklight_helper_behavior_spec.rb +10 -15
- data/spec/helpers/geoblacklight_helper_spec.rb +139 -138
- data/spec/lib/geoblacklight/bounding_box_spec.rb +14 -13
- data/spec/lib/geoblacklight/document_presenter_spec.rb +26 -25
- data/spec/lib/geoblacklight/download/geojson_download_spec.rb +8 -7
- data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +8 -7
- data/spec/lib/geoblacklight/download/hgl_download_spec.rb +16 -15
- data/spec/lib/geoblacklight/download/kmz_download_spec.rb +9 -8
- data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +8 -7
- data/spec/lib/geoblacklight/download_spec.rb +61 -60
- data/spec/lib/geoblacklight/geometry_spec.rb +29 -28
- data/spec/lib/geoblacklight/item_viewer_spec.rb +25 -24
- data/spec/lib/geoblacklight/metadata/base_spec.rb +44 -43
- data/spec/lib/geoblacklight/metadata/html_spec.rb +7 -6
- data/spec/lib/geoblacklight/metadata_spec.rb +15 -14
- data/spec/lib/geoblacklight/metadata_transformer/base_spec.rb +13 -12
- data/spec/lib/geoblacklight/metadata_transformer/fgdc_spec.rb +8 -7
- data/spec/lib/geoblacklight/metadata_transformer/iso19139_spec.rb +8 -7
- data/spec/lib/geoblacklight/metadata_transformer_spec.rb +15 -14
- data/spec/lib/geoblacklight/reference_spec.rb +28 -27
- data/spec/lib/geoblacklight/references_spec.rb +89 -76
- data/spec/lib/geoblacklight/relation/ancestors_spec.rb +17 -16
- data/spec/lib/geoblacklight/relation/descendants_spec.rb +17 -16
- data/spec/lib/geoblacklight/relation/relation_response_spec.rb +29 -28
- data/spec/lib/geoblacklight/view_helper_override_spec.rb +14 -13
- data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +19 -18
- data/spec/lib/geoblacklight/wms_layer_spec.rb +31 -30
- data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +31 -31
- data/spec/models/concerns/geoblacklight/bbox_filter_query_spec.rb +32 -32
- data/spec/models/concerns/geoblacklight/solr_document/carto_spec.rb +16 -15
- data/spec/models/concerns/geoblacklight/solr_document/citation_spec.rb +7 -6
- data/spec/models/concerns/geoblacklight/solr_document/finder_spec.rb +16 -17
- data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +7 -6
- data/spec/models/concerns/geoblacklight/solr_document_spec.rb +121 -107
- data/spec/models/concerns/geoblacklight/suppressed_records_search_behavior_spec.rb +8 -7
- data/spec/presenters/geoblacklight/bbox_item_presenter_spec.rb +10 -10
- data/spec/routing/catalog_routing_spec.rb +4 -3
- data/spec/spec_helper.rb +34 -33
- data/spec/support/backport_test_helpers.rb +6 -5
- data/spec/support/features/session_helpers.rb +8 -7
- data/spec/support/features.rb +2 -1
- data/spec/support/fixtures.rb +2 -1
- data/spec/tasks/geoblacklight_spec.rb +10 -9
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +16 -15
- data/spec/views/catalog/_document_split.html.erb_spec.rb +3 -2
- data/spec/views/catalog/_index_split.html.erb_spec.rb +3 -2
- data/spec/views/catalog/_results_pagination.html.erb_spec.rb +5 -4
- data/spec/views/catalog/_show_downloads.html.erb_spec.rb +11 -10
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +13 -12
- data/template.rb +9 -8
- metadata +29 -212
- data/.gitmodules +0 -0
- data/.rubocop.yml +0 -111
- data/.rubocop_todo.yml +0 -437
- data/config/initializers/new_gbl_settings_defaults_3_4.yml +0 -6
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
module MetadataTransformer
|
4
5
|
##
|
@@ -10,7 +11,7 @@ module Geoblacklight
|
|
10
11
|
def initialize(metadata)
|
11
12
|
@metadata = metadata
|
12
13
|
# Access the Nokogiri::XML Document from the metadata Object
|
13
|
-
fail EmptyMetadataError,
|
14
|
+
fail EmptyMetadataError, "Failed to retrieve the metadata" if @metadata.blank?
|
14
15
|
end
|
15
16
|
|
16
17
|
##
|
@@ -30,11 +31,11 @@ module Geoblacklight
|
|
30
31
|
# @return [Nokogiri::XML::Document] the Nokogiri XML Document for the cleaned HTML
|
31
32
|
def cleaned_metadata
|
32
33
|
transformed_doc = Nokogiri::XML(@metadata.to_html)
|
33
|
-
if transformed_doc.xpath(
|
34
|
+
if transformed_doc.xpath("//body").children.empty?
|
34
35
|
fail TransformError, \
|
35
|
-
|
36
|
+
"Failed to extract the <body> child elements from the transformed metadata"
|
36
37
|
end
|
37
|
-
transformed_doc.xpath(
|
38
|
+
transformed_doc.xpath("//body").children
|
38
39
|
rescue => e
|
39
40
|
raise TransformError, e.message
|
40
41
|
end
|
@@ -1,17 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "geo_combine"
|
3
4
|
|
4
5
|
module Geoblacklight
|
5
6
|
module MetadataTransformer
|
6
7
|
##
|
7
8
|
# Exceptions raised for the types of geospatial metadata
|
8
9
|
class TypeError < EncodingError; end
|
10
|
+
|
9
11
|
##
|
10
12
|
# Exceptions raised when parsing geospatial metadata in the XML
|
11
13
|
class ParseError < EncodingError; end
|
14
|
+
|
12
15
|
##
|
13
16
|
# Exception raised when the geospatial metadata content is empty
|
14
17
|
class EmptyMetadataError < ParseError; end
|
18
|
+
|
15
19
|
##
|
16
20
|
# Exceptions raised when transforming the metadata into the HTML
|
17
21
|
class TransformError < EncodingError; end
|
@@ -21,7 +25,7 @@ module Geoblacklight
|
|
21
25
|
# @param [Geoblacklight::Metadata::Base] metadata string or File path to the raw metadata
|
22
26
|
# @return [Geoblacklight::MetadataTransformer::BaseTransformer]
|
23
27
|
def self.instance(metadata)
|
24
|
-
type = metadata.class.name.split(
|
28
|
+
type = metadata.class.name.split("::").last
|
25
29
|
begin
|
26
30
|
klass = "Geoblacklight::MetadataTransformer::#{type.capitalize}".constantize
|
27
31
|
rescue
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
##
|
4
5
|
# Parses an array of dct_references to create useful reference information
|
@@ -30,7 +31,7 @@ module Geoblacklight
|
|
30
31
|
# Creates a hash, using its type as key and endpoint as value
|
31
32
|
# @return [Hash]
|
32
33
|
def to_hash
|
33
|
-
{
|
34
|
+
{type => endpoint}
|
34
35
|
end
|
35
36
|
|
36
37
|
private
|
@@ -40,7 +41,7 @@ module Geoblacklight
|
|
40
41
|
# Remove any trailing slashes
|
41
42
|
# @return [String]
|
42
43
|
def uri
|
43
|
-
@reference[0].sub(/(\/)+$/,
|
44
|
+
@reference[0].sub(/(\/)+$/, "") if @reference[0].present?
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
# References is a geoblacklight-schema dct:references parser
|
4
5
|
class References
|
@@ -52,11 +53,11 @@ module Geoblacklight
|
|
52
53
|
# @return [Hash, nil]
|
53
54
|
def downloads_by_format
|
54
55
|
case format
|
55
|
-
when
|
56
|
+
when "Shapefile"
|
56
57
|
vector_download_formats
|
57
|
-
when
|
58
|
+
when "GeoTIFF"
|
58
59
|
geotiff_download_formats
|
59
|
-
when
|
60
|
+
when "ArcGRID"
|
60
61
|
arcgrid_download_formats
|
61
62
|
end
|
62
63
|
end
|
@@ -93,7 +94,7 @@ module Geoblacklight
|
|
93
94
|
# Download hash for a static file download
|
94
95
|
# @return (see #downloads_by_format)
|
95
96
|
def file_download
|
96
|
-
{
|
97
|
+
{file_download: download.to_hash}
|
97
98
|
end
|
98
99
|
|
99
100
|
##
|
@@ -113,14 +114,14 @@ module Geoblacklight
|
|
113
114
|
# Download hash for a GeoTiff file with a WMS reference present
|
114
115
|
# @return (see #downloads_by_format)
|
115
116
|
def geotiff_download_formats
|
116
|
-
{
|
117
|
+
{geotiff: wms.to_hash} if wms.present?
|
117
118
|
end
|
118
119
|
|
119
120
|
##
|
120
121
|
# Download hash for an ArcGRID file with a WMS reference present
|
121
122
|
# @return (see #downloads_by_format)
|
122
123
|
def arcgrid_download_formats
|
123
|
-
{
|
124
|
+
{geotiff: wms.to_hash} if wms.present?
|
124
125
|
end
|
125
126
|
|
126
127
|
##
|
@@ -132,5 +133,9 @@ module Geoblacklight
|
|
132
133
|
super
|
133
134
|
end
|
134
135
|
end
|
136
|
+
|
137
|
+
def respond_to_missing?(m, *args, &b)
|
138
|
+
Geoblacklight::Constants::URI.key?(m) || super
|
139
|
+
end
|
135
140
|
end
|
136
141
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
module Relation
|
4
5
|
class Ancestors
|
@@ -9,8 +10,8 @@ module Geoblacklight
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def create_search_params
|
12
|
-
{
|
13
|
-
|
13
|
+
{fq: ["{!join from=#{@field} to=#{Settings.FIELDS.ID}}#{Settings.FIELDS.ID}:#{@search_id}"],
|
14
|
+
fl: [Settings.FIELDS.TITLE, Settings.FIELDS.ID, Settings.FIELDS.RESOURCE_TYPE]}
|
14
15
|
end
|
15
16
|
|
16
17
|
def execute_query
|
@@ -22,7 +23,7 @@ module Geoblacklight
|
|
22
23
|
|
23
24
|
def results
|
24
25
|
response = execute_query
|
25
|
-
response[
|
26
|
+
response["response"]
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
module Relation
|
4
5
|
class Descendants
|
@@ -9,8 +10,8 @@ module Geoblacklight
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def create_search_params
|
12
|
-
{
|
13
|
-
|
13
|
+
{fq: "#{@field}:#{@search_id}",
|
14
|
+
fl: [Settings.FIELDS.TITLE, Settings.FIELDS.ID, Settings.FIELDS.RESOURCE_TYPE]}
|
14
15
|
end
|
15
16
|
|
16
17
|
def execute_query
|
@@ -22,7 +23,7 @@ module Geoblacklight
|
|
22
23
|
|
23
24
|
def results
|
24
25
|
response = execute_query
|
25
|
-
response[
|
26
|
+
response["response"]
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
module Relation
|
4
5
|
class RelationResponse
|
@@ -27,9 +28,9 @@ module Geoblacklight
|
|
27
28
|
|
28
29
|
def query_type(option)
|
29
30
|
case option.query_type
|
30
|
-
when
|
31
|
+
when "ancestors"
|
31
32
|
Geoblacklight::Relation::Ancestors
|
32
|
-
when
|
33
|
+
when "descendants"
|
33
34
|
Geoblacklight::Relation::Descendants
|
34
35
|
else
|
35
36
|
fail ArgumentError, "Bad RelationResponse query_type: #{option.query_type}. Only 'ancestors' or 'descendants' is allowed."
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
module Routes
|
4
5
|
class Downloadable
|
@@ -7,8 +8,8 @@ module Geoblacklight
|
|
7
8
|
end
|
8
9
|
|
9
10
|
def call(mapper, _options = {})
|
10
|
-
mapper.get
|
11
|
-
mapper.get
|
11
|
+
mapper.get "file/:id", action: "file", as: :file
|
12
|
+
mapper.get "hgl/:id", action: "hgl", as: :hgl
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
module Routes
|
4
5
|
class Exportable
|
@@ -8,9 +9,9 @@ module Geoblacklight
|
|
8
9
|
|
9
10
|
def call(mapper, _options = {})
|
10
11
|
mapper.member do
|
11
|
-
mapper.get
|
12
|
-
mapper.get
|
13
|
-
mapper.get
|
12
|
+
mapper.get "web_services"
|
13
|
+
mapper.get "metadata"
|
14
|
+
mapper.get "relations" => "relation#index"
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
data/lib/geoblacklight/routes.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
module Routes
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require "geoblacklight/routes/exportable"
|
6
|
+
require "geoblacklight/routes/downloadable"
|
7
|
+
require "geoblacklight/routes/wms"
|
7
8
|
end
|
8
9
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
# Override Blacklight helpers to inject behavior
|
4
5
|
module ViewHelperOverride
|
@@ -7,9 +8,9 @@ module Geoblacklight
|
|
7
8
|
end
|
8
9
|
|
9
10
|
def render_search_to_s_bbox(params)
|
10
|
-
return
|
11
|
+
return "".html_safe if params["bbox"].blank?
|
11
12
|
|
12
|
-
render_search_to_s_element(t(
|
13
|
+
render_search_to_s_element(t("geoblacklight.bbox_label"), render_filter_value(params["bbox"]))
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
class FeatureInfoResponse
|
4
5
|
def initialize(response)
|
@@ -15,11 +16,11 @@ module Geoblacklight
|
|
15
16
|
|
16
17
|
def format
|
17
18
|
page = Nokogiri::HTML(@response.body)
|
18
|
-
table_values = {
|
19
|
-
page.css(
|
19
|
+
table_values = {values: []}
|
20
|
+
page.css("th").each do |th|
|
20
21
|
table_values[:values].push([th.text])
|
21
22
|
end
|
22
|
-
page.css(
|
23
|
+
page.css("td").each_with_index do |td, index|
|
23
24
|
table_values[:values][index].push(td.text) unless index >= table_values[:values].count
|
24
25
|
end
|
25
26
|
table_values
|
@@ -27,7 +28,7 @@ module Geoblacklight
|
|
27
28
|
|
28
29
|
def error?
|
29
30
|
@response[:error] ||
|
30
|
-
@response.headers[
|
31
|
+
@response.headers["content-type"].slice(0, 9) == "text/xml"
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Geoblacklight
|
3
4
|
class WmsLayer
|
4
5
|
def initialize(params)
|
@@ -7,11 +8,11 @@ module Geoblacklight
|
|
7
8
|
end
|
8
9
|
|
9
10
|
def url
|
10
|
-
@params[
|
11
|
+
@params["URL"]
|
11
12
|
end
|
12
13
|
|
13
14
|
def search_params
|
14
|
-
@params.except(
|
15
|
+
@params.except("URL")
|
15
16
|
end
|
16
17
|
|
17
18
|
def feature_info
|
@@ -27,7 +28,7 @@ module Geoblacklight
|
|
27
28
|
end
|
28
29
|
rescue Faraday::ConnectionFailed, Faraday::TimeoutError => error
|
29
30
|
Geoblacklight.logger.error error.inspect
|
30
|
-
{
|
31
|
+
{error: error.inspect}
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
data/lib/geoblacklight.rb
CHANGED
@@ -1,37 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require
|
2
|
+
|
3
|
+
require "active_support/dependencies"
|
4
|
+
require "geoblacklight/engine"
|
4
5
|
|
5
6
|
module Geoblacklight
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
7
|
+
require "geoblacklight/bounding_box"
|
8
|
+
require "geoblacklight/constants"
|
9
|
+
require "geoblacklight/exceptions"
|
10
|
+
require "geoblacklight/geometry"
|
11
|
+
require "geoblacklight/view_helper_override"
|
12
|
+
require "geoblacklight/item_viewer"
|
13
|
+
require "geoblacklight/wms_layer"
|
14
|
+
require "geoblacklight/wms_layer/feature_info_response"
|
15
|
+
require "geoblacklight/download"
|
16
|
+
require "geoblacklight/download/geojson_download"
|
17
|
+
require "geoblacklight/download/geotiff_download"
|
18
|
+
require "geoblacklight/download/kmz_download"
|
19
|
+
require "geoblacklight/download/shapefile_download"
|
20
|
+
require "geoblacklight/download/hgl_download"
|
21
|
+
require "geoblacklight/metadata"
|
22
|
+
require "geoblacklight/metadata/base"
|
23
|
+
require "geoblacklight/metadata/fgdc"
|
24
|
+
require "geoblacklight/metadata/html"
|
25
|
+
require "geoblacklight/metadata/iso19139"
|
26
|
+
require "geoblacklight/metadata_transformer"
|
27
|
+
require "geoblacklight/metadata_transformer/base"
|
28
|
+
require "geoblacklight/metadata_transformer/fgdc"
|
29
|
+
require "geoblacklight/metadata_transformer/iso19139"
|
30
|
+
require "geoblacklight/reference"
|
31
|
+
require "geoblacklight/references"
|
32
|
+
require "geoblacklight/routes"
|
33
|
+
require "geoblacklight/relation/descendants"
|
34
|
+
require "geoblacklight/relation/ancestors"
|
35
|
+
require "geoblacklight/relation/relation_response"
|
35
36
|
|
36
37
|
def self.logger
|
37
38
|
::Rails.logger
|
@@ -1,39 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
require "generators/geoblacklight/install_generator"
|
4
5
|
|
5
6
|
namespace :geoblacklight do
|
6
|
-
desc
|
7
|
+
desc "Run Solr and GeoBlacklight for interactive development"
|
7
8
|
task :server, [:rails_server_args] do |_t, args|
|
8
|
-
require
|
9
|
-
SolrWrapper.wrap(port:
|
10
|
-
solr.with_collection(name:
|
9
|
+
require "solr_wrapper"
|
10
|
+
SolrWrapper.wrap(port: "8983") do |solr|
|
11
|
+
solr.with_collection(name: "blacklight-core", dir: File.join(File.expand_path("../../", File.dirname(__FILE__)), "solr", "conf")) do
|
11
12
|
puts "\nSolr server running: http://localhost:#{solr.port}/solr/#/blacklight-core"
|
12
13
|
puts "\n^C to stop"
|
13
|
-
puts
|
14
|
+
puts " "
|
14
15
|
begin
|
15
|
-
Rake::Task[
|
16
|
+
Rake::Task["geoblacklight:solr:seed"].invoke
|
16
17
|
system "bundle exec rails s #{args[:rails_server_args]}"
|
17
18
|
rescue Interrupt
|
18
|
-
puts
|
19
|
+
puts "Shutting down..."
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
desc
|
25
|
+
desc "Run Solr and GeoBlacklight for interactive development with Webpack enabled"
|
25
26
|
task :webpack do |_t|
|
26
|
-
require
|
27
|
-
SolrWrapper.wrap(port:
|
28
|
-
solr.with_collection(name:
|
27
|
+
require "solr_wrapper"
|
28
|
+
SolrWrapper.wrap(port: "8983") do |solr|
|
29
|
+
solr.with_collection(name: "blacklight-core", dir: File.join(File.expand_path("../../", File.dirname(__FILE__)), "solr", "conf")) do
|
29
30
|
puts "\nSolr server running: http://localhost:#{solr.port}/solr/#/blacklight-core"
|
30
31
|
puts "\n^C to stop"
|
31
|
-
puts
|
32
|
+
puts " "
|
32
33
|
begin
|
33
|
-
Rake::Task[
|
34
|
-
system
|
34
|
+
Rake::Task["geoblacklight:solr:seed"].invoke
|
35
|
+
system "foreman start"
|
35
36
|
rescue Interrupt
|
36
|
-
puts
|
37
|
+
puts "Shutting down..."
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
@@ -42,41 +43,41 @@ namespace :geoblacklight do
|
|
42
43
|
# Local fixtures: bundle exec rake "geoblacklight:index:seed"
|
43
44
|
# Remote fixtures: bundle exec rake "geoblacklight:index:seed[:remote]"
|
44
45
|
namespace :index do
|
45
|
-
desc
|
46
|
+
desc "Index GBL test fixture metadata into Solr"
|
46
47
|
task :seed, [:remote] => :environment do |t, args|
|
47
48
|
docs = []
|
48
49
|
|
49
50
|
if args.remote
|
50
|
-
puts
|
51
|
-
JSON.
|
52
|
-
URI.
|
51
|
+
puts "Indexing - Remote test fixtures"
|
52
|
+
JSON.parse(
|
53
|
+
URI.parse("https://api.github.com/repos/geoblacklight/geoblacklight/contents/spec/fixtures/solr_documents").open.read
|
53
54
|
).each do |fixture|
|
54
|
-
if fixture[
|
55
|
-
docs << JSON.
|
55
|
+
if fixture["name"].include?(".json")
|
56
|
+
docs << JSON.parse(URI.parse(fixture["download_url"]).open.read)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
else
|
59
|
-
puts
|
60
|
-
docs = Dir[
|
60
|
+
puts "Indexing - Local test fixtures"
|
61
|
+
docs = Dir["spec/fixtures/solr_documents/*.json"].map { |f| JSON.parse File.read(f) }.flatten
|
61
62
|
end
|
62
63
|
|
63
64
|
Blacklight.default_index.connection.add docs
|
64
65
|
Blacklight.default_index.connection.commit
|
65
66
|
end
|
66
67
|
|
67
|
-
desc
|
68
|
-
task :
|
69
|
-
docs = JSON.parse(File.read(Rails.root.join(
|
68
|
+
desc "Ingests a GeoHydra transformed.json"
|
69
|
+
task ingest_all: :environment do
|
70
|
+
docs = JSON.parse(File.read(Rails.root.join("tmp", "transformed.json")))
|
70
71
|
docs.each do |doc|
|
71
72
|
Blacklight.default_index.connection.add doc
|
72
73
|
Blacklight.default_index.connection.commit
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
|
-
desc
|
77
|
+
desc "Ingests a directory of geoblacklight.json files"
|
77
78
|
task :ingest, [:directory] => :environment do |_t, args|
|
78
|
-
args.with_defaults(directory:
|
79
|
-
Dir.glob(File.join(args[:directory],
|
79
|
+
args.with_defaults(directory: "data")
|
80
|
+
Dir.glob(File.join(args[:directory], "**", "geoblacklight.json")).each do |fn|
|
80
81
|
puts "Ingesting #{fn}"
|
81
82
|
begin
|
82
83
|
Blacklight.default_index.connection.add(JSON.parse(File.read(fn)))
|
@@ -84,47 +85,47 @@ namespace :geoblacklight do
|
|
84
85
|
puts "Failed to ingest #{fn}: #{e.inspect}"
|
85
86
|
end
|
86
87
|
end
|
87
|
-
puts
|
88
|
+
puts "Committing changes to Solr"
|
88
89
|
Blacklight.default_index.connection.commit
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
92
93
|
namespace :downloads do
|
93
|
-
desc
|
94
|
+
desc "Delete all cached downloads"
|
94
95
|
task delete: :environment do
|
95
|
-
FileUtils.rm_rf Dir.glob(Rails.root.join(
|
96
|
+
FileUtils.rm_rf Dir.glob(Rails.root.join("tmp", "cache", "downloads", "*"))
|
96
97
|
end
|
97
|
-
desc
|
98
|
+
desc "Create download directory"
|
98
99
|
task mkdir: :environment do
|
99
|
-
FileUtils.mkdir_p(Rails.root.join(
|
100
|
+
FileUtils.mkdir_p(Rails.root.join("tmp", "cache", "downloads"), verbose: true)
|
100
101
|
end
|
101
|
-
desc
|
102
|
+
desc "Precaches a download"
|
102
103
|
task :precache, [:doc_id, :download_type, :timeout] => [:environment] do |_t, args|
|
103
104
|
unless args[:doc_id] && args[:download_type] && args[:timeout]
|
104
|
-
fail
|
105
|
+
fail "Please supply required arguments [document_id, download_type and timeout]"
|
105
106
|
end
|
106
107
|
document = Geoblacklight::SolrDocument.find(args[:doc_id])
|
107
108
|
fail Blacklight::Exceptions::RecordNotFound if document[:id] != args[:doc_id]
|
108
109
|
download = "Geoblacklight::#{args[:download_type].capitalize}Download"
|
109
|
-
|
110
|
+
.constantize.new(document, timeout: args[:timeout].to_i)
|
110
111
|
download.get
|
111
112
|
Rails.logger.info "Successfully downloaded #{download.file_name}"
|
112
113
|
Rails.logger.info Geoblacklight::ShapefileDownload.file_path.to_s
|
113
114
|
rescue Geoblacklight::Exceptions::ExternalDownloadFailed => error
|
114
|
-
Rails.logger.error error.message +
|
115
|
+
Rails.logger.error error.message + " " + error.url
|
115
116
|
rescue NameError
|
116
117
|
Rails.logger.error "Could not find that download type \"#{args[:download_type]}\""
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
120
121
|
namespace :solr do
|
121
|
-
desc
|
122
|
-
task :
|
123
|
-
Rake::Task[
|
122
|
+
desc "Put sample data into solr"
|
123
|
+
task seed: :environment do
|
124
|
+
Rake::Task["geoblacklight:index:seed"].invoke
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
|
-
desc
|
128
|
+
desc "Stdout output asset paths"
|
128
129
|
task application_asset_paths: [:environment] do
|
129
130
|
puts Rails.application.config.assets.paths
|
130
131
|
end
|