geoblacklight 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/geoblacklight/modules/layer_opacity.js +11 -8
- data/app/assets/stylesheets/geoblacklight/_geoblacklight.css.scss +1 -0
- data/app/assets/stylesheets/geoblacklight/modules/item.css.scss +4 -0
- data/app/assets/stylesheets/geoblacklight/modules/layer_opacity.css.scss +42 -13
- data/app/assets/stylesheets/geoblacklight/modules/mixins.css.scss +5 -0
- data/app/helpers/geoblacklight_helper.rb +0 -1
- data/app/views/catalog/_show_sidebar.html.erb +18 -5
- data/app/views/shared/_header_navbar.html.erb +1 -1
- data/lib/geoblacklight.rb +5 -0
- data/lib/geoblacklight/constants.rb +18 -0
- data/lib/geoblacklight/reference.rb +21 -0
- data/lib/geoblacklight/references.rb +55 -0
- data/lib/geoblacklight/solr_document.rb +9 -1
- data/lib/geoblacklight/version.rb +1 -1
- data/lib/geoblacklight/view_helper_override.rb +1 -1
- data/spec/features/dct_references_generate.rb +100 -0
- data/spec/features/dct_references_spec.rb +77 -0
- data/spec/features/download_layer_spec.rb +23 -7
- data/spec/features/search_bar_spec.rb +12 -0
- data/spec/fixtures/test-dct-references1.json +38 -0
- data/spec/fixtures/test-dct-references2.json +41 -0
- data/spec/fixtures/test-dct-references3.json +45 -0
- data/spec/fixtures/test-dct-references4.json +60 -0
- data/spec/fixtures/test-dct-references5.json +57 -0
- data/spec/fixtures/test-dct-references6.json +52 -0
- data/spec/fixtures/test-dct-references7.json +42 -0
- data/spec/fixtures/test-dct-references8.json +46 -0
- data/spec/lib/geoblacklight/references_spec.rb +86 -0
- data/spec/lib/geoblacklight/{solr_document.rb → solr_document_spec.rb} +35 -2
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 988a3047b866166e07486f36a5ee3137d1ee8063
|
4
|
+
data.tar.gz: 81983cd641d63130d8c6aa22d65ac9ef4579724b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6332e409be975db18f3f3861551875207b6748f46bfe9e4f04996d1550f2183a7891acca52dbb8b0bb652ba94ccc526ef3f10f5393009b6ca862cbbff9596dc5
|
7
|
+
data.tar.gz: d86a9a17886bf0fbe309625ea03bb70d747392261798336cf023dfc8ae698207f304dddaeeafa685ad405723db54df0364667eafeb56790fc60160acd99d09fe
|
@@ -17,16 +17,19 @@
|
|
17
17
|
var container = L.DomUtil.create('div', 'opacity-control unselectable'),
|
18
18
|
controlArea = L.DomUtil.create('div', 'opacity-area', container),
|
19
19
|
handle = L.DomUtil.create('div', 'opacity-handle', container),
|
20
|
+
handleArrowUp = L.DomUtil.create('div', 'opacity-arrow-up', handle),
|
21
|
+
handleText = L.DomUtil.create('div', 'opacity-text', handle),
|
22
|
+
handleArrowDown = L.DomUtil.create('div', 'opacity-arrow-down', handle),
|
20
23
|
bottom = L.DomUtil.create('div', 'opacity-bottom', container);
|
21
24
|
|
22
25
|
L.DomEvent.disableClickPropagation(container);
|
23
|
-
this.setListeners(handle, bottom);
|
24
|
-
handle.style.top = handle.offsetTop -
|
25
|
-
|
26
|
+
this.setListeners(handle, bottom, handleText);
|
27
|
+
handle.style.top = handle.offsetTop - 13 + 50 + 'px';
|
28
|
+
handleText.innerHTML = parseInt(this.options.layer.options.opacity * 100) + '%';
|
26
29
|
return container;
|
27
30
|
},
|
28
31
|
|
29
|
-
setListeners: function(handle, bottom) {
|
32
|
+
setListeners: function(handle, bottom, handleText) {
|
30
33
|
var _this = this,
|
31
34
|
start = false,
|
32
35
|
startTop;
|
@@ -34,10 +37,10 @@
|
|
34
37
|
L.DomEvent.addListener(document, 'mousemove', function(e) {
|
35
38
|
if (!start) return;
|
36
39
|
var percentInverse = Math.max(0, Math.min(200, startTop + parseInt(e.clientY, 10) - start)) / 2;
|
37
|
-
handle.style.top = ((percentInverse * 2) -
|
38
|
-
|
39
|
-
bottom.style.height = Math.max(0, (((100 - percentInverse) * 2) -
|
40
|
-
bottom.style.top = Math.min(200, (percentInverse * 2) +
|
40
|
+
handle.style.top = ((percentInverse * 2) - 13) + 'px';
|
41
|
+
handleText.innerHTML = Math.round((1 - (percentInverse / 100)) * 100) + '%';
|
42
|
+
bottom.style.height = Math.max(0, (((100 - percentInverse) * 2) - 13)) + 'px';
|
43
|
+
bottom.style.top = Math.min(200, (percentInverse * 2) + 13) + 'px';
|
41
44
|
_this.options.layer.setOpacity(1 - (percentInverse / 100));
|
42
45
|
});
|
43
46
|
|
@@ -1,39 +1,68 @@
|
|
1
1
|
.leaflet-control.opacity-control {
|
2
2
|
background-color: #a9acb1;
|
3
3
|
border-radius: 15px;
|
4
|
+
color: black;
|
5
|
+
font: bold 18px 'Lucida Console', Monaco, monospace;
|
4
6
|
display: block;
|
5
7
|
height: 200px;
|
6
|
-
left:
|
8
|
+
left: 11px;
|
7
9
|
position: relative;
|
8
10
|
top: 15px;
|
9
11
|
width: 5px;
|
10
12
|
|
11
13
|
.opacity-handle {
|
12
14
|
background-color: #fff;
|
13
|
-
border-radius:
|
15
|
+
border-radius: 4px;
|
16
|
+
border: 1px solid #eee;
|
14
17
|
cursor: ns-resize;
|
15
18
|
font-size: 10px;
|
16
|
-
height:
|
17
|
-
left: -
|
18
|
-
line-height:
|
19
|
+
height: 26px;
|
20
|
+
left: -11px;
|
21
|
+
line-height: 26px;
|
19
22
|
position: absolute;
|
20
23
|
text-align: center;
|
21
24
|
top: 0;
|
22
|
-
width:
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
width: 26px;
|
26
|
+
@include map-control-shadow;
|
27
|
+
|
28
|
+
&:hover {
|
29
|
+
background-color: #f4f4f4;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
.opacity-arrow-up {
|
34
|
+
color: #aaa;
|
35
|
+
position: absolute;
|
36
|
+
top: -11px;
|
37
|
+
text-align: center;
|
38
|
+
width: 100%;
|
39
|
+
|
40
|
+
&:before {
|
41
|
+
content: '=';
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
.opacity-arrow-down {
|
46
|
+
bottom: -10px;
|
47
|
+
color: #aaa;
|
48
|
+
position: absolute;
|
49
|
+
text-align: center;
|
50
|
+
width: 100%;
|
51
|
+
|
52
|
+
&:before {
|
53
|
+
content: '=';
|
54
|
+
}
|
26
55
|
}
|
27
56
|
|
28
57
|
.opacity-bottom {
|
29
58
|
background-color: #017afd;
|
30
59
|
border-radius: 15px;
|
31
60
|
display: block;
|
32
|
-
height:
|
61
|
+
height: 137px;
|
33
62
|
left: 0px;
|
34
63
|
position: relative;
|
35
|
-
top:
|
36
|
-
width: 5px;
|
64
|
+
top: 63px;
|
65
|
+
width: 5px;
|
37
66
|
}
|
38
67
|
|
39
68
|
// Area underneath slider to prevent unintentioned map clicks
|
@@ -41,7 +70,7 @@
|
|
41
70
|
padding: 14px;
|
42
71
|
cursor: default;
|
43
72
|
height: 200px;
|
44
|
-
left: -
|
73
|
+
left: -11px;
|
45
74
|
position: absolute;
|
46
75
|
top: 0px;
|
47
76
|
width: 20px;
|
@@ -20,15 +20,28 @@
|
|
20
20
|
</ul>
|
21
21
|
<% if document_downloadable? %>
|
22
22
|
<div class='btn-group'>
|
23
|
-
|
24
|
-
Download
|
23
|
+
<% unless document.direct_download.blank? %>
|
24
|
+
<%= link_to("Download #{@document[:dc_format_s]}", document.direct_download[:download], class: 'btn btn-default') %>
|
25
|
+
<% else %>
|
26
|
+
<%= link_to("Download #{document.download_types.first[0].capitalize}", '', data: { download_path: "#{download_path(document[:layer_slug_s], type: document.download_types.first[0])}"}, class: 'btn btn-default') %>
|
25
27
|
<% end %>
|
26
|
-
<
|
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'>
|
33
|
+
<% unless document.direct_download.blank? %>
|
34
|
+
<li role="presentation" class="dropdown-header">Original</li>
|
35
|
+
<li>
|
36
|
+
<%= link_to("Download #{@document[:dc_format_s]}", document.direct_download[:download]) %>
|
37
|
+
</li>
|
38
|
+
<% end %>
|
39
|
+
<li role="presentation" class="dropdown-header">Projected</li>
|
27
40
|
<% document.download_types.each do |type| %>
|
28
41
|
<%= content_tag(:li) do %>
|
29
|
-
|
42
|
+
<% link_to("Download #{type[0].capitalize}", '', data: { download_path: "#{download_path(document[:layer_slug_s], type: type[0])}" }) %>
|
30
43
|
<% end %>
|
31
|
-
<% end %>
|
44
|
+
<% end %>
|
32
45
|
</ul>
|
33
46
|
</div>
|
34
47
|
<% elsif document.restricted? && document.same_institution? %>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
</div>
|
17
17
|
</div>
|
18
18
|
|
19
|
-
<%
|
19
|
+
<% if controller_name == 'catalog' && has_search_parameters? %>
|
20
20
|
<div id="search-navbar" class="navbar navbar-default navbar-static-top" role="navigation">
|
21
21
|
<div class="container">
|
22
22
|
<%= render_search_bar %>
|
data/lib/geoblacklight.rb
CHANGED
@@ -2,6 +2,7 @@ require "geoblacklight/engine"
|
|
2
2
|
|
3
3
|
module Geoblacklight
|
4
4
|
require 'geoblacklight/config'
|
5
|
+
require 'geoblacklight/constants'
|
5
6
|
require 'geoblacklight/controller_override'
|
6
7
|
require 'geoblacklight/view_helper_override'
|
7
8
|
require 'geoblacklight/solr_document'
|
@@ -9,9 +10,13 @@ module Geoblacklight
|
|
9
10
|
require 'geoblacklight/download'
|
10
11
|
require 'geoblacklight/download/shapefile_download'
|
11
12
|
require 'geoblacklight/download/kmz_download'
|
13
|
+
require 'geoblacklight/reference'
|
14
|
+
require 'geoblacklight/references'
|
12
15
|
def self.inject!
|
13
16
|
CatalogController.send(:include, Geoblacklight::ControllerOverride)
|
14
17
|
CatalogController.send(:include, Geoblacklight::ViewHelperOverride)
|
18
|
+
CatalogController.send(:helper, Geoblacklight::ViewHelperOverride) unless
|
19
|
+
CatalogController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
|
15
20
|
SearchHistoryController.send(:helper, Geoblacklight::ViewHelperOverride) unless
|
16
21
|
SearchHistoryController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
|
17
22
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Geoblacklight
|
2
|
+
# Module to declare application level constants and lookup hash
|
3
|
+
module Constants
|
4
|
+
URI = {
|
5
|
+
download: 'http://schema.org/downloadUrl',
|
6
|
+
fgdc: 'http://www.opengis.net/cat/csw/csdgm',
|
7
|
+
html: 'http://www.w3.org/1999/xhtml',
|
8
|
+
iiif: 'http://iiif.io/api/image',
|
9
|
+
iso19139: 'http://www.isotc211.org/schemas/2005/gmd/',
|
10
|
+
mods: 'http://www.loc.gov/mods/v3',
|
11
|
+
shapefile: 'http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf',
|
12
|
+
url: 'http://schema.org/url',
|
13
|
+
wcs: 'http://www.opengis.net/def/serviceType/ogc/wcs',
|
14
|
+
wfs: 'http://www.opengis.net/def/serviceType/ogc/wfs',
|
15
|
+
wms: 'http://www.opengis.net/def/serviceType/ogc/wms'
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Geoblacklight
|
2
|
+
class Reference
|
3
|
+
attr_reader :reference
|
4
|
+
|
5
|
+
def initialize(reference)
|
6
|
+
@reference = reference
|
7
|
+
end
|
8
|
+
|
9
|
+
def endpoint
|
10
|
+
@reference[1]
|
11
|
+
end
|
12
|
+
|
13
|
+
def type
|
14
|
+
Geoblacklight::Constants::URI.key(@reference[0])
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
{ type => endpoint }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Geoblacklight
|
2
|
+
# References is a geoblacklight-schema dct:references parser
|
3
|
+
class References
|
4
|
+
attr_reader :refs
|
5
|
+
def initialize(document)
|
6
|
+
@document = document
|
7
|
+
@refs = parse_references.map { |ref| Reference.new(ref) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(m, *args, &b)
|
11
|
+
if Geoblacklight::Constants::URI.key?(m)
|
12
|
+
references m
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def format
|
19
|
+
@document[:dc_format_s]
|
20
|
+
end
|
21
|
+
|
22
|
+
def references(ref_type)
|
23
|
+
@refs.find { |reference| reference.type == ref_type }
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_references
|
27
|
+
if @document[:dct_references_s].nil?
|
28
|
+
Hash.new
|
29
|
+
else
|
30
|
+
JSON.parse(@document[:dct_references_s])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def preferred_download
|
35
|
+
return file_download unless download.blank?
|
36
|
+
end
|
37
|
+
|
38
|
+
def file_download
|
39
|
+
{ file_download: download.to_hash }
|
40
|
+
end
|
41
|
+
|
42
|
+
def downloads_by_format
|
43
|
+
case format
|
44
|
+
when 'Shapefile'
|
45
|
+
{ shapefile: wfs.to_hash, kmz: wms.to_hash }
|
46
|
+
when 'GeoTIFF'
|
47
|
+
{ geotiff: wms.to_hash }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def download_types
|
52
|
+
downloads_by_format
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -20,7 +20,15 @@ module Geoblacklight
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def download_types
|
23
|
-
|
23
|
+
references.download_types
|
24
|
+
end
|
25
|
+
|
26
|
+
def references
|
27
|
+
References.new(self)
|
28
|
+
end
|
29
|
+
|
30
|
+
def direct_download
|
31
|
+
return references.download.to_hash unless references.download.blank?
|
24
32
|
end
|
25
33
|
|
26
34
|
def same_institution?
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'json'
|
3
|
+
require 'geoblacklight'
|
4
|
+
|
5
|
+
def do_write n, doc
|
6
|
+
unless File.size?("spec/fixtures/test-dct-references#{n}.json")
|
7
|
+
puts "Writing spec/fixtures/test-dct-references#{n}.json"
|
8
|
+
File.open("spec/fixtures/test-dct-references#{n}.json", 'wb') {|f| f << JSON.pretty_generate(doc) }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
URIs = Geoblacklight::Constants::URI
|
13
|
+
selected = JSON.parse(File.open('schema/examples/selected.json').read)
|
14
|
+
|
15
|
+
# scenario 'Case 1: Minimal case of HTML metadata only' do
|
16
|
+
doc = selected.sample
|
17
|
+
doc['dct_references_s'] = {
|
18
|
+
URIs[:html] => "http://example.com/#{doc['uuid']}/metadata.html"
|
19
|
+
}.to_json
|
20
|
+
do_write 1, doc
|
21
|
+
|
22
|
+
# scenario 'Case 2: Minimal case of FGDC metadata, a URL (homepage), and WMS tile server' do
|
23
|
+
doc = selected.sample
|
24
|
+
doc['dct_references_s'] = {
|
25
|
+
URIs[:fgdc] => "http://example.com/#{doc['uuid']}/fgdc.xml",
|
26
|
+
URIs[:url] => "http://example.com/#{doc['uuid']}/homepage",
|
27
|
+
URIs[:wms] => doc['solr_wms_url']
|
28
|
+
}.to_json
|
29
|
+
do_write 2, doc
|
30
|
+
|
31
|
+
# scenario 'Case 3: ISO & MODS metadata, a URL, and WMS tile server' do
|
32
|
+
doc = selected.sample
|
33
|
+
doc['dct_references_s'] = {
|
34
|
+
URIs[:iso19139] => "http://example.com/#{doc['uuid']}/iso19139.xml",
|
35
|
+
URIs[:mods] => "http://example.com/#{doc['uuid']}/mods.xml",
|
36
|
+
URIs[:url] => "http://example.com/#{doc['uuid']}/homepage",
|
37
|
+
URIs[:wms] => doc['solr_wms_url']
|
38
|
+
}.to_json
|
39
|
+
do_write 3, doc
|
40
|
+
|
41
|
+
# scenario 'Case 4: FGDC metadata and IIIF tile server' do
|
42
|
+
doc = selected.sample
|
43
|
+
doc['dct_references_s'] = {
|
44
|
+
URIs[:fgdc] => "http://example.com/#{doc['uuid']}/fgdc.xml",
|
45
|
+
URIs[:iiif] => "http://example.com/iiif"
|
46
|
+
}.to_json
|
47
|
+
do_write 4, doc
|
48
|
+
|
49
|
+
# scenario 'Case 5: ISO & MODS metadata, a URL, Shapefile ZIP and WFS, and WMS tile server' do
|
50
|
+
doc = selected.sample
|
51
|
+
while doc['dc_format_s'] != 'Shapefile'
|
52
|
+
doc = selected.sample
|
53
|
+
end
|
54
|
+
raise ArgumentError, doc['dc_format_s'] unless doc['dc_format_s'] == 'Shapefile'
|
55
|
+
doc['dct_references_s'] = {
|
56
|
+
URIs[:download] => "http://example.com/#{doc['uuid']}/data.zip",
|
57
|
+
URIs[:iso19139] => "http://example.com/#{doc['uuid']}/iso19139.xml",
|
58
|
+
URIs[:mods] => "http://example.com/#{doc['uuid']}/mods.xml",
|
59
|
+
URIs[:url] => "http://example.com/#{doc['uuid']}/homepage",
|
60
|
+
URIs[:wms] => doc['solr_wms_url'],
|
61
|
+
URIs[:wfs] => doc['solr_wfs_url']
|
62
|
+
}.to_json
|
63
|
+
do_write 5, doc
|
64
|
+
|
65
|
+
# scenario 'Case 6: ISO & MODS metadata, GeoTIFF ZIP and WCS, and WMS tile server' do
|
66
|
+
doc = selected.sample
|
67
|
+
while doc['dc_format_s'] != 'GeoTIFF'
|
68
|
+
doc = selected.sample
|
69
|
+
end
|
70
|
+
doc['dct_references_s'] = {
|
71
|
+
URIs[:download] => "http://example.com/#{doc['uuid']}/data.zip",
|
72
|
+
URIs[:iso19139] => "http://example.com/#{doc['uuid']}/iso19139.xml",
|
73
|
+
URIs[:mods] => "http://example.com/#{doc['uuid']}/mods.xml",
|
74
|
+
URIs[:wms] => doc['solr_wms_url'],
|
75
|
+
URIs[:wcs] => doc['solr_wcs_url']
|
76
|
+
}.to_json
|
77
|
+
do_write 6, doc
|
78
|
+
|
79
|
+
# scenario 'Case 7: No metadata, GeoJSON'
|
80
|
+
doc = selected.sample
|
81
|
+
while doc['dc_format_s'] != 'Shapefile'
|
82
|
+
doc = selected.sample
|
83
|
+
end
|
84
|
+
doc['dct_references_s'] = {
|
85
|
+
URIs[:download] => "http://example.com/#{doc['uuid']}/data.json"
|
86
|
+
}.to_json
|
87
|
+
do_write 7, doc
|
88
|
+
|
89
|
+
# scenario 'Case 8: HTML metadata and WMS tile server'
|
90
|
+
doc = selected.sample
|
91
|
+
doc['dct_references_s'] = {
|
92
|
+
URIs[:html] => "http://example.com/#doc['uuid']/metadata.html",
|
93
|
+
URIs[:wms] => doc['solr_wms_url']
|
94
|
+
}.to_json
|
95
|
+
do_write 8, doc
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|