FEATURE: add support for `upload` format in theme settings.

FEATURE: add support for upload format in theme settings.

diff --git a/app/models/theme_setting.rb b/app/models/theme_setting.rb
index b34fd5f..86d8c02 100644
--- a/app/models/theme_setting.rb
+++ b/app/models/theme_setting.rb
@@ -16,7 +16,7 @@ class ThemeSetting < ActiveRecord::Base
   end
 
   def self.types
-    @types ||= Enum.new(integer: 0, float: 1, string: 2, bool: 3, list: 4, enum: 5)
+    @types ||= Enum.new(integer: 0, float: 1, string: 2, bool: 3, list: 4, enum: 5, upload: 6)
   end
 
   def self.acceptable_value_for_type?(value, type)
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index ffd3928..64ed44d 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -96,7 +96,7 @@ en:
       optimized_link: Optimized image links are ephemeral and should not be included in theme source code.
     settings_errors:
       invalid_yaml: "Provided YAML is invalid."
-      data_type_not_a_number: "Setting `%{name}` type is unsupported. Supported types are `integer`, `bool`, `list` and `enum`"
+      data_type_not_a_number: "Setting `%{name}` type is unsupported. Supported types are `integer`, `bool`, `list`, `enum` and `upload`"
       name_too_long: "There is a setting with a too long name. Maximum length is 255"
       default_value_missing: "Setting `%{name}` has no default value"
       default_not_match_type: "Setting `%{name}` default value's type doesn't match with the setting type."
diff --git a/lib/theme_settings_manager.rb b/lib/theme_settings_manager.rb
index cc69dee..49ad6a6 100644
--- a/lib/theme_settings_manager.rb
+++ b/lib/theme_settings_manager.rb
@@ -167,4 +167,7 @@ class ThemeSettingsManager
       @opts[:choices]
     end
   end
+
+  class Upload < self
+  end
 end
diff --git a/spec/fixtures/theme_settings/valid_settings.yaml b/spec/fixtures/theme_settings/valid_settings.yaml
index 2885fba..35a6973 100644
--- a/spec/fixtures/theme_settings/valid_settings.yaml
+++ b/spec/fixtures/theme_settings/valid_settings.yaml
@@ -68,3 +68,7 @@ enum_setting_03:
     - 10
     - 100
     - 1000
+
+upload_setting:
+  type: upload
+  default: ""

GitHub sha: 884eea7a

@davidtaylorhq has some feedback on this one.

1 Like