geoblacklight 4.0.0.pre.alpha.1 → 4.0.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/.github/workflows/ruby.yml +32 -64
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -6
- data/.rubocop_todo.yml +0 -3
- data/.solr_wrapper +1 -0
- data/README.md +1 -4
- data/Rakefile +0 -1
- data/app/assets/images/blacklight/child-item.svg +3 -0
- data/app/assets/images/blacklight/collections.svg +4 -0
- data/app/assets/images/blacklight/datasets.svg +7 -0
- data/app/assets/images/blacklight/geoblacklight-icons.json +363 -332
- data/app/assets/images/blacklight/imagery.svg +4 -0
- data/app/assets/images/blacklight/maps.svg +4 -0
- data/app/assets/images/blacklight/michigan-state-university.svg +0 -1
- data/app/assets/images/blacklight/parent-item.svg +3 -0
- data/app/assets/images/blacklight/pennsylvania-state-university.svg +0 -1
- data/app/assets/images/blacklight/purdue-university.svg +0 -1
- data/app/assets/images/blacklight/the-ohio-state-university.svg +0 -1
- data/app/assets/images/blacklight/university-of-chicago.svg +0 -1
- data/app/assets/images/blacklight/university-of-colorado-boulder.svg +6 -0
- data/app/assets/images/blacklight/university-of-illinois-urbana-champaign.svg +0 -1
- data/app/assets/images/blacklight/university-of-iowa.svg +0 -1
- data/app/assets/images/blacklight/university-of-maryland.svg +0 -1
- data/app/assets/images/blacklight/university-of-michigan.svg +0 -1
- data/app/assets/images/blacklight/university-of-minnesota.svg +0 -1
- data/app/assets/images/blacklight/university-of-nebraska-lincoln.svg +0 -1
- data/app/assets/images/blacklight/university-of-wisconsin-madison.svg +0 -1
- data/app/assets/images/blacklight/websites.svg +4 -0
- data/app/assets/javascripts/geoblacklight/controls/fullscreen.js +8 -0
- data/app/assets/javascripts/geoblacklight/geoblacklight.js +2 -1
- data/app/assets/javascripts/geoblacklight/viewers/esri.js +1 -0
- data/app/assets/javascripts/geoblacklight/viewers/index_map.js +1 -0
- data/app/assets/javascripts/geoblacklight/viewers/tilejson.js +33 -0
- data/app/assets/javascripts/geoblacklight/viewers/tms.js +2 -2
- data/app/assets/javascripts/geoblacklight/viewers/viewer.js +3 -0
- data/app/assets/javascripts/geoblacklight/viewers/wms.js +2 -2
- data/app/assets/javascripts/geoblacklight/viewers/wmts.js +85 -0
- data/app/assets/javascripts/geoblacklight/viewers/xyz.js +10 -0
- data/app/assets/stylesheets/geoblacklight/geoblacklight.scss +1 -0
- data/app/assets/stylesheets/geoblacklight/modules/_base.scss +0 -1
- data/app/assets/stylesheets/geoblacklight/modules/_styles.scss +5 -1
- data/app/assets/stylesheets/geoblacklight/modules/downloads.scss +20 -47
- data/app/assets/stylesheets/geoblacklight/modules/index_maps.scss +68 -0
- data/app/assets/stylesheets/geoblacklight/modules/item.scss +16 -0
- data/app/assets/stylesheets/geoblacklight/modules/modal.scss +6 -0
- data/app/assets/stylesheets/geoblacklight/modules/sidebar.scss +4 -0
- data/app/components/geoblacklight/icon_facet_item_component.rb +33 -0
- data/app/helpers/geoblacklight_helper.rb +6 -45
- data/app/models/concerns/geoblacklight/bbox_filter_field.rb +45 -0
- data/app/models/concerns/geoblacklight/bbox_filter_query.rb +50 -0
- data/app/models/concerns/geoblacklight/solr_document.rb +1 -1
- data/app/models/concerns/geoblacklight/suppressed_records_search_behavior.rb +26 -0
- data/app/presenters/geoblacklight/bbox_item_presenter.rb +9 -0
- data/app/views/catalog/_downloads_collapse.html.erb +27 -0
- data/app/views/catalog/_header_icons.html.erb +2 -2
- data/app/views/catalog/_index_split_default.html.erb +2 -2
- data/app/views/catalog/_show_default_viewer_container.html.erb +17 -0
- data/app/views/catalog/_show_downloads.html.erb +10 -21
- data/app/views/catalog/_show_sidebar.html.erb +3 -0
- data/app/views/catalog/_show_web_services.html.erb +11 -0
- data/app/views/catalog/_web_services.html.erb +3 -2
- data/app/views/catalog/web_services.html.erb +1 -1
- data/app/views/relation/_relations.html.erb +1 -1
- data/app/views/relation/index.html.erb +1 -1
- data/config/locales/geoblacklight.en.yml +4 -1
- data/geoblacklight.gemspec +6 -6
- data/lib/generators/geoblacklight/install_generator.rb +1 -1
- data/lib/generators/geoblacklight/templates/assets/_customizations.scss +5 -4
- data/lib/generators/geoblacklight/templates/assets/application.scss +0 -3
- data/lib/generators/geoblacklight/templates/catalog_controller.rb +74 -56
- data/lib/generators/geoblacklight/templates/settings.gbl_v1.yml +5 -5
- data/lib/generators/geoblacklight/templates/settings.yml +36 -23
- data/lib/geoblacklight/bounding_box.rb +4 -0
- data/lib/geoblacklight/constants.rb +3 -0
- data/lib/geoblacklight/engine.rb +3 -2
- data/lib/geoblacklight/faraday_middleware/follow_redirects.rb +176 -0
- data/lib/geoblacklight/item_viewer.rb +13 -1
- data/lib/geoblacklight/metadata/base.rb +2 -1
- data/lib/geoblacklight/version.rb +1 -1
- data/lib/geoblacklight/view_helper_override.rb +2 -28
- data/lib/geoblacklight.rb +0 -10
- data/lib/tasks/geoblacklight.rake +1 -1
- data/schema/geoblacklight-schema-aardvark.json +3 -23
- data/solr/conf/schema.xml +37 -43
- data/solr/conf/solrconfig.xml +17 -17
- data/spec/components/geoblacklight/icon_facet_item_component_spec.rb +17 -0
- data/spec/controllers/catalog_controller_spec.rb +1 -1
- data/spec/features/download_layer_spec.rb +31 -14
- data/spec/features/esri_viewer_spec.rb +5 -1
- data/spec/features/full_screen_controll_spec.rb +15 -0
- data/spec/features/home_page_spec.rb +2 -2
- data/spec/features/index_map_spec.rb +2 -2
- data/spec/features/missing_metadata_spec.rb +1 -1
- data/spec/features/multiple_downloads_spec.rb +2 -1
- data/spec/features/relations_spec.rb +1 -1
- data/spec/features/saved_searches_spec.rb +1 -1
- data/spec/features/search_results_complex_geometry_spec.rb +24 -0
- data/spec/features/search_results_icons_spec.rb +16 -0
- data/spec/features/search_results_map_spec.rb +2 -2
- data/spec/features/search_spec.rb +22 -0
- data/spec/features/show_page_download_spec.rb +29 -0
- data/spec/features/show_page_metadata_spec.rb +2 -2
- data/spec/features/split_view.html.erb_spec.rb +12 -1
- data/spec/features/tilejson_spec.rb +22 -0
- data/spec/features/tms_spec.rb +2 -2
- data/spec/features/web_services_modal_spec.rb +35 -2
- data/spec/features/wmts_spec.rb +34 -0
- data/spec/features/xyz_spec.rb +10 -0
- data/spec/fixtures/manifests/tilejson.json +21 -0
- data/spec/fixtures/manifests/wmts-multiple.xml +813 -0
- data/spec/fixtures/manifests/wmts-single.xml +126 -0
- data/spec/fixtures/solr_documents/README.md +46 -43
- data/spec/fixtures/solr_documents/actual-papermap1.json +2 -1
- data/spec/fixtures/solr_documents/actual-point1.json +2 -1
- data/spec/fixtures/solr_documents/actual-polygon1.json +2 -1
- data/spec/fixtures/solr_documents/actual-raster1.json +3 -2
- data/spec/fixtures/solr_documents/baruch_ancestor1.json +2 -1
- data/spec/fixtures/solr_documents/baruch_ancestor2.json +2 -1
- data/spec/fixtures/solr_documents/baruch_documentation_download.json +1 -1
- data/spec/fixtures/solr_documents/bbox-spans-180.json +2 -1
- data/spec/fixtures/solr_documents/cornell_html_metadata.json +4 -3
- data/spec/fixtures/solr_documents/esri-dynamic-layer-all-layers.json +3 -2
- data/spec/fixtures/solr_documents/esri-dynamic-layer-single-layer.json +3 -2
- data/spec/fixtures/solr_documents/esri-feature-layer.json +2 -1
- data/spec/fixtures/solr_documents/esri-image-map-layer.json +3 -2
- data/spec/fixtures/solr_documents/esri-tiled_map_layer.json +2 -1
- data/spec/fixtures/solr_documents/esri-wms-layer.json +2 -1
- data/spec/fixtures/solr_documents/harvard_raster.json +3 -2
- data/spec/fixtures/solr_documents/iiif-eastern-hemisphere.json +3 -2
- data/spec/fixtures/solr_documents/index-map-polygon-no-downloadurl.json +2 -1
- data/spec/fixtures/solr_documents/index-map-polygon.json +2 -1
- data/spec/fixtures/solr_documents/index-map-stanford.json +2 -1
- data/spec/fixtures/solr_documents/index_map_point.json +3 -2
- data/spec/fixtures/solr_documents/metadata_no_provider.json +2 -1
- data/spec/fixtures/solr_documents/multiple-downloads.json +3 -2
- data/spec/fixtures/solr_documents/no_spatial.json +1 -4
- data/spec/fixtures/solr_documents/oembed.json +2 -1
- data/spec/fixtures/solr_documents/princeton-child1.json +3 -2
- data/spec/fixtures/solr_documents/princeton-child2.json +3 -2
- data/spec/fixtures/solr_documents/princeton-child3.json +2 -1
- data/spec/fixtures/solr_documents/princeton-child4.json +3 -2
- data/spec/fixtures/solr_documents/princeton-parent.json +5 -3
- data/spec/fixtures/solr_documents/public_direct_download.json +2 -1
- data/spec/fixtures/solr_documents/public_iiif_princeton.json +3 -2
- data/spec/fixtures/solr_documents/public_polygon_mit.json +2 -1
- data/spec/fixtures/solr_documents/restricted-line.json +2 -1
- data/spec/fixtures/solr_documents/tilejson.json +48 -0
- data/spec/fixtures/solr_documents/tms.json +15 -18
- data/spec/fixtures/solr_documents/umn_metro_result1.json +5 -3
- data/spec/fixtures/solr_documents/umn_state_result1.json +3 -2
- data/spec/fixtures/solr_documents/umn_state_result2.json +3 -5
- data/spec/fixtures/solr_documents/uva_slug_colon.json +2 -1
- data/spec/fixtures/solr_documents/wmts-multiple.json +41 -0
- data/spec/fixtures/solr_documents/wmts-single-layer.json +48 -0
- data/spec/fixtures/solr_documents/xyz.json +46 -0
- data/spec/helpers/geoblacklight_helper_spec.rb +12 -35
- data/spec/lib/geoblacklight/document_presenter_spec.rb +3 -3
- data/spec/lib/geoblacklight/download/geojson_download_spec.rb +1 -1
- data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +1 -1
- data/spec/lib/geoblacklight/download/kmz_download_spec.rb +1 -1
- data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +1 -1
- data/spec/lib/geoblacklight/download_spec.rb +2 -2
- data/spec/lib/geoblacklight/metadata/base_spec.rb +19 -1
- data/spec/lib/geoblacklight/references_spec.rb +1 -1
- data/spec/lib/geoblacklight/relation/relation_response_spec.rb +5 -0
- data/spec/lib/geoblacklight/view_helper_override_spec.rb +0 -10
- data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +77 -0
- data/spec/models/concerns/geoblacklight/bbox_filter_query_spec.rb +105 -0
- data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +2 -1
- data/spec/models/concerns/geoblacklight/suppressed_records_search_behavior_spec.rb +31 -0
- data/spec/presenters/geoblacklight/bbox_item_presenter_spec.rb +36 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/test_app_templates/Gemfile.extra +1 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -4
- data/spec/views/catalog/_show_downloads.html.erb_spec.rb +5 -5
- data/template.rb +2 -4
- data/vendor/assets/images/fullscreen.png +0 -0
- data/vendor/assets/images/fullscreen@2x.png +0 -0
- data/vendor/assets/javascripts/Leaflet.fullscreen.js +152 -0
- data/vendor/assets/javascripts/esri-leaflet.js +10 -3
- data/vendor/assets/javascripts/esri-leaflet.js.map +1 -1
- data/vendor/assets/javascripts/leaflet-iiif.js +39 -18
- data/vendor/assets/javascripts/leaflet-src.js.erb +14062 -0
- data/vendor/assets/javascripts/leaflet-src.js.map +1 -1
- data/vendor/assets/stylesheets/leaflet.css +640 -634
- data/vendor/assets/stylesheets/leaflet.fullscreen.css +40 -0
- metadata +91 -46
- data/app/models/concerns/geoblacklight/spatial_search_behavior.rb +0 -71
- data/app/views/catalog/_download_generated_link.html.erb +0 -4
- data/app/views/catalog/_download_link.html.erb +0 -3
- data/app/views/catalog/_downloads_generated.html.erb +0 -6
- data/app/views/catalog/_downloads_primary.html.erb +0 -21
- data/app/views/catalog/_downloads_secondary.html.erb +0 -39
- data/app/views/catalog/_icon_facet.html.erb +0 -16
- data/bin/coverage.rb +0 -36
- data/lib/generators/geoblacklight/templates/Procfile +0 -3
- data/lib/generators/geoblacklight/templates/package.json +0 -14
- data/lib/generators/geoblacklight/templates/webpacker.yml +0 -67
- data/lib/generators/geoblacklight/webpacker_generator.rb +0 -36
- data/lib/geoblacklight/catalog_helper_override.rb +0 -14
- data/spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb +0 -97
- data/vendor/assets/javascripts/leaflet.js.erb +0 -13922
- data/vendor/assets/stylesheets/leaflet-label.css +0 -54
@@ -13,16 +13,17 @@ $logo-image: image_url('blacklight/logo.svg') !default;
|
|
13
13
|
// Override default Bootstrap variables here
|
14
14
|
|
15
15
|
// Example: Bootstrap Colors
|
16
|
-
$blue: #
|
16
|
+
$blue: #0d6efd !default;
|
17
17
|
$indigo: #6610f2 !default;
|
18
18
|
$purple: #6f42c1 !default;
|
19
|
-
$pink: #
|
19
|
+
$pink: #d63384 !default;
|
20
20
|
$red: #dc3545 !default;
|
21
21
|
$orange: #fd7e14 !default;
|
22
22
|
$yellow: #ffc107 !default;
|
23
|
-
$green: #
|
23
|
+
$green: #198754 !default;
|
24
24
|
$teal: #20c997 !default;
|
25
|
-
$cyan: #
|
25
|
+
$cyan: #0dcaf0 !default;
|
26
|
+
$dark: #212529 !default; // $gray-900
|
26
27
|
|
27
28
|
// Example: Bootstrap Link color
|
28
29
|
$link-color: $blue;
|
@@ -44,11 +44,15 @@ class CatalogController < ApplicationController
|
|
44
44
|
config.index.title_field = Settings.FIELDS.TITLE
|
45
45
|
|
46
46
|
# solr field configuration for document/show views
|
47
|
-
|
47
|
+
# This sets the metadata to display below the map viewer.
|
48
|
+
# To move metadata above the map viewer,
|
49
|
+
# remove the lines deleting and re-adding the :show partial
|
48
50
|
config.show.display_type_field = 'format'
|
51
|
+
config.show.partials.delete(:show)
|
49
52
|
config.show.partials << 'show_default_viewer_container'
|
50
53
|
config.show.partials << 'show_default_attribute_table'
|
51
54
|
config.show.partials << 'show_default_viewer_information'
|
55
|
+
config.show.partials << :show
|
52
56
|
|
53
57
|
##
|
54
58
|
# Configure the index document presenter.
|
@@ -89,25 +93,32 @@ class CatalogController < ApplicationController
|
|
89
93
|
# }
|
90
94
|
|
91
95
|
|
92
|
-
|
96
|
+
# FACETS
|
93
97
|
|
94
|
-
|
95
|
-
|
98
|
+
# DEFAULT FACETS
|
99
|
+
# to add additional facets, use the keys defined in the settings.yml file
|
96
100
|
config.add_facet_field Settings.FIELDS.INDEX_YEAR, :label => 'Year', :limit => 10
|
97
101
|
config.add_facet_field Settings.FIELDS.SPATIAL_COVERAGE, :label => 'Place', :limit => 8
|
98
|
-
config.add_facet_field Settings.FIELDS.ACCESS_RIGHTS, label: 'Access', limit: 8,
|
102
|
+
config.add_facet_field Settings.FIELDS.ACCESS_RIGHTS, label: 'Access', limit: 8, item_component: Geoblacklight::IconFacetItemComponent
|
99
103
|
config.add_facet_field Settings.FIELDS.RESOURCE_CLASS, label: 'Resource Class', :limit => 8
|
100
104
|
config.add_facet_field Settings.FIELDS.RESOURCE_TYPE, label: 'Resource Type', :limit => 8
|
101
105
|
config.add_facet_field Settings.FIELDS.FORMAT, :label => 'Format', :limit => 8
|
102
106
|
config.add_facet_field Settings.FIELDS.SUBJECT, :label => 'Subject', :limit => 8
|
103
|
-
config.add_facet_field Settings.FIELDS.
|
107
|
+
config.add_facet_field Settings.FIELDS.THEME, :label => 'Theme', :limit => 8
|
104
108
|
config.add_facet_field Settings.FIELDS.CREATOR, :label => 'Creator', :limit => 8
|
105
109
|
config.add_facet_field Settings.FIELDS.PUBLISHER, :label => 'Publisher', :limit => 8
|
106
|
-
config.add_facet_field Settings.FIELDS.PROVIDER, label: 'Provider', limit: 8,
|
110
|
+
config.add_facet_field Settings.FIELDS.PROVIDER, label: 'Provider', limit: 8, item_component: Geoblacklight::IconFacetItemComponent
|
107
111
|
config.add_facet_field Settings.FIELDS.GEOREFERENCED, :label => 'Georeferenced', :limit => 3
|
108
112
|
config.add_facet_field Settings.FIELDS.SOURCE, :label => 'Collection', :limit => 8, :show => false
|
109
113
|
|
114
|
+
# GEOBLACKLIGHT APPLICATION FACETS
|
110
115
|
|
116
|
+
# Map-Based "Search Here" Feature
|
117
|
+
# item_presenter - Defines how the facet appears in the GBL UI
|
118
|
+
# filter_query_builder - Defines the query generated for Solr
|
119
|
+
# filter_class - Defines how to add/remove facet from query
|
120
|
+
# label - Defines the label used in contstraints container
|
121
|
+
config.add_facet_field Settings.FIELDS.GEOMETRY, item_presenter: Geoblacklight::BboxItemPresenter, filter_class: Geoblacklight::BboxFilterField, filter_query_builder: Geoblacklight::BboxFilterQuery, within_boost: Settings.BBOX_WITHIN_BOOST, overlap_boost: Settings.OVERLAP_RATIO_BOOST, overlap_field: Settings.FIELDS.OVERLAP_FIELD, label: 'Bounding Box'
|
111
122
|
|
112
123
|
# Have BL send all facet field names to Solr, which has been the default
|
113
124
|
# previously. Simply remove these lines if you'd rather use Solr request
|
@@ -115,7 +126,7 @@ class CatalogController < ApplicationController
|
|
115
126
|
config.add_facet_fields_to_solr_request!
|
116
127
|
|
117
128
|
|
118
|
-
|
129
|
+
# SEARCH RESULTS FIELDS
|
119
130
|
|
120
131
|
# solr fields to be displayed in the index (search results) view
|
121
132
|
# The ordering of the field names is the order of the display
|
@@ -128,7 +139,7 @@ class CatalogController < ApplicationController
|
|
128
139
|
config.add_index_field Settings.FIELDS.DESCRIPTION, helper_method: :snippit
|
129
140
|
config.add_index_field Settings.FIELDS.PUBLISHER
|
130
141
|
|
131
|
-
|
142
|
+
# ITEM VIEW FIELDS
|
132
143
|
|
133
144
|
# solr fields to be displayed in the show (single result) view
|
134
145
|
# The ordering of the field names is the order of the display
|
@@ -136,14 +147,29 @@ class CatalogController < ApplicationController
|
|
136
147
|
# link_to_search: [Boolean] that can be passed to link to a facet search
|
137
148
|
# helper_method: [Symbol] method that can be used to render the value
|
138
149
|
|
139
|
-
#DEFAULT FIELDS
|
140
|
-
|
150
|
+
# DEFAULT FIELDS
|
151
|
+
# The following fields all feature string values. If there is a value present in the metadata, they fields will show up on the item show page.
|
152
|
+
# The labels and order can be customed. Comment out fields to hide them.
|
153
|
+
|
154
|
+
config.add_show_field Settings.FIELDS.ALTERNATIVE_TITLE, label: 'Alternative Title', itemprop: 'alt_title'
|
141
155
|
config.add_show_field Settings.FIELDS.DESCRIPTION, label: 'Description', itemprop: 'description', helper_method: :render_value_as_truncate_abstract
|
156
|
+
config.add_show_field Settings.FIELDS.CREATOR, label: 'Creator', itemprop: 'creator'
|
142
157
|
config.add_show_field Settings.FIELDS.PUBLISHER, label: 'Publisher', itemprop: 'publisher'
|
143
|
-
config.add_show_field Settings.FIELDS.SPATIAL_COVERAGE, label: 'Place(s)', itemprop: 'spatial', link_to_facet: true
|
144
|
-
config.add_show_field Settings.FIELDS.SUBJECT, label: 'Subject(s)', itemprop: 'keywords', link_to_facet: true
|
145
|
-
config.add_show_field Settings.FIELDS.TEMPORAL_COVERAGE, label: 'Year', itemprop: 'temporal'
|
146
158
|
config.add_show_field Settings.FIELDS.PROVIDER, label: 'Provider', link_to_facet: true
|
159
|
+
config.add_show_field Settings.FIELDS.RESOURCE_CLASS, label: 'Resource Class', itemprop: 'class'
|
160
|
+
config.add_show_field Settings.FIELDS.RESOURCE_TYPE, label: 'Resource Type', itemprop: 'type'
|
161
|
+
config.add_show_field Settings.FIELDS.SUBJECT, label: 'Subject', itemprop: 'keywords', link_to_facet: true
|
162
|
+
config.add_show_field Settings.FIELDS.THEME, label: 'Theme', itemprop: 'theme'
|
163
|
+
config.add_show_field Settings.FIELDS.TEMPORAL_COVERAGE, label: 'Temporal Coverage', itemprop: 'temporal'
|
164
|
+
config.add_show_field Settings.FIELDS.DATE_ISSUED, label: 'Date Issued', itemprop: 'issued'
|
165
|
+
config.add_show_field Settings.FIELDS.SPATIAL_COVERAGE, label: 'Spatial Coverage', itemprop: 'spatial', link_to_facet: true
|
166
|
+
config.add_show_field Settings.FIELDS.RIGHTS, label: 'Rights', itemprop: 'rights'
|
167
|
+
config.add_show_field Settings.FIELDS.RIGHTS_HOLDER, label: 'Rights Holder', itemprop: 'rights_holder'
|
168
|
+
config.add_show_field Settings.FIELDS.LICENSE, label: 'License', itemprop: 'license'
|
169
|
+
config.add_show_field Settings.FIELDS.ACCESS_RIGHTS, label: 'Access Rights', itemprop: 'access_rights'
|
170
|
+
config.add_show_field Settings.FIELDS.FORMAT, label: 'Format', itemprop: 'format'
|
171
|
+
config.add_show_field Settings.FIELDS.FILE_SIZE, label: 'File Size', itemprop: 'file_size'
|
172
|
+
config.add_show_field Settings.FIELDS.GEOREFERENCED, label: 'Georeferenced', itemprop: 'georeferenced'
|
147
173
|
config.add_show_field(
|
148
174
|
Settings.FIELDS.REFERENCES,
|
149
175
|
label: 'More details at',
|
@@ -152,50 +178,35 @@ class CatalogController < ApplicationController
|
|
152
178
|
helper_method: :render_references_url
|
153
179
|
)
|
154
180
|
|
155
|
-
#
|
156
|
-
#
|
157
|
-
|
158
|
-
|
159
|
-
# config.add_show_field Settings.FIELDS.ALTERNATIVE_TITLE, label: 'Alternative Title', itemprop: 'alt_title'
|
160
|
-
# config.add_show_field Settings.FIELDS.CENTROID, label: 'Centroid', itemprop: 'centroid'
|
161
|
-
# config.add_show_field Settings.FIELDS.CREATOR, label: 'Creator(s)', itemprop: 'creator'
|
162
|
-
# config.add_show_field Settings.FIELDS.DATE_ISSUED, label: 'Date Issued', itemprop: 'issued'
|
163
|
-
# config.add_show_field Settings.FIELDS.DATE_RANGE, label: 'Date Range', itemprop: 'date_range'
|
164
|
-
# config.add_show_field Settings.FIELDS.DESCRIPTION, label: 'Description', itemprop: 'description', helper_method: :render_value_as_truncate_abstract
|
165
|
-
# config.add_show_field Settings.FIELDS.FORMAT, label: 'Format', itemprop: 'format'
|
166
|
-
# config.add_show_field Settings.FIELDS.FILE_SIZE, label: 'File Size', itemprop: 'file_size'
|
167
|
-
# config.add_show_field Settings.FIELDS.GEOREFERENCED, label: 'Georeferenced', itemprop: 'georeferenced'
|
168
|
-
# config.add_show_field Settings.FIELDS.ID, label: 'ID', itemprop: 'id'
|
169
|
-
# config.add_show_field Settings.FIELDS.IDENTIFIER, label: 'Identifier', itemprop: 'identifier'
|
170
|
-
# config.add_show_field Settings.FIELDS.INDEX_YEAR, label: 'Year', itemprop: 'year'
|
171
|
-
# config.add_show_field Settings.FIELDS.IS_PART_OF, label: 'Is Part Of', itemprop: 'is_part_of'
|
172
|
-
# config.add_show_field Settings.FIELDS.IS_REPLACED_BY, label: 'Is Replaced By', itemprop: 'is_replaced_by'
|
173
|
-
# config.add_show_field Settings.FIELDS.ISO_TOPIC_CATEGORY, label: 'Theme', itemprop: 'theme'
|
174
|
-
# config.add_show_field Settings.FIELDS.KEYWORD, label: 'Keyword(s)', itemprop: 'keyword'
|
181
|
+
# ADDITIONAL FIELDS
|
182
|
+
# The following fields are not user friendly and are not set to appear on the item show page. They contain non-literal values, codes, URIs, or are otherwise designed to power features in the interface.
|
183
|
+
# These values might need a translations to be readable by users.
|
184
|
+
|
175
185
|
# config.add_show_field Settings.FIELDS.LANGUAGE, label: 'Language', itemprop: 'language'
|
176
|
-
# config.add_show_field Settings.FIELDS.
|
177
|
-
|
178
|
-
# config.add_show_field Settings.FIELDS.
|
179
|
-
# config.add_show_field Settings.FIELDS.
|
186
|
+
# config.add_show_field Settings.FIELDS.KEYWORD, label: 'Keyword(s)', itemprop: 'keyword'
|
187
|
+
|
188
|
+
# config.add_show_field Settings.FIELDS.INDEX_YEAR, label: 'Year', itemprop: 'year'
|
189
|
+
# config.add_show_field Settings.FIELDS.DATE_RANGE, label: 'Date Range', itemprop: 'date_range'
|
190
|
+
|
191
|
+
# config.add_show_field Settings.FIELDS.CENTROID, label: 'Centroid', itemprop: 'centroid'
|
180
192
|
# config.add_show_field Settings.FIELDS.OVERLAP_FIELD, label: 'Overlap BBox', itemprop: 'overlap_field'
|
181
|
-
|
182
|
-
# config.add_show_field Settings.FIELDS.PROVIDER, label: 'Provider', itemprop: 'provider'
|
183
|
-
# config.add_show_field Settings.FIELDS.REFERENCES, label: 'References', itemprop: 'references'
|
193
|
+
|
184
194
|
# config.add_show_field Settings.FIELDS.RELATION, label: 'Relation', itemprop: 'relation'
|
185
|
-
# config.add_show_field Settings.FIELDS.
|
186
|
-
# config.add_show_field Settings.FIELDS.
|
187
|
-
# config.add_show_field Settings.FIELDS.RESOURCE_TYPE, label: 'Resource Type', itemprop: 'type'
|
188
|
-
# config.add_show_field Settings.FIELDS.RIGHTS, label: 'Rights', itemprop: 'rights'
|
189
|
-
# config.add_show_field Settings.FIELDS.RIGHTS_HOLDER, label: 'Rights Holder', itemprop: 'rights_holder'
|
190
|
-
# config.add_show_field Settings.FIELDS.SPATIAL_COVERAGE, label: 'Place(s)', itemprop: 'spatial_coverage'
|
191
|
-
# config.add_show_field Settings.FIELDS.SPATIAL_EXTENT, label: 'Spatial Extent', itemprop: 'geometry'
|
192
|
-
# config.add_show_field Settings.FIELDS.SUBJECT, label: 'Subject', itemprop: 'subject'
|
193
|
-
# config.add_show_field Settings.FIELDS.SUPPRESSED, label: 'Suppressed', itemprop: 'suppresed'
|
194
|
-
# config.add_show_field Settings.FIELDS.TEMPORAL_COVERAGE, label: 'Temporal Coverage', itemprop: 'temporal'
|
195
|
-
# config.add_show_field Settings.FIELDS.TITLE, label: 'Title', itemprop: 'title'
|
195
|
+
# config.add_show_field Settings.FIELDS.MEMBER_OF, label: 'Member Of', itemprop: 'member_of'
|
196
|
+
# config.add_show_field Settings.FIELDS.IS_PART_OF, label: 'Is Part Of', itemprop: 'is_part_of'
|
196
197
|
# config.add_show_field Settings.FIELDS.VERSION, label: 'Version', itemprop: 'version'
|
198
|
+
# config.add_show_field Settings.FIELDS.REPLACES, label: 'Replaces', itemprop: 'replaces'
|
199
|
+
# config.add_show_field Settings.FIELDS.IS_REPLACED_BY, label: 'Is Replaced By', itemprop: 'is_replaced_by'
|
200
|
+
|
197
201
|
# config.add_show_field Settings.FIELDS.WXS_IDENTIFIER, label: 'Web Service Layer', itemprop: 'wxs_identifier'
|
202
|
+
# config.add_show_field Settings.FIELDS.ID, label: 'ID', itemprop: 'id'
|
203
|
+
# config.add_show_field Settings.FIELDS.IDENTIFIER, label: 'Identifier', itemprop: 'identifier'
|
198
204
|
|
205
|
+
# config.add_show_field Settings.FIELDS.MODIFIED, label: 'Date Modified', itemprop: 'modified'
|
206
|
+
# config.add_show_field Settings.FIELDS.METADATA_VERSION, label: 'Metadata Version', itemprop: 'metadata_version'
|
207
|
+
# config.add_show_field Settings.FIELDS.SUPPRESSED, label: 'Suppressed', itemprop: 'suppresed'
|
208
|
+
|
209
|
+
|
199
210
|
# "fielded" search configuration. Used by pulldown among other places.
|
200
211
|
# For supported keys in hash, see rdoc for Blacklight::SearchFields
|
201
212
|
#
|
@@ -215,8 +226,8 @@ class CatalogController < ApplicationController
|
|
215
226
|
# since we aren't specifying it otherwise.
|
216
227
|
|
217
228
|
config.add_search_field 'all_fields', :label => 'All Fields'
|
218
|
-
# config.add_search_field '
|
219
|
-
# config.add_search_field '
|
229
|
+
# config.add_search_field 'dct_title_ti', :label => 'Title'
|
230
|
+
# config.add_search_field 'dct_description_ti', :label => 'Description'
|
220
231
|
|
221
232
|
# Now we see how to over-ride Solr request handler defaults, in this
|
222
233
|
# case for a BL "search field", which is really a dismax aggregate
|
@@ -291,7 +302,6 @@ class CatalogController < ApplicationController
|
|
291
302
|
config.add_show_tools_partial(:sms, if: :render_sms_action?, callback: :sms_action, validator: :validate_sms_params)
|
292
303
|
|
293
304
|
# Custom tools for GeoBlacklight
|
294
|
-
config.add_show_tools_partial :web_services, if: proc { |_context, _config, options| options[:document] && (Settings.WEBSERVICES_SHOWN & options[:document].references.refs.map(&:type).map(&:to_s)).any? }
|
295
305
|
config.add_show_tools_partial :metadata, if: proc { |_context, _config, options| options[:document] && (Settings.METADATA_SHOWN & options[:document].references.refs.map(&:type).map(&:to_s)).any? }
|
296
306
|
config.add_show_tools_partial :carto, partial: 'carto', if: proc { |_context, _config, options| options[:document] && options[:document].carto_reference.present? }
|
297
307
|
config.add_show_tools_partial :arcgis, partial: 'arcgis', if: proc { |_context, _config, options| options[:document] && options[:document].arcgis_urls.present? }
|
@@ -317,6 +327,14 @@ class CatalogController < ApplicationController
|
|
317
327
|
config.autocomplete_path = 'suggest'
|
318
328
|
end
|
319
329
|
|
330
|
+
def web_services
|
331
|
+
@response, @documents = action_documents
|
320
332
|
|
321
|
-
|
333
|
+
respond_to do |format|
|
334
|
+
format.html do
|
335
|
+
return render layout: false if request.xhr?
|
336
|
+
# Otherwise draw the full page
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
322
340
|
end
|
@@ -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: '
|
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
|
-
:
|
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: "#
|
162
|
+
color: "#7FCDBB"
|
163
163
|
weight: "1"
|
164
164
|
radius: "4"
|
165
165
|
UNAVAILABLE:
|
166
166
|
<<: *default
|
167
|
-
color: "#
|
167
|
+
color: "#EDF8B1"
|
168
168
|
SELECTED:
|
169
169
|
<<: *default
|
170
|
-
color: "#
|
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: '
|
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
|
-
:
|
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
|
-
:
|
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'
|
@@ -129,12 +130,12 @@ RELATIONSHIPS_SHOWN:
|
|
129
130
|
SOURCE_ANCESTORS:
|
130
131
|
field: dct_source_sm
|
131
132
|
query_type: ancestors
|
132
|
-
icon:
|
133
|
+
icon: parent-item
|
133
134
|
label: geoblacklight.relations.ancestor
|
134
135
|
SOURCE_DESCENDANTS:
|
135
136
|
field: dct_source_sm
|
136
137
|
query_type: descendants
|
137
|
-
icon:
|
138
|
+
icon: child-item
|
138
139
|
label: geoblacklight.relations.descendant
|
139
140
|
VERSION_OF:
|
140
141
|
field: dct_isVersionOf_sm
|
@@ -153,36 +154,48 @@ WMS_PARAMS:
|
|
153
154
|
:INFO_FORMAT: 'text/html'
|
154
155
|
|
155
156
|
# Settings for leaflet
|
156
|
-
OPACITY_CONTROL: &opacity_control
|
157
|
-
CONTROLS:
|
158
|
-
- 'Opacity'
|
159
|
-
|
160
157
|
LEAFLET:
|
161
158
|
MAP:
|
162
159
|
LAYERS:
|
163
160
|
DETECT_RETINA: true
|
164
161
|
INDEX:
|
165
162
|
DEFAULT: &default
|
166
|
-
color: "#
|
163
|
+
color: "#7FCDBB"
|
167
164
|
weight: "1"
|
168
165
|
radius: "4"
|
169
166
|
UNAVAILABLE:
|
170
167
|
<<: *default
|
171
|
-
color: "#
|
168
|
+
color: "#EDF8B1"
|
172
169
|
SELECTED:
|
173
170
|
<<: *default
|
174
|
-
color: "#
|
171
|
+
color: "#2C7FB8"
|
175
172
|
VIEWERS:
|
176
|
-
WMS:
|
177
|
-
<<: *opacity_control
|
178
|
-
TILEDMAPLAYER:
|
179
|
-
<<: *opacity_control
|
180
|
-
FEATURELAYER:
|
181
|
-
<<: *opacity_control
|
182
173
|
DYNAMICMAPLAYER:
|
183
|
-
|
174
|
+
CONTROLS:
|
175
|
+
- 'Opacity'
|
176
|
+
- 'Fullscreen'
|
177
|
+
FEATURELAYER:
|
178
|
+
CONTROLS:
|
179
|
+
- 'Opacity'
|
180
|
+
- 'Fullscreen'
|
181
|
+
IIIF:
|
182
|
+
CONTROLS:
|
183
|
+
- 'Fullscreen'
|
184
184
|
IMAGEMAPLAYER:
|
185
|
-
|
185
|
+
CONTROLS:
|
186
|
+
- 'Opacity'
|
187
|
+
- 'Fullscreen'
|
188
|
+
INDEXMAP:
|
189
|
+
CONTROLS:
|
190
|
+
- 'Fullscreen'
|
191
|
+
TILEDMAPLAYER:
|
192
|
+
CONTROLS:
|
193
|
+
- 'Opacity'
|
194
|
+
- 'Fullscreen'
|
195
|
+
WMS:
|
196
|
+
CONTROLS:
|
197
|
+
- 'Opacity'
|
198
|
+
- 'Fullscreen'
|
186
199
|
|
187
200
|
# Toggle the help text feature that offers users context
|
188
201
|
HELP_TEXT:
|
@@ -23,6 +23,10 @@ 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"
|
@@ -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',
|
data/lib/geoblacklight/engine.rb
CHANGED
@@ -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
|
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
|