Split up web app manifest action

This commit is contained in:
Karina Kwiatek 2022-07-17 11:10:29 +02:00 committed by Karina Kwiatek
parent 5e4819764a
commit c384dde809
2 changed files with 36 additions and 27 deletions

View File

@ -66,26 +66,35 @@ class StaticController < ApplicationController
categories: %w[social], categories: %w[social],
lang: I18n.locale, lang: I18n.locale,
shortcuts: [ shortcuts: [
webapp_shortcut(inbox_url, t("views.navigation.inbox"), "inbox")
],
icons: webapp_icons,
theme_color: theme_color,
background_color: mobile_theme_color,
}
end
private
def webapp_shortcut(url, name, icon_name)
{ {
name: t('views.navigation.inbox'), name: name,
url: inbox_url, url: url,
icons: [ icons: [
{ {
src: "/icons/shortcuts/inbox.svg", src: "/icons/shortcuts/#{icon_name}.svg",
sizes: "96x96" sizes: "96x96"
} }
] ]
} }
], end
icons: %i[1024 512 384 192 128 96 72 48].map do |size|
def webapp_icons
%i[1024 512 384 192 128 96 72 48].map do |size|
[ [
{ src: "/icons/maskable_icon_x#{size}.webp", size: "#{size}x#{size}", type: "image/webp" }, { src: "/icons/maskable_icon_x#{size}.webp", size: "#{size}x#{size}", type: "image/webp" },
{ src: "/icons/maskable_icon_x#{size}.png", size: "#{size}x#{size}", type: "image/png" } { src: "/icons/maskable_icon_x#{size}.png", size: "#{size}x#{size}", type: "image/png" }
] ]
end.flatten, end.flatten
theme_color: theme_color,
background_color: mobile_theme_color,
orientation: "any"
}
end end
end end

View File

@ -47,7 +47,7 @@ describe StaticController, type: :controller do
"site_name" => "Specspring", "site_name" => "Specspring",
"hostname" => "test.host", "hostname" => "test.host",
"https" => false, "https" => false,
"items_per_page" => 5, "items_per_page" => 5
}) })
end end