geoblacklight 0.10.2 → 0.11.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: 011958937e26e5422c1365a2ffbdafb22da97478
4
- data.tar.gz: e9201eb061d67072de1372c24066ce352a29acd3
3
+ metadata.gz: dcd3f92534945380a7a09f870a4d824564b2800c
4
+ data.tar.gz: 8e39704e5a860b36b933816e7cd690155e10f7af
5
5
  SHA512:
6
- metadata.gz: 34843481a05279c3bf2935312873dd99298e14f5070f2baacd88939fb36f891982dbaae8dbd29dd841b182c1812c0ad26dcced0a45db0d1784437724593cdb91
7
- data.tar.gz: 1107f1be59b0188378e712a55258abcc232462831cf0a8b8107170d43503dd91ab8d4c027ea92071b755e34ddfb7822bdca933ac71e95aabeaf62b3ee4529122
6
+ metadata.gz: d177f2ee3aedaeab70153ca7d996d643c22de8b2b967d31eb976600170cdbca1bc106059fd94dd876b498a9e68180abe97c9b17f0b2b498d3e5f359d01a1c189
7
+ data.tar.gz: aa0cc7103063c8eb5f480888248197ac07fd125565f068f13eef5ac247719bf095d1da9f96cf029a5ccaf962d12f1f497f8d28e734b2b47cb798d994af1ba516
@@ -0,0 +1,4 @@
1
+ module BlacklightHelper
2
+ include Blacklight::BlacklightHelperBehavior
3
+ include Geoblacklight::GeoblacklightHelperBehavior
4
+ end
@@ -104,4 +104,17 @@ module GeoblacklightHelper
104
104
  )
105
105
  Settings.CARTODB_ONECLICK_LINK + '?' + params
106
106
  end
107
+
108
+ ##
109
+ # Renders the partials for a Geoblacklight::Reference in the web services
110
+ # modal
111
+ # @param [Geoblacklight::Reference]
112
+ def render_web_services(reference)
113
+ render(
114
+ partial: "web_services_#{reference.type}",
115
+ locals: { reference: reference }
116
+ )
117
+ rescue ActionView::MissingTemplate
118
+ render partial: 'web_services_default', locals: { reference: reference }
119
+ end
107
120
  end
@@ -1,5 +1,5 @@
1
1
  <% document ||= @document %>
2
2
  <div id='viewer-container' class="col-md-8">
3
- <%= content_tag :div, id: 'map', data: { map: 'item', protocol: document.viewer_protocol, url: document.viewer_endpoint, 'layer-id' => document[:layer_id_s], 'map-bbox' => document.bounding_box_as_wsen, 'catalog-path'=> catalog_index_path, available: document_available?, basemap: geoblacklight_basemap } do %>
3
+ <%= content_tag :div, id: 'map', data: { map: 'item', protocol: document.viewer_protocol, url: document.viewer_endpoint, 'layer-id' => wxs_identifier(document), 'map-bbox' => document.bounding_box_as_wsen, 'catalog-path'=> catalog_index_path, available: document_available?, basemap: geoblacklight_basemap } do %>
4
4
  <% end %>
5
5
  </div>
@@ -2,11 +2,7 @@
2
2
 
3
3
  <% document.references.refs.each do |reference| %>
4
4
  <% if Settings.WEBSERVICES_SHOWN.include? reference.type.to_s %>
5
- <div class='form-group web-services-form'>
6
- <label for='<%= reference.type%>_webservice'>
7
- <%= "#{formatted_name_reference(reference.type)} link" %>
8
- </label>
9
- <input type='text' id='<%= reference.type%>_webservice' value='<%= reference.endpoint %>' readonly='readonly' class='form-control'>
10
- </div>
5
+ <%= render_web_services(reference) %>
6
+ <hr>
11
7
  <% end %>
12
8
  <% end %>
