You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
1.9 KiB

  1. # frozen_string_literal: true
  2. class ManifestSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. include ActionView::Helpers::TextHelper
  5. attributes :name, :short_name, :description,
  6. :icons, :theme_color, :background_color,
  7. :display, :start_url, :scope,
  8. :share_target, :shortcuts
  9. def name
  10. object.site_title
  11. end
  12. def short_name
  13. object.site_title
  14. end
  15. def description
  16. strip_tags(object.site_short_description.presence || I18n.t('about.about_mastodon_html'))
  17. end
  18. def icons
  19. [
  20. {
  21. src: '/android-chrome-192x192.png',
  22. sizes: '192x192',
  23. type: 'image/png',
  24. },
  25. ]
  26. end
  27. def theme_color
  28. '#282c37'
  29. end
  30. def background_color
  31. '#191b22'
  32. end
  33. def display
  34. 'standalone'
  35. end
  36. def start_url
  37. '/web/timelines/home'
  38. end
  39. def scope
  40. '/'
  41. end
  42. def share_target
  43. {
  44. url_template: 'share?title={title}&text={text}&url={url}',
  45. action: 'share',
  46. method: 'GET',
  47. enctype: 'application/x-www-form-urlencoded',
  48. params: {
  49. title: 'title',
  50. text: 'text',
  51. url: 'url',
  52. },
  53. }
  54. end
  55. def shortcuts
  56. [
  57. {
  58. name: 'New toot',
  59. url: '/web/statuses/new',
  60. icons: [
  61. {
  62. src: '/shortcuts/new-status.png',
  63. type: 'image/png',
  64. sizes: '192x192',
  65. },
  66. ],
  67. },
  68. {
  69. name: 'Notifications',
  70. url: '/web/notifications',
  71. icons: [
  72. {
  73. src: '/shortcuts/notifications.png',
  74. type: 'image/png',
  75. sizes: '192x192',
  76. },
  77. ],
  78. },
  79. {
  80. name: 'Direct messages',
  81. url: '/web/timelines/direct',
  82. icons: [
  83. {
  84. src: '/shortcuts/direct.png',
  85. type: 'image/png',
  86. sizes: '192x192',
  87. },
  88. ],
  89. },
  90. ]
  91. end
  92. end