geoblacklight 4.0.0.pre.alpha.3 → 4.0.0.pre.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/.github/workflows/ruby.yml +32 -103
- data/.gitignore +1 -0
- data/.rubocop.yml +12 -6
- data/.rubocop_todo.yml +0 -3
- data/.solr_wrapper +2 -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/parent-item.svg +3 -0
- data/app/assets/images/blacklight/university-of-colorado-boulder.svg +6 -0
- 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/controllers/wms_controller.rb +1 -1
- data/app/helpers/geoblacklight_helper.rb +6 -45
- data/app/models/concerns/geoblacklight/bbox_filter_field.rb +64 -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 +31 -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/shared/_header_navbar.html.erb +13 -3
- data/config/locales/geoblacklight.en.yml +6 -1
- data/geoblacklight.gemspec +7 -7
- data/lib/generators/geoblacklight/assets_generator.rb +1 -1
- data/lib/generators/geoblacklight/install_generator.rb +18 -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 +86 -57
- data/lib/generators/geoblacklight/templates/settings.gbl_v1.yml +5 -5
- data/lib/generators/geoblacklight/templates/settings.yml +62 -25
- data/lib/geoblacklight/bounding_box.rb +5 -1
- data/lib/geoblacklight/constants.rb +3 -0
- data/lib/geoblacklight/download.rb +1 -1
- data/lib/geoblacklight/engine.rb +7 -4
- 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/metadata_transformer/base.rb +1 -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/config/initializers/rails_config_spec.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +8 -8
- data/spec/controllers/download_controller_spec.rb +4 -4
- data/spec/controllers/relation_controller_spec.rb +1 -1
- data/spec/controllers/wms_controller_spec.rb +2 -4
- 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 +12 -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 +17 -0
- data/spec/features/show_page_download_spec.rb +6 -3
- 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/b1g_wabash_child_15.json +62 -0
- data/spec/fixtures/solr_documents/b1g_wabash_child_16.json +64 -0
- data/spec/fixtures/solr_documents/b1g_wabash_child_17.json +62 -0
- data/spec/fixtures/solr_documents/b1g_wabash_child_18.json +62 -0
- data/spec/fixtures/solr_documents/b1g_wabash_parent.json +59 -0
- 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 +14 -37
- 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/metadata_transformer/fgdc_spec.rb +1 -1
- data/spec/lib/geoblacklight/metadata_transformer/iso19139_spec.rb +1 -1
- data/spec/lib/geoblacklight/references_spec.rb +5 -3
- data/spec/lib/geoblacklight/relation/relation_response_spec.rb +5 -0
- data/spec/lib/geoblacklight/view_helper_override_spec.rb +0 -10
- data/spec/lib/geoblacklight/wms_layer_spec.rb +1 -1
- data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +96 -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 +8 -3
- 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/_results_pagination.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_downloads.html.erb_spec.rb +6 -6
- 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 +14126 -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 +102 -49
- 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
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Geoblacklight::BboxFilterField do
|
6
|
+
subject(:filter) { search_state.filter('bbox') }
|
7
|
+
|
8
|
+
let(:bbox_value) { '140.143709 -65.487905 160.793791 86.107541' }
|
9
|
+
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, blacklight_config, controller) }
|
10
|
+
let(:params) { {} }
|
11
|
+
let(:blacklight_config) do
|
12
|
+
Blacklight::Configuration.new.configure do |config|
|
13
|
+
config.add_facet_field 'bbox', filter_class: described_class
|
14
|
+
end
|
15
|
+
end
|
16
|
+
let(:facet_config) { blacklight_config.facet_fields['bbox'] }
|
17
|
+
let(:controller) { double }
|
18
|
+
|
19
|
+
describe '#add' do
|
20
|
+
context 'with a ordinary parameter' do
|
21
|
+
it 'adds the parameter to the facets' do
|
22
|
+
new_state = filter.add(bbox_value)
|
23
|
+
|
24
|
+
expect(new_state.params).to include bbox: bbox_value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with a bounding box' do
|
29
|
+
it 'adds the parameter to the bbox parameter' do
|
30
|
+
new_state = filter.add(Geoblacklight::BoundingBox.from_rectangle(bbox_value))
|
31
|
+
|
32
|
+
expect(new_state.params).to include bbox: bbox_value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'with some existing data' do
|
38
|
+
let(:params) { { bbox: bbox_value } }
|
39
|
+
|
40
|
+
describe '#add' do
|
41
|
+
let(:bbox_replacement) { '100.143709 -70.487905 100.793791 96.107541' }
|
42
|
+
it 'replaces the existing range' do
|
43
|
+
new_state = filter.add(Geoblacklight::BoundingBox.from_rectangle(bbox_replacement))
|
44
|
+
|
45
|
+
expect(new_state.params).to include bbox: bbox_replacement
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#remove' do
|
50
|
+
it 'removes the existing bbox' do
|
51
|
+
new_state = filter.remove(Geoblacklight::BoundingBox.from_rectangle(bbox_value))
|
52
|
+
|
53
|
+
expect(new_state.params[:bbox]).to be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#values' do
|
58
|
+
it 'converts the parameters to a Geoblacklight::BoundingBox' do
|
59
|
+
expect(filter.values.first).to be_a(Geoblacklight::BoundingBox).and(have_attributes(to_param: bbox_value))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#needs_normalization?' do
|
64
|
+
it 'returns false for the expected keyed representation of the bounding box' do
|
65
|
+
expect(filter.needs_normalization?(search_state.params)).to be false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when array param represented by facebook as a Hash' do
|
70
|
+
let(:filter) { described_class.new(facet_config, search_state) }
|
71
|
+
let(:params) { { bbox: { '0' => bbox_value } } }
|
72
|
+
|
73
|
+
describe '#normalize' do
|
74
|
+
it 'converts the parameters to a list' do
|
75
|
+
expect(filter.normalize(search_state.params[:bbox])).to eql [bbox_value]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#needs_normalization?' do
|
80
|
+
it 'returns true for the hash-as-array keyed representation of the bounding box' do
|
81
|
+
expect(filter.needs_normalization?(search_state.params[:bbox])).to be true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'with a malformed bbox' do
|
88
|
+
let(:params) { { bbox: 'totally-not-a-bbox' } }
|
89
|
+
|
90
|
+
it 'excludes it from the values' do
|
91
|
+
filter = search_state.filter('bbox')
|
92
|
+
|
93
|
+
expect(filter.values).to be_empty
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Geoblacklight::BboxFilterQuery do
|
6
|
+
# Subject
|
7
|
+
subject(:bbox_filter_query) { described_class.new(filter, solr_params) }
|
8
|
+
|
9
|
+
let(:solr_params) { {} }
|
10
|
+
|
11
|
+
# Search State
|
12
|
+
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, blacklight_config) }
|
13
|
+
|
14
|
+
let(:params) do
|
15
|
+
{ bbox: '-180 -80 120 80' }
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:blacklight_config) do
|
19
|
+
Blacklight::Configuration.new.configure do |config|
|
20
|
+
config.add_facet_field 'bbox', filter_class: Geoblacklight::BboxFilterField
|
21
|
+
end
|
22
|
+
end
|
23
|
+
let(:facet_config) { blacklight_config.facet_fields['bbox'] }
|
24
|
+
|
25
|
+
# Filter
|
26
|
+
let(:filter) { Geoblacklight::BboxFilterField.new(facet_config, search_state) }
|
27
|
+
|
28
|
+
describe '#initialize' do
|
29
|
+
it 'initializes as a BboxFilterQuery object' do
|
30
|
+
expect(bbox_filter_query).to be_a described_class
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#envelope_bounds' do
|
35
|
+
it 'returns an BoundingBox envelope' do
|
36
|
+
expect(bbox_filter_query.envelope_bounds).to eq('ENVELOPE(-180, 120, 80, -80)')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#boost' do
|
41
|
+
context 'without an explicit boost' do
|
42
|
+
before do
|
43
|
+
facet_config.within_boost = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'returns an default boost value' do
|
47
|
+
expect(bbox_filter_query.boost).to eq('^10')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with an explicit boost' do
|
52
|
+
before do
|
53
|
+
facet_config.within_boost = 99
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'applies boost based on configured Settings.BBOX_WITHIN_BOOST' do
|
57
|
+
expect(bbox_filter_query.boost).to eq('^99')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#relevancy_boost' do
|
63
|
+
it 'returns a relevancy_boost' do
|
64
|
+
expect(bbox_filter_query.relevancy_boost[:bq].to_s).to include('IsWithin')
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'with overlap boost' do
|
68
|
+
before do
|
69
|
+
facet_config.overlap_boost = 2
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'applies overlapRatio when Settings.OVERLAP_RATIO_BOOST is configured' do
|
73
|
+
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include('$overlap^2')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'without an overlap boost' do
|
78
|
+
before do
|
79
|
+
facet_config.overlap_boost = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'does not apply overlapRatio when Settings.OVERLAP_RATIO_BOOST not configured' do
|
83
|
+
expect(bbox_filter_query.relevancy_boost).not_to have_key(:overlap)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when local boost parameter is present' do
|
88
|
+
before do
|
89
|
+
solr_params[:bf] = ['local_boost^5']
|
90
|
+
facet_config.overlap_boost = 2
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'appends overlap and includes the local boost' do
|
94
|
+
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include('$overlap^2')
|
95
|
+
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include('local_boost^5')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#intersects_filter' do
|
101
|
+
it 'returns an Intersects query' do
|
102
|
+
expect(bbox_filter_query.intersects_filter).to include('Intersects')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -2,7 +2,8 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Geoblacklight::SolrDocument::Inspection do
|
5
|
-
|
5
|
+
subject { SolrDocument.new }
|
6
|
+
|
6
7
|
describe '#inspectable?' do
|
7
8
|
it 'returns true for wms viewer protocol' do
|
8
9
|
expect(subject).to receive(:viewer_protocol).and_return('wms')
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Geoblacklight::SuppressedRecordsSearchBehavior do
|
5
|
+
subject(:searcher) { search_builder.with(user_params) }
|
6
|
+
|
7
|
+
let(:user_params) { {} }
|
8
|
+
let(:solr_params) { { q: 'water' } }
|
9
|
+
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
10
|
+
let(:context) { CatalogController.new }
|
11
|
+
let(:search_builder_class) do
|
12
|
+
Class.new(Blacklight::SearchBuilder).tap do |klass|
|
13
|
+
include Blacklight::Solr::SearchBuilderBehavior
|
14
|
+
klass.include(described_class)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
let(:search_builder) { search_builder_class.new(context) }
|
18
|
+
|
19
|
+
describe '#hide_suppressed_records' do
|
20
|
+
it 'hides/filters suppressed records' do
|
21
|
+
expect(searcher.hide_suppressed_records(solr_params)).to include('-gbl_suppressed_b: true')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when document action call like CatalogController#web_services' do
|
26
|
+
it 'does not hide/filter suppressed records' do
|
27
|
+
solr_params[:q] = "{!lucene}#{Settings.FIELDS.ID}:"
|
28
|
+
expect(searcher.hide_suppressed_records(solr_params)).to be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Geoblacklight::BboxItemPresenter, type: :presenter do
|
6
|
+
subject(:presenter) do
|
7
|
+
described_class.new(facet_item, facet_config, view_context, facet_field, search_state)
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:facet_item) { instance_double(Blacklight::Solr::Response::Facets::FacetItem) }
|
11
|
+
let(:filter_field) { instance_double(Blacklight::SearchState::FilterField, include?: true) }
|
12
|
+
let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'key') }
|
13
|
+
let(:facet_field) { instance_double(Blacklight::Solr::Response::Facets::FacetField) }
|
14
|
+
let(:view_context) { controller.view_context }
|
15
|
+
let(:search_state) { instance_double(Blacklight::SearchState, filter: filter_field) }
|
16
|
+
let(:controller) { CatalogController.new }
|
17
|
+
|
18
|
+
describe '#label' do
|
19
|
+
context 'with a single value' do
|
20
|
+
let(:facet_item) { 'blah' }
|
21
|
+
|
22
|
+
it 'uses the normal logic for item values' do
|
23
|
+
expect(presenter.label).to eq 'blah'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with a bbox' do
|
28
|
+
let(:facet_item) { Geoblacklight::BoundingBox.new(-160, -80, 120, 70) }
|
29
|
+
|
30
|
+
it 'translates the bbox into some nice, human-readable html' do
|
31
|
+
expect(Capybara.string(presenter.label))
|
32
|
+
.to have_text('-160 -80 120 70')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,8 +4,8 @@ ENV['RAILS_ENV'] ||= 'test'
|
|
4
4
|
require 'simplecov'
|
5
5
|
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
6
6
|
|
7
|
-
if ENV
|
8
|
-
dir = File.join(ENV
|
7
|
+
if ENV.fetch('CIRCLE_ARTIFACTS', false)
|
8
|
+
dir = File.join(ENV.fetch('CIRCLE_ARTIFACTS'), 'coverage')
|
9
9
|
SimpleCov.coverage_dir(dir)
|
10
10
|
end
|
11
11
|
|
@@ -16,6 +16,7 @@ SimpleCov.start 'rails' do
|
|
16
16
|
add_filter 'lib/tasks/geoblacklight.rake'
|
17
17
|
add_filter '/spec'
|
18
18
|
add_filter '.internal_test_app/'
|
19
|
+
minimum_coverage 100
|
19
20
|
end
|
20
21
|
|
21
22
|
require 'factory_bot'
|
@@ -30,6 +31,10 @@ require 'capybara/rspec'
|
|
30
31
|
require 'selenium-webdriver'
|
31
32
|
require 'webdrivers'
|
32
33
|
|
34
|
+
# Setup webmock for specific tests
|
35
|
+
require 'webmock/rspec'
|
36
|
+
WebMock.allow_net_connect!(net_http_connect_on_start: true)
|
37
|
+
|
33
38
|
Capybara.register_driver(:headless_chrome) do |app|
|
34
39
|
Capybara::Selenium::Driver.load_selenium
|
35
40
|
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
@@ -43,7 +48,7 @@ Capybara.register_driver(:headless_chrome) do |app|
|
|
43
48
|
Capybara::Selenium::Driver.new(app,
|
44
49
|
browser: :chrome,
|
45
50
|
http_client: http_client,
|
46
|
-
|
51
|
+
capabilities: [browser_options])
|
47
52
|
end
|
48
53
|
|
49
54
|
Capybara.javascript_driver = :headless_chrome
|
@@ -20,6 +20,10 @@ class TestAppGenerator < Rails::Generators::Base
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def install_webpacker
|
24
|
+
run 'bundle exec rails webpacker:install'
|
25
|
+
end
|
26
|
+
|
23
27
|
def run_blacklight_generator
|
24
28
|
say_status('warning', 'GENERATING BL', :yellow)
|
25
29
|
|
@@ -30,10 +34,6 @@ class TestAppGenerator < Rails::Generators::Base
|
|
30
34
|
generate 'geoblacklight:install', '-f'
|
31
35
|
end
|
32
36
|
|
33
|
-
def integrate_webpacker
|
34
|
-
generate 'geoblacklight:webpacker', '-f'
|
35
|
-
end
|
36
|
-
|
37
37
|
def fixtures
|
38
38
|
FileUtils.mkdir_p 'spec/fixtures/solr_documents'
|
39
39
|
directory 'solr_documents', 'spec/fixtures/solr_documents'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'catalog/_results_pagination
|
4
|
+
describe 'catalog/_results_pagination', type: :view do
|
5
5
|
it 'will have a #pagination wrapping div' do
|
6
6
|
allow(view).to receive_messages(show_pagination?: false)
|
7
7
|
render
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'catalog/_show_downloads
|
4
|
+
describe 'catalog/_show_downloads', type: :view do
|
5
5
|
context 'document is downloadable' do
|
6
6
|
let(:document) { instance_double(SolrDocument) }
|
7
7
|
before do
|
@@ -13,18 +13,18 @@ describe 'catalog/_show_downloads.html.erb', type: :view do
|
|
13
13
|
allow(document).to receive(:iiif_download).and_return({})
|
14
14
|
allow(document).to receive(:download_types).and_return(shapefile: {})
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
|
+
it 'renders the downloads collapse partial' do
|
17
18
|
expect(view).to receive(:document_downloadable?).and_return(true)
|
18
19
|
|
19
|
-
stub_template 'catalog/
|
20
|
-
stub_template 'catalog/_downloads_generated.html.erb' => 'stubbed_generated_downloads'
|
20
|
+
stub_template 'catalog/_downloads_collapse.html.erb' => 'stubbed_downloads_collapse'
|
21
21
|
|
22
22
|
render
|
23
23
|
|
24
|
-
expect(rendered).to have_content '
|
25
|
-
expect(rendered).to have_content 'stubbed_generated_downloads'
|
24
|
+
expect(rendered).to have_content 'stubbed_downloads_collapse'
|
26
25
|
end
|
27
26
|
end
|
27
|
+
|
28
28
|
context 'document is not downloadable' do
|
29
29
|
let(:document) { instance_double(SolrDocument, restricted?: true, same_institution?: true) }
|
30
30
|
before do
|
data/template.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
gem 'blacklight', '~> 7.0'
|
3
|
-
gem 'geoblacklight', '~>
|
4
|
-
gem 'webpacker' unless Rails.version.to_s.start_with? '6.1.'
|
3
|
+
gem 'geoblacklight', '~> 4.0'
|
5
4
|
gem 'sprockets', '< 4.0' # Use sprockets less than 4.0, let webpacker users set this up themselves
|
6
5
|
|
7
6
|
# Hack for https://github.com/rails/rails/issues/35153
|
8
7
|
# Adapted from https://github.com/projectblacklight/blacklight/pull/2065
|
9
8
|
gemfile = File.expand_path('Gemfile')
|
10
|
-
|
9
|
+
File.write(gemfile, File.open(gemfile) do |f|
|
11
10
|
text = f.read
|
12
11
|
text.gsub(/^gem 'sqlite3'$/, 'gem "sqlite3", "~> 1.3.6"')
|
13
12
|
end)
|
@@ -16,6 +15,5 @@ run 'bundle install'
|
|
16
15
|
|
17
16
|
generate 'blacklight:install', '--devise'
|
18
17
|
generate 'geoblacklight:install', '-f'
|
19
|
-
generate 'geoblacklight:webpacker', '-f'
|
20
18
|
|
21
19
|
rake 'db:migrate'
|
Binary file
|
Binary file
|
@@ -0,0 +1,152 @@
|
|
1
|
+
L.Control.Fullscreen = L.Control.extend({
|
2
|
+
options: {
|
3
|
+
position: 'topleft',
|
4
|
+
title: {
|
5
|
+
'false': 'View Fullscreen',
|
6
|
+
'true': 'Exit Fullscreen'
|
7
|
+
}
|
8
|
+
},
|
9
|
+
|
10
|
+
onAdd: function (map) {
|
11
|
+
var container = L.DomUtil.create('div', 'leaflet-control-fullscreen leaflet-bar leaflet-control');
|
12
|
+
|
13
|
+
this.link = L.DomUtil.create('a', 'leaflet-control-fullscreen-button leaflet-bar-part', container);
|
14
|
+
this.link.href = '#';
|
15
|
+
|
16
|
+
this._map = map;
|
17
|
+
this._map.on('fullscreenchange', this._toggleTitle, this);
|
18
|
+
this._toggleTitle();
|
19
|
+
|
20
|
+
L.DomEvent.on(this.link, 'click', this._click, this);
|
21
|
+
|
22
|
+
return container;
|
23
|
+
},
|
24
|
+
|
25
|
+
_click: function (e) {
|
26
|
+
L.DomEvent.stopPropagation(e);
|
27
|
+
L.DomEvent.preventDefault(e);
|
28
|
+
this._map.toggleFullscreen(this.options);
|
29
|
+
},
|
30
|
+
|
31
|
+
_toggleTitle: function() {
|
32
|
+
this.link.title = this.options.title[this._map.isFullscreen()];
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
L.Map.include({
|
37
|
+
isFullscreen: function () {
|
38
|
+
return this._isFullscreen || false;
|
39
|
+
},
|
40
|
+
|
41
|
+
toggleFullscreen: function (options) {
|
42
|
+
var container = this.getContainer();
|
43
|
+
if (this.isFullscreen()) {
|
44
|
+
if (options && options.pseudoFullscreen) {
|
45
|
+
this._disablePseudoFullscreen(container);
|
46
|
+
} else if (document.exitFullscreen) {
|
47
|
+
document.exitFullscreen();
|
48
|
+
} else if (document.mozCancelFullScreen) {
|
49
|
+
document.mozCancelFullScreen();
|
50
|
+
} else if (document.webkitCancelFullScreen) {
|
51
|
+
document.webkitCancelFullScreen();
|
52
|
+
} else if (document.msExitFullscreen) {
|
53
|
+
document.msExitFullscreen();
|
54
|
+
} else {
|
55
|
+
this._disablePseudoFullscreen(container);
|
56
|
+
}
|
57
|
+
} else {
|
58
|
+
if (options && options.pseudoFullscreen) {
|
59
|
+
this._enablePseudoFullscreen(container);
|
60
|
+
} else if (container.requestFullscreen) {
|
61
|
+
container.requestFullscreen();
|
62
|
+
} else if (container.mozRequestFullScreen) {
|
63
|
+
container.mozRequestFullScreen();
|
64
|
+
} else if (container.webkitRequestFullscreen) {
|
65
|
+
container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
|
66
|
+
} else if (container.msRequestFullscreen) {
|
67
|
+
container.msRequestFullscreen();
|
68
|
+
} else {
|
69
|
+
this._enablePseudoFullscreen(container);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
},
|
74
|
+
|
75
|
+
_enablePseudoFullscreen: function (container) {
|
76
|
+
L.DomUtil.addClass(container, 'leaflet-pseudo-fullscreen');
|
77
|
+
this._setFullscreen(true);
|
78
|
+
this.fire('fullscreenchange');
|
79
|
+
},
|
80
|
+
|
81
|
+
_disablePseudoFullscreen: function (container) {
|
82
|
+
L.DomUtil.removeClass(container, 'leaflet-pseudo-fullscreen');
|
83
|
+
this._setFullscreen(false);
|
84
|
+
this.fire('fullscreenchange');
|
85
|
+
},
|
86
|
+
|
87
|
+
_setFullscreen: function(fullscreen) {
|
88
|
+
this._isFullscreen = fullscreen;
|
89
|
+
var container = this.getContainer();
|
90
|
+
if (fullscreen) {
|
91
|
+
L.DomUtil.addClass(container, 'leaflet-fullscreen-on');
|
92
|
+
} else {
|
93
|
+
L.DomUtil.removeClass(container, 'leaflet-fullscreen-on');
|
94
|
+
}
|
95
|
+
this.invalidateSize();
|
96
|
+
},
|
97
|
+
|
98
|
+
_onFullscreenChange: function (e) {
|
99
|
+
var fullscreenElement =
|
100
|
+
document.fullscreenElement ||
|
101
|
+
document.mozFullScreenElement ||
|
102
|
+
document.webkitFullscreenElement ||
|
103
|
+
document.msFullscreenElement;
|
104
|
+
|
105
|
+
if (fullscreenElement === this.getContainer() && !this._isFullscreen) {
|
106
|
+
this._setFullscreen(true);
|
107
|
+
this.fire('fullscreenchange');
|
108
|
+
} else if (fullscreenElement !== this.getContainer() && this._isFullscreen) {
|
109
|
+
this._setFullscreen(false);
|
110
|
+
this.fire('fullscreenchange');
|
111
|
+
}
|
112
|
+
}
|
113
|
+
});
|
114
|
+
|
115
|
+
L.Map.mergeOptions({
|
116
|
+
fullscreenControl: false
|
117
|
+
});
|
118
|
+
|
119
|
+
L.Map.addInitHook(function () {
|
120
|
+
if (this.options.fullscreenControl) {
|
121
|
+
this.fullscreenControl = new L.Control.Fullscreen(this.options.fullscreenControl);
|
122
|
+
this.addControl(this.fullscreenControl);
|
123
|
+
}
|
124
|
+
|
125
|
+
var fullscreenchange;
|
126
|
+
|
127
|
+
if ('onfullscreenchange' in document) {
|
128
|
+
fullscreenchange = 'fullscreenchange';
|
129
|
+
} else if ('onmozfullscreenchange' in document) {
|
130
|
+
fullscreenchange = 'mozfullscreenchange';
|
131
|
+
} else if ('onwebkitfullscreenchange' in document) {
|
132
|
+
fullscreenchange = 'webkitfullscreenchange';
|
133
|
+
} else if ('onmsfullscreenchange' in document) {
|
134
|
+
fullscreenchange = 'MSFullscreenChange';
|
135
|
+
}
|
136
|
+
|
137
|
+
if (fullscreenchange) {
|
138
|
+
var onFullscreenChange = L.bind(this._onFullscreenChange, this);
|
139
|
+
|
140
|
+
this.whenReady(function () {
|
141
|
+
L.DomEvent.on(document, fullscreenchange, onFullscreenChange);
|
142
|
+
});
|
143
|
+
|
144
|
+
this.on('unload', function () {
|
145
|
+
L.DomEvent.off(document, fullscreenchange, onFullscreenChange);
|
146
|
+
});
|
147
|
+
}
|
148
|
+
});
|
149
|
+
|
150
|
+
L.control.fullscreen = function (options) {
|
151
|
+
return new L.Control.Fullscreen(options);
|
152
|
+
};
|