@@ -0,0 +1,8 @@
1
+ <% document ||= @document %>
2
+
3
+ <div class='form-group web-services-form'>
4
+ <label for='<%= reference.type%>_webservice'>
5
+ <%= "#{formatted_name_reference(reference.type)}" %>
6
+ </label>
7
+ <input type='text' id='<%= reference.type%>_webservice' value='<%= reference.endpoint %>' readonly='readonly' class='form-control'>
8
+ </div>
@@ -0,0 +1,8 @@
1
+ <% document ||= @document %>
2
+
3
+ <%= render partial: 'web_services_default', locals: { reference: reference } %>
4
+
5
+ <div class='form-group form-inline'>
6
+ <label class='control-label'>WFS <code>typeNames</code></label>
7
+ <input type='text' value='<%= wxs_identifier(document) %>' readonly='readonly' class='form-control'>
8
+ </div>
@@ -0,0 +1,8 @@
1
+ <% document ||= @document %>
2
+
3
+ <%= render partial: 'web_services_default', locals: { reference: reference } %>
4
+
5
+ <div class='form-group form-inline'>
6
+ <label class='control-label'>WMS <code>layers</code></label>
7
+ <input type='text' value='<%= wxs_identifier(document) %>' readonly='readonly' class='form-control'>
8
+ </div>
@@ -33,7 +33,9 @@ class CatalogController < ApplicationController
33
33
 
34
34
  config.show.display_type_field = 'format'
35
35
 
36
-
36
+ # Custom GeoBlacklight fields which currently map to GeoBlacklight-Schema
37
+ # v0.3.2
38
+ config.wxs_identifier_field = 'layer_id_s'
37
39
 
38
40
  # solr fields that will be treated as facets by the blacklight application
39
41
  # The ordering of the field names is the order of the display
data/lib/geoblacklight.rb CHANGED
@@ -7,6 +7,8 @@ module Geoblacklight
7
7
  require 'geoblacklight/constants'
8
8
  require 'geoblacklight/controller_override'
9
9
  require 'geoblacklight/exceptions'
10
+ require 'geoblacklight/geoblacklight_helper_behavior'
11
+ require 'geoblacklight/document_presenter'
10
12
  require 'geoblacklight/view_helper_override'
11
13
  require 'geoblacklight/item_viewer'
12
14
  require 'geoblacklight/solr_document/finder'
@@ -25,7 +27,7 @@ module Geoblacklight
25
27
  require 'geoblacklight/references'
26
28
  require 'geoblacklight/routes'
27
29
  require 'geoblacklight/search_builder'
28
-
30
+
29
31
  def self.inject!
30
32
  CatalogController.send(:include, Geoblacklight::ControllerOverride)
31
33
  CatalogController.send(:include, Geoblacklight::CatalogHelperOverride)
@@ -0,0 +1,15 @@
1
+ module Geoblacklight
2
+ ##
3
+ # Adds custom functionality for Geoblacklight document presentation
4
+ class DocumentPresenter < Blacklight::DocumentPresenter
5
+ ##
6
+ # Accesses a documents configured Wxs Identifier
7
+ # @param [SolrDocument]
8
+ # @return [String]
9
+ def wxs_identifier
10
+ fields = Array(@configuration.wxs_identifier_field)
11
+ f = fields.find { |field| @document.has? field }
12
+ render_field_value(@document[f])
13
+ end
14
+ end
15
+ end
@@ -63,10 +63,8 @@ module Geoblacklight
63
63
  conn = Faraday.new(url: url)
64
64
  conn.get do |request|
65
65
  request.params = @options[:request_params]
66
- request.options = {
67
- timeout: timeout,
68
- open_timeout: timeout
69
- }
66
+ request.options.timeout = timeout
67
+ request.options.open_timeout = timeout
70
68
  end
71
69
  rescue Faraday::Error::ConnectionFailed => error
72
70
  raise Geoblacklight::Exceptions::ExternalDownloadFailed, message: 'Download connection failed', url: conn.url_prefix.to_s
