diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 12e17907..9d96b1e5 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -58,34 +58,43 @@ class StaticController < ApplicationController def webapp_manifest render json: { - name: APP_CONFIG["site_name"], - description: t(".front.subtitle"), - start_url: root_url(source: "pwa"), - scope: root_url, - display: "standalone", - categories: %w[social], - lang: I18n.locale, - shortcuts: [ - { - name: t('views.navigation.inbox'), - url: inbox_url, - icons: [ - { - src: "/icons/shortcuts/inbox.svg", - sizes: "96x96" - } - ] - } + name: APP_CONFIG["site_name"], + description: t(".front.subtitle"), + start_url: root_url(source: "pwa"), + scope: root_url, + display: "standalone", + categories: %w[social], + lang: I18n.locale, + shortcuts: [ + webapp_shortcut(inbox_url, t("views.navigation.inbox"), "inbox") ], - 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}.png", size: "#{size}x#{size}", type: "image/png" } - ] - end.flatten, - theme_color: theme_color, + icons: webapp_icons, + theme_color: theme_color, background_color: mobile_theme_color, - orientation: "any" } end + + private + + def webapp_shortcut(url, name, icon_name) + { + name: name, + url: url, + icons: [ + { + src: "/icons/shortcuts/#{icon_name}.svg", + sizes: "96x96" + } + ] + } + end + + 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}.png", size: "#{size}x#{size}", type: "image/png" } + ] + end.flatten + end end diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb index e124fb3f..917fe404 100644 --- a/spec/controllers/static_controller_spec.rb +++ b/spec/controllers/static_controller_spec.rb @@ -47,7 +47,7 @@ describe StaticController, type: :controller do "site_name" => "Specspring", "hostname" => "test.host", "https" => false, - "items_per_page" => 5, + "items_per_page" => 5 }) end