blacklight-maps 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -12
  3. data/README.md +2 -1
  4. data/app/assets/javascripts/blacklight-maps/blacklight-maps-browse.js +7 -1
  5. data/app/assets/stylesheets/blacklight_maps/{blacklight-maps.css.scss → blacklight-maps.scss} +0 -0
  6. data/app/assets/stylesheets/blacklight_maps/{default.css.scss → default.scss} +0 -0
  7. data/app/helpers/blacklight/blacklight_maps_helper_behavior.rb +6 -6
  8. data/app/views/catalog/_document_maps.html.erb +1 -1
  9. data/app/views/catalog/{_index_map.html.erb → _index_mapview.html.erb} +1 -1
  10. data/blacklight-maps.gemspec +1 -1
  11. data/config/jetty.yml +1 -1
  12. data/lib/blacklight/maps.rb +0 -13
  13. data/lib/blacklight/maps/controller_override.rb +4 -15
  14. data/lib/blacklight/maps/engine.rb +15 -16
  15. data/lib/blacklight/maps/maps_search_builder.rb +6 -1
  16. data/lib/blacklight/maps/render_constraints_override.rb +3 -4
  17. data/lib/blacklight/maps/version.rb +1 -1
  18. data/lib/generators/blacklight_maps/install_generator.rb +36 -0
  19. data/lib/generators/blacklight_maps/templates/saved_searches_controller.rb +5 -0
  20. data/lib/generators/blacklight_maps/templates/search_history_controller.rb +5 -0
  21. data/lib/railties/blacklight_maps.rake +3 -2
  22. data/spec/features/initial_view_spec.rb +2 -2
  23. data/spec/features/maps_spec.rb +2 -52
  24. data/spec/features/show_view_maplet_spec.rb +92 -0
  25. data/spec/fixtures/sample_solr_documents.yml +100 -0
  26. data/spec/helpers/blacklight_maps_helper_spec.rb +9 -6
  27. data/spec/lib/blacklight/maps/maps_search_builder_spec.rb +22 -31
  28. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -0
  29. metadata +12 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8eea160d9da93d7b442489febe098f42ce323c2c
4
- data.tar.gz: 7fdb19ab07e58ea19ab787a393d69f3916e40fd5
3
+ metadata.gz: bc71dc7dfe0b126d989b4076ee3caf03f16b319c
4
+ data.tar.gz: 94a0708fa6cab6c59b73e5c6519b95addc33efdf
5
5
  SHA512:
6
- metadata.gz: 41125c066a77d9e8844f685a1adfdd0bf19525865713b732752c07a10286c3ef3ee54e934293ef7920e02eee19da07f86a7d3dcee6b14868ce934eac1e0ca4c5
7
- data.tar.gz: 88e97911466aec101c484a0b1abe98acf826ac13dd30f69fa811e68eb430ff65fe2c5fb5e21afb470f4e436e9175eec594069ba3a10c9505aeadfb00e01e6992
6
+ metadata.gz: 1e9c2ca3243093244412d93dd265bd8b06ecaacd15892fdc9a92e2fbf15535df24205d56e81d9d46b77468e8d13ce61ff5d1556c24610eec1798c384302278de
7
+ data.tar.gz: de5b485da3d27a1b3b7d59db34bb62c47dedffd0db6e6ce91baf73e8d7becf8628c03d06ed050cf261e736d104f9859b5e482e7b38e65bc5866ca5217ddf32c7
@@ -3,23 +3,24 @@ notifications:
3
3
  language: ruby
4
4
  sudo: false
5
5
  rvm:
6
- - 2.2.0
7
- - 2.1.0
8
- - 2.0.0
9
- - 1.9.3
10
- - jruby-19mode
6
+ - 2.3.0
7
+
8
+ matrix:
9
+ include:
10
+ - rvm: 2.2.4
11
+ env: "RAILS_VERSION=4.1.14"
12
+
13
+ before_install:
14
+ - gem install bundler
15
+
16
+ env:
17
+ - "RAILS_VERSION=4.2.6"
11
18
 
12
19
  notifications:
13
20
  irc: "irc.freenode.org#blacklight"
14
21
  email:
15
22
  - blacklight-commits@googlegroups.com
16
23
 
17
- env:
18
- global:
19
- - JRUBY_OPTS="-J-Xms512m -J-Xmx1024m"
24
+ global_env:
20
25
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
21
26
 
22
- matrix:
23
- allow_failures:
24
- - rvm: jruby-19mode
25
- - rvm: 1.9.3
data/README.md CHANGED
@@ -196,7 +196,8 @@ The table below indicates which versions of Blacklight Maps are compatible with
196
196
 
197
197
  Blacklight Maps version | works with Blacklight version
198
198
  ----------------------- | ---------------------
199
- >= 0.4.0 | >= 5.12.0 to < 6.*
199
+ 0.5.0 | >= 6.1.0
200
+ 0.4.0 | >= 5.12.0 to < 6.*
200
201
  <= 0.3.3 | >= 5.1 to <= 5.11.2
201
202
 
202
203
  ## Contributing
@@ -182,7 +182,13 @@
182
182
  * Checks to see if there are any features in the markers MarkerClusterGroup
183
183
  */
