geoblacklight 0.0.8 → 0.1.0

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: 988a3047b866166e07486f36a5ee3137d1ee8063
4
- data.tar.gz: 81983cd641d63130d8c6aa22d65ac9ef4579724b
3
+ metadata.gz: 567c21f3752e5b7c91f8dcb100a2c0d93333b48b
4
+ data.tar.gz: a5cbdded6456236c0f516dafe9e76d34042ebc68
5
5
  SHA512:
6
- metadata.gz: 6332e409be975db18f3f3861551875207b6748f46bfe9e4f04996d1550f2183a7891acca52dbb8b0bb652ba94ccc526ef3f10f5393009b6ca862cbbff9596dc5
7
- data.tar.gz: d86a9a17886bf0fbe309625ea03bb70d747392261798336cf023dfc8ae698207f304dddaeeafa685ad405723db54df0364667eafeb56790fc60160acd99d09fe
6
+ metadata.gz: fa9384f5fdf9c6c19ae43789c79afb6bafb92ed2fe3425ef2694a81887f60d9e1ae833faa437c92f8052ec3065d728094884ab355da264fa74c1614809f2207d
7
+ data.tar.gz: bcc7b6e80ae7ee42d17ec94b5c448c488ea2c5b266f10568638b3639b0b1716e8fca9f78bd690b79c6e594ee8303cb0bc12963ff2b879f36967c8f62d239e7ce
@@ -32,13 +32,23 @@
32
32
  }
33
33
  },
34
34
 
