A platform for community discussion. Free, open, simple.
FEATURE: Setting for short title used by Android on homescreen
Gerhard Schlagere7b76b319ada
diff --git a/app/controllers/metadata_controller.rb b/app/controllers/metadata_controller.rbindex 07a3ac76327..dacba4dbd7b 100644--- a/app/controllers/metadata_controller.rb+++ b/app/controllers/metadata_controller.rb@@ -27,7 +27,6 @@ class MetadataController < ApplicationControllermanifest = {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_bannermanifest = manifest.merge(prefer_related_applications: true,diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 8c8da6bc70e..4c643d449fb 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -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."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 3639fde011f..b64d9198b85 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -281,6 +281,8 @@ basic:push_notifications_icon_url:hidden: truedefault: ''+ short_title:+ default: ''vapid_public_key_bytes:default: ''client: truediff --git a/spec/requests/metadata_controller_spec.rb b/spec/requests/metadata_controller_spec.rbindex 2047b13277f..e5b2f033b87 100644--- a/spec/requests/metadata_controller_spec.rb+++ b/spec/requests/metadata_controller_spec.rb@@ -63,6 +63,19 @@ RSpec.describe MetadataController doexpect(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")+ endenddescribe 'opensearch.xml' do