mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 16:18:32 +08:00
FEATURE: Add web manifest for Chrome users.
This commit is contained in:
15
app/controllers/manifest_json_controller.rb
Normal file
15
app/controllers/manifest_json_controller.rb
Normal file
@ -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
|
@ -31,6 +31,7 @@
|
|||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
<%= render_google_universal_analytics_code %>
|
<%= render_google_universal_analytics_code %>
|
||||||
|
<link rel="manifest" href="<%= Discourse.base_uri %>/manifest.json">
|
||||||
|
|
||||||
<%= yield :head %>
|
<%= yield :head %>
|
||||||
</head>
|
</head>
|
||||||
|
@ -533,6 +533,7 @@ Discourse::Application.routes.draw do
|
|||||||
get "favicon/proxied" => "static#favicon", format: false
|
get "favicon/proxied" => "static#favicon", format: false
|
||||||
|
|
||||||
get "robots.txt" => "robots_txt#index"
|
get "robots.txt" => "robots_txt#index"
|
||||||
|
get "manifest.json" => "manifest_json#index", as: :manifest
|
||||||
|
|
||||||
Discourse.filters.each do |filter|
|
Discourse.filters.each do |filter|
|
||||||
root to: "list##{filter}", constraints: HomePageConstraint.new("#{filter}"), :as => "list_#{filter}"
|
root to: "list##{filter}", constraints: HomePageConstraint.new("#{filter}"), :as => "list_#{filter}"
|
||||||
|
12
spec/controllers/manifest_json_controller_spec.rb
Normal file
12
spec/controllers/manifest_json_controller_spec.rb
Normal file
@ -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
|
Reference in New Issue
Block a user