zendesk_apps_support 1.14.3 → 1.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/locales/en.yml +7 -0
- data/config/locales/translations/zendesk_apps_support.yml +8 -1
- data/lib/zendesk_apps_support/assets/src.js.erb +2 -0
- data/lib/zendesk_apps_support/package.rb +15 -4
- data/lib/zendesk_apps_support/validations/banner.rb +33 -0
- data/lib/zendesk_apps_support/validations/requirements.rb +29 -1
- data/lib/zendesk_apps_support/validations/source.rb +2 -1
- data/lib/zendesk_apps_support.rb +1 -0
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42facf839227ec97b70c5ddb1777a8fc35750da2
|
4
|
+
data.tar.gz: d8e73edd9f09a0db0894fe701ce63ac742e2f221
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c4de5166b970b0b8e1c01bffab99e38f62da6602899934e23ec6d26d7bb22b40139de64870e63e99c94e12da8385d20eff9c098054bc6cb92632a5b838c28b7
|
7
|
+
data.tar.gz: 3c8e1d7b0044c330457881e3050e24f6932f26d08d648fceda214e22405ad209942a0194b0487df55e90e2ae71cf40cb56926952ad2cfb3fa420b7c7b478df45
|
data/config/locales/en.yml
CHANGED
@@ -23,12 +23,19 @@ en:
|
|
23
23
|
one: 'Missing required field in manifest: %{missing_keys}'
|
24
24
|
other: 'Missing required fields in manifest: %{missing_keys}'
|
25
25
|
requirements_not_json: requirements.json is not proper JSON. %{errors}
|
26
|
+
excessive_requirements: The requirements.json file contains too many requirements.
|
27
|
+
The current limit is %{max} requirements.
|
28
|
+
missing_required_fields: 'Missing required fields in requirements.json:
|
29
|
+
"%{field}" is required in "%{identifier}"'
|
26
30
|
duplicate_requirements:
|
27
31
|
one: 'requirements.json contains a duplicate key: %{duplicate_keys}'
|
28
32
|
other: 'requirements.json contains duplicate keys: %{duplicate_keys}'
|
29
33
|
invalid_requirements_types:
|
30
34
|
one: 'requirements.json contains an invalid type: %{invalid_types}'
|
31
35
|
other: 'requirements.json contains invalid types: %{invalid_types}'
|
36
|
+
banner:
|
37
|
+
invalid_format: 'Banner image must be a PNG file'
|
38
|
+
invalid_size: 'Invalid banner image dimensions. Must be %{required_banner_width}x%{required_banner_height}px'
|
32
39
|
oauth_keys:
|
33
40
|
missing:
|
34
41
|
one: 'Missing required oauth field in manifest: %{missing_keys}'
|
@@ -5,7 +5,6 @@ title: "Apps Support"
|
|
5
5
|
packages:
|
6
6
|
- default
|
7
7
|
- apps_support
|
8
|
-
- classic
|
9
8
|
|
10
9
|
parts:
|
11
10
|
- translation:
|
@@ -52,6 +51,14 @@ parts:
|
|
52
51
|
key: "txt.apps.admin.error.app_build.requirements_not_json"
|
53
52
|
title: "App builder job: requirements file is invalid JSON error"
|
54
53
|
value: "requirements.json is not proper JSON. %{errors}"
|
54
|
+
- translation:
|
55
|
+
key: "txt.apps.admin.error.app_build.excessive_requirements"
|
56
|
+
title: "App builder job: requirements file contains too many requirements"
|
57
|
+
value: "The requirements.json file contains too many requirements. The current limit is %{max} requirements."
|
58
|
+
- translation:
|
59
|
+
key: "txt.apps.admin.error.app_build.missing_required_fields"
|
60
|
+
title: "App builder job: required key missing in requirements, e.g. \"title\" is required in \"my_custom_email_target\""
|
61
|
+
value: "Missing required fields in requirements.json: \"%{field}\" is required in \"%{identifier}\""
|
55
62
|
- translation:
|
56
63
|
key: "txt.apps.admin.error.app_build.duplicate_requirements.one"
|
57
64
|
title: "App builder job: requirements file contains duplicate key error"
|
@@ -38,6 +38,10 @@ module ZendeskAppsSupport
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
if has_banner?
|
42
|
+
errors << Validations::Banner.call(self)
|
43
|
+
end
|
44
|
+
|
41
45
|
errors.flatten!
|
42
46
|
end
|
43
47
|
end
|
@@ -98,7 +102,7 @@ module ZendeskAppsSupport
|
|
98
102
|
end
|
99
103
|
|
100
104
|
def customer_css
|
101
|
-
css_file =
|
105
|
+
css_file = file_path('app.css')
|
102
106
|
customer_css = File.exist?(css_file) ? File.read(css_file) : ""
|
103
107
|
end
|
104
108
|
|
@@ -118,6 +122,14 @@ module ZendeskAppsSupport
|
|
118
122
|
file_exists?("requirements.json")
|
119
123
|
end
|
120
124
|
|
125
|
+
def has_banner?
|
126
|
+
file_exists?("assets/banner.png")
|
127
|
+
end
|
128
|
+
|
129
|
+
def file_path(path)
|
130
|
+
File.join(root, path)
|
131
|
+
end
|
132
|
+
|
121
133
|
private
|
122
134
|
|
123
135
|
def compiled_templates(app_id, asset_url_prefix)
|
@@ -151,12 +163,11 @@ module ZendeskAppsSupport
|
|
151
163
|
end
|
152
164
|
|
153
165
|
def file_exists?(path)
|
154
|
-
File.exist?(
|
166
|
+
File.exist?(file_path(path))
|
155
167
|
end
|
156
168
|
|
157
169
|
def read_file(path)
|
158
|
-
|
159
|
-
File.read(File.join(root, path))
|
170
|
+
File.read(file_path(path))
|
160
171
|
end
|
161
172
|
|
162
173
|
def read_json(path, symbolize_names = true)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'image_size'
|
2
|
+
|
3
|
+
module ZendeskAppsSupport
|
4
|
+
module Validations
|
5
|
+
module Banner
|
6
|
+
BANNER_WIDTH = 830
|
7
|
+
BANNER_HEIGHT = 200
|
8
|
+
|
9
|
+
class <<self
|
10
|
+
def call(package)
|
11
|
+
File.open(package.file_path('assets/banner.png'), 'rb') do |fh|
|
12
|
+
begin
|
13
|
+
image = ImageSize.new(fh)
|
14
|
+
|
15
|
+
unless image.format == :png
|
16
|
+
return [ValidationError.new('banner.invalid_format')]
|
17
|
+
end
|
18
|
+
|
19
|
+
unless (image.width == BANNER_WIDTH && image.height == BANNER_HEIGHT) ||
|
20
|
+
(image.width == 2*BANNER_WIDTH && image.height == 2*BANNER_HEIGHT)
|
21
|
+
return [ValidationError.new('banner.invalid_size', :required_banner_width => BANNER_WIDTH,
|
22
|
+
:required_banner_height => BANNER_HEIGHT)]
|
23
|
+
end
|
24
|
+
rescue => e
|
25
|
+
return [ValidationError.new('banner.invalid_format')]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
[]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'multi_json'
|
2
2
|
require 'json/stream'
|
3
|
-
require 'pp'
|
4
3
|
|
5
4
|
module ZendeskAppsSupport
|
6
5
|
module Validations
|
7
6
|
module Requirements
|
8
7
|
|
8
|
+
MAX_REQUIREMENTS = 10
|
9
|
+
|
9
10
|
class <<self
|
10
11
|
def call(package)
|
11
12
|
requirements_file = package.files.find { |f| f.relative_path == 'requirements.json' }
|
@@ -21,6 +22,9 @@ module ZendeskAppsSupport
|
|
21
22
|
requirements = MultiJson.load(requirements_stream)
|
22
23
|
[].tap do |errors|
|
23
24
|
errors << invalid_requirements_types(requirements)
|
25
|
+
errors << excessive_requirements(requirements)
|
26
|
+
errors << missing_required_fields(requirements)
|
27
|
+
errors.flatten!
|
24
28
|
errors.compact!
|
25
29
|
end
|
26
30
|
rescue MultiJson::DecodeError => e
|
@@ -29,6 +33,30 @@ module ZendeskAppsSupport
|
|
29
33
|
|
30
34
|
private
|
31
35
|
|
36
|
+
def missing_required_fields(requirements)
|
37
|
+
[].tap do |errors|
|
38
|
+
requirements.values.each do |requirement|
|
39
|
+
requirement.each do |identifier, fields|
|
40
|
+
next if fields.include? 'title'
|
41
|
+
errors << ValidationError.new(:missing_required_fields, :field => 'title', :identifier => identifier)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
unless requirements['user_fields'].nil?
|
46
|
+
requirements['user_fields'].each do |identifier, fields|
|
47
|
+
next if fields.include? 'key'
|
48
|
+
errors << ValidationError.new(:missing_required_fields, :field => 'key', :identifier => identifier)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def excessive_requirements(requirements)
|
55
|
+
if requirements.values.map(&:values).flatten.size > MAX_REQUIREMENTS
|
56
|
+
ValidationError.new(:excessive_requirements, :max => MAX_REQUIREMENTS)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
32
60
|
def invalid_requirements_types(requirements)
|
33
61
|
invalid_types = requirements.keys - ZendeskAppsSupport::AppRequirement::TYPES
|
34
62
|
|
@@ -14,7 +14,8 @@ module ZendeskAppsSupport
|
|
14
14
|
:laxcomma => true,
|
15
15
|
|
16
16
|
# predefined globals:
|
17
|
-
:predef => %w(_ console services helpers alert
|
17
|
+
:predef => %w(_ console services helpers alert window document self
|
18
|
+
JSON Base64 clearInterval clearTimeout setInterval setTimeout)
|
18
19
|
}.freeze
|
19
20
|
|
20
21
|
class <<self
|
data/lib/zendesk_apps_support.rb
CHANGED
@@ -20,5 +20,6 @@ module ZendeskAppsSupport
|
|
20
20
|
autoload :JSHintValidationError, 'zendesk_apps_support/validations/validation_error'
|
21
21
|
autoload :Stylesheets, 'zendesk_apps_support/validations/stylesheets'
|
22
22
|
autoload :Requirements, 'zendesk_apps_support/validations/requirements'
|
23
|
+
autoload :Banner, 'zendesk_apps_support/validations/banner'
|
23
24
|
end
|
24
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk_apps_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James A. Rosen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: i18n
|
@@ -83,6 +83,20 @@ dependencies:
|
|
83
83
|
- - '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: image_size
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
type: :runtime
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
86
100
|
- !ruby/object:Gem::Dependency
|
87
101
|
name: erubis
|
88
102
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,11 +160,6 @@ executables: []
|
|
146
160
|
extensions: []
|
147
161
|
extra_rdoc_files: []
|
148
162
|
files:
|
149
|
-
- LICENSE
|
150
|
-
- README.md
|
151
|
-
- config/locales/en.yml
|
152
|
-
- config/locales/translations/zendesk_apps_support.yml
|
153
|
-
- lib/zendesk_apps_support.rb
|
154
163
|
- lib/zendesk_apps_support/app_file.rb
|
155
164
|
- lib/zendesk_apps_support/app_requirement.rb
|
156
165
|
- lib/zendesk_apps_support/app_version.rb
|
@@ -163,6 +172,7 @@ files:
|
|
163
172
|
- lib/zendesk_apps_support/package.rb
|
164
173
|
- lib/zendesk_apps_support/sass_functions.rb
|
165
174
|
- lib/zendesk_apps_support/stylesheet_compiler.rb
|
175
|
+
- lib/zendesk_apps_support/validations/banner.rb
|
166
176
|
- lib/zendesk_apps_support/validations/manifest.rb
|
167
177
|
- lib/zendesk_apps_support/validations/requirements.rb
|
168
178
|
- lib/zendesk_apps_support/validations/source.rb
|
@@ -170,6 +180,11 @@ files:
|
|
170
180
|
- lib/zendesk_apps_support/validations/templates.rb
|
171
181
|
- lib/zendesk_apps_support/validations/translations.rb
|
172
182
|
- lib/zendesk_apps_support/validations/validation_error.rb
|
183
|
+
- lib/zendesk_apps_support.rb
|
184
|
+
- config/locales/en.yml
|
185
|
+
- config/locales/translations/zendesk_apps_support.yml
|
186
|
+
- README.md
|
187
|
+
- LICENSE
|
173
188
|
homepage: http://github.com/zendesk/zendesk_apps_support
|
174
189
|
licenses:
|
175
190
|
- Apache License Version 2.0
|
@@ -190,9 +205,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
205
|
version: 1.3.6
|
191
206
|
requirements: []
|
192
207
|
rubyforge_project:
|
193
|
-
rubygems_version: 2.
|
208
|
+
rubygems_version: 2.0.14
|
194
209
|
signing_key:
|
195
210
|
specification_version: 4
|
196
211
|
summary: Support to help you develop Zendesk Apps.
|
197
212
|
test_files: []
|
198
|
-
has_rdoc:
|