FEATURE: Setting for short title used by Android on homescreen
This commit is contained in:
parent
25253dec56
commit
e7b76b319a
|
@ -27,7 +27,6 @@ class MetadataController < ApplicationController
|
|||
|
||||
manifest = {
|
||||
name: SiteSetting.title,
|
||||
short_name: SiteSetting.title,
|
||||
display: display,
|
||||
start_url: Discourse.base_uri.present? ? "#{Discourse.base_uri}/" : '.',
|
||||
background_color: "##{ColorScheme.hex_for_name('secondary', view_context.scheme_id)}",
|
||||
|
@ -41,6 +40,8 @@ class MetadataController < ApplicationController
|
|||
]
|
||||
}
|
||||
|
||||
manifest[:short_name] = SiteSetting.short_title if SiteSetting.short_title.present?
|
||||
|
||||
if SiteSetting.native_app_install_banner
|
||||
manifest = manifest.merge(
|
||||
prefer_related_applications: true,
|
||||
|
|
|
@ -1856,6 +1856,8 @@ en:
|
|||
push_notifications_prompt: "Display user consent prompt."
|
||||
push_notifications_icon: "The badge icon that appears in the notification corner. Recommended size is 96px by 96px."
|
||||
|
||||
short_title: "The short title will be used on the user's home screen, launcher, or other places where space may be limited. A maximum of 12 characters is recommended."
|
||||
|
||||
errors:
|
||||
invalid_email: "Invalid email address."
|
||||
invalid_username: "There's no user with that username."
|
||||
|
|
|
@ -281,6 +281,8 @@ basic:
|
|||
push_notifications_icon_url:
|
||||
hidden: true
|
||||
default: ''
|
||||
short_title:
|
||||
default: ''
|
||||
vapid_public_key_bytes:
|
||||
default: ''
|
||||
client: true
|
||||
|
|
|
@ -63,6 +63,19 @@ RSpec.describe MetadataController do
|
|||
expect(manifest["display"]).to eq("standalone")
|
||||
end
|
||||
|
||||
it 'uses the short_title if it is set' do
|
||||
get "/manifest.webmanifest"
|
||||
expect(response.status).to eq(200)
|
||||
manifest = JSON.parse(response.body)
|
||||
expect(manifest).to_not have_key("short_name")
|
||||
|
||||
SiteSetting.short_title = "foo"
|
||||
|
||||
get "/manifest.webmanifest"
|
||||
expect(response.status).to eq(200)
|
||||
manifest = JSON.parse(response.body)
|
||||
expect(manifest["short_name"]).to eq("foo")
|
||||
end
|
||||
end
|
||||
|
||||
describe 'opensearch.xml' do
|
||||
|
|
Loading…
Reference in New Issue