2022-07-18 06:30:45 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ManifestsController < ApplicationController
|
|
|
|
include ThemeHelper
|
|
|
|
|
2023-01-27 14:08:12 -08:00
|
|
|
skip_before_action :banned?
|
|
|
|
skip_before_action :find_active_announcements
|
|
|
|
|
2022-07-18 06:30:45 -07:00
|
|
|
def show
|
2023-01-27 14:08:12 -08:00
|
|
|
expires_in 1.day
|
|
|
|
return if fresh_when current_user&.theme
|
|
|
|
|
2022-07-18 06:30:45 -07:00
|
|
|
render json: {
|
|
|
|
name: APP_CONFIG["site_name"],
|
2023-01-21 09:26:08 -08:00
|
|
|
description: t("about.index.subtitle"),
|
2023-01-21 09:23:40 -08:00
|
|
|
start_url: root_url,
|
2022-07-18 06:30:45 -07:00
|
|
|
scope: root_url,
|
|
|
|
display: "standalone",
|
|
|
|
categories: %w[social],
|
|
|
|
lang: I18n.locale,
|
2023-01-27 14:08:12 -08:00
|
|
|
shortcuts:,
|
2022-07-18 06:30:45 -07:00
|
|
|
icons: webapp_icons,
|
2023-01-27 14:08:12 -08:00
|
|
|
theme_color:,
|
2022-07-18 06:30:45 -07:00
|
|
|
background_color: mobile_theme_color
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-01-27 14:08:12 -08:00
|
|
|
def shortcuts = [
|
|
|
|
webapp_shortcut(inbox_url, t("navigation.inbox"), "inbox")
|
|
|
|
]
|
|
|
|
|
2022-07-18 06:30:45 -07:00
|
|
|
def webapp_shortcut(url, name, icon_name)
|
|
|
|
{
|
|
|
|
name: name,
|
|
|
|
url: url,
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: "/icons/shortcuts/#{icon_name}.svg",
|
|
|
|
sizes: "96x96"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def webapp_icons
|
2023-01-21 09:18:14 -08:00
|
|
|
%i[1024 512 384 192 144 128 96 72 48].map do |size|
|
2022-07-18 06:30:45 -07:00
|
|
|
[
|
2023-01-21 09:16:24 -08:00
|
|
|
{ src: "/icons/icon_x#{size}.webp", sizes: "#{size}x#{size}", type: "image/webp", purpose: "any" },
|
|
|
|
{ src: "/icons/icon_x#{size}.png", sizes: "#{size}x#{size}", type: "image/png", purpose: "any" },
|
|
|
|
{ src: "/icons/maskable_icon_x#{size}.webp", sizes: "#{size}x#{size}", type: "image/webp", purpose: "maskable" },
|
|
|
|
{ src: "/icons/maskable_icon_x#{size}.png", sizes: "#{size}x#{size}", type: "image/png", purpose: "maskable" }
|
2022-07-18 06:30:45 -07:00
|
|
|
]
|
|
|
|
end.flatten
|
|
|
|
end
|
|
|
|
end
|