Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ AllCops:
- 'bin/*'
- 'config/**/*'
- 'vendor/**/*'
- 'Vagrantfile'

Style/Documentation:
Enabled: false

Metrics/MethodLength:
# WE WANT TO BRING THESE BACK WHEN WE HAVE THE BANDWIDTH TO REFACTOR
Layout/LineLength:
Enabled: false

Layout/LineLength:
Metrics/MethodLength:
Enabled: false

Metrics/BlockLength:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'blacklight'
Expand Down Expand Up @@ -25,8 +27,8 @@ gem 'uglifier'
# gem 'blacklight_range_limit'

group :development, :test do
gem 'byebug'
gem 'bundler-audit'
gem 'byebug'
gem 'capybara'
gem 'capybara-screenshot'
gem 'database_cleaner'
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path('config/application', __dir__)

Rails.application.load_tasks
16 changes: 8 additions & 8 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

# -*- mode: ruby -*-
# vi: set ft=ruby :
RUBY_V = File.open("./.ruby-version") { |f| f.read }.chomp
RUBY_V = File.open('./.ruby-version', &:read).chomp

Vagrant.configure(2) do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.hostname = "sdr-geoblacklight"
config.vm.synced_folder ".", "/vagrant/sdr"
config.vm.box = 'bento/ubuntu-16.04'
config.vm.hostname = 'sdr-geoblacklight'
config.vm.synced_folder '.', '/vagrant/sdr'

config.vm.network "forwarded_port", guest: 8983, host: 8983, auto_correct: true
config.vm.network "forwarded_port", guest: 3000, host: 3000, auto_correct: true
config.vm.network 'forwarded_port', guest: 8983, host: 8983, auto_correct: true
config.vm.network 'forwarded_port', guest: 3000, host: 3000, auto_correct: true

config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
config.vm.provider 'virtualbox' do |vb|
vb.memory = '1024'
end

$apt_script = <<-SCRIPT
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def after_sign_in_path_for(resource)
end

def current_user_dev
@current_user ||= User.find_by_username('admin') || User.new
@current_user_dev ||= User.find_by_username('admin') || User.new
end
alias current_user current_user_dev if Rails.env.development?

Expand Down
15 changes: 13 additions & 2 deletions app/controllers/concerns/nyu_slug_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@ module NyuSlugConcern
# NYU slugs ("nyu_2451_12345") and turn them into
# new style ("nyu-2451-12345")
def show
params[:id] = params[:id].gsub('_', '-') if /^nyu_\d{4}_\d{5}$/.match(params[:id])
@response, @document = fetch params[:id]
transform_id if /^nyu_\d{4}_\d{5}$/.match(params[:id])
@response, @document = fetch_document(params[:id])

respond_to do |format|
format.html { setup_next_and_previous_documents }
format.json { render json: { response: { document: @document } } }
additional_export_formats(@document, format)
end
end

private

def transform_id
params[:id].gsub!('_', '-')
end

def fetch_document(id)
fetch(id)
end
end
19 changes: 12 additions & 7 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
before_action :require_valid_omniauth, only: :nyulibraries

def nyulibraries
# Find existing or initialize new user,
# and save new attributes each time
@user = find_user_with_or_without_provider.first_or_initialize(attributes_from_omniauth)
@user.update_attributes(attributes_from_omniauth)

set_user
if @user.persisted?
sign_in_and_redirect @user, event: :authentication
logger.info(find_message(:success, kind: 'NYU Libraries'))
Expand All @@ -19,8 +15,8 @@ def nyulibraries
end
end

def find_user_with_or_without_provider
@find_user_with_or_without_provider ||= find_user_with_provider.present? ? find_user_with_provider : find_user_without_provider
def find_user
@find_user ||= find_user_with_provider.present? ? find_user_with_provider : find_user_without_provider
end

def find_user_with_provider
Expand Down Expand Up @@ -98,5 +94,14 @@ def omniauth_patron_status
def failure
redirect_to root_path
end

private

def set_user
# Find existing or initialize new user,
# and save new attributes each time
@user = find_user.first_or_initialize(attributes_from_omniauth)
@user.update_attributes(attributes_from_omniauth)
end
end
end
3 changes: 2 additions & 1 deletion app/models/concerns/multi_download_concern.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

module MultiDownloadConcern
extend Geoblacklight::SolrDocument

def multi_direct_downloads
NyuGeoblacklight::MultiDirectDownloads.new(self).downloads
end

end
7 changes: 3 additions & 4 deletions app/models/concerns/rights_concern.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# frozen_string_literal: true

module RightsConcern
extend Geoblacklight::SolrDocument

