froala-editor-sdk 1.0.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 +7 -0
 - data/lib/froala-editor-sdk.rb +11 -0
 - data/lib/froala-editor-sdk/file.rb +101 -0
 - data/lib/froala-editor-sdk/image.rb +34 -0
 - data/lib/froala-editor-sdk/s3.rb +59 -0
 - data/lib/froala-editor-sdk/utils/utils.rb +19 -0
 - data/lib/froala-editor-sdk/utils/validation.rb +30 -0
 - data/lib/froala-editor-sdk/version.rb +9 -0
 - data/lib/froala-editor-sdk/video.rb +19 -0
 - metadata +93 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f550a761087a01b88464ae9fb6ccc7109559837d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9cf4bcc1e64c5c12c01fccdd7837714c616c5619
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8a0041c0af55b3acdc5fa220897232a66f55ad06b8ad061d1a84e796dfeb91f24cfbaa3a143f7c4bbe48193eac5f797e9761586b106fcd56bf1db753ed68cc6c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ff798b2be7f7ab315bb464b02984062f23bf2d420eea88e606ff6ee6dc59cfa7c575da7cab8d2987ad549ec415f9a5ee817d73d112c298b2e048040a7cccc1b7
         
     | 
| 
         @@ -0,0 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'mime-types'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'mini_magick'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'froala-editor-sdk/utils/validation'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'froala-editor-sdk/utils/utils'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require 'froala-editor-sdk/file'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'froala-editor-sdk/image'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'froala-editor-sdk/s3'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'froala-editor-sdk/version'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'froala-editor-sdk/video'
         
     | 
| 
         @@ -0,0 +1,101 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module FroalaEditorSDK
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              require 'fileutils'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              # File functionality.
         
     | 
| 
      
 6 
     | 
    
         
            +
              class File
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                # Default options that are used if no options are passed to the upload function
         
     | 
| 
      
 9 
     | 
    
         
            +
                @@default_options = {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    fieldname: 'file',
         
     | 
| 
      
 11 
     | 
    
         
            +
                    validation: {
         
     | 
| 
      
 12 
     | 
    
         
            +
                        allowedExts: [".txt", ".pdf", ".doc", ".json", ".html"],
         
     | 
| 
      
 13 
     | 
    
         
            +
                        allowedMimeTypes: [ "text/plain", "application/msword", "application/x-pdf", "application/pdf", "application/json","text/html" ]
         
     | 
| 
      
 14 
     | 
    
         
            +
                    },
         
     | 
| 
      
 15 
     | 
    
         
            +
                    resize: nil
         
     | 
| 
      
 16 
     | 
    
         
            +
                }
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # Default upload path.
         
     | 
| 
      
 19 
     | 
    
         
            +
                @@default_upload_path = "public/uploads/files"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                # Uploads a file to the server.
         
     | 
| 
      
 22 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 23 
     | 
    
         
            +
                # +params+:: File upload parameter mostly is "file".
         
     | 
| 
      
 24 
     | 
    
         
            +
                # +upload_path+:: Server upload path, a storage path where the file will be stored.
         
     | 
| 
      
 25 
     | 
    
         
            +
                # +options+:: Hash object that contains configuration parameters for uploading a file.
         
     | 
| 
      
 26 
     | 
    
         
            +
                # Returns json object
         
     | 
| 
      
 27 
     | 
    
         
            +
                def self.upload(params, upload_path = @@default_upload_path, options = nil)
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  # Merge options.
         
     | 
| 
      
 30 
     | 
    
         
            +
                  options = (options || @@default_options).merge(options)
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  file = params[options[:fieldname]]
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  if file
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    # Validates the file extension and mime type.
         
     | 
| 
      
 37 
     | 
    
         
            +
                    validation = Validation.check(file, options)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    # Uses the Utlis name function to generate a random name for the file.
         
     | 
| 
      
 40 
     | 
    
         
            +
                    file_name = Utils.name(file)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    path = Rails.root.join(upload_path, file_name)
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                    # Saves the file on the server and returns the path.
         
     | 
| 
      
 44 
     | 
    
         
            +
                    serve_url = save(file, path)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    resize(options, path) if !options[:resize].nil?
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    return {:link => serve_url}.to_json
         
     | 
| 
      
 49 
     | 
    
         
            +
                  else
         
     | 
| 
      
 50 
     | 
    
         
            +
                    return nil
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                # Saves a file on the server.
         
     | 
| 
      
 55 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 56 
     | 
    
         
            +
                # +file+:: The uploaded file that will be saved on the server.
         
     | 