184
184
  function hasAnyFeatures() {
185
- return !$.isEmptyObject(markers._featureGroup._layers);
185
+ var has_features = false;
186
+ markers.eachLayer(function (layer) {
187
+ if (!$.isEmptyObject(layer)) {
188
+ has_features = true;
189
+ }
190
+ });
191
+ return has_features;
186
192
  }
187
193
 
188
194
  // remove stale params, add new params, and run a new search
@@ -26,7 +26,7 @@ module Blacklight::BlacklightMapsHelperBehavior
26
26
  def link_to_bbox_search bbox_coordinates
27
27
  coords_for_search = bbox_coordinates.map { |v| v.to_s }
28
28
  link_to(t('blacklight.maps.interactions.bbox_search'),
29
- catalog_index_path(spatial_search_type: "bbox",
29
+ search_catalog_path(spatial_search_type: "bbox",
30
30
  coordinates: "[#{coords_for_search[1]},#{coords_for_search[0]} TO #{coords_for_search[3]},#{coords_for_search[2]}]",
31
31
  view: default_document_index_view_type))
32
32
  end
@@ -36,11 +36,11 @@ module Blacklight::BlacklightMapsHelperBehavior
36
36
  if params[:f] && params[:f][field] && params[:f][field].include?(field_value)
37
37
  new_params = params
38
38
  else
39
- new_params = add_facet_params(field, field_value)
39
+ new_params = search_state.add_facet_params(field, field_value)
40
40
  end
41
41
  new_params[:view] = default_document_index_view_type
42
42
  link_to(displayvalue.presence || field_value,
43
- catalog_index_path(new_params.except(:id, :spatial_search_type, :coordinates)))
43
+ search_catalog_path(new_params.except(:id, :spatial_search_type, :coordinates)))
44
44
  end
45
45
 
46
46
  # create a link to a spatial search for a set of point coordinates
@@ -49,7 +49,7 @@ module Blacklight::BlacklightMapsHelperBehavior
49
49
  new_params[:spatial_search_type] = "point"
50
50
  new_params[:coordinates] = "#{point_coordinates[1]},#{point_coordinates[0]}"
51
51
  new_params[:view] = default_document_index_view_type
52
- link_to(t('blacklight.maps.interactions.point_search'), catalog_index_path(new_params))
52
+ link_to(t('blacklight.maps.interactions.point_search'), search_catalog_path(new_params))
53
53
  end
54
54
 
55
55
  # return the facet field containing geographic data
@@ -76,8 +76,8 @@ module Blacklight::BlacklightMapsHelperBehavior
76
76
  end
77
77
 
78
78
  # render the map for #index and #map views
79
- def render_index_map
80
- render :partial => 'catalog/index_map',
79
+ def render_index_mapview
80
+ render :partial => 'catalog/index_mapview',
81
81
  :locals => {:geojson_features => serialize_geojson(map_facet_values)}
82
82
  end
83
83
 
@@ -1,4 +1,4 @@
1
1
  <% # container for all documents in map view -%>
2
2
  <div id="documents" class="map">
3
- <%= render_index_map %>
3
+ <%= render_index_mapview %>
4
4
  </div>
