discourse/app/controllers/metadata_controller.rb
Nicolas 1deec95ccb Use natural orientation for web app manifest.
The `any` orientation forces the rotation even when the device's screen
 rotation is disabled. Using `natural` respects that and restores the
 expected behaviour.
2017-02-12 18:04:06 +00:00

48 lines
1.1 KiB
Ruby

class MetadataController < ApplicationController
layout false
skip_before_filter :preload_json, :check_xhr, :redirect_to_login_if_required
def manifest
render json: default_manifest.to_json
end
def opensearch
render file: "#{Rails.root}/app/views/metadata/opensearch.xml"
end
private
def default_manifest
manifest = {
name: SiteSetting.title,
short_name: SiteSetting.title,
display: 'standalone',
orientation: 'natural',
start_url: "#{Discourse.base_uri}/",
background_color: "##{ColorScheme.hex_for_name('secondary')}",
theme_color: "##{ColorScheme.hex_for_name('header_background')}",
icons: [
{
src: SiteSetting.apple_touch_icon_url,
sizes: "144x144",
type: "image/png"
}
]
}
if SiteSetting.native_app_install_banner
manifest = manifest.merge({
prefer_related_applications: true,
related_applications: [
{
platform: "play",
id: "com.discourse"
}
]
})
end
manifest
end
end