35
- initialize: function(el) {
35
+ options: {
36
+ /**
37
+ * Initial bounds of map
38
+ * @type {L.LatLngBounds}
39
+ */
40
+ bbox: [[-85, -180], [85, 180]]
41
+ },
42
+
43
+ initialize: function(el, options) {
36
44
  var data = $(el).data(),
37
45
  basemap, map;
38
46
 
47
+ L.Util.setOptions(this, options);
48
+
39
49
  basemap = L.tileLayer(
40
50
  'https://otile{s}-s.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
41
- attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">',
51
+ attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="//developer.mapquest.com/content/osm/mq_logo.png">',
42
52
  maxZoom: 18,
43
53
  worldCopyJump: true,
44
54
  subdomains: '1234' // see http://developer.mapquest.com/web/products/open/map
@@ -52,11 +62,8 @@
52
62
  map.addLayer(basemap);
53
63
  map.addLayer(this.overlay);
54
64
 
55
- if (typeof data['mapBbox'] === "string") {
56
- map.fitBounds(L.bboxToBounds(data.mapBbox));
57
- } else {
58
- map.setView([0,0], 2);
59
- }
65
+ map.fitBounds(this.options.bbox);
66
+
60
67
  },
61
68
 
62
69
  /**
@@ -1,13 +1,14 @@
1
1
  Blacklight.onLoad(function() {
2
2
  $('[data-map="item"]').each(function(i, element) {
3
- var layerMap = new GeoBlacklight.Item(element);
3
+ var bbox = L.bboxToBounds($(this).data().mapBbox);
4
+ new GeoBlacklight.Item(element, { bbox: bbox });
4
5
  });
5
6
  });
6
7
 
7
8
  GeoBlacklight.Item = GeoBlacklight.extend({
8
9
 
9
- initialize: function(element) {
10
- GeoBlacklight.prototype.initialize.call(this, element);
10
+ initialize: function(element, options) {
11
+ GeoBlacklight.prototype.initialize.call(this, element, options);
11
12
  this.dataAttributes = $(element).data();
12
13
  this.layer = new L.layerGroup().addTo(this.map);
13
14
  if (this.dataAttributes.available) {
@@ -7,12 +7,24 @@ Blacklight.onLoad(function() {
7
7
 
8
8
  $('[data-map="index"]').each(function() {
9
9
  var data = $(this).data(),
10
- dynamicSearcher, geoblacklight, search;
10
+ dynamicSearcher, geoblacklight, search, bbox;
11
+
12
+ if (typeof data.mapBbox === "string") {
13
+ bbox = L.bboxToBounds(data.mapBbox);
14
+ } else {
15
+ $('.document [data-bbox]').each(function() {
16
+ if (typeof bbox === "undefined") {
17
+ bbox = L.bboxToBounds($(this).data().bbox);
18
+ } else {
19
+ bbox.extend(L.bboxToBounds($(this).data().bbox));
20
+ }
21
+ });
22
+ }
11
23
 
12
24
  dynamicSearcher = GeoBlacklight.debounce(function(querystring) {
13
25
  History.pushState(null, null, data.catalogPath + '?' + querystring);
14
26
  }, 800);
15
- geoblacklight = new GeoBlacklight(this).setHoverListeners();
27
+ geoblacklight = new GeoBlacklight(this, { bbox: bbox }).setHoverListeners();
16
28
  search = new L.Control.GeoSearch(dynamicSearcher);
17
29
  geoblacklight.map.addControl(search);
18
30
  });
@@ -6,17 +6,16 @@
6
6
  text-align: center;
7
7
  }
8
8
 
9
- .home-facet-label {
10
- background: $gray-light;
11
- border-radius: .25em;
12
- color: #fff;
13
- font-size: 1.4em;
14
- line-height: 2em;
15
- padding: .2em .6em .3em;
16
- text-align: center;
9
+ .home-facet-link {
10
+
11
+ }
12
+
13
+ .category-block {
14
+ @extend .col-md-6;
15
+ @extend .text-center;
16
+ min-height: 200px;
17
17
 
18
- &:hover {
19
- color: #fff;
20
- text-decoration: none;
18
+ .category-icon {
19
+ font-size: 6em;
21
20
  }
22
21
  }
@@ -1,3 +1,3 @@
1
1
  <% display_facet.items.each do |item| %>
2
- <%= link_to item.value, catalog_index_path({f: {"#{facet_field.field}" => [item.value]}}), class: 'home-facet-label' %>
2
+ <%= link_to item.value, catalog_index_path({f: {"#{facet_field.field}" => [item.value]}}), class: 'home-facet-link' %><%= "," unless item == display_facet.items.last %>
3
3
  <% end %>
@@ -7,9 +7,34 @@
7
7
  </div>
8
8
 
9
9
  <div class='row'>
10
- <div class='col-md-6 text-center'>
11
- <%= content_tag :h4, t('geoblacklight.home.category_heading') %>
12
- <%= render_facet_tags [:dc_subject_sm] %>
10
+ <div class='col-md-6'>
11
+ <%= content_tag :h4, t('geoblacklight.home.category_heading'), class: 'text-center' %>
12
+ <div class='row'>
13
+ <div class='category-block'>
14
+ <div class='category-icon'>
15
+ <span class='glyphicon glyphicon-home'></span>
16
+ </div>
17
+ <%= render_facet_tags [:dct_provenance_s] %>
18
+ </div>
19
+ <div class='category-block'>
20
+ <div class='category-icon'>
21
+ <span class='glyphicon glyphicon-download'></span>
22
+ </div>
23
+ <%= render_facet_tags [:layer_geom_type_s] %>
24
+ </div>
25
+ <div class='category-block'>
26
+ <div class='category-icon'>
27
+ <span class='glyphicon glyphicon-globe'></span>
28
+ </div>
29
+ <%= render_facet_tags [:dct_spatial_sm] %>
30
+ </div>
31
+ <div class='category-block'>
32
+ <div class='category-icon'>
33
+ <span class='glyphicon glyphicon-tags'></span>
34
+ </div>
35
+ <%= render_facet_tags [:dc_subject_sm] %>
36
+ </div>
37
+ </div>
13
38
  </div>
14
39
  <div class='col-md-6 text-center'>
15
40
  <%= content_tag :h4, t('geoblacklight.home.map_heading') %>
@@ -68,12 +68,12 @@ class CatalogController < ApplicationController
68
68
  # :years_25 => { :label => 'within 25 Years', :fq => "pub_date:[#{Time.now.year - 25 } TO *]" }
69
69
  # }
70
70
 
71
- config.add_facet_field 'dct_provenance_s', :label => 'Institution', :limit => 7
72
- config.add_facet_field 'dc_creator_sm', :label => 'Author', :limit => 6
73
- config.add_facet_field 'dc_publisher_s', :label => 'Publisher', :limit => 6
74
- config.add_facet_field 'dc_subject_sm', :label => 'Subject', :limit => 6
75
- config.add_facet_field 'dct_spatial_sm', :label => 'Place', :limit => 6
76
- config.add_facet_field 'dct_isPartOf_sm', :label => 'Collection', :limit => 6
71
+ config.add_facet_field 'dct_provenance_s', :label => 'Institution', :limit => 8
72
+ config.add_facet_field 'dc_creator_sm', :label => 'Author', :limit => 8
73
+ config.add_facet_field 'dc_publisher_s', :label => 'Publisher', :limit => 8
74
+ config.add_facet_field 'dc_subject_sm', :label => 'Subject', :limit => 8
75
+ config.add_facet_field 'dct_spatial_sm', :label => 'Place', :limit => 8
76
+ config.add_facet_field 'dct_isPartOf_sm', :label => 'Collection', :limit => 8
77
77
 
78
78
  config.add_facet_field 'solr_year_i', :label => 'Year', :limit => 10, :range => {
79
79
  # :num_segments => 6,
@@ -81,11 +81,9 @@ class CatalogController < ApplicationController
81
81
  # :segments => true
82
82
  }
83
83
 
84
- config.add_facet_field 'dc_rights_s', :label => 'Access', :limit => 3
85
- config.add_facet_field 'layer_geom_type_s', :label => 'Data type', :limit => 5
86
- config.add_facet_field 'dc_format_s', :label => 'Format', :limit => 3
87
- config.add_facet_field 'dc_language_s', :label => 'Language', :limit => 3
88
-
84
+ config.add_facet_field 'dc_rights_s', :label => 'Access', :limit => 8
85
+ config.add_facet_field 'layer_geom_type_s', :label => 'Data type', :limit => 8
86
+ config.add_facet_field 'dc_format_s', :label => 'Format', :limit => 8
89
87
 
90
88
  # Have BL send all facet field names to Solr, which has been the default
91
89
  # previously. Simply remove these lines if you'd rather use Solr request
@@ -1,3 +1,4 @@
1
1
  /*
2
2
  *= require geoblacklight/application
3
+ *= require blacklight_range_limit
3
4
  */
@@ -1 +1,2 @@
1
1
  //= require geoblacklight/application
2
+ //= require blacklight_range_limit
data/lib/geoblacklight.rb CHANGED
@@ -19,5 +19,7 @@ module Geoblacklight
19
19
  CatalogController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
20
20
  SearchHistoryController.send(:helper, Geoblacklight::ViewHelperOverride) unless
21
21
  SearchHistoryController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
22
+ SavedSearchesController.send(:helper, Geoblacklight::ViewHelperOverride) unless
23
+ SavedSearchesController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
22
24
  end
23
25
  end
@@ -4,6 +4,7 @@ module Geoblacklight
4
4
  URI = {
5
5
  download: 'http://schema.org/downloadUrl',
6
6
  fgdc: 'http://www.opengis.net/cat/csw/csdgm',
7
+ geojson: 'http://geojson.org/geojson-spec.html',
7
8
  html: 'http://www.w3.org/1999/xhtml',
8
9
  iiif: 'http://iiif.io/api/image',
9
10
  iso19139: 'http://www.isotc211.org/schemas/2005/gmd/',
@@ -5,6 +5,7 @@ require 'httparty'
5
5
  require 'font-awesome-rails'
6
6
  require 'rails_config'
7
7
  require 'faraday'
8
+ require 'blacklight_range_limit'
8
9
 
9
10
  module Geoblacklight
10
11
  class Engine < ::Rails::Engine
@@ -43,8 +43,6 @@ module Geoblacklight
43
43
  case format
44
44
  when 'Shapefile'
45
45
  { shapefile: wfs.to_hash, kmz: wms.to_hash }
46
- when 'GeoTIFF'
47
- { geotiff: wms.to_hash }
48
46
  end
49
47
  end
50
48
 
@@ -16,7 +16,7 @@ module Geoblacklight
16
16
  end
17
17
 
18
18
  def downloadable?
19
- get(:solr_wfs_url) && get(:solr_wms_url) && available?
19
+ download_types.present? && available?
20
20
  end
21
21
 
22
22
  def download_types
@@ -1,3 +1,3 @@
1
1
  module Geoblacklight
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,17 +1,25 @@
1
1
  module Geoblacklight
2
2
  module ViewHelperOverride
3
-
4
3
  def has_spatial_parameters?
5
4
  params[:bbox]
6
5
  end
7
-
6
+
8
7
  # Overrides BL method to enable results for spatial only params
9
8
  def has_search_parameters?
10
- super || has_spatial_parameters?
9
+ has_spatial_parameters? || super
11
10
  end
12
-
11
+
13
12
  def query_has_contraints?(params = params)
14
- super || has_search_parameters?
13
+ has_search_parameters? || super
14
+ end
15
+
16
+ def render_search_to_s(params)
17
+ super + render_search_to_s_bbox(params)
18
+ end
19
+
20
+ def render_search_to_s_bbox(params)
21
+ return ''.html_safe if params['bbox'].blank?
22
+ render_search_to_s_element('Bounding box', render_filter_value(params['bbox']) )
15
23
  end
16
24
  end
17
- end
25
+ end
@@ -13,7 +13,8 @@ feature 'Home page', js: true do # use js: true for tests which require js, but
13
13
  end
14
14
  end
15
15
  scenario 'find by category' do
16
- expect(page).to have_css '.home-facet-label', count: 7
16
+ expect(page).to have_css '.category-block', count: 4
17
+ expect(page).to have_css '.home-facet-link', count: 28
17
18
  click_link 'Census'
18
19
  expect(page).to have_css '.filterName', text: 'Subject'
19
20
  expect(page).to have_css '.filterValue', text: 'Census'
@@ -21,7 +22,7 @@ feature 'Home page', js: true do # use js: true for tests which require js, but
21
22
  scenario 'map should be visible' do
22
23
  within '#main-container' do
23
24
  expect(page).to have_css('#map')
24
- expect(page).to have_css('img.leaflet-tile', count: 4)
25
+ expect(page).to have_css('img.leaflet-tile', minimum: 3)
25
26
  end
26
27
  end
27
28
  scenario 'clicking map search should create a spatial search' do
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'saved searches' do
4
+ scenario 'list spatial search', js: true do
5
+ visit root_path
6
+ find('#map').double_click
7
+ within '#map' do
8
+ find('a.search-control').click
9
+ expect(page.current_url).to match /bbox=/
10
+ end
11
+ visit search_history_path
12
+ expect(page).to have_css 'td.query a', text: /Bounding box:/
13
+ end
14
+ end
@@ -22,7 +22,6 @@ feature 'Index view', js: true do
22
22
  expect(page).to have_css('div.panel.facet_limit', text: 'Access')
23
23
  expect(page).to have_css('div.panel.facet_limit', text: 'Data type')
24
24
  expect(page).to have_css('div.panel.facet_limit', text: 'Format')
25
- expect(page).to have_css('div.panel.facet_limit', text: 'Language')
26
25
  end
27
26
  click_link 'Institution'
28
27
  expect(page).to have_css('a.facet_select', text: 'Harvard', visible: true)
@@ -38,9 +38,18 @@ describe Geoblacklight::References do
38
38
  )
39
39
  )
40
40
  }