def rights_text
if nyu? && restricted?
"This dataset is only available to members of the <b>New York University</b> community and is limited to <em>current</em> students, staff, and faculty. Do not copy or redistribute this data. If you have questions about what constitutes fair use of this material, please contact us directly at <a href='mailto:data.services@nyu.edu'>data.services@nyu.edu</a>."
end
"This dataset is only available to members of the <b>New York University</b> community and is limited to <em>current</em> students, staff, and faculty. Do not copy or redistribute this data. If you have questions about what constitutes fair use of this material, please contact us directly at <a href='mailto:data.services@nyu.edu'>data.services@nyu.edu</a>." if nyu? && restricted?
end

def nyu?
fetch(:dct_provenance_s).downcase == 'nyu'
end

end
12 changes: 6 additions & 6 deletions app/models/concerns/wms_rewrite_concern.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
require 'open-uri'
str = "\x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a".force_encoding('ASCII-8BIT')
# frozen_string_literal: true

require 'open-uri'
module WmsRewriteConcern
extend Geoblacklight::SolrDocument

def viewer_endpoint
if is_nyu_restricted?
'http://proxy.library.nyu.edu/login?url=https://maps-restricted.geo.nyu.edu/geoserver/sdr/wms?'
if nyu_restricted?
'http://proxy.library.nyu.edu/login?url=https://maps-restricted.geo.nyu.edu/geoserver/sdr/wms?'
else
super
end
end

def is_nyu_restricted?
def nyu_restricted?
nyu? && restricted?
end

def nyu?
fetch(:dct_provenance_s).downcase == 'nyu'
end
end
end
2 changes: 2 additions & 0 deletions app/models/search_builder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
include Geoblacklight::SpatialSearchBehavior
Expand Down
11 changes: 5 additions & 6 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding : utf-8 -*-
class SolrDocument
# frozen_string_literal: true

class SolrDocument
include Blacklight::Solr::Document
include Geoblacklight::SolrDocument
include WmsRewriteConcern
Expand All @@ -10,16 +10,15 @@ class SolrDocument
self.unique_key = 'layer_slug_s'

# Email uses the semantic field mappings below to generate the body of an email.
SolrDocument.use_extension( Blacklight::Document::Email )
SolrDocument.use_extension(Blacklight::Document::Email)

# SMS uses the semantic field mappings below to generate the body of an SMS email.
SolrDocument.use_extension( Blacklight::Document::Sms )
SolrDocument.use_extension(Blacklight::Document::Sms)

# DublinCore uses the semantic field mappings below to assemble an OAI-compliant Dublin Core document
# Semantic mappings of solr stored fields. Fields may be multi or
# single valued. See Blacklight::Document::SemanticFields#field_semantics
# and Blacklight::Document::SemanticFields#to_semantic_values
# Recommendation: Use field names from Dublin Core
use_extension( Blacklight::Document::DublinCore)

use_extension(Blacklight::Document::DublinCore)
end
10 changes: 4 additions & 6 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
class User < ActiveRecord::Base

if Blacklight::Utils.needs_attr_accessible?
# frozen_string_literal: true

attr_accessible :email, :password, :password_confirmation
end
# Connects this user object to Blacklights Bookmarks.
class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation if Blacklight::Utils.needs_attr_accessible?
# Connects this user object to Blacklights Bookmarks.
include Blacklight::User
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
Expand Down
4 changes: 3 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path('config/environment', __dir__)
run Rails.application
40 changes: 17 additions & 23 deletions lib/nyugeoblacklight/curated_collections.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
module NyuGeoblacklight
class CuratedCollections

def CuratedCollections.collections
def self.collections
[
{title: "New York City Open Data", description: "A collection of datasets related to NYC infrastructure, real estate, transportation, and political geography", f: { "dc_rights_s" => ["Public"], "dct_spatial_sm" => ["New York, New York, United States"]}},
{title: "NYU Research Data", description: "Geospatial data submitted for preservation by NYU students, faculty, and staff", f: {"dct_isPartOf_sm" => ["NYU Research Data"]}},
#{title: "U.S. Census Data", description: "Datasets which package data from the U.S. Census, or American Community Survey, along with geographic boundaries", f: {"dct_isPartOf_sm" => ["United States Census Data"]}},
#{title: "Soviet Topographic Maps of the Arabian Peninsula", description: "Raster scans of Soviet military topographic maps produced in the late 1970s", f: { "dc_publisher_s" => ["Omni Resources (Firm)"]}}
{title: "Latin American Census Geodatabases", description: "ESRI Geodatabases of census data from Latin American countries", f: {"dct_isPartOf_sm" => ["Latin American Census Data"]}},
{title: "Vector Map 1 (VMap1) Layers", description: "Highly detailed vector layers depecting terrain, topology, transportation, and civil infrastructure", f: {"dct_isPartOf_sm" => ["VMap 1"]}},
{ title: 'New York City Open Data', description: 'A collection of datasets related to NYC infrastructure, real estate, transportation, and political geography', f: { 'dc_rights_s' => ['Public'], 'dct_spatial_sm' => ['New York, New York, United States'] } },
{ title: 'NYU Research Data', description: 'Geospatial data submitted for preservation by NYU students, faculty, and staff', f: { 'dct_isPartOf_sm' => ['NYU Research Data'] } },
{ title: 'Latin American Census Geodatabases', description: 'ESRI Geodatabases of census data from Latin American countries', f: { 'dct_isPartOf_sm' => ['Latin American Census Data'] } },
{ title: 'Vector Map 1 (VMap1) Layers', description: 'Highly detailed vector layers depecting terrain, topology, transportation, and civil infrastructure', f: { 'dct_isPartOf_sm' => ['VMap 1'] } }
]
end