@@ -1,6 +1,6 @@
1
1
  <%= blacklight_map_tag('blacklight-index-map',
2
2
  {data:{searchcontrol: true,
3
- catalogpath: catalog_index_path,
3
+ catalogpath: search_catalog_path,
4
4
  placenamefield: blacklight_config.view.maps.placename_field,
5
5
  clustercount:'hits',
6
6
  searchresultsview: default_document_index_view_type
@@ -18,7 +18,7 @@ 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.12.0"
21
+ spec.add_dependency "blacklight", ">= 6.1.0"
22
22
  spec.add_dependency "bootstrap-sass", "~> 3.2"
23
23
  spec.add_dependency "leaflet-rails"
24
24
  spec.add_dependency "leaflet-markercluster-rails"
@@ -3,5 +3,5 @@ development:
3
3
  jetty_port: 8983
4
4
  test:
5
5
  startup_wait: 60
6
- jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
6
+ jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
7
7
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
@@ -9,18 +9,5 @@ module Blacklight
9
9
  require 'blacklight/maps/geometry'
10
10
  require 'blacklight/maps/maps_search_builder'
11
11
 
12
- def self.inject!
13
- CatalogController.send(:include, BlacklightMaps::ControllerOverride)
14
- CatalogController.send(:include, BlacklightMaps::RenderConstraintsOverride)
15
- CatalogController.send(:helper, BlacklightMaps::RenderConstraintsOverride) unless
16
- CatalogController.helpers.is_a?(BlacklightMaps::RenderConstraintsOverride)
17
-
18
- # inject into SearchHistory and SavedSearches so spatial queries display properly
19
- SearchHistoryController.send(:helper, BlacklightMaps::RenderConstraintsOverride) unless
20
- SearchHistoryController.helpers.is_a?(BlacklightMaps::RenderConstraintsOverride)
21
- SavedSearchesController.send(:helper, BlacklightMaps::RenderConstraintsOverride) unless
22
- SavedSearchesController.helpers.is_a?(BlacklightMaps::RenderConstraintsOverride)
23
- end
24
-
25
12
  end
26
13
  end
@@ -1,25 +1,14 @@
1
1
  module BlacklightMaps
2
2
  module ControllerOverride
3
3
  extend ActiveSupport::Concern
4
- included do
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
4
 
5
+ included do
6
+ self.send(:include, BlacklightMaps::RenderConstraintsOverride)
7
+ self.send(:helper, BlacklightMaps::RenderConstraintsOverride)
19
8
  end
20
9
 
21
10
  def map
22
- (@response, @document_list) = search_results(params, search_params_logic)
11
+ (@response, @document_list) = search_results(params)
23
12
  params[:view] = 'maps'
24
13
  respond_to do |format|
25
14
  format.html
@@ -5,29 +5,28 @@ require 'leaflet-markercluster-rails'
5
5
  module Blacklight
6
6
  module Maps
7
7
  class Engine < Rails::Engine
8
+
8
9
  # Set some default configurations
9
- Blacklight::Configuration.default_values[:view].maps.geojson_field = "geojson"
10
- Blacklight::Configuration.default_values[:view].maps.placename_property = "placename"
11
- Blacklight::Configuration.default_values[:view].maps.coordinates_field = "coordinates"
12
- Blacklight::Configuration.default_values[:view].maps.search_mode = "placename" # or 'coordinates'
13
- Blacklight::Configuration.default_values[:view].maps.spatial_query_dist = 0.5
14
- Blacklight::Configuration.default_values[:view].maps.placename_field = "placename_field"
15
- Blacklight::Configuration.default_values[:view].maps.coordinates_facet_field = "coordinates_facet_field"
16
- Blacklight::Configuration.default_values[:view].maps.facet_mode = "geojson" # or 'coordinates'
17
- Blacklight::Configuration.default_values[:view].maps.tileurl = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
18
- Blacklight::Configuration.default_values[:view].maps.mapattribution = '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>'
19
- Blacklight::Configuration.default_values[:view].maps.maxzoom = 18
20
- Blacklight::Configuration.default_values[:view].maps.show_initial_zoom = 5
10
+ initializer 'blacklight-maps.default_config' do |app|
11
+ Blacklight::Configuration.default_values[:view].maps.geojson_field = "geojson"
12
+ Blacklight::Configuration.default_values[:view].maps.placename_property = "placename"
13
+ Blacklight::Configuration.default_values[:view].maps.coordinates_field = "coordinates"
14
+ Blacklight::Configuration.default_values[:view].maps.search_mode = "placename" # or 'coordinates'
15
+ Blacklight::Configuration.default_values[:view].maps.spatial_query_dist = 0.5
16
+ Blacklight::Configuration.default_values[:view].maps.placename_field = "placename_field"
17
+ Blacklight::Configuration.default_values[:view].maps.coordinates_facet_field = "coordinates_facet_field"
18
+ Blacklight::Configuration.default_values[:view].maps.facet_mode = "geojson" # or 'coordinates'
19
+ Blacklight::Configuration.default_values[:view].maps.tileurl = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
20
+ Blacklight::Configuration.default_values[:view].maps.mapattribution = '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>'
21
+ Blacklight::Configuration.default_values[:view].maps.maxzoom = 18
22
+ Blacklight::Configuration.default_values[:view].maps.show_initial_zoom = 5
23
+ end
21
24
 
22
25
  # Add our helpers
23
26
  initializer 'blacklight-maps.helpers' do |app|
24
27
  ActionView::Base.send :include, BlacklightMapsHelper
25
28
  end
26
29
 
27
- config.to_prepare do
28
- Blacklight::Maps.inject!
29
- end
30
-
31
30
  # This makes our rake tasks visible.
32
31
  rake_tasks do
33
32
  Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))) do
@@ -1,5 +1,10 @@
1
1
  module BlacklightMaps
2
- module MapsSearchBuilder
2
+ module MapsSearchBuilderBehavior
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.default_processor_chain += [:add_spatial_search_to_solr]
7
+ end
3
8
 
4
9
  # add spatial search params to solr
5
10
  def add_spatial_search_to_solr(solr_parameters = {})
@@ -40,15 +40,14 @@ module BlacklightMaps
40
40
  # Render the spatial query constraints
41
41
  def render_spatial_query(localized_params = params)
42
42
  # So simple don't need a view template, we can just do it here.
43
- scope = localized_params.delete(:route_set) || self
44
43
  return ''.html_safe if localized_params[:coordinates].blank?
45
44
 
46
45
  render_constraint_element(spatial_constraint_label(localized_params),
47
46
  localized_params[:coordinates],
48
47
  :classes => ['coordinates'],
49
- :remove => scope.url_for(localized_params.merge(:coordinates=>nil,
50
- :spatial_search_type=>nil,
51
- :action=>'index')))
48
+ :remove => remove_constraint_url(localized_params.merge(:coordinates=>nil,
49
+ :spatial_search_type=>nil,
50
+ :action=>'index')))
52
51
  end
53
52
 