41
+ let(:direct_download_only) {
42
+ Geoblacklight::References.new(
43
+ dc_format_s: 'GeoTIFF',
44
+ dct_references_s: {
45
+ 'http://schema.org/downloadUrl' => 'http://example.com/layer-id-geotiff.tiff'
46
+ }.to_json
47
+ )
48
+ }
41
49
  describe 'format' do
42
50
  it 'should return format' do
43
51
  expect(complex_shapefile.format).to eq 'Shapefile'
52
+ expect(direct_download_only.format).to eq 'GeoTIFF'
44
53
  end
45
54
  end
46
55
  describe 'refs' do
@@ -55,6 +64,7 @@ describe Geoblacklight::References do
55
64
  download = complex_shapefile.download
56
65
  expect(download).to be_an Geoblacklight::Reference
57
66
  expect(download.endpoint).to eq('http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip')
67
+ expect(direct_download_only.download.endpoint).to eq 'http://example.com/layer-id-geotiff.tiff'
58
68
  end
59
69
  it 'should not return if download not available' do
60
70
  expect(typical_ogp_shapefile.download).to be_nil
@@ -63,6 +73,7 @@ describe Geoblacklight::References do
63
73
  describe 'preferred_download' do
64
74
  it 'should return the direct download if available' do
65
75
  expect(complex_shapefile.preferred_download[:file_download][:download]).to eq 'http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip'
