blacklight-maps 0.3.3 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9a4c9d51a9b188233f983469e290609fead6e4f
4
- data.tar.gz: 3d61ff5d65da2592b37515f3c62b773425f2fac0
3
+ metadata.gz: 8eea160d9da93d7b442489febe098f42ce323c2c
4
+ data.tar.gz: 7fdb19ab07e58ea19ab787a393d69f3916e40fd5
5
5
  SHA512:
6
- metadata.gz: 2ba42a84d843b12148894593e41a705f0ac85d7dd5abc84eeb906ea4f9d28468a4d5d6b717a2be00d08662f0d1e476723969fb1451c9c08edfa2744cc90a00c7
7
- data.tar.gz: 44d3a6067b0cc5465089318211b47fa2e00fdb9a241a8d87b309dab01afe8595baf0f58ec6a33086981ded5da4b24189c5cd525785589a9c85d9be1797849c78
6
+ metadata.gz: 41125c066a77d9e8844f685a1adfdd0bf19525865713b732752c07a10286c3ef3ee54e934293ef7920e02eee19da07f86a7d3dcee6b14868ce934eac1e0ca4c5
7
+ data.tar.gz: 88e97911466aec101c484a0b1abe98acf826ac13dd30f69fa811e68eb430ff65fe2c5fb5e21afb470f4e436e9175eec594069ba3a10c9505aeadfb00e01e6992
data/Gemfile CHANGED
@@ -8,12 +8,6 @@ gemspec
8
8
  # it'll want sprockets 2.11.0 and we'll have a conflict
9
9
  gem 'sprockets', '2.11.0'
10
10
 
11
- # If we don't specify 3.2.15 we'll end up with sass 3.3.2 in the main
12
- # Gemfile.lock but since sass-rails gets generated (rails new) into the test app
13
- # it'll want sass 3.2.0 and we'll have a conflict
14
- gem 'sass', '~> 3.2.0'
15
- gem 'bootstrap-sass', ">= 3.1.1.1"
16
-
17
11
  group :test do
18
12
  gem 'simplecov', require: false
19
13
  gem 'coveralls', require: false
data/README.md CHANGED
@@ -15,6 +15,8 @@ Maplet widget in item detail view:
15
15
 
16
16
  ## Installation
17
17
 
