Skip to content

Commit

Permalink
Update to GeoBlacklight v4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
thatbudakguy committed Mar 29, 2024
1 parent b4ffef8 commit 6d801a1
Show file tree
Hide file tree
Showing 41 changed files with 952 additions and 902 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end

gem 'blacklight', '~> 7.33'
gem 'rsolr' # required for Blacklight
gem "geoblacklight", '~> 3.8'
gem "geoblacklight", '~> 4.3'
gem 'faraday', '~> 2.0'
gem "devise"
gem "devise-guests", ">= 0.3.3"
Expand Down
24 changes: 18 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ GEM
capistrano-shared_configs
docile (1.4.0)
domain_name (0.6.20240107)
dry-cli (1.0.0)
erubi (1.12.0)
execjs (2.9.1)
factory_bot (6.2.1)
Expand Down Expand Up @@ -208,17 +209,19 @@ GEM
rsolr
sanitize
thor
geoblacklight (3.8.0)
blacklight (~> 7.8)
geoblacklight (4.3.0)
blacklight (~> 7.0)
coderay
config
deprecation
faraday (>= 1.0)
geo_combine (~> 0.8)
faraday (~> 2.0)
geo_combine (~> 0.9)
handlebars_assets
mime-types
rails (>= 5.2.4, < 7.1)
rails (>= 6.1, < 7.2)
rgeo-geojson
sprockets-rails (~> 3.0)
vite_rails (~> 3.0)
git (1.19.1)
addressable (~> 2.8)
rchardet (~> 1.8)
Expand Down Expand Up @@ -334,6 +337,8 @@ GEM
rack (>= 1.0, < 4)
rack-mini-profiler (2.3.4)
rack (>= 1.2.0)
rack-proxy (0.7.7)
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8.1)
Expand Down Expand Up @@ -498,6 +503,13 @@ GEM
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
vite_rails (3.0.17)
railties (>= 5.1, < 8)
vite_ruby (~> 3.0, >= 3.2.2)
vite_ruby (3.5.0)
dry-cli (>= 0.7, < 2)
rack-proxy (~> 0.6, >= 0.6.1)
zeitwerk (~> 2.2)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.1)
Expand Down Expand Up @@ -543,7 +555,7 @@ DEPENDENCIES
faraday (~> 2.0)
geo_combine (>= 0.9)
geo_monitor (~> 0.7)!
geoblacklight (~> 3.8)
geoblacklight (~> 4.3)
honeybadger
http
jbuilder (~> 2.5)
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/geoblacklight.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@import 'geoblacklight/geoblacklight';
@import 'leaflet-label';
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class ApplicationController < ActionController::Base
# Please be sure to impelement current_user and user_session. Blacklight depends on
# these methods in order to perform user specific actions.

before_action :allow_geoblacklight_params

layout :determine_layout if respond_to? :layout

# Prevent CSRF attacks by raising an exception.
Expand All @@ -14,4 +16,9 @@ class ApplicationController < ActionController::Base
def after_sign_out_path_for(_resource_or_scope)
'/Shibboleth.sso/Logout'
end

def allow_geoblacklight_params
# Blacklight::Parameters will pass these to params.permit
blacklight_config.search_state_fields.append(Settings.GBL_PARAMS)
end
end
233 changes: 136 additions & 97 deletions app/controllers/catalog_controller.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/helpers/earthworks_geoblacklight_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def render_constraints_filters(localized_params = params)

if localized_params[:featured]
value = localized_params[:featured].humanize.split.map(&:capitalize).join(' ')
path = search_action_path(remove_spatial_filter_group(:featured, localized_params))
path = search_action_path(localized_params)
content << render_constraint_element('Featured', value, remove: path)
end

Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/featured_content_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ def add_featured_content(solr_params)
# rubocop:disable Layout/LineLength
def scanned_maps_content_params
[
'layer_geom_type_s:Image OR layer_geom_type_s:"Paper Map"'
'gbl_resourceType_sm:Image OR gbl_resourceType_sm:"Paper Map"'
]
end

