blacklight-maps 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6bffe02f056bdbd0cddc8b63f3f30b1ff7d08d9
4
- data.tar.gz: 99876fe750aebda63112736254ea34d893f4c294
3
+ metadata.gz: c9a4c9d51a9b188233f983469e290609fead6e4f
4
+ data.tar.gz: 3d61ff5d65da2592b37515f3c62b773425f2fac0
5
5
  SHA512:
6
- metadata.gz: e37de7d922821ede6726b35bd1b2139fc72ca804000940c8411f40b1ec8320d95de79e1bc41315ecb50f10b70020da6ee02fca4b73096022734567777602be95
7
- data.tar.gz: e7ffbbb907a95830329d2cbbc004bb0320c6a842e1adf5d9da9a2646fc4cae0d3ea36dfc5c349671e87d4416fe67a1f9399b1f3db1688033f0b4550e8caded55
6
+ metadata.gz: 2ba42a84d843b12148894593e41a705f0ac85d7dd5abc84eeb906ea4f9d28468a4d5d6b717a2be00d08662f0d1e476723969fb1451c9c08edfa2744cc90a00c7
7
+ data.tar.gz: 44d3a6067b0cc5465089318211b47fa2e00fdb9a241a8d87b309dab01afe8595baf0f58ec6a33086981ded5da4b24189c5cd525785589a9c85d9be1797849c78
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -1,6 +1,5 @@
1
1
  notifications:
2
2
  email: false
3
- cache: bundler
4
3
  language: ruby
5
4
  sudo: false
6
5
  rvm:
@@ -23,3 +22,4 @@ env:
23
22
  matrix:
24
23
  allow_failures:
25
24
  - rvm: jruby-19mode
