froala-editor-sdk 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b215ddc9205aff5ce708096e7d5a2b5d919dff1d
4
- data.tar.gz: a20709121f413700510b4c5b58046ec2ad066478
3
+ metadata.gz: c86f7b8547036336a509a375e6c3cffe05b08158
4
+ data.tar.gz: 4d1f1fc90cb5a151148fa22689f295f8466f0e09
5
5
  SHA512:
6
- metadata.gz: 04b2db37f9f18f1be79ad2a41e47e62f6552fd962fcfb4d0784ce29f79d967c6cbe04653903af18dac037bbba20a5324faeefedcad920708361754116c80b1c4
7
- data.tar.gz: 9d4a1a020fc91cbca4fbbf0f39b88d5159fd6a14d6faa0ca6a64bc03d3f4cf9a2bb312a398272bac504e2efa0c6d1bdc4c2ee07b06c920335b2e9e71e6bdb1dc
6
+ metadata.gz: 57d7ffbc0e31ea8147d636352811e828bd115687d44ab48e588c908d6f151b1b495f785e657b30fd029e8c0e6f70f67524459f95999bb30403229efa41950be8
7
+ data.tar.gz: e47944bbf7c724d6f62d3c76ed1e8762dc757c7593355c7d756301d1544fac527f1b6b37e4e91e73f0620af6f3bbd4b09afb5d3a75fc4881281127d205580231
@@ -6,7 +6,7 @@ module FroalaEditorSDK
6
6
  class File
7
7
 
8
8
  # Default options that are used if no options are passed to the upload function
9
- @@default_options = {
9
+ @default_options = {
10
10
  fieldname: 'file',
11
11
  validation: {
12
12
  allowedExts: [".txt", ".pdf", ".doc", ".json", ".html"],
@@ -16,7 +16,7 @@ module FroalaEditorSDK
16
16
  }
17
17
 
18
18
  # Default upload path.
19
- @@default_upload_path = "public/uploads/files"
19
+ @default_upload_path = "public/uploads/files"
20
20
 
21
21
  # Uploads a file to the server.
22
22
  # Params:
@@ -24,10 +24,10 @@ module FroalaEditorSDK
24
24
  # +upload_path+:: Server upload path, a storage path where the file will be stored.
25
25
  # +options+:: Hash object that contains configuration parameters for uploading a file.
26
26
  # Returns json object
27
- def self.upload(params, upload_path = @@default_upload_path, options = {})
27
+ def self.upload(params, upload_path = @default_upload_path, options = {})
28
28
 
29
29
  # Merge options.
30
- options = @@default_options.merge(options)
30
+ options = @default_options.merge(options)
31
31
 
32
32
  file = params[options[:fieldname]]
33
33
 
@@ -97,5 +97,13 @@ module FroalaEditorSDK
97
97
  image.path
98
98
  image.resize("#{options[:resize][:height]}x#{options[:resize][:width]}")
99
99
  end
100
+
101
+ class << self
102
+ attr_reader :var
103
+ end
104
+
105
+ def var
106
+ self.class.var
107
+ end
100
108
  end
101
109
  end
@@ -3,7 +3,7 @@ module FroalaEditorSDK
3
3
  class Image < File
4
4
 
5
5
  # Default options that are used if no options are passed to the upload function.
6
- @@default_options = {
6
+ @default_options = {
7
7
  fieldname: 'file',
8
8
  validation: {
9
9
  allowedExts: [".gif", ".jpeg", ".jpg", ".png", ".svg", ".blob"],
@@ -13,7 +13,7 @@ module FroalaEditorSDK
13
13
  }
14
14
 
15
15
  # Default upload path.
16
- @@default_upload_path = "public/uploads/images"
16
+ @default_upload_path = "public/uploads/images"
17
17
 
18
18
  # Loads the images from a specific path
19
19
  # Params:
@@ -22,7 +22,12 @@ module FroalaEditorSDK
22
22
 
23
23
  mime = file.content_type
24
24
  ext = ::File.extname(file.original_filename)
25
- if ext(ext, options) && mime(mime, options)
25
+
26
+ # Check if there is custom validation.
27
+ if options[:validation].class != Proc
28
+ ext(ext, options) && mime(mime, options)
29
+ else
30
+ options[:validation].call(file.path, mime)
26
31
  end
27
32
  end
28
33
 
@@ -1,8 +1,8 @@
1
1
  module FroalaEditorSDK
2
2
  module Version
3
3
  Major = 1
4
- Minor = 0
5
- Tiny = 2
4
+ Minor = 1
5
+ Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
8
8
  end
@@ -4,7 +4,7 @@ module FroalaEditorSDK
4
4
  class Video < File
5
5
 
6
6
  # Default options that are used if no options are passed to the upload function
7
- @@default_options = {
7
+ @default_options = {
8
8
  fieldname: 'file',
9
9
  validation: {
10
10
  allowedExts: [".mp4", ".webm", ".ogg"],
@@ -14,6 +14,6 @@ module FroalaEditorSDK
14
14
  }
15
15
 
16
16
  # Default upload path.
17
- @@default_upload_path = "public/uploads/videos"
17
+ @default_upload_path = "public/uploads/videos"
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: froala-editor-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Froala Labs