Skip to content

Commit

Permalink
Add icon field to instance endpoint
Browse files Browse the repository at this point in the history
As we now allow admins to customize their app icon, it may be useful to expose it so apps can use it in the UI.

This is using the Android icons as they provide a good range of sizes.
  • Loading branch information
renchap committed May 19, 2024
1 parent 0f07e1c commit 2015db1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/serializers/rest/instance_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ class ContactSerializer < ActiveModel::Serializer
has_one :account, serializer: REST::AccountSerializer
end

include InstanceHelper
include ApplicationHelper
include RoutingHelper

attributes :domain, :title, :version, :source_url, :description,
:usage, :thumbnail, :languages, :configuration,
:usage, :thumbnail, :icon, :languages, :configuration,
:registrations

has_one :contact, serializer: ContactSerializer
Expand All @@ -33,6 +35,18 @@ def thumbnail
end
end

def icon
SiteUpload::ANDROID_ICON_SIZES.map do |size|
src = app_icon_path(size.to_i)
src = URI.join(root_url, src).to_s if src.present?

{
src: src || frontend_asset_url("icons/android-chrome-#{size}x#{size}.png"),
size: "#{size}x#{size}",
}
end
end

def usage
{
users: {
Expand Down

0 comments on commit 2015db1

Please sign in to comment.