76
+ expect(direct_download_only.preferred_download[:file_download][:download]).to eq 'http://example.com/layer-id-geotiff.tiff'
66
77
  end
67
78
  it 'should return nil if there is no direct download' do
68
79
  expect(typical_ogp_shapefile.preferred_download).to be_nil
@@ -76,6 +87,7 @@ describe Geoblacklight::References do
76
87
  types = complex_shapefile.download_types
77
88
  expect(types.first[1]).to eq wfs: 'http://hgl.harvard.edu:8080/geoserver/wfs'
78
89
  expect(types.count).to eq 2
90
+ expect(direct_download_only.download_types).to be_nil
79
91
  end
80
92
  it 'should only return available downloads if no direct is present' do
81
93
  types = typical_ogp_shapefile.download_types
@@ -20,4 +20,17 @@ describe Geoblacklight::ViewHelperOverride do
20
20
  expect(@fake_controller.has_spatial_parameters?).to be_truthy
21
21
  end
22
22
  end
23
- end
23
+ describe 'render_search_to_s_bbox' do
24
+ it 'returns an empty string for no bbox' do
25
+ @fake_controller.params = {}
26
+ expect(@fake_controller.render_search_to_s_bbox(@fake_controller.params)).to eq ''
27
+ end
28
+ it 'returns render_search_to_s_element when bbox is present' do
29
+ @fake_controller.params = { bbox: '123'}
30
+ params = { 'bbox' => '123' }
31
+ expect(@fake_controller).to receive(:render_search_to_s_element)
32
+ expect(@fake_controller).to receive(:render_filter_value)
33
+ @fake_controller.render_search_to_s_bbox(params)
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoblacklight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Hardy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-21 00:00:00.000000000 Z
12
+ date: 2014-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: blacklight
@@ -319,12 +319,12 @@ files:
319
319
  - lib/tasks/geoblacklight.rake