25
+ - rvm: 1.9.3
@@ -0,0 +1,14 @@
1
+ # Contributing to Blacklight-Maps
2
+
3
+ ## To submit a patch or feature
4
+
5
+ 1. Fork it ( http://github.com/<my-github-username>/blacklight-maps/fork )
6
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
7
+ 3. Make some changes (with [tests](https://github.com/projectblacklight/blacklight/wiki/testing), please)
8
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
9
+ 5. Push to the branch (`git push origin my-new-feature`)
10
+ 6. Create new Pull Request
11
+
12
+ ## Style preferences
13
+
14
+ From version 0.3.2 forward, Blacklight-Maps will be using the [AirBnb JavaScript Style guide](https://github.com/airbnb/javascript) for JavaScript. Ruby code uses the community [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide).
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Blacklight::Maps
2
2
 
3
- [![Build Status](https://travis-ci.org/sul-dlss/blacklight-maps.png?branch=master)](https://travis-ci.org/sul-dlss/blacklight-maps)
3
+ [![Build Status](https://travis-ci.org/projectblacklight/blacklight-maps.png?branch=master)](https://travis-ci.org/sul-dlss/blacklight-maps) | [![Coverage Status](https://coveralls.io/repos/projectblacklight/blacklight-maps/badge.svg?branch=master)](https://coveralls.io/r/projectblacklight/blacklight-maps?branch=master)
4
4
 
5
5
  Provides map views for Blacklight for items with geospatial coordinate (latitude/longitude) metadata.
6
6
 
@@ -110,6 +110,11 @@ Blacklight-Maps expects you to provide these configuration options:
110
110
  + `placename_field` = the name of the Solr field containing the location names
111
111
  + `coordinates_field` = the name of the Solr `location_rpt` type field containing geospatial coordinate data
112
112
 
113
+ In addition, you must add the geospatial facet field to the list of facet fields:
114
+ ```ruby
115
+ config.add_facet_field 'geojson_field', :limit => -2, :label => 'Coordinates', :show => false
116
+ ```
117
+
113
118
  #### Optional
114
119
 
115
120
  - `show_initial_zoom` = the zoom level to be used in the catalog#show view map (zoom levels for catalog#map and catalog#index map views are computed automatically)
@@ -137,6 +142,8 @@ All of these options can easily be configured in `CatalogController.rb` in the `
137
142
  config.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>'
138
143
  config.view.maps.maxzoom = 18
139
144
  config.view.maps.show_initial_zoom = 5
145
+
146
+ config.add_facet_field 'geojson', :limit => -2, :label => 'Coordinates', :show => false
140
147
  ...
141
148
 
142
149
  ```
@@ -167,24 +174,22 @@ However, the catalog#show maplet widget must be included manually, via one of tw
167
174
 
168
175
  The ```blacklight_map_tag``` helper takes an options hash as one of its arguments that can be used to provide customization options for the Leaflet map functionality via data attributes. (See ```app/views/catalog/index_map``` for an example.) The available options include:
169
176
 
170
- - ```viewpoint``` = the center point of the map (```[lat,long]```)
171
- - ```searchcontrol``` = whether to display the search control on the map (```boolean```)
172
- - ```catalogpath``` = the search path for the search control (e.g. ```catalog_index_path```)
173
- - ```placenamefield``` = the name of the Solr field containing the location names (e.g. ```"placename_field"```)
174
- - ```searchctrlcue``` = the hover text to display when the mouse hovers over the search control
175
- - ```singlemarkermode``` = whether locations should be clustered (```boolean```)
176
- - ```clustercount``` = whether clusters should display the location count or the number of hits (```"hits" || "locations"```)
177
- - ```maxzoom``` = the maxZoom [property of the map](http://leafletjs.com/reference.html#map-maxzoom)
178
- - ```tileurl``` = a [tileLayer url](http://leafletjs.com/reference.html#tilelayer-l.tilelayer) to change the basemap
179
- - ```mapattribution``` = an [attribution string](http://leafletjs.com/reference.html#tilelayer-attribution) to describe the basemap layer
180
- - ```nodata``` = 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.
177
+ Option | Type | Default | Description
178
+ ------ | ---- | ------- | -----------
179
+ `initialview` | Array | `null` | the initial extend of the map as a 2d Array (e.g. `[[minLat, minLng], [maxLat, maxLng]]`)
180
+ `searchcontrol` | Boolean | `false` | display the search control on the map
181
+ `catalogpath` | String | `'catalog'` | the search path for the search control
182
+ `placenamefield` | String | `'placename_field'` | the name of the Solr field containing the location names
183
+ `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
185
+ `singlemarkermode` | Boolean | `true` | whether locations should be clustered
186
+ `clustercount` | String | `'locations'` | whether clusters should display the location count or the number of hits (`'hits'` or `'locations'`)
187
+ `maxzoom` | Integer | 18 | the maxZoom [property of the map](http://leafletjs.com/reference.html#map-maxzoom)
188
+ `tileurl` | String | `'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'` | a [tileLayer url](http://leafletjs.com/reference.html#tilelayer-l.tilelayer) to change the basemap
189
+ `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
+ `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.
181
191
 
182
192
 
183
193
  ## Contributing
184
194
 
185
- 1. Fork it ( http://github.com/<my-github-username>/blacklight-maps/fork )
186
- 2. Create your feature branch (`git checkout -b my-new-feature`)
187
- 3. Make some changes (with [tests](https://github.com/projectblacklight/blacklight/wiki/testing), please)
188
- 4. Commit your changes (`git commit -am 'Add some feature'`)
189
- 5. Push to the branch (`git push origin my-new-feature`)
190
- 6. Create new Pull Request
195
+ We encourage you to contribute to Blacklight-Maps. Please see the [contributing guide](/CONTRIBUTING.md) for more information on contributing to the project.
@@ -7,15 +7,15 @@
7
7
  var options = $.extend({
8
8
  tileurl : 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
9
9
  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>',
10
- viewpoint: [0,0],
11
- initialzoom: 2,
10
+ initialZoom: 2,
12
11
  singlemarkermode: true,
13
12
  searchcontrol: false,
14
13
  catalogpath: 'catalog',
15
14
  searchctrlcue: 'Search for all items within the current map window',
16
15
  placenamefield: 'placename_field',
17
16
  nodata: 'Sorry, there is no data for this location.',
18
- clustercount:'locations'
17
+ clustercount:'locations',
18
+ searchresultsview: 'list'
19
19
  }, arg_opts );
20
20
 
21
21
  // Extend options from data-attributes
@@ -27,6 +27,8 @@
27
27
 
28
28
  var sortAndPerPage = $('#sortAndPerPage');
29
29
 
30
+ var markers;
31
+
30
32
  // Update page links with number of mapped items, disable sort, per_page, pagination
31
33
  if (sortAndPerPage.length) { // catalog#index and #map view
32
34
  var page_links = sortAndPerPage.find('.page_links');
@@ -64,18 +66,10 @@
64
66
  options.id = this.id;
65
67
 
66
68
  // Setup Leaflet map
67
- map = L.map(this.id);
68
-
69
- // set the viewpoint and zoom
70
- if (options.viewpoint[0].constructor === Array) {
71
- map.fitBounds(options.viewpoint,
72
- {
73
- padding:[10,10],
74
- maxZoom:options.maxzoom
75
- });
76
- } else {
77
- map.setView(options.viewpoint, options.initialzoom);
78
- }
69
+ map = L.map(this.id, {
70
+ center: [0, 0],
71
+ zoom: options.initialZoom
72
+ });
79
73
 
80
74
  L.tileLayer(options.tileurl, {
81
75
  attribution: options.mapattribution,
@@ -104,6 +98,9 @@
104
98
  // Add markers to map
105
99
  map.addLayer(markers);
106
100
 
101
+ // Fit bounds of map
102
+ setMapBounds(map);
103
+
107
104
  // create overlay for search control hover
108
105
  var searchHoverLayer = L.rectangle([[0,0], [0,0]], {
109
106
  color: "#0033ff",
@@ -148,6 +145,46 @@
148
145
 
149
146
  });
150
147
 
148
+ /**
149
+ * Sets the view of the map, based off of the map bounds
150
+ */
151
+ function setMapBounds() {
152
+ map.fitBounds(mapBounds(), {
153
+ padding: [10, 10],
154
+ maxZoom: options.maxzoom
155
+ });
156
+ }
157
+
158
+ /**
159
+ * Returns the bounds of the map based off of initialview being set or gets
160
+ * the bounds of the markers object
161
+ */
162
+ function mapBounds() {
163
+ if (options.initialview) {
164
+ return options.initialview;
165
+ } else {
166
+ return markerBounds();
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Returns the bounds of markers, if there are not any return
172
+ */
173
+ function markerBounds() {
174
+ if (hasAnyFeatures()) {
175
+ return markers.getBounds();
176
+ } else {
177
+ return [[90, 180], [-90, -180]];
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Checks to see if there are any features in the markers MarkerClusterGroup
183
+ */
184
+ function hasAnyFeatures() {
185
+ return !$.isEmptyObject(markers._featureGroup._layers);
186
+ }
187
+
151
188
  // remove stale params, add new params, and run a new search
152
189
  function _search() {
153
190
  var params = filterParams(['view', 'spatial_search_type', 'coordinates', 'f%5B' + options.placenamefield + '%5D%5B%5D']),
@@ -160,7 +197,7 @@
160
197
  return Math.round(parseFloat(coord) * 1000000) / 1000000;
161
198
  }),
162
199
  coordinate_params = '[' + bounds[1] + ',' + bounds[0] + ' TO ' + bounds[3] + ',' + bounds[2] + ']';
163
- params.push('coordinates=' + encodeURIComponent(coordinate_params), 'spatial_search_type=bbox');
200
+ params.push('coordinates=' + encodeURIComponent(coordinate_params), 'spatial_search_type=bbox', 'view=' + options.searchresultsview);
164
201
  $(location).attr('href', options.catalogpath + '?' + params.join('&'));
165
202
  }
166
203
 
@@ -27,7 +27,8 @@ module Blacklight::BlacklightMapsHelperBehavior
27
27
  coords_for_search = bbox_coordinates.map { |v| v.to_s }
28
28
  link_to(t('blacklight.maps.interactions.bbox_search'),
29
29
  catalog_index_path(spatial_search_type: "bbox",
30
- coordinates: "[#{coords_for_search[1]},#{coords_for_search[0]} TO #{coords_for_search[3]},#{coords_for_search[2]}]"))
30
+ coordinates: "[#{coords_for_search[1]},#{coords_for_search[0]} TO #{coords_for_search[3]},#{coords_for_search[2]}]",
31
+ view: default_document_index_view_type))
31
32
  end
32
33
 
33
34
  # create a link to a location name facet value
@@ -37,8 +38,9 @@ module Blacklight::BlacklightMapsHelperBehavior
37
38
  else
38
39
  new_params = add_facet_params(field, field_value)
39
40
  end
41
+ new_params[:view] = default_document_index_view_type
40
42
  link_to(displayvalue.presence || field_value,
41
- catalog_index_path(new_params.except(:view, :id, :spatial_search_type, :coordinates)))
43
+ catalog_index_path(new_params.except(:id, :spatial_search_type, :coordinates)))
42
44
  end
43
45
 
44
46
  # create a link to a spatial search for a set of point coordinates
@@ -46,6 +48,7 @@ module Blacklight::BlacklightMapsHelperBehavior
46
48
  new_params = params.except(:controller, :action, :view, :id, :spatial_search_type, :coordinates)
47
49
  new_params[:spatial_search_type] = "point"
48
50
  new_params[:coordinates] = "#{point_coordinates[1]},#{point_coordinates[0]}"
51
+ new_params[:view] = default_document_index_view_type
49
52
  link_to(t('blacklight.maps.interactions.point_search'), catalog_index_path(new_params))
50
53
  end
51
54
 
@@ -95,32 +98,4 @@ module Blacklight::BlacklightMapsHelperBehavior
95
98
  options)
96
99
  export.to_geojson
97
100
  end
98
-
99
- # determine the best viewpoint for the map so all markers are visible
100
- def set_viewpoint(geojson_features)
101
- viewpoint = nil
102
- geojson_docs = JSON.parse(geojson_features)["features"]
103
- if !geojson_docs.blank?
104
- if geojson_docs.length == 1
105
- viewpoint = geojson_docs[0]["bbox"] ? nil : geojson_docs[0]["geometry"]["coordinates"].reverse
106
- end
107
- if geojson_docs.length > 1 || !viewpoint
108
- longs, lats = [[],[]]
109
- geojson_docs.each do |feature|
110
- if feature["bbox"]
111
- feature["bbox"].values_at(0,2).each {|long| longs << long }
112
- feature["bbox"].values_at(1,3).each {|lat| lats << lat }
113
- else
114
- longs << feature["geometry"]["coordinates"][0]
115
- lats << feature["geometry"]["coordinates"][1]
116
- end
117
- end
118
- sorted_longs, sorted_lats = longs.sort, lats.sort
119
- viewpoint = [[sorted_lats.first,sorted_longs.first],[sorted_lats.last,sorted_longs.last]]
120
- end
121
- end
122
- viewpoint = [0,0] if !viewpoint
123
- viewpoint
124
- end
125
-
126
- end
101
+ end
@@ -1,8 +1,8 @@
1
1
  <%= blacklight_map_tag('blacklight-index-map',
2
- {data:{viewpoint: set_viewpoint(geojson_features),
3
- searchcontrol: true,
2
+ {data:{searchcontrol: true,
4
3
  catalogpath: catalog_index_path,
5
4
  placenamefield: blacklight_config.view.maps.placename_field,
6
- clustercount:'hits'
5
+ clustercount:'hits',
6
+ searchresultsview: default_document_index_view_type
7
7
  }}) %>
8
8
  <%= javascript_tag "$('#blacklight-index-map').blacklight_leaflet_map(#{geojson_features});" %>
@@ -3,8 +3,7 @@
3
3
  <% if @document[blacklight_config.view.maps.geojson_field.to_sym] || @document[blacklight_config.view.maps.coordinates_field.to_sym] %>
4
4
  <% geojson_features = serialize_geojson(@document) %>
5
5
  <%= blacklight_map_tag('blacklight-show-map',
6
- {data:{viewpoint: set_viewpoint(geojson_features),
7
- initialzoom:blacklight_config.view.maps.show_initial_zoom,
6
+ {data:{initialzoom:blacklight_config.view.maps.show_initial_zoom,
8
7
  singlemarkermode:false}}) %>
9
8
  <%= javascript_tag "$('#blacklight-show-map').blacklight_leaflet_map(#{geojson_features});" %>
10
9
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Maps
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
@@ -9,12 +9,12 @@ describe CatalogController do
9
9
  before { get :map }
10
10
 
11
11
  it "should respond to the #map action" do
12
- response.should be_success
13
- assigns(:document_list).should_not be_nil
12
+ expect(response).to be_success
13
+ expect(assigns(:document_list)).to_not be_nil
14
14
  end
15
15
 
16
16
  it "should render the '/map' page" do
17
- response.body.should have_selector("body.blacklight-catalog-map")
17
+ expect(response.body).to have_css 'body.blacklight-catalog-map'
18
18
  end
19
19
 
20
20
  end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Initial view parameter', js: true do
4
+ before :all do
5
+ CatalogController.configure_blacklight do |config|
6
+ config.view.maps.facet_mode = 'coordinates'
7
+ config.view.maps.coordinates_facet_field = 'coordinates_facet'
8
+ config.add_facet_field 'coordinates_facet', :limit => -2, :label => 'Coordinates', :show => false
9
+ end
10
+ end
11
+ scenario 'defaults to zoom area of markers' do
12
+ visit catalog_index_path f: { format: ['Book'] }, view: 'maps'
13
+ expect(page).to have_css '.leaflet-marker-icon.marker-cluster', count: 8
14
+ end
15
+ scenario 'when provided sets map to its view' do
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
+ 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'
19
+ expect(page).to_not have_css '.leaflet-marker-icon.marker-cluster'
20
+ end
21
+ end
@@ -91,8 +91,9 @@ describe "Map View", js: true do
91
91
  end
92
92
 
93
93
  describe "marker popups" do
94
-
95
- before { find(".marker-cluster:first-child").click }
94
+ before do
95
+ find('.marker-cluster', text: '1', match: :first).click
96
+ end
96
97
 
97
98
  it "should show a popup with correct content" do
98
99
  expect(page).to have_selector("div.leaflet-popup-content-wrapper")
@@ -107,6 +108,10 @@ describe "Map View", js: true do
107
108
  expect(page).to have_selector(".constraint-value .filterValue", text: "Seoul (Korea)")
108
109
  end
109
110
 
111
+ it "should use the default view type" do
112
+ expect(current_url).to include("view=list")
113
+ end
114
+
110
115
  end
111
116
 
112
117
  end
@@ -133,6 +138,7 @@ describe "Map View", js: true do
133
138
 
134
139
  it "should run a new search" do
135
140
  expect(page).to have_selector(".constraint.coordinates")
141
+ expect(current_url).to include("view=list")
136
142
  end
137
143
 
138
144
  end
@@ -182,6 +188,7 @@ describe "Map View", js: true do
182
188
 
183
189
  it "should run a new search" do
184
190
  expect(page).to have_selector(".constraint-value .filterValue", text: "35.86166,104.195397")
191
+ expect(current_url).to include("view=list")
185
192
  end
186
193
 
187
194
  end
@@ -11,19 +11,19 @@ describe BlacklightMapsHelper do
11
11
  end
12
12
 
13
13
  let(:r) { create_response }
14
+ let(:geojson_hash) { { type: 'Feature', geometry: { type: 'Point', coordinates: [91.117212, 29.646923] }, properties: { placename: 'Tibet' } } }
15
+ let(:coords) { [91.117212, 29.646923] }
16
+ let(:bbox) { [78.3955448, 26.8548157, 99.116241, 36.4833345] }
14
17
 
15
18
  before :each do
19
+ allow(helper).to receive_messages(blacklight_config: blacklight_config)
16
20
  CatalogController.blacklight_config = Blacklight::Configuration.new
17
- helper.stub(blacklight_config: blacklight_config)
18
21
  @request = ActionDispatch::TestRequest.new
19
22
  @catalog = CatalogController.new
20
23
  @catalog.request = @request
21
24
  @catalog.action_name = "index"
22
25
  helper.instance_variable_set(:@_controller, @catalog)
23
26
  @docs = r.facet_by_field_name(blacklight_config.view.maps.geojson_field).items
24
- @geojson_hash = {type:"Feature", geometry:{type:"Point",coordinates:[91.117212, 29.646923]},properties:{placename:"Tibet"}}
25
- @coords = [91.117212,29.646923]
26
- @bbox = [78.3955448,26.8548157,99.116241,36.4833345]
27
27
  end
28
28
 
29
29
  describe "blacklight_map_tag" do
@@ -59,20 +59,20 @@ describe BlacklightMapsHelper do
59
59
  describe "placename_value" do
60
60
 
61
61
  it "should return the placename value" do
62
- expect(helper.placename_value(@geojson_hash)).to eq('Tibet')
62
+ expect(helper.placename_value(geojson_hash)).to eq('Tibet')
63
63
  end
64
64
 
65
65
  end
66
66
 
67
67
  describe "link_to_bbox_search" do
68
68
 
69
- before do
70
- @bbox = [78.3955448,26.8548157,99.116241,36.4833345]
69
+ it "should create a spatial search link" do
70
+ expect(helper.link_to_bbox_search(bbox)).to include('catalog?coordinates')
71
+ expect(helper.link_to_bbox_search(bbox)).to include('spatial_search_type=bbox')
71
72
  end
72
73
 
73
- it "should create a spatial search link" do
74
- expect(helper.link_to_bbox_search(@bbox)).to include('catalog?coordinates')
75
- expect(helper.link_to_bbox_search(@bbox)).to include('spatial_search_type=bbox')
74
+ it "should include the default_document_index_view_type in the params" do
75
+ expect(helper.link_to_bbox_search(bbox)).to include('view=list')
76
76
  end
77
77
 
78
78
  end
@@ -87,17 +87,21 @@ describe BlacklightMapsHelper do
87
87
  expect(helper.link_to_placename_field('Tibet', blacklight_config.view.maps.placename_field, 'foo')).to include('">foo</a>')
88
88
  end
89
89
 
90
+ it "should include the default_document_index_view_type in the params" do
91
+ expect(helper.link_to_placename_field('Tibet', blacklight_config.view.maps.placename_field)).to include('view=list')
92
+ end
93
+
90
94
  end
91
95
 
92
96
  describe "link_to_point_search" do
93
97
 
94
- before do
95
- @coords = [91.117212,29.646923]
98
+ it "should create a link to a coordinate point" do
99
+ expect(helper.link_to_point_search(coords)).to include('catalog?coordinates')
100
+ expect(helper.link_to_point_search(coords)).to include('spatial_search_type=point')
96
101
  end
97
102
 
98
- it "should create a link to a coordinate point" do
99
- expect(helper.link_to_point_search(@coords)).to include('catalog?coordinates')
100
- expect(helper.link_to_point_search(@coords)).to include('spatial_search_type=point')
103
+ it "should include the default_document_index_view_type in the params" do
104
+ expect(helper.link_to_point_search(coords)).to include('view=list')
101
105
  end
102
106
 
103
107
  end
@@ -127,7 +131,7 @@ describe BlacklightMapsHelper do
127
131
  describe "render_placename_heading" do
128
132
 
129
133
  it "should return the placename heading" do
130
- expect(helper.render_placename_heading(@geojson_hash)).to eq('Tibet')
134
+ expect(helper.render_placename_heading(geojson_hash)).to eq('Tibet')
131
135
  end
132
136
 
133
137
  end
@@ -147,36 +151,15 @@ describe BlacklightMapsHelper do
147
151
  describe "render_spatial_search_link" do
148
152
 
149
153
  it "should return link_to_bbox_search if bbox coordinates are passed" do
150
- expect(helper.render_spatial_search_link(@bbox)).to include('spatial_search_type=bbox')
154
+ expect(helper.render_spatial_search_link(bbox)).to include('spatial_search_type=bbox')
151
155
  end
152
156
 
153
157
  it "should return link_to_point_search if point coordinates are passed" do
154
- expect(helper.render_spatial_search_link(@coords)).to include('spatial_search_type=point')
155
- end
156
-
157
- end
158
-
159
- describe "set_viewpoint" do
160
-
161
- describe "map with a single point" do
162
-
163
- it "should return a coordinate array matching the point" do
164
- expect(helper.set_viewpoint(helper.serialize_geojson([@docs.first]))).to eq([29.646923, 91.117212])
165
- end
166
-
167
- end
168
-
169
- describe "map with multiple points" do
170
-
171
- it "should return an array of coordinates with the max lat-long of the range of points" do
172
- expect(helper.set_viewpoint(helper.serialize_geojson(@docs))).to eq([[20.593684, 78.96288], [35.86166, 104.195397]])
173
- end
174
-
158
+ expect(helper.render_spatial_search_link(coords)).to include('spatial_search_type=point')
175
159
  end
176
160
 
177
161
  end
178
162
 
179
-
180
163
  def mock_query_response
181
164
  %({"responseHeader"=>{"status"=>0, "QTime"=>14, "params"=>{"q"=>"tibet", "spellcheck.q"=>"tibet", "qt"=>"search", "wt"=>"ruby", "rows"=>"10"}}, "response"=>{"numFound"=>2, "start"=>0, "maxScore"=>0.016135123, "docs"=>[{"published_display"=>["Dharamsala, H.P."], "author_display"=>"Thub-bstan-yar-ʼphel, Rnam-grwa", "lc_callnum_display"=>["DS785 .T475 2005"], "pub_date"=>["2005"], "format"=>"Book", "material_type_display"=>["a-e, iv, ii, 407 p."], "title_display"=>"Bod gaá¹…s can gyi rgyal rabs mdor bsdus dris lan brgya pa rab gsal Å›el gyi me loá¹… źes bya ba bźugs so", "id"=>"2008308202", "subject_geo_facet"=>["Tibet"], "language_facet"=>["Tibetan"], "geojson"=>["{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Point\\",\\"coordinates\\":[91.117212, 29.646923]},\\"properties\\":{\\"placename\\":\\"Tibet\\"}}", "{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Polygon\\",\\"coordinates\\":[[[78.3955448, 26.8548157], [99.116241, 26.8548157], [99.116241, 36.4833345], [78.3955448, 36.4833345], [78.3955448, 26.8548157]]]},\\"bbox\\":[78.3955448,26.8548157,99.116241,36.4833345]}"], "coordinates"=>["91.117212 29.646923", "78.3955448 26.8548157 99.116241 36.4833345"], "score"=>0.016135123}, {"published_display"=>["Dharamsala, Distt. Kangra, H.P."], "pub_date"=>["2007"], "format"=>"Book", "title_display"=>"Ses yon", "material_type_display"=>["xii, 419 p."], "id"=>"2008308478", "subject_geo_facet"=>["China", "Tibet", "India"], "subject_topic_facet"=>["Education and state", "Tibetans", "Tibetan language", "Teaching"], "language_facet"=>["Tibetan"], "geojson"=>["{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Point\\",\\"coordinates\\":[104.195397,35.86166]},\\"properties\\":{\\"placename\\":\\"China\\"}}", "{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Point\\",\\"coordinates\\":[91.117212,29.646923]},\\"properties\\":{\\"placename\\":\\"Tibet\\"}}", "{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Point\\",\\"coordinates\\":[78.96288,20.593684]},\\"properties\\":{\\"placename\\":\\"India\\"}}","{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Polygon\\",\\"coordinates\\":[[[68.162386, 6.7535159], [97.395555, 6.7535159], [97.395555, 35.5044752], [68.162386, 35.5044752], [68.162386, 6.7535159]]]},\\"bbox\\":[68.162386,6.7535159,97.395555,35.5044752]}"], "coordinates"=>["68.162386 6.7535159 97.395555 35.5044752", "104.195397 35.86166", "91.117212 29.646923", "78.96288 20.593684"], "score"=>0.0026767207}]}, "facet_counts"=>{"facet_queries"=>{}, "facet_fields"=>{"format"=>["Book", 2], "lc_1letter_facet"=>["D - World History", 1], "lc_alpha_facet"=>["DS", 1], "lc_b4cutter_facet"=>["DS785", 1], "language_facet"=>["Tibetan", 2], "pub_date"=>["2005", 1, "2007", 1], "subject_era_facet"=>[], "subject_geo_facet"=>["China", 1, "India", 1, "Tibet", 1, "Tibet (China)", 1], "coordinates"=>["91.117212 29.646923", 2, "78.3955448 26.8548157 99.116241 36.4833345", 1, "68.162386 6.7535159 97.395555 35.5044752", 1, "104.195397 35.86166", 1, "78.96288 20.593684", 1], "geojson"=>["{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Point\\",\\"coordinates\\":[91.117212, 29.646923]},\\"properties\\":{\\"placename\\":\\"Tibet\\"}}", 2, "{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Polygon\\",\\"coordinates\\":[[[78.3955448, 26.8548157], [99.116241, 26.8548157], [99.116241, 36.4833345], [78.3955448, 36.4833345], [78.3955448, 26.8548157]]]},\\"bbox\\":[78.3955448,26.8548157,99.116241,36.4833345]}", 1, "{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Point\\",\\"coordinates\\":[104.195397,35.86166]},\\"properties\\":{\\"placename\\":\\"China\\"}}", 1, "{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Point\\",\\"coordinates\\":[78.96288,20.593684]},\\"properties\\":{\\"placename\\":\\"India\\"}}", 1, "{\\"type\\":\\"Feature\\",\\"geometry\\":{\\"type\\":\\"Polygon\\",\\"coordinates\\":[[[68.162386, 6.7535159], [97.395555, 6.7535159], [97.395555, 35.5044752], [68.162386, 35.5044752], [68.162386, 6.7535159]]]},\\"bbox\\":[68.162386,6.7535159,97.395555,35.5044752]}", 1], "subject_topic_facet"=>["Education and state", 1, "Teaching", 1, "Tibetan language", 1, "Tibetans", 1]}, "facet_dates"=>{}, "facet_ranges"=>{}}, "spellcheck"=>{"suggestions"=>["tibet", {"numFound"=>1, "startOffset"=>0, "endOffset"=>5, "origFreq"=>2, "suggestion"=>[{"word"=>"tibetan", "freq"=>6}]}, "correctlySpelled", true]}})
182
165
  end
@@ -9,7 +9,7 @@ describe "BlacklightMaps::GeojsonExport" do
9
9
  @request = ActionDispatch::TestRequest.new
10
10
  @controller.request = @request
11
11
  @response = ActionDispatch::TestResponse.new
12
- @response.stub(:docs) {[{ "published_display"=>["Dharamsala, Distt. Kangra, H.P."], "pub_date"=>["2007"], "format"=>"Book", "title_display"=>"Ses yon", "material_type_display"=>["xii, 419 p."], "id"=>"2008308478", "placename_field"=>["China", "Tibet", "India"], "subject_topic_facet"=>["Education and state", "Tibetans", "Tibetan language", "Teaching"], "language_facet"=>["Tibetan"], "geojson"=>["{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[104.195397,35.86166]},\"properties\":{\"placename\":\"China\"}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[91.117212,29.646923]},\"properties\":{\"placename\":\"Tibet\"}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[78.96288,20.593684]},\"properties\":{\"placename\":\"India\"}}"], "coordinates"=>["68.162386 6.7535159 97.395555 35.5044752", "104.195397 35.86166", "91.117212 29.646923", "20.593684,78.96288"], "score"=>0.0026767207 }]}
12
+ expect(@response).to receive(:docs).and_return([{ "published_display"=>["Dharamsala, Distt. Kangra, H.P."], "pub_date"=>["2007"], "format"=>"Book", "title_display"=>"Ses yon", "material_type_display"=>["xii, 419 p."], "id"=>"2008308478", "placename_field"=>["China", "Tibet", "India"], "subject_topic_facet"=>["Education and state", "Tibetans", "Tibetan language", "Teaching"], "language_facet"=>["Tibetan"], "geojson"=>["{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[104.195397,35.86166]},\"properties\":{\"placename\":\"China\"}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[91.117212,29.646923]},\"properties\":{\"placename\":\"Tibet\"}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[78.96288,20.593684]},\"properties\":{\"placename\":\"India\"}}"], "coordinates"=>["68.162386 6.7535159 97.395555 35.5044752", "104.195397 35.86166", "91.117212 29.646923", "20.593684,78.96288"], "score"=>0.0026767207 }])
13
13
  end
14
14
 
15
15
  # TODO: use @response.facet_by_field_name('geojson').items instead of @response
@@ -1,6 +1,8 @@
1
1
  ENV["RAILS_ENV"] ||= 'test'
2
2
 
3
3
  require 'engine_cart'
4
+ require 'coveralls'
5
+ Coveralls.wear!('rails')
4
6
  EngineCart.load_application!
5
7
 
6
8
  require 'capybara/poltergeist'
@@ -16,7 +18,6 @@ end
16
18
 
17
19
  if ENV["COVERAGE"] or ENV["CI"]
18
20
  require 'simplecov'
19
- require 'coveralls'
20
21
 
21
22
  SimpleCov.formatter = Coveralls::SimpleCov::Formatter
22
23
  SimpleCov.start do
@@ -24,12 +25,9 @@ if ENV["COVERAGE"] or ENV["CI"]
24
25
  end
25
26
  end
26
27
 
27
-
28
- require 'blacklight'
29
28
  require 'blacklight/maps'
30
29
 
31
30
  require 'rspec/rails'
32
- require 'rspec/autorun'
33
31
  require 'capybara/rspec'
34
32
 
35
33
 
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.2
4
+ version: 0.3.3
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-04-08 00:00:00.000000000 Z
12
+ date: 2015-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -187,8 +187,10 @@ executables: []
187
187
  extensions: []
188
188
  extra_rdoc_files: []
189
189
  files:
190
+ - ".coveralls.yml"
190
191
  - ".gitignore"
191
192
  - ".travis.yml"
193
+ - CONTRIBUTING.md
192
194
  - Gemfile
193
195
  - LICENSE.txt
194
196
  - README.md
@@ -226,6 +228,7 @@ files:
226
228
  - solr_conf/conf/schema.xml
227
229
  - solr_conf/conf/solrconfig.xml
228
230
  - spec/controllers/catalog_controller_spec.rb
231
+ - spec/features/initial_view_spec.rb
229
232
  - spec/features/maps_spec.rb
230
233
  - spec/fixtures/sample_solr_documents.yml
231
234
  - spec/helpers/blacklight_maps_helper_spec.rb
@@ -262,6 +265,7 @@ specification_version: 4
262
265
  summary: Maps for Blacklight
263
266
  test_files:
264
267
  - spec/controllers/catalog_controller_spec.rb
268
+ - spec/features/initial_view_spec.rb
265
269
  - spec/features/maps_spec.rb
266
270
  - spec/fixtures/sample_solr_documents.yml
267
271
  - spec/helpers/blacklight_maps_helper_spec.rb