diff --git a/app/controllers/manifest_json_controller.rb b/app/controllers/manifest_json_controller.rb new file mode 100644 index 00000000000..5462ec1fd63 --- /dev/null +++ b/app/controllers/manifest_json_controller.rb @@ -0,0 +1,15 @@ +class ManifestJsonController < ApplicationController + layout false + skip_before_filter :preload_json, :check_xhr + + def index + manifest = { + short_name: SiteSetting.title, + display: 'browser', + orientation: 'portrait', + start_url: "#{Discourse.base_uri}/" + } + + render json: manifest.to_json + end +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8a29518367d..65cf09b5350 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -31,6 +31,7 @@ <%- end %> <%= render_google_universal_analytics_code %> + <%= yield :head %> diff --git a/config/routes.rb b/config/routes.rb index 66125570f49..75d3dcf7cc6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -533,6 +533,7 @@ Discourse::Application.routes.draw do get "favicon/proxied" => "static#favicon", format: false get "robots.txt" => "robots_txt#index" + get "manifest.json" => "manifest_json#index", as: :manifest Discourse.filters.each do |filter| root to: "list##{filter}", constraints: HomePageConstraint.new("#{filter}"), :as => "list_#{filter}" diff --git a/spec/controllers/manifest_json_controller_spec.rb b/spec/controllers/manifest_json_controller_spec.rb new file mode 100644 index 00000000000..41df4e221ca --- /dev/null +++ b/spec/controllers/manifest_json_controller_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +RSpec.describe ManifestJsonController do + context 'index' do + it 'returns the right output' do + title = 'MyApp' + SiteSetting.title = title + get :index + expect(response.body).to include(title) + end + end +end