| 
      
 57 
     | 
    
         
            +
                # +path+:: The path where the file will be saved.
         
     | 
| 
      
 58 
     | 
    
         
            +
                def self.save (file, path)
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  # Create directory if it doesn't exist.
         
     | 
| 
      
 61 
     | 
    
         
            +
                  dirname = ::File.dirname(path)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  unless ::File.directory?(dirname)
         
     | 
| 
      
 63 
     | 
    
         
            +
                    ::FileUtils.mkdir_p(dirname)
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                  if ::File.open(path, "wb") {|f| f.write(file.read)}
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                    # Returns a public accessible server path.
         
     | 
| 
      
 69 
     | 
    
         
            +
                    return "#{"/uploads/"}#{Utils.get_file_name(path)}"
         
     | 
| 
      
 70 
     | 
    
         
            +
                  else
         
     | 
| 
      
 71 
     | 
    
         
            +
                    return "error"
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                # Deletes a file found on the server.
         
     | 
| 
      
 76 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 77 
     | 
    
         
            +
                # +file+:: The file that will be deleted from the server.
         
     | 
| 
      
 78 
     | 
    
         
            +
                # +path+:: The server path where the file resides.
         
     | 
| 
      
 79 
     | 
    
         
            +
                # Returns true or false.
         
     | 
| 
      
 80 
     | 
    
         
            +
                def self.delete(file = params[:file], path)
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                  file_path = Rails.root.join(path, ::File.basename(file))
         
     | 
| 
      
 83 
     | 
    
         
            +
                  if ::File.delete(file_path)
         
     | 
| 
      
 84 
     | 
    
         
            +
                    return true
         
     | 
| 
      
 85 
     | 
    
         
            +
                  else
         
     | 
| 
      
 86 
     | 
    
         
            +
                    return false
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                # Resizes an image based on the options provided.
         
     | 
| 
      
 91 
     | 
    
         
            +
                # The function resizes the original file,
         
     | 
| 
      
 92 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 93 
     | 
    
         
            +
                # +options+:: The options that contain the resize hash
         
     | 
| 
      
 94 
     | 
    
         
            +
                # +path+:: The path where the image is stored
         
     | 
| 
      
 95 
     | 
    
         
            +
                def self.resize (options, path)
         
     | 
| 
      
 96 
     | 
    
         
            +
                  image = MiniMagick::Image.new(path)
         
     | 
| 
      
 97 
     | 
    
         
            +
                  image.path
         
     | 
| 
      
 98 
     | 
    
         
            +
                  image.resize("#{options[:resize][:height]}x#{options[:resize][:width]}")
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
              end
         
     | 
| 
      
 101 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module FroalaEditorSDK
         
     | 
| 
      
 2 
     | 
    
         
            +
              # Image functionality.
         
     | 
| 
      
 3 
     | 
    
         
            +
              class Image < File
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                # Default options that are used if no options are passed to the upload function.
         
     | 
| 
      
 6 
     | 
    
         
            +
                @@default_options = {
         
     | 
| 
      
 7 
     | 
    
         
            +
                    fieldname: 'file',
         
     | 
| 
      
 8 
     | 
    
         
            +
                    validation: {
         
     | 
| 
      
 9 
     | 
    
         
            +
                        allowedExts: [".gif", ".jpeg", ".jpg", ".png", ".svg", ".blob"],
         
     | 
| 
      
 10 
     | 
    
         
            +
                        allowedMimeTypes: [ "image/gif", "image/jpeg", "image/pjpeg", "image/x-png", "image/png", "image/svg+xml" ]
         
     | 
| 
      
 11 
     | 
    
         
            +
                    },
         
     | 
| 
      
 12 
     | 
    
         
            +
                    resize: nil
         
     | 
| 
      
 13 
     | 
    
         
            +
                }
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                # Default upload path.
         
     | 
| 
      
 16 
     | 
    
         
            +
                @@default_upload_path = "public/uploads/images"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # Loads the images from a specific path
         
     | 
| 
      
 19 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 20 
     | 
    
         
            +
                # +path+:: The server path where the images are saved
         
     | 
| 
      
 21 
     | 
    
         
            +
                # Returns Json object
         
     | 
| 
      
 22 
     | 
    
         
            +
                def self.load_images(path)
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  images = Dir["#{path}*"]
         
     | 
| 
      
 25 
     | 
    
         
            +
                  all_images = []
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  images.each do |img|
         
     | 
