diff options
Diffstat (limited to 'app/models/appearance.rb')
-rw-r--r-- | app/models/appearance.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/app/models/appearance.rb b/app/models/appearance.rb index 3a5e06e9a1c..b926c6abedc 100644 --- a/app/models/appearance.rb +++ b/app/models/appearance.rb @@ -5,9 +5,13 @@ class Appearance < ApplicationRecord include CacheMarkdownField include WithUploads + ALLOWED_PWA_ICON_SCALER_WIDTHS = [192, 512].freeze + attribute :title, default: '' - attribute :pwa_short_name, default: '' attribute :description, default: '' + attribute :pwa_name, default: '' + attribute :pwa_short_name, default: '' + attribute :pwa_description, default: '' attribute :new_project_guidelines, default: '' attribute :profile_image_guidelines, default: '' attribute :header_message, default: '' @@ -22,6 +26,24 @@ class Appearance < ApplicationRecord cache_markdown_field :header_message, pipeline: :broadcast_message cache_markdown_field :footer_message, pipeline: :broadcast_message + validates :pwa_name, + length: { maximum: 255, too_long: ->(object, data) { + N_("is too long (maximum is %{count} characters)") + } }, + allow_blank: true + + validates :pwa_short_name, + length: { maximum: 255, too_long: ->(object, data) { + N_("is too long (maximum is %{count} characters)") + } }, + allow_blank: true + + validates :pwa_description, + length: { maximum: 2048, too_long: ->(object, data) { + N_("is too long (maximum is %{count} characters)") + } }, + allow_blank: true + validates :logo, file_size: { maximum: 1.megabyte } validates :pwa_icon, file_size: { maximum: 1.megabyte } validates :header_logo, file_size: { maximum: 1.megabyte } @@ -47,6 +69,12 @@ class Appearance < ApplicationRecord end end + def pwa_icon_path_scaled(width) + return unless pwa_icon_path.present? + + pwa_icon_path + "?width=#{width}" + end + def logo_path logo_system_path(logo, 'logo') end |