From cedcb54b5431a56b27d621a05f970ccaedc1beef Mon Sep 17 00:00:00 2001 From: Eliot Jordan Date: Fri, 13 Sep 2024 11:24:00 -0500 Subject: [PATCH] Move pul and vatican logos to public directory --- app/services/manifest_builder/logo_builder.rb | 11 +++++++---- app/services/manifest_builder_v3/logo_builder.rb | 11 +++++++---- {app/assets/images => public}/pul_logo_icon.png | Bin {app/assets/images => public}/vatican.png | Bin .../manifest_builder_scanned_resource_spec.rb | 4 ++-- .../manifest_builder_v3_audio_resource_spec.rb | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) rename {app/assets/images => public}/pul_logo_icon.png (100%) rename {app/assets/images => public}/vatican.png (100%) diff --git a/app/services/manifest_builder/logo_builder.rb b/app/services/manifest_builder/logo_builder.rb index fd2c5509ff..820292f5d4 100644 --- a/app/services/manifest_builder/logo_builder.rb +++ b/app/services/manifest_builder/logo_builder.rb @@ -7,12 +7,10 @@ class LogoBuilder # @param [Resource] resource the Resource being viewed def initialize(record) @record = record - protocol = /localhost/.match?(Figgy.default_url_options[:host]) ? "http" : "https" - @host = "#{protocol}://#{Figgy.default_url_options[:host]}" end def apply(manifest) - manifest["logo"] = ActionController::Base.helpers.image_url(logo, host: @host) + manifest["logo"] = logo_url manifest end @@ -22,12 +20,17 @@ def resource_logo Array.wrap(@record.resource.rights_statement) end - def logo + def logo_file if @record.resource.respond_to?(:rights_statement) && resource_logo.include?(RDF::URI("http://cicognara.org/microfiche_copyright")) "vatican.png" else "pul_logo_icon.png" end end + + def logo_url + protocol = /localhost/.match?(Figgy.default_url_options[:host]) ? "http" : "https" + "#{protocol}://#{Figgy.default_url_options[:host]}/#{logo_file}" + end end end diff --git a/app/services/manifest_builder_v3/logo_builder.rb b/app/services/manifest_builder_v3/logo_builder.rb index f9757c911e..f1908ac113 100644 --- a/app/services/manifest_builder_v3/logo_builder.rb +++ b/app/services/manifest_builder_v3/logo_builder.rb @@ -10,8 +10,6 @@ class LogoBuilder # @param [Resource] resource the Resource being viewed def initialize(record) @record = record - protocol = /localhost/.match?(Figgy.default_url_options[:host]) ? "http" : "https" - @host = "#{protocol}://#{Figgy.default_url_options[:host]}" end def apply(manifest) @@ -25,7 +23,7 @@ def resource_logo Array.wrap(@record.resource.rights_statement) end - def logo_url + def logo_file if @record.resource.respond_to?(:rights_statement) && resource_logo.include?(RDF::URI("http://cicognara.org/microfiche_copyright")) "vatican.png" else @@ -33,9 +31,14 @@ def logo_url end end + def logo_url + protocol = /localhost/.match?(Figgy.default_url_options[:host]) ? "http" : "https" + "#{protocol}://#{Figgy.default_url_options[:host]}/#{logo_file}" + end + def logo { - "id" => ActionController::Base.helpers.image_url(logo_url, host: @host), + "id" => logo_url, "type" => "Image", "format" => "image/png", "height" => 100, diff --git a/app/assets/images/pul_logo_icon.png b/public/pul_logo_icon.png similarity index 100% rename from app/assets/images/pul_logo_icon.png rename to public/pul_logo_icon.png diff --git a/app/assets/images/vatican.png b/public/vatican.png similarity index 100% rename from app/assets/images/vatican.png rename to public/vatican.png diff --git a/spec/services/manifest_builder/by_resource_type/manifest_builder_scanned_resource_spec.rb b/spec/services/manifest_builder/by_resource_type/manifest_builder_scanned_resource_spec.rb index b52ecb8ed9..19967df42c 100644 --- a/spec/services/manifest_builder/by_resource_type/manifest_builder_scanned_resource_spec.rb +++ b/spec/services/manifest_builder/by_resource_type/manifest_builder_scanned_resource_spec.rb @@ -135,7 +135,7 @@ def logical_structure(file_set_id) expect(output["thumbnail"]["@id"]).to eq "#{first_image['resource']['service']['@id']}/full/!200,150/0/default.jpg" expect(output["thumbnail"]["service"]["@id"]).to eq first_image["resource"]["service"]["@id"] expect(output["sequences"][0]["startCanvas"]).to eq canvas_id - expect(output["logo"]).to eq("https://www.example.com/assets/pul_logo_icon-5333765252f2b86e34cd7c096c97e79495fe4656c5f787c5510a84ee6b67afd8.png") + expect(output["logo"]).to eq("https://www.example.com/pul_logo_icon.png") expect(output["seeAlso"].length).to eq 2 expect(output["seeAlso"].last).to include "@id" => "https://catalog.princeton.edu/catalog/991234563506421.marcxml", "format" => "text/xml" @@ -150,7 +150,7 @@ def logical_structure(file_set_id) end it "provides the vatican logo" do output = manifest_builder.build - expect(output["logo"]).to eq("https://www.example.com/assets/vatican-2a0de5479c7ad0fcacf8e0bf4eccab9f963a5cfc3e0197051314c8d50969a478.png") + expect(output["logo"]).to eq("https://www.example.com/vatican.png") end end diff --git a/spec/services/manifest_builder_v3/by_resource_type/manifest_builder_v3_audio_resource_spec.rb b/spec/services/manifest_builder_v3/by_resource_type/manifest_builder_v3_audio_resource_spec.rb index c6fa82f2ac..f525b06eab 100644 --- a/spec/services/manifest_builder_v3/by_resource_type/manifest_builder_v3_audio_resource_spec.rb +++ b/spec/services/manifest_builder_v3/by_resource_type/manifest_builder_v3_audio_resource_spec.rb @@ -50,7 +50,7 @@ # pres 3 context is always an array expect(output["@context"]).to include "http://iiif.io/api/presentation/3/context.json" # logo is always an array - expect(output["logo"].first).to include("id" => "https://www.example.com/assets/pul_logo_icon-5333765252f2b86e34cd7c096c97e79495fe4656c5f787c5510a84ee6b67afd8.png") + expect(output["logo"].first).to include("id" => "https://www.example.com/pul_logo_icon.png") # Logical structure should be able to have nested and un-nested members. expect(output["structures"][0]["items"][0]["id"]).to include "#t=" expect(output["structures"][1]["items"][0]["items"][0]["id"]).to include "#t=" @@ -188,7 +188,7 @@ # This value rounds up/down based on mediainfo compilation, 0.255 vs 0.256 # is close enough for our purpose expect(canvases.first["items"][0]["items"][0]["body"]["duration"].to_s).to start_with "0.25" - expect(output["logo"].first).to include("id" => "https://www.example.com/assets/vatican-2a0de5479c7ad0fcacf8e0bf4eccab9f963a5cfc3e0197051314c8d50969a478.png", + expect(output["logo"].first).to include("id" => "https://www.example.com/vatican.png", "format" => "image/png", "height" => 100, "width" => 120,