FEATURE: Update the webmanifest

- Remove share target because the spec is changing
- Allow any orientation again because natural is too restrictive
- Use correct file and mime types for the manifest
This commit is contained in:
Rafael dos Santos Silva 2018-06-14 00:13:28 -03:00
parent 66982c7800
commit 8fc08aad09
4 changed files with 10 additions and 12 deletions

View File

@ -3,7 +3,7 @@ class MetadataController < ApplicationController
skip_before_action :preload_json, :check_xhr, :redirect_to_login_if_required
def manifest
render json: default_manifest.to_json
render json: default_manifest.to_json, content_type: 'application/manifest+json'
end
def opensearch
@ -23,11 +23,8 @@ class MetadataController < ApplicationController
name: SiteSetting.title,
short_name: SiteSetting.title,
display: 'standalone',
orientation: 'natural',
orientation: 'any',
start_url: "#{Discourse.base_uri}/",
share_target: {
url_template: 'new-topic?title={title}&body={text}%0A%0A{url}'
},
background_color: "##{ColorScheme.hex_for_name('secondary')}",
theme_color: "##{ColorScheme.hex_for_name('header_background')}",
icons: [

View File

@ -46,7 +46,7 @@
<%= render_google_tag_manager_head_code %>
<%= render_google_universal_analytics_code %>
<link rel="manifest" href="<%= Discourse.base_uri %>/manifest.json">
<link rel="manifest" href="<%= Discourse.base_uri %>/manifest.webmanifest">
<%- if SiteSetting.native_app_install_banner? %>
<meta name="apple-itunes-app" content="app-id=1173672076">

View File

@ -747,7 +747,8 @@ Discourse::Application.routes.draw do
get "robots.txt" => "robots_txt#index"
get "robots-builder.json" => "robots_txt#builder"
get "offline.html" => "offline#index"
get "manifest.json" => "metadata#manifest", as: :manifest
get "manifest.webmanifest" => "metadata#manifest", as: :manifest
get "manifest.json" => "metadata#manifest"
get "opensearch" => "metadata#opensearch", format: :xml
scope "/tags" do

View File

@ -1,15 +1,15 @@
require 'rails_helper'
RSpec.describe MetadataController do
describe 'manifest.json' do
describe 'manifest.webmanifest' do
it 'returns the right output' do
title = 'MyApp'
SiteSetting.title = title
SiteSetting.large_icon_url = "http://big.square/png"
get "/manifest.json"
get "/manifest.webmanifest"
expect(response.status).to eq(200)
expect(response.content_type).to eq('application/json')
expect(response.content_type).to eq('application/manifest+json')
manifest = JSON.parse(response.body)
expect(manifest["name"]).to eq(title)
@ -18,7 +18,7 @@ RSpec.describe MetadataController do
it 'can guess mime types' do
SiteSetting.large_icon_url = "http://big.square/ico.jpg"
get "/manifest.json"
get "/manifest.webmanifest"
expect(response.status).to eq(200)
manifest = JSON.parse(response.body)
expect(manifest["icons"].first["type"]).to eq("image/jpeg")
@ -26,7 +26,7 @@ RSpec.describe MetadataController do
it 'defaults to png' do
SiteSetting.large_icon_url = "http://big.square/noidea.bogus"
get "/manifest.json"
get "/manifest.webmanifest"
expect(response.status).to eq(200)
manifest = JSON.parse(response.body)
expect(manifest["icons"].first["type"]).to eq("image/png")