mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-30 00:30:40 +00:00
bf3cb42da7
Cherry-picked d2528b26b6
Conflicts:
- `app/serializers/initial_state_serializer.rb`:
Upstream changed stuff, we had extra attributes.
Applied upstream changes while keeping our extra attributes.
- `app/serializers/rest/instance_serializer.rb`:
Upstream actually moved that to `app/serializers/rest/v1/instance_serializer.rb`,
so updated that file by keeping our extra attributes, and took upstream's
version of `app/serializers/rest/instance_serializer.rb`.
- `spec/views/about/show.html.haml_spec.rb`:
Took upstream's version.
89 lines
1.4 KiB
Ruby
89 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class ManifestSerializer < ActiveModel::Serializer
|
|
include RoutingHelper
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
ICON_SIZES = %w(
|
|
36
|
|
48
|
|
72
|
|
96
|
|
144
|
|
192
|
|
256
|
|
384
|
|
512
|
|
).freeze
|
|
|
|
attributes :name, :short_name,
|
|
:icons, :theme_color, :background_color,
|
|
:display, :start_url, :scope,
|
|
:share_target, :shortcuts
|
|
|
|
def name
|
|
object.title
|
|
end
|
|
|
|
def short_name
|
|
object.title
|
|
end
|
|
|
|
def icons
|
|
ICON_SIZES.map do |size|
|
|
{
|
|
src: full_pack_url("media/icons/android-chrome-#{size}x#{size}.png"),
|
|
sizes: "#{size}x#{size}",
|
|
type: 'image/png',
|
|
}
|
|
end
|
|
end
|
|
|
|
def theme_color
|
|
'#6364FF'
|
|
end
|
|
|
|
def background_color
|
|
'#191b22'
|
|
end
|
|
|
|
def display
|
|
'standalone'
|
|
end
|
|
|
|
def start_url
|
|
'/web/home'
|
|
end
|
|
|
|
def scope
|
|
'/'
|
|
end
|
|
|
|
def share_target
|
|
{
|
|
url_template: 'share?title={title}&text={text}&url={url}',
|
|
action: 'share',
|
|
method: 'GET',
|
|
enctype: 'application/x-www-form-urlencoded',
|
|
params: {
|
|
title: 'title',
|
|
text: 'text',
|
|
url: 'url',
|
|
},
|
|
}
|
|
end
|
|
|
|
def shortcuts
|
|
[
|
|
{
|
|
name: 'Compose new post',
|
|
url: '/web/publish',
|
|
},
|
|
{
|
|
name: 'Notifications',
|
|
url: '/web/notifications',
|
|
},
|
|
]
|
|
end
|
|
end
|