54
53
  def spatial_constraint_label(params)
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Maps
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -21,5 +21,41 @@ module BlacklightMaps
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ def inject_search_builder
26
+ inject_into_file 'app/models/search_builder.rb', after: /include Blacklight::Solr::SearchBuilderBehavior.*$/ do
27
+ "\n include BlacklightMaps::MapsSearchBuilderBehavior\n"
28
+ end
29
+ end
30
+
31
+ def install_catalog_controller_mixin
32
+ inject_into_file "app/controllers/catalog_controller.rb", after: /include Blacklight::Catalog.*$/ do
33
+ "\n include BlacklightMaps::ControllerOverride\n"
34
+ end
35
+ end
36
+
37
+ def install_search_history_controller
38
+ target_file = "app/controllers/search_history_controller.rb"
39
+ if File.exists?(target_file)
40
+ inject_into_file target_file, after: /include Blacklight::SearchHistory/ do
41
+ "\n helper BlacklightMaps::RenderConstraintsOverride\n"
42
+ end
43
+ else
44
+ copy_file "search_history_controller.rb", target_file
45
+ end
46
+ end
47
+
48
+ def install_saved_searches_controller
49
+ target_file = "app/controllers/saved_searches_controller.rb"
50
+ if File.exists?(target_file)
51
+ inject_into_file target_file, after: /include Blacklight::SavedSearches/ do
52
+ "\n helper BlacklightMaps::RenderConstraintsOverride\n"
53
+ end
54
+ else
55
+ copy_file "saved_searches_controller.rb", target_file
56
+ end
57
+ end
58
+
59
+
24
60
  end
25
61
  end
@@ -0,0 +1,5 @@
1
+ class SavedSearchesController < ApplicationController
2
+ include Blacklight::SavedSearches
3
+
4
+ helper BlacklightMaps::RenderConstraintsOverride
5
+ end
@@ -0,0 +1,5 @@
1
+ class SearchHistoryController < ApplicationController
2
+ include Blacklight::SearchHistory
3
+
4
+ helper BlacklightMaps::RenderConstraintsOverride
5
+ end
@@ -6,8 +6,9 @@ namespace :blacklight_maps do
6
6
  desc "Put sample data into solr"
7
7
  task :seed => :environment do
8
8
  docs = YAML::load(File.open(File.expand_path(File.join('..', '..', '..', 'spec', 'fixtures', 'sample_solr_documents.yml'), __FILE__)))
9
- Blacklight.solr.add docs
10
- Blacklight.solr.commit
9
+ conn = Blacklight.default_index.connection
10
+ conn.add docs
11
+ conn.commit
11
12
  end
12
13
  end
13
14
  end
@@ -9,13 +9,13 @@ feature 'Initial view parameter', js: true do
9
9
  end
10
10
  end
11
11
  scenario 'defaults to zoom area of markers' do
12
- visit catalog_index_path f: { format: ['Book'] }, view: 'maps'
12
+ visit search_catalog_path f: { format: ['Book'] }, view: 'maps'
13
13
  expect(page).to have_css '.leaflet-marker-icon.marker-cluster', count: 8
14
14
  end
15
15
  scenario 'when provided sets map to its view' do
16
16
  map_tag = '<div id="blacklight-index-map" data-initialview="[[37.65, -122.56],[37.89, -122.27]]" data-maxzoom="18" data-tileurl="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" data-mapattribution="Map data &amp;copy; &lt;a href=&quot;http://openstreetmap.org&quot;&gt;OpenStreetMap&lt;/a&gt; contributors, &lt;a href=&quot;http://creativecommons.org/licenses/by-sa/2.0/&quot;&gt;CC-BY-SA&lt;/a&gt;" data-searchcontrol="true" data-catalogpath="/catalog" data-placenamefield="placename_field" data-clustercount="hits" />'.html_safe
17
17
  expect_any_instance_of(Blacklight::BlacklightMapsHelperBehavior).to receive(:blacklight_map_tag).and_return(map_tag)
18
- visit catalog_index_path f: { format: ['Book'] }, view: 'maps'
18
+ visit search_catalog_path f: { format: ['Book'] }, view: 'maps'
19
19
  expect(page).to_not have_css '.leaflet-marker-icon.marker-cluster'
20
20
  end
21
21
  end
@@ -16,7 +16,7 @@ describe "Map View", js: true do
16
16
  config.add_facet_field 'geojson', :limit => -2, :label => 'GeoJSON', :show => false
17
17
  config.add_facet_fields_to_solr_request!
18
18
  end
19
- visit catalog_index_path :q => 'korea', :view => 'maps'
19
+ visit search_catalog_path :q => 'korea', :view => 'maps'
20
20
  end
21
21
 
22
22
  it "should display map elements" do
@@ -158,7 +158,7 @@ describe "Map View", js: true do
158
158
  config.add_facet_fields_to_solr_request!
159
159
  end
160
160
  visit map_path
161
- #print page.html # debugging
161
+ # print page.html # debugging
162
162
  end
163
163
 
164
164
  it "should display map elements" do
@@ -199,54 +199,4 @@ describe "Map View", js: true do
199
199
 
200
200
  end
201
201
 