320
320
  - spec/controllers/download_controller_spec.rb
321
321
  - spec/factories/user.rb
322
- - spec/features/dct_references_generate.rb
323
322
  - spec/features/dct_references_spec.rb
324
323
  - spec/features/download_layer_spec.rb
325
324
  - spec/features/home_page_spec.rb
326
325
  - spec/features/layer_inspection_spec.rb
327
326
  - spec/features/layer_preview_spec.rb
327
+ - spec/features/saved_searches_spec.rb
328
328
  - spec/features/search_bar_spec.rb
329
329
  - spec/features/split_view.html.erb_spec.rb
330
330
  - spec/fixtures/test-dct-references1.json
@@ -345,6 +345,7 @@ files:
345
345
  - spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb
346
346
  - spec/lib/geoblacklight/wms_layer_spec.rb
347
347
  - spec/spec_helper.rb
348
+ - spec/support/dct_references_generate.rb
348
349
  - spec/support/features.rb
349
350
  - spec/support/features/session_helpers.rb
350
351
  - spec/test_app_templates/lib/generators/test_app_generator.rb
@@ -379,12 +380,12 @@ summary: A discovery platform for geospatial holdings
379
380
  test_files:
380
381
  - spec/controllers/download_controller_spec.rb
381
382
  - spec/factories/user.rb
382
- - spec/features/dct_references_generate.rb
383
383
  - spec/features/dct_references_spec.rb
384
384
  - spec/features/download_layer_spec.rb
385
385
  - spec/features/home_page_spec.rb
386
386
  - spec/features/layer_inspection_spec.rb
387
387
  - spec/features/layer_preview_spec.rb
388
+ - spec/features/saved_searches_spec.rb
388
389
  - spec/features/search_bar_spec.rb
389
390
  - spec/features/split_view.html.erb_spec.rb
390
391
  - spec/fixtures/test-dct-references1.json
@@ -405,6 +406,7 @@ test_files:
405
406
  - spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb
406
407
  - spec/lib/geoblacklight/wms_layer_spec.rb
407
408
  - spec/spec_helper.rb
409
+ - spec/support/dct_references_generate.rb
408
410
  - spec/support/features.rb
409
411
  - spec/support/features/session_helpers.rb
410
412
  - spec/test_app_templates/lib/generators/test_app_generator.rb