@@ -0,0 +1,20 @@
1
+ module Geoblacklight
2
+ ##
3
+ # Adds helper behavior logic for GeoBlacklight, to used alongside
4
+ # BlacklightHelperBehavior
5
+ module GeoblacklightHelperBehavior
6
+ ##
7
+ # @param [SolrDocument]
8
+ # @return [String]
9
+ def wxs_identifier(document = nil)
10
+ document ||= @document
11
+ presenter(document).wxs_identifier
12
+ end
13
+
14
+ ##
15
+ # Use the Geoblacklight::DocumentPresenter
16
+ def presenter_class
17
+ Geoblacklight::DocumentPresenter
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Geoblacklight
2
- VERSION = '0.10.2'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -23,10 +23,8 @@ module Geoblacklight
23
23
  conn = Faraday.new(url: url)
24
24
  conn.get do |request|
25
25
  request.params = search_params
26
- request.options = {
27
- timeout: Settings.TIMEOUT_WMS,
28
- open_timeout: Settings.TIMEOUT_WMS
29
- }
26
+ request.options.timeout = Settings.TIMEOUT_WMS
27
+ request.options.open_timeout = Settings.TIMEOUT_WMS
30
28
  end
31
29
  rescue Faraday::Error::ConnectionFailed => error
32
30
  Geoblacklight.logger.error error.inspect
@@ -7,11 +7,14 @@ feature 'web services tools' do
7
7
  expect(page).to have_css 'li.web_services a', text: 'Web services'
8
8
  click_link 'Web services'
9
9
  within '.modal-body' do
10
- expect(page).to have_css 'input', count: 2
11
- expect(page).to have_css 'label', text: 'Web Feature Service (WFS) link'
10
+ expect(page).to have_css 'input', count: 4
11
+ expect(page).to have_css 'label', text: 'Web Feature Service (WFS)'
12
12
  expect(page).to have_css 'input[value="http://geowebservices-restricted.stanford.edu/geoserver/wfs"]'
13
- expect(page).to have_css 'label', text: 'Web Mapping Service (WMS) link'
13
+ expect(page).to have_css 'label', text: 'WFS typeNames'
14
+ expect(page).to have_css 'input[value="druid:cg357zz0321"]', count: 2
15
+ expect(page).to have_css 'label', text: 'Web Mapping Service (WMS)'
14
16
  expect(page).to have_css 'input[value="http://geowebservices-restricted.stanford.edu/geoserver/wms"]'
17
+ expect(page).to have_css 'label', text: 'WMS layers'
15
18
  end
16
19
  end
17
20
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe GeoblacklightHelper do
3
+ describe GeoblacklightHelper, type: :helper do
4
4
  include GeoblacklightHelper
5
5
  include ActionView::Helpers::UrlHelper
6
6
  include ActionView::Helpers::TranslationHelper
@@ -45,4 +45,22 @@ describe GeoblacklightHelper do
45
45
  expect(geoblacklight_basemap).to eq 'positron'
46
46
  end
47
47
  end
