-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
significant updates to the way item level documents are handled
- Loading branch information
1 parent
5477eaa
commit 4325852
Showing
15 changed files
with
199 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Blacklight.onLoad(function() { | ||
$('[data-map="item"]').each(function(i, element) { | ||
var layerMap = new GeoBlacklight.Item(element); | ||
}); | ||
}); | ||
|
||
GeoBlacklight.Item = function(element) { | ||
var _this = this; | ||
_this.element = element; | ||
L.extend(_this, GeoBlacklight.setupMap(element)); | ||
_this.map.options.catalogPath = _this.dataAttributes.catalogPath; | ||
_this.layer = new L.layerGroup() | ||
.addTo(_this.map); | ||
if (_this.dataAttributes.available) { | ||
_this.addPreviewLayer(); | ||
} else { | ||
_this.addBboxLayer(); | ||
} | ||
}; | ||
|
||
GeoBlacklight.Item.prototype = { | ||
addPreviewLayer: function() { | ||
var _this = this; | ||
_this.wmsLayer = L.tileLayer.wms(_this.dataAttributes.wmsUrl, { | ||
layers: _this.dataAttributes.layerId, | ||
format: 'image/png', | ||
transparent: true, | ||
tiled: true, | ||
CRS: 'EPSG:900913', | ||
opacity: 0.75 | ||
}); | ||
_this.layer.addLayer(_this.wmsLayer); | ||
}, | ||
addBboxLayer: function() { | ||
var _this = this; | ||
_this.bounds = GeoBlacklight.bboxToBounds( | ||
_this.element.dataset.mapBbox | ||
); | ||
_this.bboxLayer = L.polygon([_this.bounds.getSouthWest(), _this.bounds.getSouthEast(), _this.bounds.getNorthEast(), _this.bounds.getNorthWest()]); | ||
_this.layer.addLayer(_this.bboxLayer); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<% document ||= @document %> | ||
<div class="geoblacklight-view-panel"> | ||
|
||
<dl class="dl-horizontal"> | ||
<% unless document['dc_creator_sm'].nil? %> | ||
<dt>Author</dt> | ||
<dd><%= document['dc_creator_sm'].join(', ') %> </dd> | ||
<% end %> | ||
<% unless document['dc_publisher_s'].nil? %> | ||
<dt>Publisher</dt> | ||
<dd><%= document['dc_publisher_s'] %> </dd> | ||
<% end %> | ||
<dt>Year</dt> | ||
<dd><%= document['solr_year_i'] %> </dd> | ||
<dt>Abstract</dt> | ||
<dd id=""><%= abstract_truncator(document['dc_description_s']) %> </dd> | ||
<% unless document['dct_isPartOf_sm'].nil? %> | ||
<dt>Collection</dt> | ||
<dd><%= document['dct_isPartOf_sm'].sort.join(', ') %> </dd> | ||
<% end %> | ||
<% if document['dct_provenance_s'] == 'Stanford' and not document['dc_identifier_s'].nil? %> | ||
<dt>Citation</dt> | ||
<dd><%= link_to document['dc_identifier_s'], document['dc_identifier_s'] %> </dd> | ||
<% end %> | ||
<% unless document['dct_spatial_sm'].nil? %> | ||
<dt>Places</dt> | ||
<dd><%= document['dct_spatial_sm'].sort.join(', ') %> </dd> | ||
<% end %> | ||
<% unless document['dc_subject_sm'].nil? %> | ||
<dt>Subjects</dt> | ||
<dd><%= document['dc_subject_sm'].sort.join(', ') %> </dd> | ||
<% end %> | ||
<% unless document['dct_temporal_sm'].nil? %> | ||
<dt>Years</dt> | ||
<dd><%= document['dct_temporal_sm'].sort.join(', ') %> </dd> | ||
<% end %> | ||
</dl> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RailsConfig.setup do |config| | ||
config.const_name = "Settings" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INSTITUTION: 'Stanford' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Geoblacklight | ||
# Extends Blacklight::Solr::Document for GeoBlacklight specific functionalit | ||
module SolrDocument | ||
extend Blacklight::Solr::Document | ||
|
||
def available? | ||
public? || same_institution? | ||
end | ||
|
||
def public? | ||
get(:dc_rights_s) == 'Public' | ||
end | ||
|
||
def same_institution? | ||
get(:dct_provenance_s) == Settings.Institution | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'spec_helper' | ||
|
||
feature 'Layer preview', js: true do | ||
scenario 'Restricted layer should show bounding box' do | ||
visit catalog_path('mit-us-ma-cambridge-s1consv-2007') | ||
expect(Nokogiri::HTML.parse(page.body).css('path').length).to eq 1 | ||
end | ||
|
||
scenario 'Public layer should show wms layer not bounding box' do | ||
visit catalog_path('mit-us-ma-e25zcta5dct-2000') | ||
expect(Nokogiri::HTML.parse(page.body).css('path').length).to eq 0 | ||
within '.leaflet-tile-pane' do | ||
expect(page).to have_css('.leaflet-layer', count: 2) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'spec_helper' | ||
|
||
describe Geoblacklight::SolrDocument do | ||
let(:document) { SolrDocument.new(document_attributes) } | ||
describe '#available?' do | ||
let(:document_attributes) { {} } | ||
describe 'a public document' do | ||
it 'should always be available' do | ||
allow(document).to receive('same_institution?').and_return(false) | ||
allow(document).to receive('public?').and_return(true) | ||
expect(document.available?).to be_truthy | ||
end | ||
end | ||
describe 'a restricted document' do | ||
describe 'should only be available if from same institution' do | ||
allow(document).to receive('same_institution?').and_return(true) | ||
allow(document).to receive('public?').and_return(false) | ||
expect(document.available?).to be_truthy | ||
end | ||
end | ||
end | ||
describe '#public?' do | ||
describe 'a public document' do | ||
let(:document_attributes) { { dc_rights_s: 'Public' } } | ||
it 'should be public' do | ||
expect(document.public?).to be_truthy | ||
end | ||
end | ||
describe 'a restricted resource' do | ||
let(:document_attributes) { { dc_rights_s: 'Restricted' } } | ||
it 'should not be public' do | ||
expect(document.public?).to be_falsey | ||
end | ||
end | ||
end | ||
describe '#same_institution?' do | ||
describe 'within the same institution' do | ||
let(:document_attributes) { { dct_provenance_s: 'Stanford' } } | ||
it 'should be true' do | ||
allow(Settings).to receive('Institution').and_return('Stanford') | ||
expect(document.same_institution?).to be_truthy | ||
end | ||
end | ||
describe 'within a different institution' do | ||
let(:document_attributes) { { dct_provenance_s: 'MIT' } } | ||
it 'should be false' do | ||
allow(Settings).to receive('Institution').and_return('Stanford') | ||
expect(document.same_institution?).to be_falsey | ||
end | ||
end | ||
end | ||
end |