Skip to content

Commit

Permalink
Move pul and vatican logos to public directory
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Sep 13, 2024
1 parent bb34747 commit cedcb54
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
11 changes: 7 additions & 4 deletions app/services/manifest_builder/logo_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
11 changes: 7 additions & 4 deletions app/services/manifest_builder_v3/logo_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -25,17 +23,22 @@ 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
"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

def logo
{
"id" => ActionController::Base.helpers.image_url(logo_url, host: @host),
"id" => logo_url,
"type" => "Image",
"format" => "image/png",
"height" => 100,
Expand Down
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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="
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit cedcb54

Please sign in to comment.