48
+ describe '#render_web_services' do
49
+ let(:reference) { double(type: 'wms') }
50
+ it 'with a reference to a defined partial' do
51
+ expect(helper).to receive(:render)
52
+ .with(partial: 'web_services_wms', locals: { reference: reference })
53
+ helper.render_web_services(reference)
54
+ end
55
+ it 'with a reference to a missing partial' do
56
+ reference = double(type: 'iiif')
57
+ # expect(helper).to receive(:render).and_raise ActionView::MissingTemplate
58
+ expect(helper).to receive(:render)
59
+ .with(partial: 'web_services_iiif', locals: { reference: reference })
60
+ .and_raise ActionView::MissingTemplate.new({}, '', '', '', '')
61
+ expect(helper).to receive(:render)
62
+ .with(partial: 'web_services_default', locals: { reference: reference })
63
+ helper.render_web_services(reference)
64
+ end
65
+ end
48
66
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geoblacklight::DocumentPresenter do
4
+ let(:request_context) { double(add_facet_params: '') }
5
+ let(:config) { Blacklight::Configuration.new }
6
+ subject { presenter }
7
+ let(:presenter) do
8
+ Geoblacklight::DocumentPresenter.new(document, request_context, config)
9
+ end
10
+
11
+ let(:document) do
12
+ SolrDocument.new(id: 1, layer_id_s: 'druid:abc123')
13
+ end
14
+
15
+ describe '#wxs_identifier' do
16
+ describe 'without wxs identifier in configuration' do
17
+ end
18
+ it 'returns empty string' do
19
+ expect(subject.wxs_identifier).to eq ''
20
+ end
21
+ describe 'without wxs identifier in configuration' do
22
+ let(:config) do
23
+ Blacklight::Configuration.new.configure do |config|
24
+ config.wxs_identifier_field = 'layer_id_s'
25
+ end
26
+ end
27
+ it 'returns configured field' do
28
+ expect(subject.wxs_identifier).to eq 'druid:abc123'
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geoblacklight::GeoblacklightHelperBehavior do
4
+ let(:dummy_class) do
5
+ Class.new { include Geoblacklight::GeoblacklightHelperBehavior }.new
6
+ end
7
+ describe '#wxs_identifier' do
8
+ it 'calls defined presenter class' do
9
+ expect(dummy_class).to receive(:presenter)
10
+ .and_return(double(wxs_identifier: 'druid:abc123'))
11
+ expect(dummy_class.wxs_identifier).to eq 'druid:abc123'
12
+ end
13
+ end
14
+ describe '#presenter_class' do
15
+ it 'is defined as Geoblacklight::DocumentPresenter' do
16
+ expect(dummy_class.presenter_class.new({}, {}, {}))
17
+ .to be_a Geoblacklight::DocumentPresenter
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Leaflet-IIIF 0.0.5
2
+ * Leaflet-IIIF 0.0.7
3
3
  * IIIF Viewer for Leaflet
4
4
  * by Jack Reed, @mejackreed
5
5
  */
