2017-10-02 10:23:32 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ManifestSerializer < ActiveModel::Serializer
|
|
|
|
include RoutingHelper
|
|
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
|
2022-06-10 06:25:23 +10:00
|
|
|
ICON_SIZES = %w(
|
|
|
|
36
|
|
|
|
48
|
|
|
|
72
|
|
|
|
96
|
|
|
|
144
|
|
|
|
192
|
|
|
|
256
|
|
|
|
384
|
|
|
|
512
|
|
|
|
).freeze
|
|
|
|
|
|
|
|
attributes :name, :short_name,
|
2017-10-02 10:23:32 +11:00
|
|
|
:icons, :theme_color, :background_color,
|
2018-01-18 03:08:10 +11:00
|
|
|
:display, :start_url, :scope,
|
2020-12-15 12:04:56 +11:00
|
|
|
:share_target, :shortcuts
|
2017-10-02 10:23:32 +11:00
|
|
|
|
|
|
|
def name
|
2022-10-05 12:47:56 +11:00
|
|
|
object.title
|
2017-10-02 10:23:32 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def short_name
|
2022-10-05 12:47:56 +11:00
|
|
|
object.title
|
2017-10-02 10:23:32 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def icons
|
2022-06-10 06:25:23 +10:00
|
|
|
ICON_SIZES.map do |size|
|
2017-10-02 10:23:32 +11:00
|
|
|
{
|
2022-06-10 06:25:23 +10:00
|
|
|
src: full_pack_url("media/icons/android-chrome-#{size}x#{size}.png"),
|
|
|
|
sizes: "#{size}x#{size}",
|
2017-10-02 10:23:32 +11:00
|
|
|
type: 'image/png',
|
2022-06-10 06:25:23 +10:00
|
|
|
}
|
|
|
|
end
|
2017-10-02 10:23:32 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def theme_color
|
2022-06-10 06:25:23 +10:00
|
|
|
'#6364FF'
|
2017-10-02 10:23:32 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def background_color
|
|
|
|
'#191b22'
|
|
|
|
end
|
|
|
|
|
|
|
|
def display
|
|
|
|
'standalone'
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_url
|
2022-03-31 20:20:26 +11:00
|
|
|
'/web/home'
|
2017-10-02 10:23:32 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def scope
|
2021-09-09 07:33:36 +10:00
|
|
|
'/'
|
2017-10-02 10:23:32 +11:00
|
|
|
end
|
2018-01-18 03:08:10 +11:00
|
|
|
|
|
|
|
def share_target
|
2019-02-02 11:26:49 +11:00
|
|
|
{
|
|
|
|
url_template: 'share?title={title}&text={text}&url={url}',
|
|
|
|
action: 'share',
|
2019-09-05 23:51:51 +10:00
|
|
|
method: 'GET',
|
|
|
|
enctype: 'application/x-www-form-urlencoded',
|
2019-02-02 11:26:49 +11:00
|
|
|
params: {
|
|
|
|
title: 'title',
|
|
|
|
text: 'text',
|
|
|
|
url: 'url',
|
|
|
|
},
|
|
|
|
}
|
2018-01-18 03:08:10 +11:00
|
|
|
end
|
2020-12-15 12:04:56 +11:00
|
|
|
|
|
|
|
def shortcuts
|
|
|
|
[
|
|
|
|
{
|
2022-06-10 06:25:23 +10:00
|
|
|
name: 'Compose new post',
|
2022-03-31 20:20:26 +11:00
|
|
|
url: '/web/publish',
|
2020-12-15 12:04:56 +11:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Notifications',
|
|
|
|
url: '/web/notifications',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
end
|
2017-10-02 10:23:32 +11:00
|
|
|
end
|