2017-10-02 01:23:32 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ManifestSerializer < ActiveModel::Serializer
|
|
|
|
include RoutingHelper
|
|
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
|
|
|
|
attributes :name, :short_name, :description,
|
|
|
|
:icons, :theme_color, :background_color,
|
2018-01-17 17:08:10 +01:00
|
|
|
:display, :start_url, :scope,
|
2020-12-15 02:04:56 +01:00
|
|
|
:share_target, :shortcuts
|
2017-10-02 01:23:32 +02:00
|
|
|
|
|
|
|
def name
|
|
|
|
object.site_title
|
|
|
|
end
|
|
|
|
|
|
|
|
def short_name
|
|
|
|
object.site_title
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
2019-03-21 23:33:28 +01:00
|
|
|
strip_tags(object.site_short_description.presence || I18n.t('about.about_mastodon_html'))
|
2017-10-02 01:23:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def icons
|
|
|
|
[
|
|
|
|
{
|
|
|
|
src: '/android-chrome-192x192.png',
|
|
|
|
sizes: '192x192',
|
|
|
|
type: 'image/png',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def theme_color
|
|
|
|
'#282c37'
|
|
|
|
end
|
|
|
|
|
|
|
|
def background_color
|
|
|
|
'#191b22'
|
|
|
|
end
|
|
|
|
|
|
|
|
def display
|
|
|
|
'standalone'
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_url
|
2022-03-31 11:20:26 +02:00
|
|
|
'/web/home'
|
2017-10-02 01:23:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def scope
|
2021-09-08 23:33:36 +02:00
|
|
|
'/'
|
2017-10-02 01:23:32 +02:00
|
|
|
end
|
2018-01-17 17:08:10 +01:00
|
|
|
|
|
|
|
def share_target
|
2019-02-02 01:26:49 +01:00
|
|
|
{
|
|
|
|
url_template: 'share?title={title}&text={text}&url={url}',
|
|
|
|
action: 'share',
|
2019-09-05 15:51:51 +02:00
|
|
|
method: 'GET',
|
|
|
|
enctype: 'application/x-www-form-urlencoded',
|
2019-02-02 01:26:49 +01:00
|
|
|
params: {
|
|
|
|
title: 'title',
|
|
|
|
text: 'text',
|
|
|
|
url: 'url',
|
|
|
|
},
|
|
|
|
}
|
2018-01-17 17:08:10 +01:00
|
|
|
end
|
2020-12-15 02:04:56 +01:00
|
|
|
|
|
|
|
def shortcuts
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name: 'New toot',
|
2022-03-31 11:20:26 +02:00
|
|
|
url: '/web/publish',
|
2020-12-15 02:04:56 +01:00
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: '/shortcuts/new-status.png',
|
|
|
|
type: 'image/png',
|
|
|
|
sizes: '192x192',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Notifications',
|
|
|
|
url: '/web/notifications',
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: '/shortcuts/notifications.png',
|
|
|
|
type: 'image/png',
|
|
|
|
sizes: '192x192',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Direct messages',
|
2022-03-31 11:20:26 +02:00
|
|
|
url: '/web/conversations',
|
2020-12-15 02:04:56 +01:00
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: '/shortcuts/direct.png',
|
|
|
|
type: 'image/png',
|
|
|
|
sizes: '192x192',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
end
|
2017-10-02 01:23:32 +02:00
|
|
|
end
|