@@ -8,7 +8,8 @@ L.TileLayer.Iiif = L.TileLayer.extend({
8
8
  options: {
9
9
  continuousWorld: true,
10
10
  tileSize: 256,
11
- updateWhenIdle: true
11
+ updateWhenIdle: true,
12
+ tileFormat: 'jpg'
12
13
  },
13
14
 
14
15
  initialize: function(url, options) {
@@ -23,21 +24,38 @@ L.TileLayer.Iiif = L.TileLayer.extend({
23
24
  x = coords.x,
24
25
  y = (coords.y),
25
26
  zoom = _this._map.getZoom(),
26
- scale = Math.pow(2, _this.maxZoom - zoom),
27
+ scale = Math.pow(2, _this.maxNativeZoom - zoom),
27
28
  tileBaseSize = _this.options.tileSize * scale,
28
29
  minx = (x * tileBaseSize),
29
30
  miny = (y * tileBaseSize),
30
31
  maxx = Math.min(minx + tileBaseSize, _this.x),
31
32
  maxy = Math.min(miny + tileBaseSize, _this.y);
33
+
34
+ var xDiff = (maxx - minx);
35
+ var yDiff = (maxy - miny);
32
36
 
33
37
  return L.Util.template(this._baseUrl, L.extend({
34
- format: 'jpg',
38
+ format: _this.options.tileFormat,
35
39
  quality: _this.quality,
36
- region: [minx, miny, (maxx - minx), (maxy - miny)].join(','),
40
+ region: [minx, miny, xDiff, yDiff].join(','),
37
41
  rotation: 0,
38
- size: 'pct:' + (100 / scale)
42
+ size: _this._iiifSizeParam(Math.ceil(xDiff / scale), Math.ceil(yDiff / scale))
39
43
  }, this.options));
40
44
  },
45
+ /**
46
+ * Returns a IIIF size parameter based off of the max dimension of
47
+ * a tile
48
+ * @param {Number} x - The width of a tile
49
+ * @param {Number} y - The height of a tile
50
+ * @returns {String}
51
+ */
52
+ _iiifSizeParam: function(x, y) {
53
+ if (x >= y) {
54
+ return x + ',';
55
+ } else {
56
+ return ',' + y;
57
+ }
58
+ },
41
59
  onAdd: function(map) {
42
60
  var _this = this;
43
61
 
@@ -98,23 +116,11 @@ L.TileLayer.Iiif = L.TileLayer.extend({
98
116
  }else {
99
117
  profile = data.profile;
100
118
  }
101
- switch (profile) {
102
- case 'http://library.stanford.edu/iiif/image-api/compliance.html#level1':
103
- _this.quality = 100;
104
- break;
105
- case 'http://library.stanford.edu/iiif/image-api/1.1/compliance.html':
119
+ switch (true) {
120
+ case /^http:\/\/library.stanford.edu\/iiif\/image-api\/1.1\/compliance.html.*$/.test(profile):
106
121
  _this.quality = 'native';
107
122
  break;
108
- case 'http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1':
109
- _this.quality = 'native';
110
- break;
111
- case 'http://iiif.io/api/image/2/level2.json':
112
- _this.quality = 'default';
113
- break;
114
- case 'http://iiif.io/api/image/2/level1.json':
115
- _this.quality = 'default';
116
- break;
117
- case 'http://iiif.io/api/image/2/level0.json':
123
+ case /^http:\/\/iiif.io\/api\/image\/2.*$/.test(profile):
118
124
  _this.quality = 'default';
119
125
  break;
120
126
  }
@@ -123,12 +129,20 @@ L.TileLayer.Iiif = L.TileLayer.extend({
123
129
  return Math.ceil(Math.log(x) / Math.LN2);
124
130
  };
125
131
 
126
- // Calculates maxZoom for the layer
127
- _this.maxZoom = Math.max(ceilLog2(_this.x / _this.options.tileSize),
132
+ // Calculates maximum native zoom for the layer
133
+ _this.maxNativeZoom = Math.max(ceilLog2(_this.x / _this.options.tileSize),
128
134
  ceilLog2(_this.y / _this.options.tileSize));
129
-
135
+
136
+ // Enable zooming further than native if needed
137
+ if (_this.options.maxZoom && _this.options.maxZoom > _this.maxNativeZoom) {
138
+ _this.maxZoom = _this.options.maxZoom;
139
+ }
140
+ else {
141
+ _this.maxZoom = _this.maxNativeZoom;
142
+ }
143
+
130
144
  for (var i = 0; i <= _this.maxZoom; i++) {
131
- scale = Math.pow(2, _this.maxZoom - i);
145
+ scale = Math.pow(2, _this.maxNativeZoom - i);
132
146
  width_ = Math.ceil(_this.x / scale);
133
147
  height_ = Math.ceil(_this.y / scale);
134
148
  tilesX_ = Math.ceil(width_ / _this.options.tileSize);
@@ -169,7 +183,7 @@ L.TileLayer.Iiif = L.TileLayer.extend({
169
183
  tolerance = 0.8,
170
184
  imageSize;
171
185
 
172
- for (var i = _this.maxZoom; i >= 0; i--) {
186
+ for (var i = _this.maxNativeZoom; i >= 0; i--) {
173
187
  imageSize = this._imageSizes[i];
174
188
  if (imageSize.x * tolerance < mapSize.x && imageSize.y * tolerance < mapSize.y) {
175
189
  return i;
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.10.2
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Graves
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-08-11 00:00:00.000000000 Z
14
+ date: 2015-10-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: blacklight
@@ -308,6 +308,7 @@ files:
308
308
  - app/assets/stylesheets/geoblacklight/modules/web_services.scss
309
309
  - app/controllers/download_controller.rb
310
310
  - app/controllers/wms_controller.rb
311
+ - app/helpers/blacklight_helper.rb
311
312
  - app/helpers/geoblacklight_helper.rb
312
313
  - app/views/catalog/_document_action.html.erb
313
314
  - app/views/catalog/_document_split.html.erb
@@ -326,6 +327,9 @@ files:
326
327
  - app/views/catalog/_show_header_default.html.erb
327
328
  - app/views/catalog/_upper_metadata.html.erb
328
329
  - app/views/catalog/_web_services.html.erb
330
+ - app/views/catalog/_web_services_default.html.erb
331
+ - app/views/catalog/_web_services_wfs.html.erb
332
+ - app/views/catalog/_web_services_wms.html.erb
329
333
  - app/views/catalog/index.html.erb
330
334
  - app/views/catalog/metadata.html.erb
331
335
  - app/views/catalog/metadata.js.erb
@@ -349,6 +353,7 @@ files:
349
353
  - lib/geoblacklight/config.rb
350
354
  - lib/geoblacklight/constants.rb
351
355
  - lib/geoblacklight/controller_override.rb
356
+ - lib/geoblacklight/document_presenter.rb
352
357
  - lib/geoblacklight/download.rb
353
358
  - lib/geoblacklight/download/geojson_download.rb
354
359
  - lib/geoblacklight/download/geotiff_download.rb
@@ -357,6 +362,7 @@ files:
357
362
  - lib/geoblacklight/download/shapefile_download.rb
358
363
  - lib/geoblacklight/engine.rb
359
364
  - lib/geoblacklight/exceptions.rb
365
+ - lib/geoblacklight/geoblacklight_helper_behavior.rb
360
366
  - lib/geoblacklight/item_viewer.rb
361
367
  - lib/geoblacklight/metadata.rb
362
368
  - lib/geoblacklight/reference.rb
@@ -404,12 +410,14 @@ files:
404
410
  - spec/javascripts/spec_helper.js
405
411
  - spec/lib/geoblacklight/bounding_box_spec.rb
406
412
  - spec/lib/geoblacklight/controller_override_spec.rb
413
+ - spec/lib/geoblacklight/document_presenter_spec.rb
407
414
  - spec/lib/geoblacklight/download/geojson_download_spec.rb
408
415
  - spec/lib/geoblacklight/download/geotiff_download_spec.rb
409
416
  - spec/lib/geoblacklight/download/hgl_download_spec.rb
410
417
  - spec/lib/geoblacklight/download/kmz_download_spec.rb
411
418
  - spec/lib/geoblacklight/download/shapefile_download_spec.rb
412
419
  - spec/lib/geoblacklight/download_spec.rb
420
+ - spec/lib/geoblacklight/geoblacklight_helper_behavior_spec.rb
413
421
  - spec/lib/geoblacklight/item_viewer_spec.rb
414
422
  - spec/lib/geoblacklight/metadata_spec.rb
415
423
  - spec/lib/geoblacklight/reference_spec.rb
@@ -489,12 +497,14 @@ test_files:
489
497
  - spec/javascripts/spec_helper.js
490
498
  - spec/lib/geoblacklight/bounding_box_spec.rb
491
499
  - spec/lib/geoblacklight/controller_override_spec.rb
500
+ - spec/lib/geoblacklight/document_presenter_spec.rb
492
501
  - spec/lib/geoblacklight/download/geojson_download_spec.rb
493
502
  - spec/lib/geoblacklight/download/geotiff_download_spec.rb
494
503
  - spec/lib/geoblacklight/download/hgl_download_spec.rb
495
504
  - spec/lib/geoblacklight/download/kmz_download_spec.rb
496
505
  - spec/lib/geoblacklight/download/shapefile_download_spec.rb
497
506
  - spec/lib/geoblacklight/download_spec.rb
507
+ - spec/lib/geoblacklight/geoblacklight_helper_behavior_spec.rb
498
508
  - spec/lib/geoblacklight/item_viewer_spec.rb
499
509
  - spec/lib/geoblacklight/metadata_spec.rb
500
510
  - spec/lib/geoblacklight/reference_spec.rb