202
- describe "catalog#show maplet view" do
203
-
204
- before :each do
205
- CatalogController.configure_blacklight do |config|
206
- # add maplet to show partials
207
- config.show.partials << :show_maplet
208
- end
209
- visit catalog_path('2008308175')
210
- end
211
-
212
- it "should show the maplet" do
213
- expect(page).to have_selector("#blacklight-show-map")
214
- end
215
-
216
- it "should show the mapped item count" do
217
- expect(page).to have_selector(".mapped-count .badge", text: "2")
218
- end
219
-
220
- it "should show a bounding box and a point marker" do
221
- expect(page).to have_selector(".leaflet-overlay-pane path.leaflet-clickable")
222
- expect(page).to have_selector(".leaflet-marker-icon")
223
- end
224
-
225
- describe "click marker icon" do
226
-
227
- before { find(".leaflet-marker-icon").click }
228
-
229
- it "should show a popup with correct content" do
230
- expect(page).to have_selector("div.leaflet-popup-content-wrapper")
231
- expect(page).to have_content("India")
232
- end
233
-
234
- end
235
-
236
- describe "click bbox path" do
237
-
238
- before do
239
- 0.upto(4) { find("a.leaflet-control-zoom-in").click } #so bbox not covered by point
240
- find(".leaflet-overlay-pane svg").click
241
- end
242
-
243
- it "should show a popup with correct content" do
244
- expect(page).to have_selector("div.leaflet-popup-content-wrapper")
245
- expect(page).to have_content("[68.162386, 6.7535159, 97.395555, 35.5044752]")
246
- end
247
-
248
- end
249
-
250
- end
251
-
252
202
  end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe "catalog#show view", js: true do
4
+
5
+ before :each do
6
+ CatalogController.blacklight_config = Blacklight::Configuration.new
7
+ CatalogController.configure_blacklight do |config|
8
+ # add maplet to show view partials
9
+ config.show.partials << :show_maplet
10
+ end
11
+ end
12
+
13
+ describe "item with point feature" do
14
+
15
+ before :each do
16
+ visit solr_document_path("00314247")
17
+ end
18
+
19
+ it "should display the maplet" do
20
+ expect(page).to have_selector("#blacklight-show-map-container")
21
+ end
22
+
23
+ it "should have a single marker icon" do
24
+ expect(page).to have_selector(".leaflet-marker-icon", count: 1)
25
+ end
26
+
27
+ describe "click marker icon" do
28
+
29
+ before { find(".leaflet-marker-icon").click }
30
+
31
+ it "should show a popup with correct content" do
32
+ expect(page).to have_selector("div.leaflet-popup-content-wrapper")
33
+ expect(page).to have_content("Japan")
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ describe "item with point and bbox features" do
41
+
42
+ before :each do
43
+ visit solr_document_path("2008308175")
44
+ end
45
+
46
+ it "should show the correct mapped item count" do
47
+ expect(page).to have_selector(".mapped-count .badge", text: "2")
48
+ end
49
+
50
+ it "should show a bounding box and a point marker" do
51
+ expect(page).to have_selector(".leaflet-overlay-pane path.leaflet-clickable")
52
+ expect(page).to have_selector(".leaflet-marker-icon")
53
+ end
54
+
55
+ describe "click bbox path" do
56
+
57
+ before do
58
+ 0.upto(4) { find("a.leaflet-control-zoom-in").click } #so bbox not covered by point
59
+ find(".leaflet-overlay-pane svg").click
60
+ end
61
+
62
+ it "should show a popup with correct content" do
63
+ expect(page).to have_selector("div.leaflet-popup-content-wrapper")
64
+ expect(page).to have_content("[68.162386, 6.7535159, 97.395555, 35.5044752]")
65
+ end
66
+
67
+ end
68
+
69
+ end
70
+
71
+ describe "item with bbox feature" do
72
+
73
+ before :each do
74
+ CatalogController.configure_blacklight do |config|
75
+ # set maxzoom so we can test whether initial zoom is correct
76
+ config.view.maps.maxzoom = 8
77
+ end
78
+ visit solr_document_path("2009373514")
79
+ end
80
+
81
+ it "should display a bounding box" do
82
+ expect(page).to have_selector(".leaflet-overlay-pane path.leaflet-clickable")
83
+ end
84
+
85
+ it "should zoom to the correct map bounds" do
86
+ # if initial zoom >= maxzoom, zoom-in control will be disabled
87
+ expect(page).to have_selector(".leaflet-control-zoom-in.leaflet-disabled")
88
+ end
89
+
90
+ end
91
+
92
+ end
@@ -2759,3 +2759,103 @@
2759
2759
  coordinates:
2760
2760
  - 113.835078 22.1533884 114.4069561 22.561968
2761
2761
  - 114.109497 22.396428
