From 722d152082a20c96ca6f1db92c172f9d3772d737 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 6 Jun 2017 19:29:42 +0200 Subject: [PATCH] Fix #3063 - Add dynamic app manifest (#3563) * Fix #3063 - Add dynamic app manifest * Added short_name * Add background_color --- app/controllers/manifests_controller.rb | 11 +++++++++++ app/views/manifests/show.json.rabl | 11 +++++++++++ config/routes.rb | 1 + public/manifest.json | 14 -------------- 4 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 app/controllers/manifests_controller.rb create mode 100644 app/views/manifests/show.json.rabl delete mode 100644 public/manifest.json diff --git a/app/controllers/manifests_controller.rb b/app/controllers/manifests_controller.rb new file mode 100644 index 000000000..832e1eb6f --- /dev/null +++ b/app/controllers/manifests_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class ManifestsController < ApplicationController + before_action :set_instance_presenter + + def show; end + + def set_instance_presenter + @instance_presenter = InstancePresenter.new + end +end diff --git a/app/views/manifests/show.json.rabl b/app/views/manifests/show.json.rabl new file mode 100644 index 000000000..0aa1728e7 --- /dev/null +++ b/app/views/manifests/show.json.rabl @@ -0,0 +1,11 @@ +object false + +node(:name) { Setting.site_title } +node(:short_name) { Setting.site_title } +node(:description) { strip_tags(Setting.site_description.presence || I18n.t('about.about_mastodon')) } +node(:icons) { [{ src: '/android-chrome-192x192.png', sizes: '192x192', type: 'image/png' }] } +node(:theme_color) { '#282c37' } +node(:background_color) { '#d9e1e8' } +node(:display) { 'standalone' } +node(:start_url) { '/web/timelines/home' } +node(:scope) { root_url } diff --git a/config/routes.rb b/config/routes.rb index 7a2286f92..c71c5603c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,6 +17,7 @@ Rails.application.routes.draw do get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' } get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger + get 'manifest', to: 'manifests#show', defaults: { format: 'json' } devise_for :users, path: 'auth', controllers: { sessions: 'auth/sessions', diff --git a/public/manifest.json b/public/manifest.json deleted file mode 100644 index 26e169ad2..000000000 --- a/public/manifest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "Mastodon", - "description": "Mastodon is a free, open-source social network server.", - "icons": [ - { - "src": "\/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image\/png" - } - ], - "theme_color": "#282c37", - "display": "standalone", - "start_url": "/web/timelines/home" -}