| 
      
 28 
     | 
    
         
            +
                    all_images.push({url: "#{"/uploads/"}#{Utils.get_file_name(img)}"})
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  return all_images.to_json
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,59 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module FroalaEditorSDK
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              # Uploads files to S3/AWS
         
     | 
| 
      
 4 
     | 
    
         
            +
              class S3
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                # Builds a signature based on  the options.
         
     | 
| 
      
 7 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 8 
     | 
    
         
            +
                # +options+:: The configuration params that are needed to compute the signature.
         
     | 
| 
      
 9 
     | 
    
         
            +
                def self.signature (options = nil)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  Base64.encode64(
         
     | 
| 
      
 11 
     | 
    
         
            +
                      OpenSSL::HMAC.digest(
         
     | 
| 
      
 12 
     | 
    
         
            +
                          OpenSSL::Digest.new('sha1'),
         
     | 
| 
      
 13 
     | 
    
         
            +
                          options[:secretKey], self.policy(options)
         
     | 
| 
      
 14 
     | 
    
         
            +
                      )
         
     | 
| 
      
 15 
     | 
    
         
            +
                  ).gsub("\n", "")
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # Encodes to Base64 the policy data and replaces new lines chars.
         
     | 
| 
      
 19 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 20 
     | 
    
         
            +
                # +options+:: The configuration params that are needed to compute the signature.
         
     | 
| 
      
 21 
     | 
    
         
            +
                def self.policy (options = nil)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  Base64.encode64(self.policy_data(options).to_json).gsub("\n", "")
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                # Sets policy params, bucket that will be used max file size and other params.
         
     | 
| 
      
 26 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 27 
     | 
    
         
            +
                # +options+:: Configuration params that are needed to set the policy
         
     | 