2762
+ - subject_addl_t:
2763
+ - 1990-
2764
+ - 2005-2015
2765
+ - Economic conditions 1997-
2766
+ - Politics and government 1997-
2767
+ title_display: Test item with bounding box only
2768
+ subject_era_facet:
2769
+ - 1990-
2770
+ - 2005-2015
2771
+ - 1997-
2772
+ id: '2009373514'
2773
+ isbn_t:
2774
+ - '9789573908678'
2775
+ - '9573908670'
2776
+ subject_geo_facet:
2777
+ - Economic history
2778
+ - World politics
2779
+ - Hong Kong (China)
2780
+ lc_alpha_facet:
2781
+ - HC
2782
+ title_series_t:
2783
+ - Lin Xingzhi zuo pin ji ; 51
2784
+ author_t:
2785
+ - Lin, Xingzhi.
2786
+ lc_1letter_facet:
2787
+ - H - Social Sciences
2788
+ marc_display: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><collection xmlns=\"http://www.loc.gov/MARC21/slim\"><record><leader>01213nam
2789
+ a22003614a 4500</leader><controlfield tag=\"001\"> 2009373513</controlfield><controlfield
2790
+ tag=\"003\">DLC</controlfield><controlfield tag=\"005\">20090121153231.0</controlfield><controlfield
2791
+ tag=\"008\">090114s2008 ch 000 0 chi d</controlfield><datafield
2792
+ tag=\"010\" ind1=\" \" ind2=\" \"><subfield code=\"a\"> 2009373513</subfield></datafield><datafield
2793
+ tag=\"020\" ind1=\" \" ind2=\" \"><subfield code=\"a\">9789573908678</subfield></datafield><datafield
2794
+ tag=\"020\" ind1=\" \" ind2=\" \"><subfield code=\"a\">9573908670</subfield></datafield><datafield
2795
+ tag=\"035\" ind1=\" \" ind2=\" \"><subfield code=\"a\">(OCoLC)ocn268619391</subfield></datafield><datafield
2796
+ tag=\"040\" ind1=\" \" ind2=\" \"><subfield code=\"a\">HUA</subfield><subfield
2797
+ code=\"c\">HUA</subfield><subfield code=\"d\">HKP</subfield><subfield code=\"d\">DLC</subfield></datafield><datafield
2798
+ tag=\"042\" ind1=\" \" ind2=\" \"><subfield code=\"a\">lccopycat</subfield></datafield><datafield
2799
+ tag=\"043\" ind1=\" \" ind2=\" \"><subfield code=\"a\">a-cc-hk</subfield></datafield><datafield
2800
+ tag=\"050\" ind1=\"0\" ind2=\"0\"><subfield code=\"a\">HC59.15</subfield><subfield
2801
+ code=\"b\">.L533 2008</subfield></datafield><datafield tag=\"066\" ind1=\" \"
2802
+ ind2=\" \"><subfield code=\"c\">$1</subfield></datafield><datafield tag=\"100\"
2803
+ ind1=\"1\" ind2=\" \"><subfield code=\"6\">880-01</subfield><subfield code=\"a\">Lin,
2804
+ Xingzhi.</subfield></datafield><datafield tag=\"245\" ind1=\"1\" ind2=\"0\"><subfield
2805
+ code=\"6\">880-02</subfield><subfield code=\"a\">Ci an zhou bian /</subfield><subfield
2806
+ code=\"c\">Lin Xingzhi zhu.</subfield></datafield><datafield tag=\"250\" ind1=\"
2807
+ \" ind2=\" \"><subfield code=\"6\">880-03</subfield><subfield code=\"a\">Chu ban.</subfield></datafield><datafield
2808
+ tag=\"260\" ind1=\" \" ind2=\" \"><subfield code=\"6\">880-04</subfield><subfield
2809
+ code=\"a\">Taibei Xian Banqiao Shi :</subfield><subfield code=\"b\">Yuan jing
2810
+ chu ban shi ye you xian gong si,</subfield><subfield code=\"c\">2008.</subfield></datafield><datafield
2811
+ tag=\"300\" ind1=\" \" ind2=\" \"><subfield code=\"a\">5, 300 p. ;</subfield><subfield
2812
+ code=\"c\">21 cm.</subfield></datafield><datafield tag=\"490\" ind1=\"0\" ind2=\"
2813
+ \"><subfield code=\"6\">880-05</subfield><subfield code=\"a\">Lin Xingzhi zuo
2814
+ pin ji ;</subfield><subfield code=\"v\">51</subfield></datafield><datafield tag=\"651\"
2815
+ ind1=\" \" ind2=\"0\"><subfield code=\"a\">Economic history</subfield><subfield
2816
+ code=\"y\">1990-</subfield></datafield><datafield tag=\"651\" ind1=\" \" ind2=\"0\"><subfield
2817
+ code=\"a\">World politics</subfield><subfield code=\"y\">2005-2015.</subfield></datafield><datafield
2818
+ tag=\"651\" ind1=\" \" ind2=\"0\"><subfield code=\"a\">Hong Kong (China)</subfield><subfield
2819
+ code=\"x\">Economic conditions</subfield><subfield code=\"y\">1997-</subfield></datafield><datafield
2820
+ tag=\"651\" ind1=\" \" ind2=\"0\"><subfield code=\"a\">Hong Kong (China)</subfield><subfield
2821
+ code=\"x\">Politics and government</subfield><subfield code=\"y\">1997-</subfield></datafield><datafield
2822
+ tag=\"880\" ind1=\"1\" ind2=\" \"><subfield code=\"6\">100-01/$1</subfield><subfield
2823
+ code=\"a\">林行止.</subfield></datafield><datafield tag=\"880\" ind1=\"1\" ind2=\"0\"><subfield
2824
+ code=\"6\">245-02/$1</subfield><subfield code=\"a\">次按驟變 /</subfield><subfield
2825
+ code=\"c\">林行止著.</subfield></datafield><datafield tag=\"880\" ind1=\" \" ind2=\"
2826
+ \"><subfield code=\"6\">250-03/$1</subfield><subfield code=\"a\">初版.</subfield></datafield><datafield
2827
+ tag=\"880\" ind1=\" \" ind2=\" \"><subfield code=\"6\">260-04/$1</subfield><subfield
2828
+ code=\"a\">臺北縣板橋市 :</subfield><subfield code=\"b\">遠景出版事業有限公司,</subfield><subfield
2829
+ code=\"c\">2008.</subfield></datafield><datafield tag=\"880\" ind1=\"0\" ind2=\"
2830
+ \"><subfield code=\"6\">490-05/$1</subfield><subfield code=\"a\">林行止作品集 ;</subfield><subfield
2831
+ code=\"v\">51</subfield></datafield></record></collection>"
2832
+ published_display:
2833
+ - Taibei Xian Banqiao Shi
2834
+ author_display: Lin, Xingzhi
2835
+ lc_callnum_display:
2836
+ - HC59.15 .L533 2008
2837
+ title_t:
2838
+ - Test item with bounding box only /
2839
+ pub_date:
2840
+ - '2008'
2841
+ pub_date_sort: 2008
2842
+ format: Book
2843
+ lc_b4cutter_facet:
2844
+ - HC59.15
2845
+ material_type_display:
2846
+ - 5, 300 p.
2847
+ subject_t:
2848
+ - Economic history
2849
+ - World politics
2850
+ - Hong Kong (China)
2851
+ title_sort: test item with bounding box only
2852
+ author_sort: Lin Xingzhi Ci an zhou bian
2853
+ title_addl_t:
2854
+ - Ci an zhou bian /
2855
+ language_facet:
2856
+ - Chinese
2857
+ timestamp: '2014-02-03T18:42:53.056Z'
2858
+ geojson:
2859
+ - "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[115.1, 20.1], [118.1, 20.1], [118.1, 21.1], [115.1, 21.1], [115.1, 20.1]]]},\"bbox\":[115.1, 20.1, 118.1, 21.1]}"
2860
+ coordinates:
2861
+ - 115.1 20.1 118.1 21.1
@@ -4,10 +4,11 @@ require 'spec_helper'
4
4
  describe BlacklightMapsHelper do