18
+ (See [Blacklight Version Compatibility](#blacklight-compatibility) below to make sure you're using a version of the gem that works with the version of Blacklight you're using.)
19
+
18
20
  Add this line to your application's Gemfile:
19
21
 
20
22
  gem 'blacklight-maps'
@@ -181,7 +183,7 @@ Option | Type | Default | Description
181
183
  `catalogpath` | String | `'catalog'` | the search path for the search control
182
184
  `placenamefield` | String | `'placename_field'` | the name of the Solr field containing the location names
183
185
  `searchctrlcue` | String | `'Search for all items within the current map window'` | the hover text to display when the mouse hovers over the ![search control](docs/blacklight-maps_search-control.png) search control
184
- `searchresultsview` | String | `'list'` | the view type for the search results on the catalog#index page after the ![search control](docs/blacklight-maps_search-control.png) search control is used
186
+ `searchresultsview` | String | `'list'` | the view type for the search results on the catalog#index page after the map ![search control](docs/blacklight-maps_search-control.png) search control is used
185
187
  `singlemarkermode` | Boolean | `true` | whether locations should be clustered
186
188
  `clustercount` | String | `'locations'` | whether clusters should display the location count or the number of hits (`'hits'` or `'locations'`)
187
189
  `maxzoom` | Integer | 18 | the maxZoom [property of the map](http://leafletjs.com/reference.html#map-maxzoom)
@@ -189,6 +191,13 @@ Option | Type | Default | Description
189
191
  `mapattribution` | String | ``Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'` | an [attribution string](http://leafletjs.com/reference.html#tilelayer-attribution) to describe the basemap layer
190
192
  `nodata` | String | `'Sorry, there is no data for this location.'` | a message to display in the Leaflet popup when the "popup" member is not present in the properties hash in the GeoJSON Feature for a location.
191
193
 
194
+ ### <a name="blacklight-compatibility"></a>Blacklight Version Compatibility
195
+ The table below indicates which versions of Blacklight Maps are compatible with which versions of Blacklight.
196
+
197
+ Blacklight Maps version | works with Blacklight version
198
+ ----------------------- | ---------------------
199
+ >= 0.4.0 | >= 5.12.0 to < 6.*
200
+ <= 0.3.3 | >= 5.1 to <= 5.11.2
192
201
 
193
202
  ## Contributing
194
203
 
@@ -61,8 +61,8 @@ module Blacklight::BlacklightMapsHelperBehavior
61
61
 
62
62
  # return an array of Blacklight::SolrResponse::Facets::FacetItem items
63
63
  def map_facet_values
64
- if @response.facet_by_field_name(map_facet_field)
65
- @response.facet_by_field_name(map_facet_field).items
64
+ if @response.aggregations[map_facet_field]
65
+ @response.aggregations[map_facet_field].items
66
66
  else
67
67
  []
68
68
  end
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "rails"
21
- spec.add_dependency "blacklight", ">= 5.1.0"
22
- spec.add_dependency "bootstrap-sass", "~> 3.0"
21
+ spec.add_dependency "blacklight", ">= 5.12.0"
22
+ spec.add_dependency "bootstrap-sass", "~> 3.2"
23
23
  spec.add_dependency "leaflet-rails"
24
24
  spec.add_dependency "leaflet-markercluster-rails"
25
25
 
@@ -7,6 +7,7 @@ module Blacklight
7
7
  require 'blacklight/maps/engine'
8
8
  require 'blacklight/maps/export'
9
9
  require 'blacklight/maps/geometry'
10
+ require 'blacklight/maps/maps_search_builder'
10
11
 
11
12
  def self.inject!
12
13
  CatalogController.send(:include, BlacklightMaps::ControllerOverride)
@@ -2,32 +2,30 @@ module BlacklightMaps
2
2
  module ControllerOverride
3
3
  extend ActiveSupport::Concern
4
4
  included do
5
- solr_search_params_logic << :add_spatial_search_to_solr
5
+
6
+ if self.respond_to? :search_params_logic
7
+ search_params_logic << :add_spatial_search_to_solr
8
+ end
9
+
10
+ if self.blacklight_config.search_builder_class
11
+ self.blacklight_config.search_builder_class.send(:include,
12
+ BlacklightMaps::MapsSearchBuilder
13
+ ) unless
14
+ self.blacklight_config.search_builder_class.include?(
15
+ BlacklightMaps::MapsSearchBuilder
16
+ )
17
+ end
18
+
6
19
  end
7
20
 
8
21
  def map
9
- (@response, @document_list) = get_search_results
22
+ (@response, @document_list) = search_results(params, search_params_logic)
10
23
  params[:view] = 'maps'
11
24
  respond_to do |format|
12
25
  format.html
13
26
  end
14
27
  end
15
28
 
16
- # add spatial search params to solr
17
- def add_spatial_search_to_solr(solr_parameters, user_parameters)
18
- if user_parameters[:spatial_search_type] && user_parameters[:coordinates]
19
- solr_parameters[:fq] ||= []
20
- if user_parameters[:spatial_search_type] == 'bbox'
21
- solr_parameters[:fq] << blacklight_config.view.maps.coordinates_field + ":" + user_parameters[:coordinates]
22
- else
23
- solr_parameters[:fq] << "{!geofilt sfield=#{blacklight_config.view.maps.coordinates_field}}"
24
- solr_parameters[:pt] = user_parameters[:coordinates]
25
- solr_parameters[:d] = blacklight_config.view.maps.spatial_query_dist
26
- end
27
- end
28
- solr_parameters
29
- end
30
-
31
29
  end
32
30
 
33
31
  end
@@ -0,0 +1,20 @@
1
+ module BlacklightMaps
2
+ module MapsSearchBuilder
3
+
4
+ # add spatial search params to solr
5
+ def add_spatial_search_to_solr(solr_parameters = {})
6
+ if blacklight_params[:spatial_search_type] && blacklight_params[:coordinates]
7
+ solr_parameters[:fq] ||= []
8
+ if blacklight_params[:spatial_search_type] == 'bbox'
9
+ solr_parameters[:fq] << blacklight_config.view.maps.coordinates_field + ":" + blacklight_params[:coordinates]
10
+ else
11
+ solr_parameters[:fq] << "{!geofilt sfield=#{blacklight_config.view.maps.coordinates_field}}"
12
+ solr_parameters[:pt] = blacklight_params[:coordinates]
13
+ solr_parameters[:d] = blacklight_config.view.maps.spatial_query_dist
14
+ end
15
+ end
16
+ solr_parameters
17
+ end
18
+
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Maps
3
- VERSION = "0.3.3"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -23,7 +23,7 @@ describe BlacklightMapsHelper do
23
23
  @catalog.request = @request
24
24
  @catalog.action_name = "index"
25
25
  helper.instance_variable_set(:@_controller, @catalog)
26
- @docs = r.facet_by_field_name(blacklight_config.view.maps.geojson_field).items
26
+ @docs = r.aggregations[blacklight_config.view.maps.geojson_field].items
27
27
  end
28
28
 
29
29
  describe "blacklight_map_tag" do
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe BlacklightMaps::MapsSearchBuilder do
4
+
5
+ class MapsSearchBuilderTestClass
6
+ cattr_accessor :blacklight_config, :blacklight_params
7
+
8
+ include Blacklight::SearchHelper
9
+ include BlacklightMaps::MapsSearchBuilder
10
+
11
+ def initialize blacklight_config, blacklight_params
12
+ self.blacklight_config = blacklight_config
13
+ self.blacklight_params = blacklight_params
14
+ end
15
+
16
+ end
17
+
18
+ let(:blacklight_config) { Blacklight::Configuration.new }
19
+ let(:blacklight_params) { Hash.new }
20
+ let(:solr_parameters) { Blacklight::Solr::Request.new }
21
+
22
+ describe "add_spatial_search_to_solr" do
23
+
24
+ before { @obj = MapsSearchBuilderTestClass.new blacklight_config, blacklight_params }
25
+
26
+ describe "coordinate search" do
27
+
28
+ before do
29
+ @obj.blacklight_params[:coordinates] = "35.86166,104.195397"
30
+ @obj.blacklight_params[:spatial_search_type] = "point"
31
+ end
32
+
33
+ it "should return a coordinate point spatial search if coordinates are given" do
34
+ expect(@obj.add_spatial_search_to_solr(solr_parameters)[:fq].first).to include('geofilt')
35
+ expect(@obj.add_spatial_search_to_solr(solr_parameters)[:pt]).to eq(@obj.blacklight_params[:coordinates])
36
+ end
37
+
38
+ end
39
+
40
+ describe "bbox search" do
41
+
42
+ before do
43
+ @obj.blacklight_params[:coordinates] = "[6.7535159,68.162386 TO 35.5044752,97.395555]"
44
+ @obj.blacklight_params[:spatial_search_type] = "bbox"
45
+ end
46
+
47
+ it "should return a bbox spatial search if a bbox is given" do
48
+ expect(@obj.add_spatial_search_to_solr(solr_parameters)[:fq].first).to include(blacklight_config.view.maps.coordinates_field)
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-maps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-13 00:00:00.000000000 Z
12
+ date: 2015-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,28 +31,28 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 5.1.0
34
+ version: 5.12.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 5.1.0
41
+ version: 5.12.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bootstrap-sass
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '3.0'
48
+ version: '3.2'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '3.0'
55
+ version: '3.2'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: leaflet-rails
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +220,7 @@ files:
220
220
  - lib/blacklight/maps/engine.rb
221
221
  - lib/blacklight/maps/export.rb
222
222
  - lib/blacklight/maps/geometry.rb
223
+ - lib/blacklight/maps/maps_search_builder.rb
223
224
  - lib/blacklight/maps/render_constraints_override.rb
224
225
  - lib/blacklight/maps/version.rb
225
226
  - lib/generators/blacklight_maps/install_generator.rb
@@ -232,9 +233,9 @@ files:
232
233
  - spec/features/maps_spec.rb
233
234
  - spec/fixtures/sample_solr_documents.yml
234
235
  - spec/helpers/blacklight_maps_helper_spec.rb
235
- - spec/lib/blacklight/maps/controller_override_spec.rb
236
236
  - spec/lib/blacklight/maps/export_spec.rb
237
237
  - spec/lib/blacklight/maps/geometry_spec.rb
238
+ - spec/lib/blacklight/maps/maps_search_builder_spec.rb
238
239
  - spec/lib/blacklight/maps/render_constraints_override_spec.rb
239
240
  - spec/spec_helper.rb
240
241
  - spec/test_app_templates/Gemfile.extra
@@ -269,9 +270,9 @@ test_files:
269
270
  - spec/features/maps_spec.rb
270
271
  - spec/fixtures/sample_solr_documents.yml
271
272
  - spec/helpers/blacklight_maps_helper_spec.rb
272
- - spec/lib/blacklight/maps/controller_override_spec.rb
273
273
  - spec/lib/blacklight/maps/export_spec.rb
274
274
  - spec/lib/blacklight/maps/geometry_spec.rb
275
+ - spec/lib/blacklight/maps/maps_search_builder_spec.rb
275
276
  - spec/lib/blacklight/maps/render_constraints_override_spec.rb
276
277
  - spec/spec_helper.rb
277
278
  - spec/test_app_templates/Gemfile.extra
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe BlacklightMaps::ControllerOverride do
4
-
5
- class BlacklightMapsControllerTestClass < CatalogController
6
- end
7
-
8
- before(:each) do
9
- CatalogController.blacklight_config = Blacklight::Configuration.new
10
- @fake_controller = BlacklightMapsControllerTestClass.new
11
- @fake_controller.extend(BlacklightMaps::ControllerOverride)
12
- end
13
-
14
- let(:solr_params) { Hash.new }
15
- let(:req_params) { Hash.new }
16
-
17
- describe "add_spatial_search_to_solr" do
18
-
19
- it "should return a coordinate point spatial search if coordinates are given" do
20
- req_params[:coordinates] = "35.86166,104.195397"
21
- req_params[:spatial_search_type] = "point"
22
- expect(@fake_controller.add_spatial_search_to_solr(solr_params, req_params)[:fq].first).to include('geofilt')
23
- expect(@fake_controller.add_spatial_search_to_solr(solr_params, req_params)[:pt]).to eq(req_params[:coordinates])
24
- end
25
-
26
- it "should return a bbox spatial search if a bbox is given" do
27
- req_params[:coordinates] = "[6.7535159,68.162386 TO 35.5044752,97.395555]"
28
- req_params[:spatial_search_type] = "bbox"
29
- expect(@fake_controller.add_spatial_search_to_solr(solr_params, req_params)[:fq].first).to include(CatalogController.blacklight_config.view.maps.coordinates_field)
30
- end
31
-
32
- end
33
-
34
- end