2022-07-18 06:30:45 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ManifestsController < ApplicationController
|
|
|
|
include ThemeHelper
|
|
|
|
|
|
|
|
def show
|
|
|
|
render json: {
|
|
|
|
name: APP_CONFIG["site_name"],
|
2022-07-31 14:19:42 -07:00
|
|
|
description: t("about.about.subtitle"),
|
2022-07-18 06:30:45 -07:00
|
|
|
start_url: root_url(source: "pwa"),
|
|
|
|
scope: root_url,
|
|
|
|
display: "standalone",
|
|
|
|
categories: %w[social],
|
|
|
|
lang: I18n.locale,
|
|
|
|
shortcuts: [
|
2022-07-31 13:55:03 -07:00
|
|
|
webapp_shortcut(inbox_url, t("navigation.inbox"), "inbox")
|
2022-07-18 06:30:45 -07:00
|
|
|
],
|
|
|
|
icons: webapp_icons,
|
|
|
|
theme_color: theme_color,
|
|
|
|
background_color: mobile_theme_color
|
|
|
|
}
|
|
|
|
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|
|
|
|
|
[
|
2023-01-21 03:30:52 -08:00
|
|
|
{ src: "/icons/icon_x#{size}.webp", size: "#{size}x#{size}", type: "image/webp" },
|
|
|
|
{ src: "/icons/icon_x#{size}.png", size: "#{size}x#{size}", type: "image/png" }
|
2022-07-18 06:30:45 -07:00
|
|
|
]
|
|
|
|
end.flatten
|
|
|
|
end
|
|
|
|
end
|