froala-editor-sdk 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c86f7b8547036336a509a375e6c3cffe05b08158
|
4
|
+
data.tar.gz: 4d1f1fc90cb5a151148fa22689f295f8466f0e09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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 =
|
27
|
+
def self.upload(params, upload_path = @default_upload_path, options = {})
|
28
28
|
|
29
29
|
# Merge options.
|
30
|
-
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
|
-
|
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
|
-
|
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
|
-
|
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
|
|
@@ -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
|
-
|
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
|
-
|
17
|
+
@default_upload_path = "public/uploads/videos"
|
18
18
|
end
|
19
19
|
end
|