5
5
 
6
6
  let(:blacklight_config) { Blacklight::Configuration.new }
7
+ let(:search_state) { Blacklight::SearchState.new({}, blacklight_config) }
7
8
 
8
9
  def create_response
9
10
  raw_response = eval(mock_query_response)
10
- Blacklight::SolrResponse.new(raw_response, raw_response['params'])
11
+ Blacklight::Solr::Response.new(raw_response, raw_response['params'])
11
12
  end
12
13
 
13
14
  let(:r) { create_response }
@@ -20,6 +21,8 @@ describe BlacklightMapsHelper do
20
21
  CatalogController.blacklight_config = Blacklight::Configuration.new
21
22
  @request = ActionDispatch::TestRequest.new
22
23
  @catalog = CatalogController.new
24
+ allow(helper).to receive_messages(blacklight_configuration_context: Blacklight::Configuration::Context.new(@catalog))
25
+ allow(helper).to receive(:search_state).and_return(search_state)
23
26
  @catalog.request = @request
24
27
  @catalog.action_name = "index"
25
28
  helper.instance_variable_set(:@_controller, @catalog)
@@ -120,9 +123,9 @@ describe BlacklightMapsHelper do
120
123
  @response = r
121
124
  end
122
125
 
123
- it "should return an array of Blacklight::SolrResponse::Facets::FacetItem items" do
126
+ it "should return an array of Blacklight::Solr::Response::Facets::FacetItem items" do
124
127
  expect(helper.map_facet_values.class).to eq(Array)
125
- expect(helper.map_facet_values.first.class).to eq(Blacklight::SolrResponse::Facets::FacetItem)
128
+ expect(helper.map_facet_values.first.class).to eq(Blacklight::Solr::Response::Facets::FacetItem)
126
129
  expect(helper.map_facet_values.length).to eq(5)
127
130
  end
128
131
 
@@ -136,14 +139,14 @@ describe BlacklightMapsHelper do
136
139
 
137
140
  end
138
141
 
139
- describe "render_index_map" do
142
+ describe "render_index_mapview" do
140
143
 
141
144
  before do
142
145
  @response = r
143
146
  end
144
147
 
145
- it "should render the 'catalog/index_map' partial" do
146
- expect(helper.render_index_map).to include("$('#blacklight-index-map').blacklight_leaflet_map")
148
+ it "should render the 'catalog/index_mapview' partial" do
149
+ expect(helper.render_index_mapview).to include("$('#blacklight-index-map').blacklight_leaflet_map")
147
150
  end
148
151
 
149
152
  end
@@ -1,55 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BlacklightMaps::MapsSearchBuilder do
3
+ describe BlacklightMaps::MapsSearchBuilderBehavior do
4
4
 
5
- class MapsSearchBuilderTestClass
6
- cattr_accessor :blacklight_config, :blacklight_params
5
+ let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
6
+ let(:user_params) { Hash.new }
7
+ let(:context) { CatalogController.new }
7
8
 
8
- include Blacklight::SearchHelper
9
- include BlacklightMaps::MapsSearchBuilder
9
+ before { allow(context).to receive(:blacklight_config).and_return(blacklight_config) }
10
10
 
11
- def initialize blacklight_config, blacklight_params
12
- self.blacklight_config = blacklight_config
13
- self.blacklight_params = blacklight_params
11
+ let(:search_builder_class) do
12
+ Class.new(Blacklight::SearchBuilder) do
13
+ include Blacklight::Solr::SearchBuilderBehavior
14
+ include BlacklightMaps::MapsSearchBuilderBehavior
14
15
  end
15
-
16
16
  end
17
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
18
+ let(:search_builder) { search_builder_class.new(context) }
23
19
 