| 
      
 28 
     | 
    
         
            +
                def self.policy_data (options = nil)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  {
         
     | 
| 
      
 30 
     | 
    
         
            +
                      expiration: 10.hours.from_now.utc.iso8601,
         
     | 
| 
      
 31 
     | 
    
         
            +
                      conditions: [
         
     | 
| 
      
 32 
     | 
    
         
            +
                          ["starts-with", "$key", options[:keyStart]],       # Start key/folder
         
     | 
| 
      
 33 
     | 
    
         
            +
                          ["starts-with", "$x-requested-with", "xhr"],  # Request type
         
     | 
| 
      
 34 
     | 
    
         
            +
                          ["starts-with", "$content-type", ""],         # Content type
         
     | 
| 
      
 35 
     | 
    
         
            +
                          {bucket: options[:bucket]},                   # Bucket name
         
     | 
| 
      
 36 
     | 
    
         
            +
                          {acl: options[:acl]},                         # ACL property
         
     | 
| 
      
 37 
     | 
    
         
            +
                          {success_action_status: "201"}                # Response status 201 'file created'
         
     | 
| 
      
 38 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 39 
     | 
    
         
            +
                  }
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                # Makes all the request in order and returns AWS hash response
         
     | 
| 
      
 43 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 44 
     | 
    
         
            +
                # +options+:: Configuration params to generate the AWS response.
         
     | 
| 
      
 45 
     | 
    
         
            +
                def self.data_hash (options = nil)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  options[:region] = 'us-east-1' if options[:region].nil? ||  options[:region] == 's3'
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  {
         
     | 
| 
      
 49 
     | 
    
         
            +
                      :signature => self.signature(options), # Defined signature
         
     | 
| 
      
 50 
     | 
    
         
            +
                      :policy => self.policy(options),       # Defined policy
         
     | 
| 
      
 51 
     | 
    
         
            +
                      :bucket => options[:bucket],           # Upload bucket
         
     | 
| 
      
 52 
     | 
    
         
            +
                      :acl => options[:acl],                 # ACL property 'public-read'
         
     | 
| 
      
 53 
     | 
    
         
            +
                      :keyStart => options[:keyStart],       # Start key/folder
         
     | 
| 
      
 54 
     | 
    
         
            +
                      :accessKey => options[:accessKey],     # Your Access key
         
     | 
| 
      
 55 
     | 
    
         
            +
                      :region =>  options[:region] != 'us-east-1' ? "s3-#{options[:region]}" : 's3' # Upload region
         
     | 
| 
      
 56 
     | 
    
         
            +
                  }
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module FroalaEditorSDK
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              # Basic utility functionality.
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Utils
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                # Generates a random name that will be used as name for files.
         
     | 
| 
      
 7 
     | 
    
         
            +
                def self.name (file)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  name = SecureRandom.urlsafe_base64
         
     | 
| 
      
 9 
     | 
    
         
            +
                  ext = ::File.extname(file.original_filename)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  return "#{name}#{ext}"
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                # Returns file name from an file path
         
     | 
| 
      
 15 
     | 
    
         
            +
                def self.get_file_name(path)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  return ::File.basename(path)
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module FroalaEditorSDK
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              # Image Validation class.
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Checks if image is matching the allowed extensions and mime types.
         
     | 
| 
      
 5 
     | 
    
         
            +
              class Validation
         
     | 
| 
      
 6 
     | 
    
         
            +
                require "mime-types"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def self.ext(ext, options)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  raise "Not allowed" unless options[:validation][:allowedExts].include?(ext)
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def self.mime(mime, options)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  raise "Invalid mime type" unless options[:validation][:allowedMimeTypes].include?(mime)
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                # Checks an image with the options.
         
     | 
| 
      
 17 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 18 
     | 
    
         
            +
                # +file+:: The image that will be validated.
         
     | 
| 
      
 19 
     | 
    
         
            +
                # +options+:: The image options that contain allowed extensions and mime types.
         
     | 
| 
      
 20 
     | 
    
         
            +
                # Raises exception if the image has not passed the validation
         
     | 
| 
      
 21 
     | 
    
         
            +
                def self.check(file, options = nil)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  mime = file.content_type
         
     | 
| 
      
 24 
     | 
    
         
            +
                  ext = ::File.extname(file.original_filename)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  if ext(ext, options) && mime(mime, options)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module FroalaEditorSDK
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              # Video functionality.
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Video < File
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                # Default options that are used if no options are passed to the upload function
         
     | 
| 
      
 7 
     | 
    
         
            +
                @@default_options = {
         
     | 
| 
      
 8 
     | 
    
         
            +
                    fieldname: 'file',
         
     | 
| 
      
 9 
     | 
    
         
            +
                    validation: {
         
     | 
| 
      
 10 
     | 
    
         
            +
                        allowedExts: [".mp4", ".webm", ".ogg"],
         
     | 
| 
      
 11 
     | 
    
         
            +
                        allowedMimeTypes: [ "video/mp4", "video/webm", "video/ogg" ]
         
     | 
| 
      
 12 
     | 
    
         
            +
                    },
         
     | 
| 
      
 13 
     | 
    
         
            +
                    resize: nil
         
     | 
| 
      
 14 
     | 
    
         
            +
                }
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                # Default upload path.
         
     | 
| 
      
 17 
     | 
    
         
            +
                @@default_upload_path = "public/uploads/videos"
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,93 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: froala-editor-sdk
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Froala Labs
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-05-29 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: mime-types
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '3.1'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '3.1'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: wysiwyg-rails
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 2.6.0
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: 2.6.0
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: mini_magick
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: 4.5.0
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: 4.5.0
         
     | 
| 
      
 55 
     | 
    
         
            +
            description: Ruby SDK for Froala Editor
         
     | 
| 
      
 56 
     | 
    
         
            +
            email: 
         
     | 
| 
      
 57 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 58 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 59 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 60 
     | 
    
         
            +
            files:
         
     | 
| 
      
 61 
     | 
    
         
            +
            - lib/froala-editor-sdk.rb
         
     | 
| 
      
 62 
     | 
    
         
            +
            - lib/froala-editor-sdk/file.rb
         
     | 
| 
      
 63 
     | 
    
         
            +
            - lib/froala-editor-sdk/image.rb
         
     | 
| 
      
 64 
     | 
    
         
            +
            - lib/froala-editor-sdk/s3.rb
         
     | 
| 
      
 65 
     | 
    
         
            +
            - lib/froala-editor-sdk/utils/utils.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
            - lib/froala-editor-sdk/utils/validation.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
            - lib/froala-editor-sdk/version.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
            - lib/froala-editor-sdk/video.rb
         
     | 
| 
      
 69 
     | 
    
         
            +
            homepage: https://github.com/froala/wysiwyg-rails
         
     | 
| 
      
 70 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 71 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 72 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 73 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 74 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 75 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 76 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 77 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 78 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 79 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 80 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 81 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 82 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 83 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 84 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 85 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 86 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 87 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 88 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 89 
     | 
    
         
            +
            rubygems_version: 2.6.10
         
     | 
| 
      
 90 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 91 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 92 
     | 
    
         
            +
            summary: Ruby on Rails SDK for Froala WYSIWYG Editor.
         
     | 
| 
      
 93 
     | 
    
         
            +
            test_files: []
         
     |