2016-02-14 02:29:53 +08:00
|
|
|
class MetadataController < ApplicationController
|
2015-09-20 23:00:30 +08:00
|
|
|
layout false
|
2016-03-21 10:18:40 +08:00
|
|
|
skip_before_filter :preload_json, :check_xhr, :redirect_to_login_if_required
|
2015-09-20 23:00:30 +08:00
|
|
|
|
2016-02-14 02:29:53 +08:00
|
|
|
def manifest
|
2016-06-30 12:03:52 +08:00
|
|
|
render json: default_manifest.to_json
|
|
|
|
end
|
|
|
|
|
|
|
|
def opensearch
|
|
|
|
render file: "#{Rails.root}/app/views/metadata/opensearch.xml"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def default_manifest
|
2017-01-04 01:50:45 +08:00
|
|
|
manifest = {
|
2016-04-20 22:54:01 +08:00
|
|
|
name: SiteSetting.title,
|
2015-09-20 23:00:30 +08:00
|
|
|
short_name: SiteSetting.title,
|
2016-03-21 10:18:40 +08:00
|
|
|
display: 'standalone',
|
2017-02-13 02:04:06 +08:00
|
|
|
orientation: 'natural',
|
2016-03-21 10:18:40 +08:00
|
|
|
start_url: "#{Discourse.base_uri}/",
|
|
|
|
background_color: "##{ColorScheme.hex_for_name('secondary')}",
|
2016-04-20 22:54:01 +08:00
|
|
|
theme_color: "##{ColorScheme.hex_for_name('header_background')}",
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: SiteSetting.apple_touch_icon_url,
|
|
|
|
sizes: "144x144",
|
|
|
|
type: "image/png"
|
|
|
|
}
|
|
|
|
]
|
2015-09-20 23:00:30 +08:00
|
|
|
}
|
2017-01-04 01:50:45 +08:00
|
|
|
|
|
|
|
if SiteSetting.native_app_install_banner
|
2017-07-28 09:20:09 +08:00
|
|
|
manifest = manifest.merge(
|
2017-01-04 01:50:45 +08:00
|
|
|
prefer_related_applications: true,
|
|
|
|
related_applications: [
|
|
|
|
{
|
|
|
|
platform: "play",
|
|
|
|
id: "com.discourse"
|
|
|
|
}
|
|
|
|
]
|
2017-07-28 09:20:09 +08:00
|
|
|
)
|
2017-01-04 01:50:45 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
manifest
|
2016-02-14 02:29:53 +08:00
|
|
|
end
|
2015-09-20 23:00:30 +08:00
|
|
|
end
|