def CuratedCollections.recent
def self.recent
[
#{title: "2019 Sunset Park LiDAR", description: "High-density LiDAR datasets of Sunset Park, Brooklyn, from Debra Laefer (NYU) and collaborators", f: {"dct_isPartOf_sm" => ["2019 Sunset Park LiDAR"]}},
{title: "2004 New York State Tax Parcels", description: "Point data on property ownership and land value", f: {"dct_isPartOf_sm" => ["NYS GIS Clearinghouse"]}},
{title: "2011 India Census Data", description: "Vector village-level demographic data from the 2011 India Census", f: { "dc_publisher_s" => ["ML InfoMap (Firm)"]}}
{ title: '2004 New York State Tax Parcels', description: 'Point data on property ownership and land value', f: { 'dct_isPartOf_sm' => ['NYS GIS Clearinghouse'] } },
{ title: '2011 India Census Data', description: 'Vector village-level demographic data from the 2011 India Census', f: { 'dc_publisher_s' => ['ML InfoMap (Firm)'] } }
]
end

def CuratedCollections.maps
def self.maps
[
{title: "2015 Aerial Laser and Photogrammetry Survey of Dublin", slug: "nyu-2451-38684"},
#{title: "2019 Aerial Lasar and Photogrammetry Survey of Sunset Park, Brooklyn", slug: "nyu-2451-60458"},
{title: "China: Ch'ang-sha Region", slug: "harvard-ams7810-s250-u54-nh49-16"},
{title: "1967 Communist China Agriculture", slug: "nyu-2451-36739"},
{title: "2015 New York City Real Estate Sales", slug: "nyu-2451-34678"},
{title: "1978 Soviet Map of Abu Dhabi", slug: "nyu-2451-34737"},
{title: "2015 MapPLUTO Brooklyn V. 1", slug: "nyu-2451-34521"},
{title: "100-Meter Resolution Land Cover of the Conterminous United States", slug: "stanford-wv372bn9329"},
{title: "2016 LION Single Line Map for New York City", slug: "nyu-2451-34565"}
{ title: '2015 Aerial Laser and Photogrammetry Survey of Dublin', slug: 'nyu-2451-38684' },
{ title: "China: Ch'ang-sha Region", slug: 'harvard-ams7810-s250-u54-nh49-16' },
{ title: '1967 Communist China Agriculture', slug: 'nyu-2451-36739' },
{ title: '2015 New York City Real Estate Sales', slug: 'nyu-2451-34678' },
{ title: '1978 Soviet Map of Abu Dhabi', slug: 'nyu-2451-34737' },
{ title: '2015 MapPLUTO Brooklyn V. 1', slug: 'nyu-2451-34521' },
{ title: '100-Meter Resolution Land Cover of the Conterminous United States', slug: 'stanford-wv372bn9329' },
{ title: '2016 LION Single Line Map for New York City', slug: 'nyu-2451-34565' }
]
end

end
end
14 changes: 4 additions & 10 deletions lib/nyugeoblacklight/multi_direct_downloads.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
module NyuGeoblacklight
# MultiDirectDownloads is a (NYU-specific) geoblacklight-schema parser for multi-direct-downloads field
class MultiDirectDownloads
#attr_reader :refs, :reference_field
attr_reader :downloads
def initialize(document, multi_downloads_field = Settings.FIELDS.MULTI_DOWNLOADS)
@document = document
@multi_downloads_field = multi_downloads_field
@downloads = parse_downloads.map{ |k,v| [k, v] }
@downloads = parse_downloads.map { |k, v| [k, v] }
end

def parse_downloads
downloads = {}
if @document[@multi_downloads_field].nil?
{}
else
downloads = JSON.parse(@document[@multi_downloads_field])
JSON.parse(@document[@multi_downloads_field])
end
end

def downloads
@downloads
end

end
end
end
Loading