24
- before { @obj = MapsSearchBuilderTestClass.new blacklight_config, blacklight_params }
20
+ describe 'add_spatial_search_to_solr' do
25
21
 
26
- describe "coordinate search" do
22
+ describe 'coordinate search' do
27
23
 
28
- before do
29
- @obj.blacklight_params[:coordinates] = "35.86166,104.195397"
30
- @obj.blacklight_params[:spatial_search_type] = "point"
31
- end
24
+ subject { search_builder.with({coordinates: '35.86166,104.195397', spatial_search_type: 'point'}) }
32
25
 
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])
26
+ it 'should return a coordinate point spatial search if coordinates are given' do
27
+ expect(subject[:fq].first).to include('geofilt')
28
+ expect(subject[:pt]).to eq('35.86166,104.195397')
36
29
  end
37
30
 
38
31
  end
39
32
 
40
- describe "bbox search" do
33
+ describe 'bbox search' do
41
34
 
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
35
+ subject { search_builder.with({coordinates: '[6.7535159,68.162386 TO 35.5044752,97.395555]',
36
+ spatial_search_type: 'bbox'}) }
46
37
 
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)
38
+ it 'should return a bbox spatial search if a bbox is given' do
39
+ expect(subject[:fq].first).to include(blacklight_config.view.maps.coordinates_field)
49
40
  end
50
41
 
51
42
  end
52
43
 
53
44
  end
54
45
 
55
- end
46
+ end
@@ -1,6 +1,7 @@
1
1
  require 'rails/generators'
2
2
 
3
3
  class TestAppGenerator < Rails::Generators::Base
4
+ source_root "../../spec/test_app_templates"
4
5
 
5
6
  def remove_index
6
7
  remove_file "public/index.html"
@@ -20,4 +21,12 @@ class TestAppGenerator < Rails::Generators::Base
20
21
  generate 'blacklight_maps:install'
21
22
  end
22
23
 
24
+ def configure_test_assets
25
+ insert_into_file 'config/environments/test.rb', :after => 'Rails.application.configure do' do
26
+ %q{
27
+ config.assets.digest = false
28
+ }
29
+ end
30
+ end
31
+
23
32
  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.4.0
4
+ version: 0.5.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-08-13 00:00:00.000000000 Z
12
+ date: 2016-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 5.12.0
34
+ version: 6.1.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.12.0
41
+ version: 6.1.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bootstrap-sass
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -197,12 +197,12 @@ files:
197
197
  - Rakefile
198
198
  - app/assets/javascripts/blacklight-maps.js
199
199
  - app/assets/javascripts/blacklight-maps/blacklight-maps-browse.js
200
- - app/assets/stylesheets/blacklight_maps/blacklight-maps.css.scss
201
- - app/assets/stylesheets/blacklight_maps/default.css.scss
200
+ - app/assets/stylesheets/blacklight_maps/blacklight-maps.scss
201
+ - app/assets/stylesheets/blacklight_maps/default.scss
202
202
  - app/helpers/blacklight/blacklight_maps_helper_behavior.rb
203
203
  - app/helpers/blacklight_maps_helper.rb
204
204
  - app/views/catalog/_document_maps.html.erb
205
- - app/views/catalog/_index_map.html.erb
205
+ - app/views/catalog/_index_mapview.html.erb
206
206
  - app/views/catalog/_map_placename_search.html.erb
207
207
  - app/views/catalog/_map_spatial_search.html.erb
208
208
  - app/views/catalog/_show_maplet_default.html.erb
@@ -225,12 +225,15 @@ files:
225
225
  - lib/blacklight/maps/version.rb
226
226
  - lib/generators/blacklight_maps/install_generator.rb
227
227
  - lib/generators/blacklight_maps/templates/blacklight_maps.css.scss
228
+ - lib/generators/blacklight_maps/templates/saved_searches_controller.rb
229
+ - lib/generators/blacklight_maps/templates/search_history_controller.rb
228
230
  - lib/railties/blacklight_maps.rake
229
231
  - solr_conf/conf/schema.xml
230
232
  - solr_conf/conf/solrconfig.xml
231
233
  - spec/controllers/catalog_controller_spec.rb
232
234
  - spec/features/initial_view_spec.rb
233
235
  - spec/features/maps_spec.rb
236
+ - spec/features/show_view_maplet_spec.rb
234
237
  - spec/fixtures/sample_solr_documents.yml
235
238
  - spec/helpers/blacklight_maps_helper_spec.rb
236
239
  - spec/lib/blacklight/maps/export_spec.rb
@@ -260,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
263
  version: '0'
261
264
  requirements: []
262
265
  rubyforge_project:
263
- rubygems_version: 2.2.2
266
+ rubygems_version: 2.4.6
264
267
  signing_key:
265
268
  specification_version: 4
266
269
  summary: Maps for Blacklight
@@ -268,6 +271,7 @@ test_files:
268
271
  - spec/controllers/catalog_controller_spec.rb
269
272
  - spec/features/initial_view_spec.rb
270
273
  - spec/features/maps_spec.rb
274
+ - spec/features/show_view_maplet_spec.rb
271
275
  - spec/fixtures/sample_solr_documents.yml
272
276
  - spec/helpers/blacklight_maps_helper_spec.rb
273
277
  - spec/lib/blacklight/maps/export_spec.rb