Skip to content

Commit

Permalink
Merge branch 'release/5.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed May 17, 2024
2 parents e44c623 + 60e9551 commit fdbaa06
Show file tree
Hide file tree
Showing 15 changed files with 376 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ gem 'sitemap_generator', '~> 6.0.2'
gem 'appsignal'

# Allmaps
gem 'blacklight_allmaps'
gem 'blacklight_allmaps', "~> 0.4.0"

group :test do
gem 'm', '~> 1.5.0'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ GEM
ostruct (>= 0.3.2)
rails (>= 5.1, < 7.1)
view_component (~> 2.66)
blacklight_allmaps (0.2.0)
blacklight_allmaps (0.4.0)
blacklight (>= 7.25.2, < 9)
httparty (~> 0.20)
blacklight_range_limit (7.0.1)
Expand Down Expand Up @@ -807,7 +807,7 @@ DEPENDENCIES
axe-core-api
blacklight (~> 7.33.0)
blacklight_advanced_search!
blacklight_allmaps
blacklight_allmaps (~> 0.4.0)
blacklight_range_limit (~> 7.0.0)
blazer
bootsnap (~> 1.9.3)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Visit the [project wiki](https://github.com/BTAA-Geospatial-Data-Project/geoport

#### Release Version

B1G Geoportal Version v5.7.0 / GeoBlacklight v4.4.0 / GeoBlacklight Admin v0.4.1 (vite branch)
B1G Geoportal Version v5.8.0 / GeoBlacklight v4.4.0 / GeoBlacklight Admin v0.4.1 (vite branch)
2 changes: 1 addition & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//= require blacklight/blacklight

// Required by Blacklight::Allmaps
//= require blacklight/allmaps/blacklight-allmaps
//= require blacklight-allmaps/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js

// Geoportal
// Required by GeoBlacklight
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class CatalogController < ApplicationController

config.raw_endpoint.enabled = true

# Blacklight::Allmaps Viewer
config.default_solr_unique_key = "geomg_id_s"
config.default_georeferenced_field = "b1g_georeferenced_allmaps_b"

## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
config.default_solr_params = {
:start => 0,
Expand Down Expand Up @@ -152,6 +156,7 @@ class CatalogController < ApplicationController
config.add_facet_field Settings.FIELDS.ACCESS_RIGHTS, :label => 'Public/Restricted'
config.add_facet_field Settings.FIELDS.B1G_MEDIATOR, label: 'Institutional Access', limit: 15
config.add_facet_field Settings.FIELDS.GEOREFERENCED, label: 'Georeferenced'
config.add_facet_field Settings.FIELDS.B1G_GEOREFERENCED_ALLMAPS, label: 'Georeferenced via Allmaps Plugin'

# GEOBLACKLIGHT APPLICATION FACETS

Expand Down
9 changes: 9 additions & 0 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,13 @@ def sidecar_allmaps

sidecar
end

# Blacklight::Allmaps
def allmaps_georeferenced?
self.sidecar_allmaps.present? && self.sidecar_allmaps.annotated?
end

def allmaps_georeferenceable?
self.viewer_protocol == "iiif_manifest"
end
end
6 changes: 3 additions & 3 deletions app/views/catalog/_home_text.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Datasets
</h3>
<%= link_to "/?f%5Bgbl_resourceClass_sm%5D%5B%5D=Datasets" do %>
<%= image_tag('homepage/geospatial_data.png', {:class => "img-fluid img-thumbnail", :alt => "Geospatial Data"}) %>
<%= image_tag("homepage/geospatial_data.png", {:class => "img-fluid img-thumbnail", :alt => "Geospatial Data"}) %>
<% end %>
</div>

Expand Down Expand Up @@ -72,13 +72,13 @@

<div class="card-header">
<span class="facet-field-heading">
<a href="/about">About the BTAA Geoportal</a>
<a href="https://gin.btaa.org">About the BTAA Geoportal</a>
</span>
</div>

<div class="card-body">
<p>
<%= link_to 'https://gin.btaa.org' do %>
<%= link_to "https://gin.btaa.org" do %>
<%= image_tag('gin-cropped.png', {alt: "Big Ten Academic Alliance Logo", height: '80px'}) %>
<% end %>
</p>
Expand Down
3 changes: 2 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
require "rails/all"
require "blacklight/allmaps"


require "blacklight/allmaps/engine"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Geoblacklight
class Application < Rails::Application

config.railties_order = [:main_app, Blacklight::Allmaps::Engine, :all]

# Initialize configuration defaults for originally generated Rails version.
Expand Down
3 changes: 2 additions & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
Rails.application.config.assets.precompile += %w[application.js]

# Blacklight Allmaps
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'images')
Rails.application.config.assets.precompile += %w( blacklight/allmaps/allmaps-logo.svg )
Rails.application.config.assets.precompile += %w( blacklight/allmaps/allmaps-logo.svg )
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Rails.application.routes.draw do
get 'about', :to => redirect('https://sites.google.com/umn.edu/btaa-gdp/about')
get 'help', :to => redirect('https://sites.google.com/umn.edu/btaa-gdp/help')
get 'about', :to => redirect('https://gin.btaa.org/')
get 'help', :to => redirect('https://gin.btaa.org/guides/')
get 'robots.:format' => 'robots#robots'
get '/centroids.json', :to => redirect('/centroids.json')

Expand Down
6 changes: 3 additions & 3 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@

# Blacklight::Allmaps
# Harvest Maps
every :day, at: '3:30am', roles: [:app] do
every :day, at: '3:00am', roles: [:app] do
rake 'geoportal:allmaps:harvest'
end

# Populate the Georeferenced Facet
every :day, at: '5:30am', roles: [:app] do
rake 'blacklight_allmaps:index:gbl_georeferenced_facet'
every :day, at: '6:30am', roles: [:app] do
rake 'geoportal:allmaps:georeferenced_facet'
end
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ FIELDS:
:B1G_CODE: 'b1g_code_s'
:B1G_DATE_CREATED: 'date_created_dtsi'
:B1G_GEOMG_ID: 'geomg_id_s'
:B1G_GEOREFERENCED_ALLMAPS: 'b1g_georeferenced_allmaps_b'
:B1G_IMAGE: 'b1g_image_ss'
:B1G_LANGUAGE: 'b1g_language_sm'
:B1G_MEDIATOR: 'b1g_dct_mediator_sm'
Expand Down
77 changes: 76 additions & 1 deletion lib/tasks/geoportal.rake
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace :geoportal do
response = Blacklight.default_index.connection.get(
"select", params: {
q: "*:*", # all docs
fl: "id", # just id field
fl: "geomg_id_s, id", # just id field
cursorMark: cursor_mark, # use the cursor mark to handle paging
rows: 1000,
sort: "geomg_id_s asc" # must sort by id to use the cursor mark
Expand All @@ -119,5 +119,80 @@ namespace :geoportal do
cursor_mark = response["nextCursorMark"]
end
end

desc "Index - add Allmaps facet data to GeoBlacklight solr"
task georeferenced_facet: [:environment] do
# Steps
# 1. Use cursor to paginate all documents in Solr
# 2. Determine which documents have georeferenced data
# 3. Clean JSON for re-indexing
# 4. Add georeferenced values
# 5. Re-index the georeferenced documents

# 1. Get all the documents from Solr
cursor_mark = "*"
loop do
response = Blacklight.default_index.connection.get(
"select", params: {
q: "*:*", # all docs
fl: "*", # all fields
cursorMark: cursor_mark, # use the cursor mark to handle paging
rows: 1000,
sort: "#{CatalogController.blacklight_config.default_solr_unique_key} asc" # must sort by id to use the cursor mark
}
)

response["response"]["docs"].each do |doc|
# 2. Determine which documents have georeferenced data
solr_document = SolrDocument.find(doc[CatalogController.blacklight_config.default_solr_unique_key])

if solr_document.allmaps_georeferenced?
# 3. Clean JSON for re-indexing
keys_for_deletion = %w[
_version_
timestamp
solr_bboxtype
solr_bboxtype__minX
solr_bboxtype__minY
solr_bboxtype__maxX
solr_bboxtype__maxY
]

cleaned_doc = doc.except!(*keys_for_deletion)

# 4. Add georeferenced value
cleaned_doc["gbl_georeferenced_b"] = true
cleaned_doc["b1g_georeferenced_allmaps_b"] = true

# 5. Re-index the georeferenced documents
Blacklight.default_index.connection.add cleaned_doc

elsif solr_document.allmaps_georeferenceable?
# 3. Clean JSON for re-indexing
keys_for_deletion = %w[
_version_
timestamp
solr_bboxtype
solr_bboxtype__minX
solr_bboxtype__minY
solr_bboxtype__maxX
solr_bboxtype__maxY
]

cleaned_doc = doc.except!(*keys_for_deletion)

# 4. Add georeferenced value
cleaned_doc["b1g_georeferenced_allmaps_b"] = false

# 5. Re-index the georeferenced documents
Blacklight.default_index.connection.add cleaned_doc
end
end

break if response["nextCursorMark"] == cursor_mark # this means the result set is finished
cursor_mark = response["nextCursorMark"]
end
Blacklight.default_index.connection.commit
end
end
end
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@rails/ujs": "^7.0.7-2",
"@rails/webpacker": "^5.4.4",
"babel-loader": "^8.0.6",
"blacklight-allmaps": "^0.3.1",
"bloodhound-js": "^1.2.3",
"bootstrap": "^4.5.0",
"bootstrap-datepicker": "^1.10.0",
Expand Down
Loading

0 comments on commit fdbaa06

Please sign in to comment.