geoblacklight 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c08882be65fd2fa60c1df470d8bd108d6f91f48
4
- data.tar.gz: c9a105520e93ea3289286141a1e971ff0aaf969a
3
+ metadata.gz: bd5d9169412d20001902df8f9b190829237ae511
4
+ data.tar.gz: d2eaeafd8633c2512d0f917f5a45e25981036167
5
5
  SHA512:
6
- metadata.gz: ca3de4a27f65f96999a33ec65f852efa87533a2eec2ca9c136a1895dadfd7d790a5241fd704c46b11b93d427586efbde4ebb471e0bc95cbc7069ad50a18660dc
7
- data.tar.gz: ac0a1aa66f06d4be608ebd74273861fb6cc1a5b1f00d0b60394bf2b383efd7c80cd916fd9b4c4a674ac95325d3908193f7aac2aeb056055206786878b2dfc7df
6
+ metadata.gz: 26a1988031a4e0ec4bf578911c62708a23c25da3a5da487c3b22ff38ff0ca4697ec08e33f0fe49cc35bfb75c06fa3c17d0f6d72697d2ada5fa5bd394b5cc4f1a
7
+ data.tar.gz: beeeb39b51cef29487020632e867f3c50389f3cd4bd99ae960420f5e3b98c1ae63f1c287448151952b8fac916a804427e2a08a044c06fce31e00d67d5fb29d7a
@@ -54,7 +54,7 @@ GeoBlacklight.Viewer.Wms = GeoBlacklight.Viewer.Map.extend({
54
54
  url: '/wms/handle',
55
55
  data: wmsoptions,
56
56
  success: function(data) {
57
- if (data.hasOwnProperty('error')) {
57
+ if (data.hasOwnProperty('error') || data.values.length === 0) {
58
58
  $('.attribute-table-body').html('<tbody class="attribute-table-body"><tr><td colspan="2">Could not find that feature</td></tr></tbody>');
59
59
  return;
60
60
  }
@@ -9,21 +9,19 @@
9
9
  </div>
10
10
  <% if show_attribute_table? %>
11
11
  <div id='table-container' class='col-md-4'>
12
- <div id='attribute-table'>
13
- <table id="attribute-table" class="table table-hover table-condensed table-responsive table-striped table-bordered">
14
- <thead>
15
- <tr>
16
- <th>Attribute</th>
17
- <th>Value</th>
18
- </tr>
19
- </thead>
20
- <tbody class='attribute-table-body'>
21
- <tr>
22
- <td class='default-text' colspan='2'><em>Click on map to inspect values</em></td>
23
- </tr>
24
- </tbody>
25
- </table>
26
- </div>
12
+ <table id="attribute-table" class="table table-hover table-condensed table-responsive table-striped table-bordered">
13
+ <thead>
14
+ <tr>
15
+ <th>Attribute</th>
16
+ <th>Value</th>
17
+ </tr>
18
+ </thead>
19
+ <tbody class='attribute-table-body'>
20
+ <tr>
21
+ <td class='default-text' colspan='2'><em>Click on map to inspect values</em></td>
22
+ </tr>
23
+ </tbody>
24
+ </table>
27
25
  </div>
28
26
  <% end %>
29
27
  </div>
@@ -6,48 +6,46 @@
6
6
  Tools
7
7
  </div>
8
8
  <div class="panel-body">
9
- <ul class="list-group">
10
- <%= render_show_doc_actions @document, wrapping_class: 'list-group-item' %>
11
- <% if @document.respond_to?( :to_email_text ) %>
12
- <%= link_to email_helper, email_catalog_path(:id => @document), {:id => 'emailLink', :data => {:ajax_modal => "trigger"}, :class => 'list-group-item'} %>
13
- <%- end -%>
14
- <%- if @document.respond_to?( :to_sms_text ) -%>
15
- <%= link_to sms_helper, sms_catalog_path(:id => @document), {:id => 'smsLink', :data => {:ajax_modal => "trigger"}, :class => 'list-group-item'} %>
16
- <%- end -%>
17
- <a href="#" data-no-turbolink class="list-group-item">
18
- <i class="fa fa-bookmark fa-fw"></i>&nbsp;Cite This
19
- </a>
20
- </ul>
21
- <% if document_downloadable? %>
22
- <div class='btn-group' itemprop='distribution' itemscope='itemscope' itemtype='http://schema.org/DataDownload'>
23
- <% unless document.direct_download.blank? %>
24
- <%= link_to(download_text(@document[:dc_format_s]), document.direct_download[:download], class: 'btn btn-default', 'contentUrl' => document.direct_download[:download]) %>
25
- <% else %>
26
- <%= link_to(download_text(document.download_types.first[0]), '', data: { download_path: "#{download_path(document[:layer_slug_s], type: document.download_types.first[0])}"}, class: 'btn btn-default') %>
27
- <% end %>
28
- <button type='button' class='btn btn-default dropdown-toggle download-dropdown-toggle' data-toggle='dropdown' aria-expanded='false'>
29
- <span class='caret'></span>
30
- <span class='sr-only'>Toggle Download Dropdown</span>
31
- </button>
32
- <ul class='dropdown-menu' role='menu'>
9
+ <ul class="list-group">
10
+ <%= render_show_doc_actions @document, wrapping_class: 'list-group-item' %>
11
+ <% if @document.respond_to?( :to_email_text ) %>
12
+ <%= link_to email_helper, email_catalog_path(:id => @document), {:id => 'emailLink', :data => {:ajax_modal => "trigger"}, :class => 'list-group-item'} %>
13
+ <%- end -%>
14
+ <%- if @document.respond_to?( :to_sms_text ) -%>
15
+ <%= link_to sms_helper, sms_catalog_path(:id => @document), {:id => 'smsLink', :data => {:ajax_modal => "trigger"}, :class => 'list-group-item'} %>
16
+ <%- end -%>
17
+ </ul>
18
+ <% if document_downloadable? %>
19
+ <div class='btn-group' itemprop='distribution' itemscope='itemscope' itemtype='http://schema.org/DataDownload'>
33
20
  <% unless document.direct_download.blank? %>
34
- <li role="presentation" class="dropdown-header">Original</li>
35
- <li>
36
- <%= link_to(download_text(@document[:dc_format_s]), document.direct_download[:download], 'contentUrl' => document.direct_download[:download]) %>
37
- </li>
21
+ <%= link_to(download_text(@document[:dc_format_s]), document.direct_download[:download], class: 'btn btn-default', 'contentUrl' => document.direct_download[:download]) %>
22
+ <% else %>
23
+ <%= link_to(download_text(document.download_types.first[0]), '', data: { download_path: "#{download_path(document[:layer_slug_s], type: document.download_types.first[0])}"}, class: 'btn btn-default') %>
38
24
  <% end %>
39
- <% if document.download_types.present? %>
40
- <li role="presentation" class="dropdown-header">Generated</li>
41
- <% document.download_types.each do |type| %>
42
- <%= content_tag(:li) do %>
43
- <% link_to(download_text(type[0]), '', data: { download_path: "#{download_path(document[:layer_slug_s], type: type[0])}" }) %>
44
- <% end %>
45
- <% end %>
46
- <% end %>
47
- </ul>
48
- </div>
49
- <% elsif document.restricted? && document.same_institution? %>
50
- <%= link_to t('geoblacklight.tools.login_to_view'), new_user_session_path(referrer: request.original_url) %>
51
- <% end %>
25
+ <button type='button' class='btn btn-default dropdown-toggle download-dropdown-toggle' data-toggle='dropdown' aria-expanded='false'>
26
+ <span class='caret'></span>
27
+ <span class='sr-only'>Toggle Download Dropdown</span>
28
+ </button>
29
+ <ul class='dropdown-menu' role='menu'>
30
+ <% unless document.direct_download.blank? %>
31
+ <li role="presentation" class="dropdown-header">Original</li>
32
+ <li>
33
+ <%= link_to(download_text(@document[:dc_format_s]), document.direct_download[:download], 'contentUrl' => document.direct_download[:download]) %>
34
+ </li>
35
+ <% end %>
36
+ <% if document.download_types.present? %>
37
+ <li role="presentation" class="dropdown-header">Generated</li>
38
+ <% document.download_types.each do |type| %>
39
+ <%= content_tag(:li) do %>
40
+ <% link_to(download_text(type[0]), '', data: { download_path: "#{download_path(document[:layer_slug_s], type: type[0])}" }) %>
41
+ <% end %>
42
+ <% end %>
43
+ <% end %>
44
+ </ul>
45
+ </div>
46
+ <% elsif document.restricted? && document.same_institution? %>
47
+ <%= link_to t('geoblacklight.tools.login_to_view'), new_user_session_path(referrer: request.original_url) %>
48
+ <% end %>
49
+ </div>
52
50
  </div>
53
51
  </div>
@@ -2,41 +2,41 @@
2
2
  <div class="geoblacklight-view-panel">
3
3
 
4
4
  <dl class="dl-horizontal">
5
- <% unless document['dct_provenance_s'].nil? %>
6
- <dt>Institution</dt>
7
- <dd><%= document['dct_provenance_s'] %></dd>
8
- <% end %>
9
- <% unless document['dc_creator_sm'].nil? %>
10
- <dt>Author</dt>
5
+ <% if document['dc_creator_sm'].present? %>
6
+ <dt>Authors</dt>
11
7
  <dd itemprop="author"><%= document['dc_creator_sm'].join(', ') %>&nbsp;</dd>
12
8
  <% end %>
13
- <% unless document['dc_publisher_s'].nil? %>
14
- <dt>Publisher</dt>
9
+ <%= render 'abstract_metadata' %>
10
+ <% if document['dc_publisher_s'].present? %>
11
+ <dt>Publishers</dt>
15
12
  <dd itemprop="publisher"><%= document['dc_publisher_s'] %>&nbsp;
16
13
  <% if document['dct_issued_s'].present? %>
17
- <div itemprop="datePublished">
14
+ <span itemprop="datePublished">
18
15
  (<%= document['dct_issued_s'] %>)
19
- </div>
16
+ </span>
20
17
  <% end %>
21
18
  </dd>
22
19
  <% end %>
23
- <%= render 'abstract_metadata' %>
24
- <% unless document['dct_isPartOf_sm'].nil? %>
25
- <dt>Collection</dt>
20
+ <% if document['dct_isPartOf_sm'].present? %>
21
+ <dt>Collections</dt>
26
22
  <dd itemprop="isPartOf"><%= document['dct_isPartOf_sm'].sort.uniq.join(', ') %>&nbsp;</dd>
27
23
  <% end %>
28
- <% unless document['dct_spatial_sm'].nil? %>
24
+ <% if document['dct_spatial_sm'].present? %>
29
25
  <dt>Places</dt>
30
26
  <dd itemprop="spatial"><%= render_facet_links('dct_spatial_sm', document['dct_spatial_sm']) %>&nbsp;</dd>
31
27
  <% end %>
32
- <% unless document['dc_subject_sm'].nil? %>
28
+ <% if document['dc_subject_sm'].present? %>
33
29
  <dt>Subjects</dt>
34
30
  <dd itemprop="keywords"><%= render_facet_links('dc_subject_sm', document['dc_subject_sm']) %>&nbsp;</dd>
35
31
  <% end %>
36
- <% unless document['dct_temporal_sm'].nil? %>
32
+ <% if document['dct_temporal_sm'].present? %>
37
33
  <dt>Years</dt>
38
34
  <dd itemprop="temporal"><%= document['dct_temporal_sm'].sort.uniq.join(', ') %>&nbsp;</dd>
39
35
  <% end %>
36
+ <% if document['dct_provenance_s'].present? %>
37
+ <dt>Held by</dt>
38
+ <dd><%= document['dct_provenance_s'] %></dd>
39
+ <% end %>
40
40
  <% if !@document.references.nil? && !@document.references.url.nil? %>
41
41
  <dt>More details at</dt>
42
42
  <dd itemprop="url"><%= link_to @document.references.url.endpoint, @document.references.url.endpoint %></dd>
@@ -1,4 +1,13 @@
1
+ # Institution deployed at
1
2
  INSTITUTION: 'Stanford'
3
+
4
+ # (For external Download) timeout and open_timeout parameters for Faraday
5
+ TIMEOUT_DOWNLOAD: 16
6
+
7
+ # (For WMS inspection) timeout and open_timeout parameters for Faraday
8
+ TIMEOUT_WMS: 4
9
+
10
+ # WMS Parameters
2
11
  WMS_PARAMS:
3
12
  :SERVICE: 'WMS'
4
13
  :VERSION: '1.1.1'
@@ -30,6 +30,9 @@ class Download
30
30
 
31
31
  def create_download_file
32
32
  download = initiate_download
33
+ unless download.present?
34
+ raise Geoblacklight::Exceptions::ExternalDownloadFailed
35
+ end
33
36
  File.open("#{file_path}.tmp", 'wb') do |file|
34
37
  if download.headers['content-type'] == @options[:content_type]
35
38
  file.write download.body
@@ -39,6 +42,9 @@ class Download
39
42
  end
40
43
  File.rename("#{file_path}.tmp", file_path)
41
44
  file_name
45
+ rescue Geoblacklight::Exceptions::ExternalDownloadFailed
46
+ Geoblacklight.logger.error 'Download from external server failed'
47
+ nil
42
48
  rescue Geoblacklight::Exceptions::WrongDownloadFormat => error
43
49
  Geoblacklight.logger.error "#{error} expected #{@options[:content_type]} received #{download.headers['content-type']}"
44
50
  File.delete("#{file_path}.tmp")
@@ -52,15 +58,15 @@ class Download
52
58
  conn.get do |request|
53
59
  request.params = @options[:request_params]
54
60
  request.options = {
55
- timeout: 16,
56
- open_timeout: 16
61
+ timeout: Settings.TIMEOUT_DOWNLOAD,
62
+ open_timeout: Settings.TIMEOUT_DOWNLOAD
57
63
  }
58
64
  end
59
65
  rescue Faraday::Error::ConnectionFailed => error
60
- Geoblacklight.logger.error error
66
+ Geoblacklight.logger.error error.inspect
61
67
  nil
62
68
  rescue Faraday::Error::TimeoutError => error
63
- Geoblacklight.logger.error error
69
+ Geoblacklight.logger.error error.inspect
64
70
  nil
65
71
  end
66
72
  end
@@ -1,5 +1,7 @@
1
1
  module Geoblacklight
2
2
  module Exceptions
3
+ class ExternalDownloadFailed < StandardError
4
+ end
3
5
  class WrongDownloadFormat < StandardError
4
6
  end
5
7
  end
@@ -1,3 +1,3 @@
1
1
  module Geoblacklight
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
@@ -25,14 +25,16 @@ class WmsLayer
25
25
  conn.get do |request|
26
26
  request.params = search_params
27
27
  request.options = {
28
- timeout: 2,
29
- open_timeout: 2
28
+ timeout: Settings.TIMEOUT_WMS,
29
+ open_timeout: Settings.TIMEOUT_WMS
30
30
  }
31
31
  end
32
32
  rescue Faraday::Error::ConnectionFailed => error
33
- { error: error }
33
+ Geoblacklight.logger.error error.inspect
34
+ { error: error.inspect }
34
35
  rescue Faraday::Error::TimeoutError => error
35
- { error: error }
36
+ Geoblacklight.logger.error error.inspect
37
+ { error: error.inspect }
36
38
  end
37
39
  end
38
40
  end
@@ -40,7 +40,7 @@ describe Download do
40
40
  end
41
41
  it 'should call create_download_file if it does not exist' do
42
42
  expect(download).to receive(:download_exists?).and_return(false)
43
- expect(download).to receive(:initiate_download).and_return('')
43
+ expect(download).to receive(:initiate_download).and_return(object: 'file')
44
44
  expect(File).to receive(:open).with("#{download.file_path}.tmp", 'wb').and_return('')
45
45
  expect(File).to receive(:rename)
46
46
  expect(download.get).to eq 'test-shapefile.zip'
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.3.3
4
+ version: 0.3.4
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: 2014-12-11 00:00:00.000000000 Z
14
+ date: 2014-12-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: blacklight