Skip to content

Commit

Permalink
StandardRB fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Jun 27, 2024
1 parent 7c14166 commit c55a71b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/assets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def index
Asset.where(parent_id: params[:q])
)
end

@pagy, @assets = pagy(scope, items: 20)
end

Expand Down
2 changes: 1 addition & 1 deletion app/jobs/geoblacklight_admin/delete_thumbnail_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module GeoblacklightAdmin
class DeleteThumbnailJob < ApplicationJob
queue_as do
queue = self.arguments.last
arguments.last
end

def perform(solr_document_id, bad_id = nil, queue = :priority)
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/geoblacklight_admin/store_image_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module GeoblacklightAdmin
class StoreImageJob < ApplicationJob
queue_as do
queue = self.arguments.last
queue_as do
arguments.last
end

def perform(solr_document_id, bad_id = nil, queue = :default)
Expand Down
4 changes: 2 additions & 2 deletions app/models/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def full_file_url
after_promotion :set_parent_dct_references_uri

def set_parent_dct_references_uri
GeoblacklightAdmin::SetParentDctReferencesUriJob.perform_later(self) if self.parent_id.present?
GeoblacklightAdmin::SetParentDctReferencesUriJob.perform_later(self) if parent_id.present?
end

# Before Destroy Callbacks
before_destroy :remove_parent_dct_references_uri

def remove_parent_dct_references_uri
GeoblacklightAdmin::RemoveParentDctReferencesUriJob.perform_later(self) if self.parent_id.present?
GeoblacklightAdmin::RemoveParentDctReferencesUriJob.perform_later(self) if parent_id.present?
end
end
62 changes: 31 additions & 31 deletions app/services/geoblacklight_admin/image_service/iiif_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module GeoblacklightAdmin
class ImageService
module IiifManifest
require 'down'
require 'json'
require "down"
require "json"

## IIIF Manifests are messy
# - some have a sequence
Expand All @@ -21,30 +21,30 @@ module IiifManifest
# ex. https://digital.library.illinois.edu/items/a07f9c70-994e-0134-2096-0050569601ca-8/manifest
#
# Iowa - No IIIF Manifests (that I know of)
#
#
# Maryland - No IIIF Manifests (that I know of)
#
#
# Michigan - IIIF Manifests have thumbnail entries
# ex. https://quod.lib.umich.edu/cgi/i/image/api/search/clark1ic:003287878
#
#
# Michigan State -
# ex. https://d.lib.msu.edu/maps/1084/manifest
#
#
# Minnesota
# ex. https://cdm16022.contentdm.oclc.org/iiif/info/p16022coll205/265/manifest.json
#
#
# Nebraska -
# ex. https://mediacommons.unl.edu/luna/servlet/iiif/m/RUMSEY~8~1~317895~90086920/manifest
#
#
# Northwestern -
# ex. https://api.dc.library.northwestern.edu/api/v2/works/183249d3-aff6-40d5-b445-8f70addedcc3?as=iiif
#
#
# Ohio State - IIIF Manifests do not have thumbnail entries
# ex. https://library.osu.edu/dc/concern/generic_works/9k41zr126/manifest
#
#
# Penn State -
# ex. https://digital.libraries.psu.edu/iiif/2/maps1:30183/manifest.json
#
#
# Rutgers - No IIIF Manifests (that I know of)
#

Expand All @@ -55,55 +55,55 @@ module IiifManifest
# @return [String] iiif thumbnail url
def self.image_url(document, _size)
Rails.logger.debug("\n\nViewer Endpoint: #{document.viewer_endpoint}")

begin
tempfile = Down.download(document.viewer_endpoint)
manifest_json = JSON.parse(tempfile.read)

# Sequences - Return the first image if it exists
# - best case option
if manifest_json.dig('sequences',0,'canvases',0,'images',0,'resource','@id')
if manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id")
Rails.logger.debug("\n Image: sequences \n")
if manifest_json.dig('sequences',0,'canvases',0,'images',0,'resource', '@id').include?("osu")
if manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id").include?("osu")
Rails.logger.debug("\n Image: sequences - OSU variant \n")
manifest_json.dig('sequences',0,'canvases',0,'images',0,'resource', 'service','@id') + "/full/1000,/0/default.jpg"
manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "service", "@id") + "/full/1000,/0/default.jpg"
else
manifest_json.dig('sequences',0,'canvases',0,'images',0,'resource','@id')
manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id")
end

# Items - Return the first item image if it exists
# - Northwestern
elsif manifest_json.dig("items",0,"items",0,"items",0,"body","id")
elsif manifest_json.dig("items", 0, "items", 0, "items", 0, "body", "id")
Rails.logger.debug("\n Image: items body id \n")
manifest_json.dig("items",0,"items",0,"items",0,"body","id")
manifest_json.dig("items", 0, "items", 0, "items", 0, "body", "id")

# Items - Return the first item image if it exists
# - strange option
elsif manifest_json.dig('items',0,'items',0,'items',0,'id')
elsif manifest_json.dig("items", 0, "items", 0, "items", 0, "id")
Rails.logger.debug("\n Image: items id \n")
manifest_json.dig('items',0,'items',0,'items',0,'id')
manifest_json.dig("items", 0, "items", 0, "items", 0, "id")

# Thumbnail - Return the "thumbnail" if it exists
# - varies in size depending on the provider
# - worst case option really
# - can be @id or id
elsif manifest_json['thumbnail']
elsif manifest_json["thumbnail"]
Rails.logger.debug("\n Image: thumbnail \n")
if manifest_json.dig('thumbnail','@id')
manifest_json.dig('thumbnail','@id')
else manifest_json.dig('thumbnail','id')
manifest_json.dig('thumbnail','id')
if manifest_json.dig("thumbnail", "@id")
manifest_json.dig("thumbnail", "@id")
else
manifest_json.dig("thumbnail", "id")
manifest_json.dig("thumbnail", "id")
end

# Fail - Gonna fail
else
Rails.logger.debug("\n Image: failed \n")
"#{document.viewer_endpoint}"
document.viewer_endpoint
end

rescue => e
Rails.logger.debug("\n Rescued: #{e.inspect} \n")
"#{document.viewer_endpoint}"
document.viewer_endpoint
end
end
end
Expand Down

0 comments on commit c55a71b

Please sign in to comment.