Parse mask icon from HTML
This commit is contained in:
parent
7be7e45493
commit
9042ca0b87
@ -92,8 +92,7 @@ module Manifique
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_icons_from_html
|
def parse_icons_from_html
|
||||||
icon_links = @html.css("link[rel=icon]")
|
if icon_links = @html.css("link[rel=icon]")
|
||||||
if icon_links.any?
|
|
||||||
icon_links.each do |link|
|
icon_links.each do |link|
|
||||||
icon = {}
|
icon = {}
|
||||||
icon["src"] = link.attributes["href"].value rescue nil
|
icon["src"] = link.attributes["href"].value rescue nil
|
||||||
@ -104,6 +103,15 @@ module Manifique
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if mask_icon_link = @html.at_css("link[rel=mask-icon]")
|
||||||
|
icon = { "purpose" => "mask-icon" }
|
||||||
|
icon["src"] = mask_icon_link.attributes["href"].value rescue nil
|
||||||
|
return if icon["src"].to_s.empty?
|
||||||
|
icon["type"] = link.attributes["type"].value rescue get_icon_type(icon["src"])
|
||||||
|
icon["color"] = mask_icon_link.attributes["color"].value rescue nil
|
||||||
|
@metadata.icons.push icon
|
||||||
|
end
|
||||||
|
|
||||||
@metadata.from_html.push "icons" unless @metadata.icons.empty?
|
@metadata.from_html.push "icons" unless @metadata.icons.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -170,6 +170,10 @@ RSpec.describe Manifique::WebClient do
|
|||||||
png_icons = subject.icons.select{|i| i["type"] == "image/png"}
|
png_icons = subject.icons.select{|i| i["type"] == "image/png"}
|
||||||
expect(png_icons.length).to eq(5)
|
expect(png_icons.length).to eq(5)
|
||||||
expect(subject.icons.find{|i| i["sizes"] == "512x512"}["src"]).to eq( "/application_icon_x512.png")
|
expect(subject.icons.find{|i| i["sizes"] == "512x512"}["src"]).to eq( "/application_icon_x512.png")
|
||||||
|
mask_icon = subject.icons.find{|i| i["purpose"] == "mask-icon"}
|
||||||
|
expect(mask_icon["color"]).to eq("#2b90d9")
|
||||||
|
expect(mask_icon["type"]).to eq("image/svg")
|
||||||
|
expect(mask_icon["sizes"]).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "knows which properties were loaded from HTML" do
|
it "knows which properties were loaded from HTML" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user