def geospatial_data_content_params
[
'-layer_geom_type_s:Image AND -layer_geom_type_s:"Paper Map" AND -layer_geom_type_s:Mixed AND -layer_geom_type_s:Table'
'-gbl_resourceType_sm:Image AND -gbl_resourceType_sm:"Paper Map" AND -gbl_resourceType_sm:Mixed AND -gbl_resourceType_sm:Table'
]
end

def census_data_content_params
[
'dc_title_ti:census OR dc_description_ti:census OR dc_publisher_ti:census OR dc_subject_tmi:census'
'dct_title_ti:census OR dct_description_ti:census OR dct_publisher_ti:census OR dct_subject_tmi:census'
]
end

def california_data_content_params
[
'dc_title_ti:california OR dc_description_ti:california OR dc_publisher_ti:california OR dc_subject_tmi:california'
'dct_title_ti:california OR dct_description_ti:california OR dct_publisher_ti:california OR dct_subject_tmi:california'
]
end
# rubocop:enable Layout/LineLength
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/status_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module StatusExtension
def update_index
data = [{
layer_availability_score_f: { set: layer.availability_score },
layer_slug_s: layer.slug
id: layer.id
}]
Indexer.new.solr_update(data)
end
Expand Down
10 changes: 1 addition & 9 deletions app/models/concerns/wms_rewrite_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@ module WmsRewriteConcern
extend Geoblacklight::SolrDocument

def viewer_endpoint
if is_stanford_restricted?
if stanford? && restricted?
# replace wms prefix with webauthed proxy
super.gsub(%r{.+?(?=/geoserver)}, Settings.PROXY_URL)
else
super
end
end

def is_stanford_restricted?
stanford? && restricted?
end

def stanford?
fetch(:dct_provenance_s).casecmp('stanford').zero?
end
end
16 changes: 1 addition & 15 deletions app/models/search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,8 @@ class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
include BlacklightRangeLimit::RangeLimitBuilder

include Geoblacklight::SpatialSearchBehavior
include Geoblacklight::SuppressedRecordsSearchBehavior
include ::FeaturedContentBehavior

self.default_processor_chain += %i[add_featured_content]

def add_spatial_params(solr_params)
if blacklight_params[:bbox]
solr_params[:bq] ||= []
solr_params[:bq] =
["#{Settings.GEOMETRY_FIELD}:\"IsWithin(#{envelope_bounds})\"^300"]
solr_params[:fq] ||= []
solr_params[:fq] <<
"#{Settings.GEOMETRY_FIELD}:\"Intersects(#{envelope_bounds})\""
end
solr_params
rescue Geoblacklight::Exceptions::WrongBoundingBoxFormat
solr_params
end
end
13 changes: 4 additions & 9 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ class SolrDocument
include RightsMetadataConcern
include WmsRewriteConcern

# self.unique_key = 'id'
self.unique_key = 'layer_slug_s'

field_semantics[:author] = :dc_creator_sm
field_semantics[:title] = :dc_title_s
field_semantics[:year] = :dct_temporal_sm
alias stanford? same_institution?

def institution
fetch(Settings.FIELDS.PROVENANCE)
fetch(Settings.FIELDS.PROVIDER, '')
end

def contact_email
Expand All @@ -25,11 +20,11 @@ def department
end

def collection?
fetch(Settings.FIELDS.GEOM_TYPE, nil) == 'Collection'
fetch(Settings.FIELDS.RESOURCE_CLASS, []).include? 'Collections'
end

def mixed?
fetch(Settings.FIELDS.GEOM_TYPE, nil) == 'Mixed'
fetch(Settings.FIELDS.RESOURCE_CLASS, []) == 'Other'
end

# Email uses the semantic field mappings below to generate the body of an email.
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/blacklight/base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
gtag('js', new Date());

const config = {};
<% if Settings.analytics_debug %>
<% if Settings.ANALYTICS_DEBUG %>
config.debug_mode = true
<% end %>

Expand Down
4 changes: 2 additions & 2 deletions config/locales/geoblacklight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ en:
home:
headline: 'Discover and download GIS data and maps'
relations:
ancestor: Item belongs to a collection
descendant: Collection items
member_of_ancestors: 'Item belongs to a collection'
member_of_descendants: 'Collection items'
Loading

0 comments on commit 6d801a1

Please sign in to comment.