├── .gitignore ├── AutoRemote.dzbundle ├── action.rb └── icon.png ├── Boxcar.dzbundle ├── action.rb ├── icon.png └── notification.rb ├── Clean Text.dzbundle ├── action.rb └── icon.png ├── Clone Git Repository.dzbundle ├── action.rb └── icon.png ├── CompressImage.dzbundle ├── action.rb └── icon.png ├── Convert to MP4.dzbundle ├── action.rb └── icon.png ├── DRACOON.dzbundle ├── action.rb ├── dracoon.rb └── icon.png ├── Decode Base64.dzbundle ├── action.rb └── icon.png ├── Edit Images in Pixelmator Pro.dzbundle ├── action.rb └── icon.png ├── File Sort.dzbundle ├── action.rb └── icon.png ├── Gist.dzbundle ├── Gemfile ├── Gemfile.lock ├── action.rb ├── bundler │ └── setup.rb ├── icon.png └── ruby │ ├── 2.3.0 │ └── gems │ │ └── gist-5.1.0 │ │ └── lib │ │ └── gist.rb │ └── 2.6.0 │ └── gems │ └── gist-5.1.0 │ └── lib │ └── gist.rb ├── Google Maps.dzbundle ├── action.rb └── icon.png ├── ImageShack.dzbundle ├── action.rb ├── icon.png └── imageshack.rb ├── KDiff3.dzbundle ├── action.rb └── icon.png ├── Kaleidoscope Diff.dzbundle ├── action.rb └── icon.png ├── MD to HTML Presentation Converter.dzbundle ├── .bundle │ └── config ├── Basic.css ├── Script.css ├── action.rb ├── icon.png ├── presbegin.html └── presend.html ├── Make GIF.dzbundle ├── action.rb └── icon.png ├── Merge Directories.dzbundle ├── action.rb └── icon.png ├── Node HTTP Server at Path.dzbundle ├── action.rb └── icon.png ├── NotePad.dzbundle ├── action.rb └── icon.png ├── Open URL in Incognito Mode.dzbundle ├── action.rb └── icon.png ├── Open VS Code at Path.dzbundle ├── action.rb └── icon.png ├── Open Warp at Path.dzbundle ├── action.rb └── icon.png ├── Open iTerm at Path.dzbundle ├── action.rb └── icon.png ├── Open iTerm tab at Path.dzbundle ├── action.rb └── icon.png ├── PDF Separate.dzbundle ├── action.rb └── icon.png ├── Pushbullet.dzbundle ├── action.rb └── icon.png ├── Pushover.dzbundle ├── action.rb ├── icon.png └── notification.rb ├── Qiniu.dzbundle ├── action.py ├── icon.png ├── pngpaste ├── qiniu │ ├── __init__.py │ ├── auth.py │ ├── compat.py │ ├── config.py │ ├── http.py │ ├── main.py │ ├── services │ │ ├── __init__.py │ │ ├── processing │ │ │ ├── __init__.py │ │ │ ├── cmd.py │ │ │ └── pfop.py │ │ └── storage │ │ │ ├── __init__.py │ │ │ ├── bucket.py │ │ │ └── uploader.py │ └── utils.py └── requests │ ├── __init__.py │ ├── adapters.py │ ├── api.py │ ├── auth.py │ ├── cacert.pem │ ├── certs.py │ ├── compat.py │ ├── cookies.py │ ├── exceptions.py │ ├── hooks.py │ ├── models.py │ ├── packages │ ├── __init__.py │ ├── chardet │ │ ├── __init__.py │ │ ├── big5freq.py │ │ ├── big5prober.py │ │ ├── chardetect.py │ │ ├── chardistribution.py │ │ ├── charsetgroupprober.py │ │ ├── charsetprober.py │ │ ├── codingstatemachine.py │ │ ├── compat.py │ │ ├── constants.py │ │ ├── cp949prober.py │ │ ├── escprober.py │ │ ├── escsm.py │ │ ├── eucjpprober.py │ │ ├── euckrfreq.py │ │ ├── euckrprober.py │ │ ├── euctwfreq.py │ │ ├── euctwprober.py │ │ ├── gb2312freq.py │ │ ├── gb2312prober.py │ │ ├── hebrewprober.py │ │ ├── jisfreq.py │ │ ├── jpcntx.py │ │ ├── langbulgarianmodel.py │ │ ├── langcyrillicmodel.py │ │ ├── langgreekmodel.py │ │ ├── langhebrewmodel.py │ │ ├── langhungarianmodel.py │ │ ├── langthaimodel.py │ │ ├── latin1prober.py │ │ ├── mbcharsetprober.py │ │ ├── mbcsgroupprober.py │ │ ├── mbcssm.py │ │ ├── sbcharsetprober.py │ │ ├── sbcsgroupprober.py │ │ ├── sjisprober.py │ │ ├── universaldetector.py │ │ └── utf8prober.py │ └── urllib3 │ │ ├── __init__.py │ │ ├── _collections.py │ │ ├── connection.py │ │ ├── connectionpool.py │ │ ├── contrib │ │ ├── __init__.py │ │ ├── ntlmpool.py │ │ └── pyopenssl.py │ │ ├── exceptions.py │ │ ├── fields.py │ │ ├── filepost.py │ │ ├── packages │ │ ├── __init__.py │ │ ├── ordered_dict.py │ │ ├── six.py │ │ └── ssl_match_hostname │ │ │ ├── __init__.py │ │ │ └── _implementation.py │ │ ├── poolmanager.py │ │ ├── request.py │ │ ├── response.py │ │ └── util │ │ ├── __init__.py │ │ ├── connection.py │ │ ├── request.py │ │ ├── response.py │ │ ├── retry.py │ │ ├── ssl_.py │ │ ├── timeout.py │ │ └── url.py │ ├── sessions.py │ ├── status_codes.py │ ├── structures.py │ └── utils.py ├── Quick Image Compressor.dzbundle ├── action.rb ├── bin │ ├── convert │ ├── image_optim │ └── jpegoptim └── icon.png ├── README.md ├── Rackspace Cloud Files.dzbundle ├── action.rb ├── icon.png └── rackspace.rb ├── Rename and Move Files.dzbundle ├── action.rb └── icon.png ├── SCP Upload.dzbundle ├── action.rb ├── icon.png └── scp_uploader.rb ├── Screenshot.dzbundle ├── action.rb └── icon.png ├── Search Mac App Store.dzbundle ├── action.rb └── icon.png ├── Show Image Size.dzbundle ├── action.rb ├── fastimage.rb ├── icon.icns └── icon.png ├── Slack.dzbundle ├── action.rb ├── icon.png ├── lib │ ├── composite_io.rb │ ├── faraday.rb │ ├── faraday │ │ ├── adapter.rb │ │ ├── adapter │ │ │ ├── em_http.rb │ │ │ ├── em_http_ssl_patch.rb │ │ │ ├── em_synchrony.rb │ │ │ ├── em_synchrony │ │ │ │ └── parallel_manager.rb │ │ │ ├── excon.rb │ │ │ ├── httpclient.rb │ │ │ ├── net_http.rb │ │ │ ├── net_http_persistent.rb │ │ │ ├── patron.rb │ │ │ ├── rack.rb │ │ │ ├── test.rb │ │ │ └── typhoeus.rb │ │ ├── autoload.rb │ │ ├── connection.rb │ │ ├── error.rb │ │ ├── middleware.rb │ │ ├── options.rb │ │ ├── parameters.rb │ │ ├── rack_builder.rb │ │ ├── request.rb │ │ ├── request │ │ │ ├── authorization.rb │ │ │ ├── basic_authentication.rb │ │ │ ├── instrumentation.rb │ │ │ ├── multipart.rb │ │ │ ├── retry.rb │ │ │ ├── token_authentication.rb │ │ │ └── url_encoded.rb │ │ ├── response.rb │ │ ├── response │ │ │ ├── logger.rb │ │ │ └── raise_error.rb │ │ ├── upload_io.rb │ │ └── utils.rb │ ├── json.rb │ ├── json │ │ ├── add │ │ │ ├── bigdecimal.rb │ │ │ ├── complex.rb │ │ │ ├── core.rb │ │ │ ├── date.rb │ │ │ ├── date_time.rb │ │ │ ├── exception.rb │ │ │ ├── ostruct.rb │ │ │ ├── range.rb │ │ │ ├── rational.rb │ │ │ ├── regexp.rb │ │ │ ├── struct.rb │ │ │ ├── symbol.rb │ │ │ └── time.rb │ │ ├── common.rb │ │ ├── ext.rb │ │ ├── ext │ │ │ ├── .keep │ │ │ ├── generator.bundle │ │ │ └── parser.bundle │ │ ├── generic_object.rb │ │ ├── pure.rb │ │ ├── pure │ │ │ ├── generator.rb │ │ │ └── parser.rb │ │ └── version.rb │ ├── multipart_post.rb │ ├── multipartable.rb │ ├── net │ │ └── http │ │ │ └── post │ │ │ └── multipart.rb │ └── parts.rb └── slack.rb ├── Sleep.dzbundle ├── action.rb └── icon.png ├── SparseImage.dzbundle ├── action.rb └── icon.png ├── Strip PDF Front.dzbundle ├── action.rb ├── icon.png └── pdfpict.pxm ├── Strip PDF from Zip.dzbundle ├── action.rb ├── icon.png └── pdfpict.pxm ├── Trash.dzbundle ├── action.rb ├── finderRunning ├── icon.png └── trash ├── UnbundleZipByName.dzbundle ├── action.rb └── icon.png ├── Up1.dzbundle ├── action.rb ├── bundler │ └── setup.rb ├── icon.png └── ruby │ └── 2.0.0 │ └── gems │ └── sjcl-1.0.1 │ └── lib │ ├── sjcl.rb │ └── sjcl │ ├── aes.rb │ ├── aes_tables.rb │ ├── bit_array.rb │ ├── ccm.rb │ ├── codec_base64.rb │ ├── codec_hex.rb │ ├── codec_string.rb │ ├── pbkdf2.rb │ ├── random.rb │ └── version.rb ├── YouTube Uploader.dzbundle ├── .idea │ ├── YouTube.dzbundle.iml │ ├── encodings.xml │ ├── misc.xml │ ├── modules.xml │ ├── scopes │ │ └── scope_settings.xml │ ├── vcs.xml │ └── workspace.xml ├── action.rb ├── icon.png └── youtube.rb ├── Zip by Parent Name.dzbundle ├── action.rb └── icon.png ├── docs ├── alert.png ├── copy-and-edit.png ├── debug-console.png ├── determinate-false.png ├── determinate-true.png ├── develop-action.png ├── develop-dialog.png ├── develop-python.png ├── dzbundle.png ├── error.png ├── fail-notification.png ├── finish-notification.png ├── inputbox.png ├── keymodifiers.png ├── login-optionsnib.png ├── open-debug-console.png ├── pashua-enter-text.png ├── pashua-selection-dialog.png ├── replace-icon.png ├── reveal.png └── show-package-contents.png └── md5 Filename.dzbundle ├── action.rb └── icon.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /AutoRemote.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/AutoRemote.dzbundle/icon.png -------------------------------------------------------------------------------- /Boxcar.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Boxcar 3 | # Description: Send message to Boxcar App (https://boxcar.io/). 4 | # Creator: Dominique Da Silva 5 | # URL: https://inspira.io 6 | # Events: Clicked, Dragged 7 | # SkipConfig: No 8 | # Handles: Text 9 | # OptionsNIB: APIKey 10 | # LoginTitle: Boxcar User API Key 11 | # RunsSandboxed: Yes 12 | # MinDropzoneVersion: 3.0 13 | # Version: 1.0 14 | # UniqueID: 7000 15 | 16 | require 'notification' 17 | 18 | def send(data) 19 | 20 | $dz.begin("Sending message via Boxcar") 21 | 22 | notification = Notification.new('boxcar', ENV['api_key']) 23 | notification.message = data.chomp 24 | notification.sound = 'beep-soft' 25 | 26 | notification.push 27 | 28 | end 29 | 30 | def readClipboard 31 | IO.popen('pbpaste') {|clipboard| clipboard.read} 32 | end 33 | 34 | def dragged 35 | if ENV['dragged_type'] == 'text' 36 | send($items[0]) 37 | $dz.finish("Message sent via Boxcar") 38 | end 39 | $dz.url(false) 40 | end 41 | 42 | def clicked 43 | system("open https://new.boxcar.io/account") 44 | end 45 | -------------------------------------------------------------------------------- /Boxcar.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Boxcar.dzbundle/icon.png -------------------------------------------------------------------------------- /Clean Text.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Clean Text 3 | # Description: Removes any formatting and puts cleaned text into clipboard. A click cleans the clipboard's contents. 4 | # Handles: Text 5 | # Creator: Dennis Kuypers 6 | # URL: http://yoursite.com 7 | # Events: Clicked, Dragged 8 | # KeyModifiers: Command, Option, Control, Shift 9 | # SkipConfig: No 10 | # RunsSandboxed: Yes 11 | # Version: 1.0 12 | # MinDropzoneVersion: 3.0 13 | 14 | def dragged 15 | $dz.text($items[0]) 16 | end 17 | 18 | def clicked 19 | $dz.text($dz.read_clipboard) 20 | end 21 | 22 | # Yes, that's all. -------------------------------------------------------------------------------- /Clean Text.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Clean Text.dzbundle/icon.png -------------------------------------------------------------------------------- /Clone Git Repository.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Clone Git Repository 3 | # Description: Drag the URL of a git repository onto this action and it will be cloned into the selected folder.\n\nHold the command key to select a different destination folder. Hold Shift to clone all project history. 4 | # Handles: Text 5 | # Creator: Dominique Da Silva 6 | # URL: https://apps.inspira.io 7 | # OptionsNIB: ChooseFolder 8 | # SkipConfig: No 9 | # RunsSandboxed: No 10 | # Events: Dragged, Clicked 11 | # KeyModifiers: Command, Shift 12 | # Version: 1.5 13 | # MinDropzoneVersion: 3.2.1 14 | # UniqueID: 1031 15 | 16 | require 'uri' 17 | 18 | def dragged 19 | 20 | modifier = ENV['KEY_MODIFIERS'] 21 | folder = ENV['path'] 22 | depth = "--depth 1" 23 | item = $items[0] 24 | 25 | if item =~ /\A#{URI::regexp}\z/ 26 | 27 | url = URI.parse(item) 28 | project_folder = url.path.split('/').last # Last path components 29 | project_folder = project_folder.gsub(/\.git$/,"") # Replace url ending with .git 30 | project_folder = "Undefined" if project_folder.empty? # If name undefined 31 | 32 | # Let user select a folder to clone to 33 | if modifier == "Command" 34 | selected_folder = `osascript -e 'set directory to POSIX path of (choose folder with prompt "Select the folder where you want git to clone this project." default location ("#{folder}"))' 2>/dev/null` 35 | 36 | if selected_folder.empty? 37 | $dz.fail("You must select a folder") 38 | else 39 | folder = selected_folder.strip 40 | end 41 | end 42 | 43 | absolute_path = File.join(folder, project_folder) 44 | 45 | # Clone all Git project history 46 | if modifier == "Shift" 47 | puts "Cloning all Git project history." 48 | depth = "" 49 | end 50 | 51 | # Create directory if it doesn't already exist 52 | if File.exists?(absolute_path) and File.directory?(absolute_path) 53 | puts "Destination folder already exists." 54 | idx = 1 55 | while File.exists?(absolute_path) do 56 | idx += 1 57 | newname = project_folder + "-" + idx.to_s 58 | absolute_path = File.join(folder, newname) 59 | end 60 | project_folder = newname 61 | end 62 | 63 | puts "Create directory at #{absolute_path}" 64 | Dir.mkdir(absolute_path) 65 | 66 | $dz.begin("Cloning git repository to #{project_folder}") 67 | $dz.determinate(false) 68 | 69 | # Do the actual clone 70 | gitclone = `/usr/bin/git clone #{depth} #{url} "#{absolute_path}" 2>&1` 71 | if ! $?.success? 72 | $dz.error("Git clone failed","Git failed to clone the repository:\n#{gitclone}") 73 | $dz.fail("Git failed to clone the repository.") 74 | end 75 | system("open \"#{absolute_path}\"") 76 | 77 | $dz.finish("Git project cloned to #{project_folder} folder.") 78 | $dz.text(absolute_path.gsub(" ", "\\ ")) 79 | else 80 | $dz.fail("#{item} is not a valid URL.") 81 | end 82 | 83 | end 84 | 85 | def clicked 86 | folder = ENV['path'] 87 | system("open #{folder}") 88 | $dz.url(false) 89 | end 90 | -------------------------------------------------------------------------------- /Clone Git Repository.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Clone Git Repository.dzbundle/icon.png -------------------------------------------------------------------------------- /CompressImage.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/CompressImage.dzbundle/icon.png -------------------------------------------------------------------------------- /Convert to MP4.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Convert to MP4.dzbundle/icon.png -------------------------------------------------------------------------------- /DRACOON.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/DRACOON.dzbundle/icon.png -------------------------------------------------------------------------------- /Decode Base64.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Decode Base64 3 | # Description: Decodes the text or the content of the clipboard using Base64 and puts the result in the clipboard. Alt-Drag text to encode. 4 | # Creator: Melvin Gundlach 5 | # URL: http://www.melvin-gundlach.de 6 | # Events: Clicked, Dragged 7 | # Handles: Text 8 | # KeyModifiers: Option 9 | # SkipConfig: Yes 10 | # RunsSandboxed: Yes 11 | # Version: 1.0 12 | # MinDropzoneVersion: 3.0 13 | # UniqueID: 23452 14 | 15 | require "base64" 16 | 17 | def dragged 18 | $dz.text($items[0]) 19 | clicked 20 | end 21 | 22 | def clicked 23 | modifier = ENV['KEY_MODIFIERS'] 24 | if modifier 25 | $dz.text(Base64.encode64($dz.read_clipboard)) 26 | else 27 | $dz.text(Base64.decode64($dz.read_clipboard)) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /Decode Base64.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Decode Base64.dzbundle/icon.png -------------------------------------------------------------------------------- /Edit Images in Pixelmator Pro.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Edit Images in Pixelmator Pro 3 | # Description: Dropped images will be opened in Pixelmator Pro. 4 | # Handles: Files 5 | # Creator: Sachin Shekhar 6 | # URL: https://sachinshekhar.com 7 | # Events: Clicked, Dragged 8 | # SkipConfig: No 9 | # RunsSandboxed: Yes 10 | # Version: 1.0 11 | # MinDropzoneVersion: 3.0 12 | 13 | def dragged 14 | allowed_exts = ["jpg", "jpeg", "png", "gif", "tif", "tiff", "bmp", "psd", "svg", "pdf", "webp", "tga"] 15 | 16 | supported_files = $items.select {|item| allowed_exts.include?(File.extname(item).downcase[1..-1])} 17 | 18 | # Open all supported files in Pixelmator Pro 19 | if !supported_files.empty? 20 | supported_files.each do |file| 21 | system("open", "-a", "Pixelmator Pro", file) 22 | end 23 | end 24 | 25 | # Notify about unsupported files 26 | unsupported_files = $items - supported_files 27 | $dz.fail(unsupported_files.length.to_s + " unsupported file#{'s' if unsupported_files.length > 1} not opened:\n\n" + unsupported_files.join("\n\n")) if !unsupported_files.empty? 28 | end 29 | 30 | def clicked 31 | system("open", "-a", "Pixelmator Pro") 32 | end 33 | -------------------------------------------------------------------------------- /Edit Images in Pixelmator Pro.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Edit Images in Pixelmator Pro.dzbundle/icon.png -------------------------------------------------------------------------------- /File Sort.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: File Sort 3 | # Description: Auto move a file to its corresponding folder if a part of the filename match the folder name. 4 | # Handles: Files 5 | # Creator: Dominique Da Silva 6 | # URL: https://inspira.io 7 | # OptionsNIB: ChooseFolder 8 | # Events: Clicked, Dragged 9 | # SkipConfig: No 10 | # RunsSandboxed: No 11 | # MinDropzoneVersion: 3.0 12 | # Version: 1.1 13 | # UniqueID: 7001 14 | 15 | require 'FileUtils' 16 | 17 | @folderlist = Array.new 18 | @destination = "" 19 | @log = "" 20 | @fail = "" 21 | 22 | def checkFilenameMatch(str) 23 | titlePart = str.downcase 24 | puts "Search for #{titlePart.downcase}" 25 | destination = @folderlist.select {|e| e.downcase =~ /#{titlePart}/ }.first 26 | return destination 27 | end 28 | 29 | def dragged 30 | 31 | folder = ENV['path'] 32 | @folderlist = Dir.glob "#{folder}/*/" 33 | 34 | $items.each do |filepath| 35 | filename = File.basename(filepath) 36 | filetitle = File.basename(filepath,".*") 37 | #*filetitleArr, ext = filetitle.split(/\W/) 38 | filetitleArr = filetitle.split(/\W/) 39 | @destination = "" 40 | 41 | puts filetitle.inspect 42 | puts filetitleArr.inspect 43 | 44 | # First two words in filename 45 | if filetitleArr.count >= 2 46 | @destination = checkFilenameMatch("#{filetitleArr[0]} #{filetitleArr[1]}") 47 | end 48 | 49 | # Last two words in filename 50 | if filetitleArr.count > 2 && (@destination.nil? || @destination.empty?) 51 | last2Parts = Array.new 52 | filetitleArr.reverse.each do |part| 53 | if part.length > 2 and part !~ /^[0-9]+$/ 54 | last2Parts.push(part) 55 | end 56 | if last2Parts.count == 2 then 57 | break 58 | end 59 | end 60 | @destination = checkFilenameMatch(last2Parts.reverse.join(" ")) 61 | end 62 | 63 | # Search for all parts of filename 64 | if @destination.nil? || @destination.empty? 65 | filetitleArr.each do |titlePart| 66 | if titlePart.length > 2 and titlePart !~ /^[0-9]+$/ 67 | @destination = checkFilenameMatch(titlePart) 68 | if !@destination.nil? then break; end 69 | end 70 | end 71 | end 72 | 73 | if !@destination.nil? 74 | puts "Found destination! Move file to #{@destination}" 75 | $dz.begin("Moving \"#{filename}\" to #{@destination}...") 76 | FileUtils.mv(filepath, @destination) 77 | system("open \"#{@destination}\"") 78 | @log = "[Done] Moved \"#{filename}\" to #{File.basename(@destination)}.\n#{@log}" 79 | else 80 | puts "Folder for \"#{filename}\" not found!" 81 | @fail = "[Fail] Folder for \"#{filename}\" not found!\n#{@fail}" 82 | end 83 | end 84 | 85 | if @fail.empty? then 86 | $dz.finish("Finishing sorting files.") 87 | else 88 | $dz.finish("Finishing sorting files with errors.") 89 | end 90 | $dz.url(false) 91 | $dz.alert("File Sort for "+File.basename(folder),"#{@log}--\n#{@fail}") 92 | end 93 | 94 | def clicked 95 | folder = ENV['path'] 96 | system("open \"#{folder}\"") 97 | end 98 | -------------------------------------------------------------------------------- /File Sort.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/File Sort.dzbundle/icon.png -------------------------------------------------------------------------------- /Gist.dzbundle/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'gist' 4 | -------------------------------------------------------------------------------- /Gist.dzbundle/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | gist (5.1.0) 5 | 6 | PLATFORMS 7 | ruby 8 | 9 | DEPENDENCIES 10 | gist 11 | 12 | BUNDLED WITH 13 | 1.15.4 14 | -------------------------------------------------------------------------------- /Gist.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Gist 3 | # Version: 1.4 4 | # Description: Sends the dropped text or files to the GitHub Gist service (http://gist.github.com) and puts the resulting URL on the clipboard.\nGists are private by default, hold any modifier key while dragging to create a public one.\n\nCreate a personal access token at https://github.com/settings/tokens with gist permissions and paste this into the API key field. 5 | # Handles: Files, Text 6 | # Creator: Leonardo Fedalto 7 | # URL: https://github.com/Fedalto 8 | # Events: Clicked, Dragged 9 | # KeyModifiers: Command, Option, Control, Shift 10 | # SkipConfig: No 11 | # LoginTitle: GitHub Access Token 12 | # OptionsNIB: APIKey 13 | # RunsSandboxed: Yes 14 | # MinDropzoneVersion: 3.0 15 | # UniqueID: 1034 16 | 17 | require './bundler/setup' 18 | require 'gist' 19 | 20 | def public? 21 | not ENV['KEY_MODIFIERS'].nil? 22 | end 23 | 24 | def create_gist gist_args 25 | begin 26 | Gist.multi_gist( 27 | gist_args, 28 | access_token: ENV['api_key'].strip, 29 | public: public?, 30 | ) 31 | rescue RuntimeError => exc 32 | if exc.message.include? "Net::HTTPUnauthorized" 33 | $dz.error("Could not create gist.", 34 | "Please ensure that the API access token is correct " \ 35 | "and has permission to manage your gists.") 36 | else 37 | $dz.error("Could not create gist.", exc.message) 38 | end 39 | end 40 | end 41 | 42 | def gist_text text 43 | new_gist = create_gist({'gistfile.txt' => text}) 44 | new_gist['html_url'] 45 | end 46 | 47 | def gist_files files 48 | gist_arg = {} 49 | files.each do |file_path| 50 | if File.directory? file_path 51 | $dz.error("Could not create gist", "#{file_path} is a directory") 52 | end 53 | unless `/usr/bin/file -bI \"#{file_path}\"` =~ /^text/ 54 | $dz.error("Invalid file type", "#{File.basename(file_path)} is not a text file.") 55 | end 56 | filename = File.basename file_path 57 | gist_arg[filename] = File.read file_path 58 | end 59 | 60 | new_gist = create_gist gist_arg 61 | new_gist['html_url'] 62 | end 63 | 64 | def dragged 65 | $dz.begin("Creating gist...") 66 | $dz.determinate(false) 67 | 68 | gist_url = case ENV['dragged_type'] 69 | when 'files' 70 | gist_files $items 71 | when 'text' 72 | gist_text $items[0] 73 | end 74 | 75 | $dz.finish("Gist URL copied to clipboard") 76 | $dz.url(gist_url) 77 | end 78 | 79 | def clicked 80 | system("open http://gist.github.com/") 81 | $dz.url(false) 82 | end 83 | -------------------------------------------------------------------------------- /Gist.dzbundle/bundler/setup.rb: -------------------------------------------------------------------------------- 1 | require 'rbconfig' 2 | # ruby 1.8.7 doesn't define RUBY_ENGINE 3 | ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' 4 | ruby_version = RbConfig::CONFIG["ruby_version"] 5 | path = File.expand_path('..', __FILE__) 6 | $:.unshift "#{path}/" 7 | $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/gist-5.1.0/lib" 8 | -------------------------------------------------------------------------------- /Gist.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Gist.dzbundle/icon.png -------------------------------------------------------------------------------- /Google Maps.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Google Maps 3 | # Description: Localise an address with Google Maps, drag an address to the dropzone or click on the action after pasting an address. 4 | # Handles: Text 5 | # Creator: jota3 6 | # URL: https://github.com/jota3 7 | # Events: Clicked, Dragged 8 | # KeyModifiers: Command, Option, Control, Shift 9 | # SkipConfig: No 10 | # RunsSandboxed: Yes 11 | # Version: 1.0 12 | # MinDropzoneVersion: 3.0 13 | # UniqueID: 168438749 14 | 15 | def dragged 16 | puts $items.inspect 17 | case ENV['dragged_type'] 18 | when 'text' 19 | localise_address($items[0]) 20 | end 21 | $dz.url(false) 22 | end 23 | 24 | def clicked 25 | address = $dz.read_clipboard 26 | localise_address(address) 27 | $dz.url(false) 28 | end 29 | 30 | def localise_address(address) 31 | gmaps_url = "https://maps.google.com/?q=" 32 | system("open", gmaps_url + address) 33 | end 34 | 35 | -------------------------------------------------------------------------------- /Google Maps.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Google Maps.dzbundle/icon.png -------------------------------------------------------------------------------- /ImageShack.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/ImageShack.dzbundle/icon.png -------------------------------------------------------------------------------- /ImageShack.dzbundle/imageshack.rb: -------------------------------------------------------------------------------- 1 | require 'post_request' 2 | require 'json' 3 | require 'uri' 4 | require 'net/https' 5 | 6 | class ImageShack 7 | attr_accessor :error_message 8 | 9 | def get_auth_token(username, password) 10 | form_data = { 11 | :user => username, 12 | :password => password 13 | } 14 | 15 | post_request = PostRequest.new("https://api.imageshack.com/v2/user/login", form_data) 16 | 17 | begin 18 | response = post_request.post 19 | json = JSON.parse(response) 20 | rescue 21 | @error_message = $! 22 | return 23 | end 24 | 25 | if json["result"] and json["result"]["auth_token"] 26 | return json["result"]["auth_token"] 27 | else 28 | if json["error"] and json["error"]["error_message"] 29 | @error_message = json["error"]["error_message"] 30 | else 31 | puts response.body 32 | @error_message = "Invalid JSON received" 33 | end 34 | return nil 35 | end 36 | end 37 | 38 | def get_url(json) 39 | if json["result"] and json["result"]["images"].length > 0 40 | return json["result"]["images"][0]["direct_link"] 41 | else 42 | if json["error"] and json["error"]["error_message"] 43 | @error_message = json["error"]["error_message"] 44 | else 45 | @error_message = "Invalid JSON received" 46 | end 47 | return nil 48 | end 49 | end 50 | 51 | def create_album(album_name, auth_token) 52 | form_data = { 53 | :api_key => ENV['api_key'], 54 | :auth_token => auth_token, 55 | :title => album_name 56 | } 57 | 58 | post_request = PostRequest.new("https://api.imageshack.com/v2/albums", form_data) 59 | 60 | album_creation_success = false 61 | 62 | begin 63 | response = post_request.post 64 | json = JSON.parse(response) 65 | if json["success"] and json["result"] and json["result"]["id"] 66 | album_creation_success = true 67 | else 68 | album_creation_success = false 69 | end 70 | rescue 71 | album_creation_success = false 72 | error_message = $! 73 | end 74 | 75 | if (album_creation_success) 76 | return json 77 | else 78 | puts response 79 | if json["error"] and json["error"]["error_message"] 80 | error_output = json["error"]["error_message"] 81 | else 82 | error_output = (error_message ? "Error:: #{error_message}\n\nResponse: #{response}" : "Response not valid:: #{response}") 83 | end 84 | $dz.error("Album creation failed", "The album could not be created.\n\n#{error_output}") 85 | end 86 | 87 | end 88 | end -------------------------------------------------------------------------------- /KDiff3.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: KDiff3 3 | # Description: Drag 2 or 3 files or folders to diff them with KDiff3. Hold a modifier key (⌘, ⌥, ⌃, or ⇧) while dragging to merge the items. 4 | # Creator: Eric W. Wallace 5 | # URL: http://www.ewall.org/dev/dropzone 6 | # Handles: Files 7 | # Events: Clicked, Dragged 8 | # KeyModifiers: Command, Option, Control, Shift 9 | # SkipConfig: Yes 10 | # RunsSandboxed: Yes 11 | # UniqueID: 1033 12 | # Version: 1.0 13 | # MinDropzoneVersion: 3.0 14 | 15 | def findApp 16 | # try default location to start 17 | app = '/Applications/kdiff3.app/Contents/MacOS/kdiff3' 18 | 19 | unless FileTest.executable?(app) 20 | 21 | if !ENV['apppath'].nil? and FileTest.executable?(ENV['apppath']) 22 | # we have a valid saved path 23 | app = ENV['apppath'] 24 | 25 | else 26 | # no saved path, so prompt for it 27 | output = $dz.cocoa_dialog('fileselect --title "Select the Application" --informative-text "Browse to the KDiff3 app:" --with-directory /Applications --select-directories ‑‑with‑extensions .app') 28 | apppkg = output.strip 29 | 30 | $dz.fail("Cancelled") if apppkg == '' 31 | 32 | app = "#{apppkg}/Contents/MacOS/kdiff3" 33 | unless FileTest.executable?(app) 34 | $dz.fail('Cannot find KDiff3 at given location; please try again and browse to the appropriate app.') 35 | end 36 | 37 | # ...and save it for future use 38 | $dz.save_value('apppath', app) 39 | end 40 | 41 | end 42 | return app 43 | end 44 | 45 | def dragged 46 | $dz.begin("Opening KDiff3...") 47 | 48 | if $items.size < 2 49 | $dz.fail "KDiff3 can compare 2 or 3 items, whether files or folders. Have you considered stashing the itmes in the Drop Bar, then dragging them onto the action as group?" 50 | exit 51 | elsif $items.size > 3 52 | $dz.finish "Sorry, but KDiff3 can only compare no more than 3 items (files or folders)." 53 | end 54 | 55 | if !ENV['KEY_MODIFIERS'].nil? 56 | $items.push('-m') # add flag to merge 57 | end 58 | 59 | result = system(findApp(), *$items) 60 | #$dz.fail("Error executing KDiff3") if result > 0 #skip error check due to Mavericks' "modalSession has been exited prematurely" bug on KDiff3 and other apps 61 | $dz.url(false) 62 | end 63 | 64 | def clicked 65 | $dz.begin("Opening KDiff3...") 66 | 67 | result = system(findApp()) 68 | #$dz.fail("Error executing KDiff3") if result > 0 #skip error check due to Mavericks' "modalSession has been exited prematurely" bug on KDiff3 and other apps 69 | $dz.url(false) 70 | end -------------------------------------------------------------------------------- /KDiff3.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/KDiff3.dzbundle/icon.png -------------------------------------------------------------------------------- /Kaleidoscope Diff.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Kaleidoscope Diff 3 | # Description: Drag two or more files to diff them with Kaleidoscope 4 | # Handles: Files 5 | # Events: Dragged 6 | # Creator: Justin Hileman 7 | # URL: http://justinhileman.com 8 | # Version: 1.1 9 | # SkipConfig: Yes 10 | # RunsSandboxed: Yes 11 | # MinDropzoneVersion: 3.0 12 | # UniqueID: 1018 13 | 14 | def dragged 15 | unless system('open', '-bcom.blackpixel.kaleidoscope', *$items) 16 | $dz.fail('Error opening Kaleidoscope') 17 | end 18 | 19 | $dz.url(false) 20 | end 21 | -------------------------------------------------------------------------------- /Kaleidoscope Diff.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Kaleidoscope Diff.dzbundle/icon.png -------------------------------------------------------------------------------- /MD to HTML Presentation Converter.dzbundle/.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_PATH: bundle 3 | BUNDLE_DISABLE_SHARED_GEMS: '1' 4 | -------------------------------------------------------------------------------- /MD to HTML Presentation Converter.dzbundle/Basic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Will be the CSS file for the Basic Theme 3 | */ 4 | 5 | body { 6 | background-color: rgba(79, 150, 200, 0.4); 7 | } 8 | 9 | .slide { 10 | color: rgb(221, 239, 252); 11 | background-color: rgba(79, 150, 200, 0.4); 12 | } 13 | 14 | .slide h1, .slide h2, .slide h3, .slide h4, .slide h5, .slide h6, .slide p, .slide ol li, .slide ul li { 15 | font-family: Times; 16 | } 17 | 18 | .background { 19 | opacity : .80; 20 | } 21 | 22 | .slide h1 { 23 | font-size: 10em; 24 | } 25 | 26 | .slide h2 { 27 | font-size: 8em; 28 | } 29 | 30 | .slide h3 { 31 | font-size: 6em; 32 | } 33 | 34 | .slide h4 { 35 | font-size: 4em; 36 | } 37 | 38 | .slide h5 { 39 | font-size: 2em; 40 | } 41 | 42 | .slide h6 { 43 | font-size: 1em; 44 | } 45 | 46 | .slide p { 47 | font-size: 2em; 48 | } 49 | 50 | .slide ol { 51 | list-style: decimal-leading-zero; 52 | text-align: left; 53 | } 54 | 55 | .slide ol li { 56 | font-size: 2em; 57 | } 58 | 59 | .slide ul { 60 | list-style: disc; 61 | text-align: left; 62 | } 63 | 64 | .slide ul li { 65 | font-size: 2em; 66 | } 67 | -------------------------------------------------------------------------------- /MD to HTML Presentation Converter.dzbundle/Script.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is the Script Theme. Mostly a test for Google Fonts usage. 3 | */ 4 | 5 | @import url(http://fonts.googleapis.com/css?family=Playball); 6 | 7 | body { 8 | background-color: rgba(178, 161, 82, 0.4); 9 | } 10 | 11 | .slide { 12 | color: rgb(155, 133, 25); 13 | background-color: rgba(178, 161, 82, .4); 14 | } 15 | 16 | .slide h1, .slide h2, .slide h3, .slide h4, .slide h5, .slide h6, .slide p, .slide ol li, .slide ul li { 17 | font-family: 'Playball', cursive; 18 | } 19 | 20 | .background { 21 | opacity : .50; 22 | } 23 | 24 | .slide h1 { 25 | font-size: 10em; 26 | margin-bottom: .5em; 27 | } 28 | 29 | .slide h2 { 30 | font-size: 8em; 31 | } 32 | 33 | .slide h3 { 34 | font-size: 6em; 35 | } 36 | 37 | .slide h4 { 38 | font-size: 4em; 39 | } 40 | 41 | .slide h5 { 42 | font-size: 2em; 43 | } 44 | 45 | .slide h6 { 46 | font-size: 1em; 47 | } 48 | 49 | .slide p { 50 | font-size: 2em; 51 | } 52 | 53 | .slide ol { 54 | list-style: decimal-leading-zero; 55 | text-align: left; 56 | } 57 | 58 | .slide ol li { 59 | font-size: 2em; 60 | } 61 | 62 | .slide ul { 63 | list-style: disc; 64 | text-align: left; 65 | } 66 | 67 | .slide ul li { 68 | font-size: 2em; 69 | } 70 | -------------------------------------------------------------------------------- /MD to HTML Presentation Converter.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/MD to HTML Presentation Converter.dzbundle/icon.png -------------------------------------------------------------------------------- /Make GIF.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Make GIF 3 | # Description: This action converts videos to GIFs using ffmpeg 4 | # Handles: Files 5 | # Creator: BlahGeek 6 | # URL: http://blahgeek.com 7 | # Events: Clicked, Dragged 8 | # RunsSandboxed: No 9 | # Version: 1.0 10 | # MinDropzoneVersion: 3.0 11 | # OptionsNIB: ChooseFolder 12 | 13 | def dragged 14 | $dz.determinate(false) 15 | 16 | path = ENV['path'] 17 | if !File.directory?(path) 18 | $dz.error("Please set a output directory") 19 | end 20 | 21 | basename = File.basename($items[0]) 22 | ret = system("/usr/local/bin/ffmpeg -i \"#{$items[0]}\" -pix_fmt rgb24 -r 5 \"#{path}\"/\"#{basename}\".gif") 23 | 24 | if !ret 25 | $dz.fail("Have you installed ffmpeg? Or is your input valid?") 26 | else 27 | $dz.finish("Done making GIF") 28 | $dz.url(false) 29 | end 30 | end 31 | 32 | def clicked 33 | path = ENV['path'] 34 | if !File.directory?(path) 35 | $dz.error("Please set a output directory") 36 | end 37 | `open #{path}` 38 | end 39 | -------------------------------------------------------------------------------- /Make GIF.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Make GIF.dzbundle/icon.png -------------------------------------------------------------------------------- /Merge Directories.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Merge Directories 3 | # Description: Takes directories as the input. Each directory should have the same number of files. The files are combined into a zip: one from each directory in order. 4 | # Handles: Files 5 | # Creator: Richard Guay 6 | # URL: http://customct.com 7 | # Events: Dragged 8 | # SkipConfig: No 9 | # RunsSandboxed: No 10 | # Version: 1.2 11 | # MinDropzoneVersion: 3.2.1 12 | 13 | def dragged 14 | # 15 | # Begin the Action. 16 | # 17 | $dz.determinate(true) 18 | mainDir = File.dirname($items[0]) 19 | 20 | # 21 | # Create the Zip directory. 22 | # 23 | zipDir = File.join(mainDir,"Zips") 24 | Dir.mkdir(zipDir) 25 | 26 | # 27 | # Get a list of each directories files. 28 | # 29 | dirList = Array.new 30 | $items.each_index { |index| 31 | dirList[index] = Dir.entries($items[index]) 32 | dirList[index].delete(".") 33 | dirList[index].delete("..") 34 | dirList[index].delete(".DS_Store") 35 | } 36 | numFiles = dirList[0].length 37 | 38 | # 39 | # Create the Zip files in the zipDir. 40 | # 41 | for index in (0..(numFiles-1)) do 42 | files = Array.new() 43 | $items.each_index { |inner| 44 | files[inner] = File.join($items[inner],dirList[inner][index]) 45 | } 46 | filename = File.basename(files[0],".*") + ".zip" 47 | zipfile = ZipFiles.zip(files, filename) 48 | zipfile = zipfile[1, zipfile.length - 2] 49 | 50 | # 51 | # Remove the OS X files from the zip file. 52 | # 53 | system("zip -d \"#{zipfile}\" '__MACOSX*' '*.DS_Store' >& /dev/null") 54 | 55 | # 56 | # Move the zip to the directory of the files. 57 | # 58 | Rsync.do_copy([zipfile], "#{zipDir}/#{filename}", true) 59 | 60 | # 61 | # Set the percentage done. 62 | # 63 | $dz.percent((index/numFiles)*100) 64 | end 65 | 66 | # 67 | # Finalize. 68 | # 69 | $dz.finish("ZIPs created") 70 | $dz.url(false) 71 | end 72 | -------------------------------------------------------------------------------- /Merge Directories.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Merge Directories.dzbundle/icon.png -------------------------------------------------------------------------------- /Node HTTP Server at Path.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Node HTTP Server at Path 3 | # Description: Creates a Node HTTP-Server at path and opens default browser. Node http-server required, to install `npm install -g http-server` Close iTerm or CTRL+C to quit server 4 | # Handles: Files 5 | # Creator: Sam Turner 6 | # URL: http://www.digi.ltd.uk 7 | # Events: Dragged 8 | # SkipConfig: No 9 | # RunsSandboxed: Yes 10 | # Version: 1.0 11 | # MinDropzoneVersion: 3.0 12 | 13 | 14 | def dragged 15 | dir = false 16 | 17 | $dz.begin("Starting Note HTTP Server...") 18 | $dz.determinate(true) 19 | 20 | case ENV['dragged_type'] 21 | when 'files' 22 | # If it's a directory then cd to that directory, otherwise we will cd to the directory the file is in 23 | if File.directory?($items[0]) 24 | dir = $items[0] 25 | else 26 | dir = File.dirname($items[0]) 27 | end 28 | when 'text' 29 | # Verify that this is a directory path 30 | dir = $items[0] if File.directory?($items[0]) 31 | end 32 | 33 | puts dir 34 | 35 | # Launch iTerm in desired directory 36 | if dir 37 | puts `osascript -so < 8 | ''' 9 | 10 | # flake8: noqa 11 | 12 | __version__ = '7.0.5' 13 | 14 | from .auth import Auth 15 | 16 | from .config import set_default, Zone 17 | 18 | from .services.storage.bucket import BucketManager, build_batch_copy, build_batch_rename, build_batch_move, build_batch_stat, build_batch_delete 19 | from .services.storage.uploader import put_data, put_file, put_stream 20 | from .services.processing.pfop import PersistentFop 21 | from .services.processing.cmd import build_op, pipe_cmd, op_save 22 | 23 | from .utils import urlsafe_base64_encode, urlsafe_base64_decode, etag, entry 24 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/qiniu/compat.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | pythoncompat 5 | """ 6 | 7 | import sys 8 | 9 | try: 10 | import simplejson as json 11 | except (ImportError, SyntaxError): 12 | # simplejson does not support Python 3.2, it thows a SyntaxError 13 | # because of u'...' Unicode literals. 14 | import json # noqa 15 | 16 | 17 | # ------- 18 | # Pythons 19 | # ------- 20 | 21 | _ver = sys.version_info 22 | 23 | #: Python 2.x? 24 | is_py2 = (_ver[0] == 2) 25 | 26 | #: Python 3.x? 27 | is_py3 = (_ver[0] == 3) 28 | 29 | 30 | # --------- 31 | # Specifics 32 | # --------- 33 | 34 | if is_py2: 35 | from urlparse import urlparse # noqa 36 | import StringIO 37 | StringIO = BytesIO = StringIO.StringIO 38 | 39 | builtin_str = str 40 | bytes = str 41 | str = unicode # noqa 42 | basestring = basestring # noqa 43 | numeric_types = (int, long, float) # noqa 44 | 45 | def b(data): 46 | return data 47 | 48 | def s(data): 49 | return data 50 | 51 | def u(data): 52 | return unicode(data, 'unicode_escape') # noqa 53 | 54 | elif is_py3: 55 | from urllib.parse import urlparse # noqa 56 | import io 57 | StringIO = io.StringIO 58 | BytesIO = io.BytesIO 59 | 60 | builtin_str = str 61 | str = str 62 | bytes = bytes 63 | basestring = (str, bytes) 64 | numeric_types = (int, float) 65 | 66 | def b(data): 67 | if isinstance(data, str): 68 | return data.encode('utf-8') 69 | return data 70 | 71 | def s(data): 72 | if isinstance(data, bytes): 73 | data = data.decode('utf-8') 74 | return data 75 | 76 | def u(data): 77 | return data 78 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/qiniu/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | RS_HOST = 'rs.qbox.me' # 管理操作Host 4 | IO_HOST = 'iovip.qbox.me' # 七牛源站Host 5 | RSF_HOST = 'rsf.qbox.me' # 列举操作Host 6 | API_HOST = 'api.qiniu.com' # 数据处理操作Host 7 | 8 | _BLOCK_SIZE = 1024 * 1024 * 4 # 断点续上传分块大小,该参数为接口规格,暂不支持修改 9 | 10 | 11 | class Zone(object): 12 | """七牛上传区域类 13 | 14 | 该类主要内容上传区域地址。 15 | 16 | Attributes: 17 | up_host: 首选上传地址 18 | up_host_backup: 备用上传地址 19 | """ 20 | def __init__(self, up_host, up_host_backup): 21 | """初始化Zone类""" 22 | self.up_host, self.up_host_backup = up_host, up_host_backup 23 | 24 | 25 | zone0 = Zone('up.qiniu.com', 'upload.qiniu.com') 26 | zone1 = Zone('up-z1.qiniu.com', 'upload-z1.qiniu.com') 27 | 28 | _config = { 29 | 'default_up_host': zone0.up_host, # 设置为默认上传Host 30 | 'default_up_host_backup': zone0.up_host_backup, 31 | 'default_rs_host': RS_HOST, 32 | 'default_io_host': IO_HOST, 33 | 'default_rsf_host': RSF_HOST, 34 | 'default_api_host': API_HOST, 35 | 'connection_timeout': 30, # 链接超时为时间为30s 36 | 'connection_retries': 3, # 链接重试次数为3次 37 | 'connection_pool': 10, # 链接池个数为10 38 | } 39 | 40 | 41 | def get_default(key): 42 | return _config[key] 43 | 44 | 45 | def set_default( 46 | default_zone=None, connection_retries=None, connection_pool=None, 47 | connection_timeout=None, default_rs_host=None, default_io_host=None, 48 | default_rsf_host=None, default_api_host=None): 49 | if default_zone: 50 | _config['default_up_host'] = default_zone.up_host 51 | _config['default_up_host_backup'] = default_zone.up_host_backup 52 | if default_rs_host: 53 | _config['default_rs_host'] = default_rs_host 54 | if default_io_host: 55 | _config['default_io_host'] = default_io_host 56 | if default_rsf_host: 57 | _config['default_rsf_host'] = default_rsf_host 58 | if default_api_host: 59 | _config['default_api_host'] = default_api_host 60 | if connection_retries: 61 | _config['connection_retries'] = connection_retries 62 | if connection_pool: 63 | _config['connection_pool'] = connection_pool 64 | if connection_timeout: 65 | _config['connection_timeout'] = connection_timeout 66 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/qiniu/main.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import argparse 5 | 6 | from qiniu import etag 7 | 8 | 9 | def main(): 10 | parser = argparse.ArgumentParser(prog='qiniu') 11 | sub_parsers = parser.add_subparsers() 12 | 13 | parser_etag = sub_parsers.add_parser( 14 | 'etag', description='calculate the etag of the file', help='etag [file...]') 15 | parser_etag.add_argument( 16 | 'etag_files', metavar='N', nargs='+', help='the file list for calculate') 17 | 18 | args = parser.parse_args() 19 | 20 | try: 21 | etag_files = args.etag_files 22 | 23 | except AttributeError: 24 | etag_files = None 25 | 26 | if etag_files: 27 | r = [etag(file) for file in etag_files] 28 | if len(r) == 1: 29 | print(r[0]) 30 | else: 31 | print(' '.join(r)) 32 | 33 | if __name__ == '__main__': 34 | main() 35 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/qiniu/services/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Qiniu.dzbundle/qiniu/services/__init__.py -------------------------------------------------------------------------------- /Qiniu.dzbundle/qiniu/services/processing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Qiniu.dzbundle/qiniu/services/processing/__init__.py -------------------------------------------------------------------------------- /Qiniu.dzbundle/qiniu/services/processing/cmd.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from qiniu.utils import entry 4 | 5 | 6 | def build_op(cmd, first_arg, **kwargs): 7 | op = [cmd] 8 | if first_arg is not None: 9 | op.append(first_arg) 10 | 11 | for k, v in kwargs.items(): 12 | op.append('{0}/{1}'.format(k, v)) 13 | 14 | return '/'.join(op) 15 | 16 | 17 | def pipe_cmd(*cmds): 18 | return '|'.join(cmds) 19 | 20 | 21 | def op_save(op, bucket, key): 22 | return pipe_cmd(op, 'saveas/' + entry(bucket, key)) 23 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/qiniu/services/processing/pfop.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from qiniu import config 4 | from qiniu import http 5 | 6 | 7 | class PersistentFop(object): 8 | """持久化处理类 9 | 10 | 该类用于主动触发异步持久化操作,具体规格参考: 11 | http://developer.qiniu.com/docs/v6/api/reference/fop/pfop/pfop.html 12 | 13 | Attributes: 14 | auth: 账号管理密钥对,Auth对象 15 | bucket: 操作资源所在空间 16 | pipeline: 多媒体处理队列,详见 https://portal.qiniu.com/mps/pipeline 17 | notify_url: 持久化处理结果通知URL 18 | """ 19 | 20 | def __init__(self, auth, bucket, pipeline=None, notify_url=None): 21 | """初始化持久化处理类""" 22 | self.auth = auth 23 | self.bucket = bucket 24 | self.pipeline = pipeline 25 | self.notify_url = notify_url 26 | 27 | def execute(self, key, fops, force=None): 28 | """执行持久化处理: 29 | 30 | Args: 31 | key: 待处理的源文件 32 | fops: 处理详细操作,规格详见 http://developer.qiniu.com/docs/v6/api/reference/fop/ 33 | force: 强制执行持久化处理开关 34 | 35 | Returns: 36 | 一个dict变量,返回持久化处理的persistentId,类似{"persistentId": 5476bedf7823de4068253bae}; 37 | 一个ResponseInfo对象 38 | """ 39 | ops = ';'.join(fops) 40 | data = {'bucket': self.bucket, 'key': key, 'fops': ops} 41 | if self.pipeline: 42 | data['pipeline'] = self.pipeline 43 | if self.notify_url: 44 | data['notifyURL'] = self.notify_url 45 | if force == 1: 46 | data['force'] = 1 47 | 48 | url = 'http://{0}/pfop'.format(config.get_default('default_api_host')) 49 | return http._post_with_auth(url, data, self.auth) 50 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/qiniu/services/storage/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Qiniu.dzbundle/qiniu/services/storage/__init__.py -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # __ 4 | # /__) _ _ _ _ _/ _ 5 | # / ( (- (/ (/ (- _) / _) 6 | # / 7 | 8 | """ 9 | requests HTTP library 10 | ~~~~~~~~~~~~~~~~~~~~~ 11 | 12 | Requests is an HTTP library, written in Python, for human beings. Basic GET 13 | usage: 14 | 15 | >>> import requests 16 | >>> r = requests.get('https://www.python.org') 17 | >>> r.status_code 18 | 200 19 | >>> 'Python is a programming language' in r.content 20 | True 21 | 22 | ... or POST: 23 | 24 | >>> payload = dict(key1='value1', key2='value2') 25 | >>> r = requests.post('http://httpbin.org/post', data=payload) 26 | >>> print(r.text) 27 | { 28 | ... 29 | "form": { 30 | "key2": "value2", 31 | "key1": "value1" 32 | }, 33 | ... 34 | } 35 | 36 | The other HTTP methods are supported - see `requests.api`. Full documentation 37 | is at . 38 | 39 | :copyright: (c) 2015 by Kenneth Reitz. 40 | :license: Apache 2.0, see LICENSE for more details. 41 | 42 | """ 43 | 44 | __title__ = 'requests' 45 | __version__ = '2.7.0' 46 | __build__ = 0x020700 47 | __author__ = 'Kenneth Reitz' 48 | __license__ = 'Apache 2.0' 49 | __copyright__ = 'Copyright 2015 Kenneth Reitz' 50 | 51 | # Attempt to enable urllib3's SNI support, if possible 52 | try: 53 | from .packages.urllib3.contrib import pyopenssl 54 | pyopenssl.inject_into_urllib3() 55 | except ImportError: 56 | pass 57 | 58 | from . import utils 59 | from .models import Request, Response, PreparedRequest 60 | from .api import request, get, head, post, patch, put, delete, options 61 | from .sessions import session, Session 62 | from .status_codes import codes 63 | from .exceptions import ( 64 | RequestException, Timeout, URLRequired, 65 | TooManyRedirects, HTTPError, ConnectionError 66 | ) 67 | 68 | # Set default logging handler to avoid "No handler found" warnings. 69 | import logging 70 | try: # Python 2.7+ 71 | from logging import NullHandler 72 | except ImportError: 73 | class NullHandler(logging.Handler): 74 | def emit(self, record): 75 | pass 76 | 77 | logging.getLogger(__name__).addHandler(NullHandler()) 78 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/certs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | certs.py 6 | ~~~~~~~~ 7 | 8 | This module returns the preferred default CA certificate bundle. 9 | 10 | If you are packaging Requests, e.g., for a Linux distribution or a managed 11 | environment, you can change the definition of where() to return a separately 12 | packaged CA bundle. 13 | """ 14 | import os.path 15 | 16 | try: 17 | from certifi import where 18 | except ImportError: 19 | def where(): 20 | """Return the preferred certificate bundle.""" 21 | # vendored bundle inside Requests 22 | return os.path.join(os.path.dirname(__file__), 'cacert.pem') 23 | 24 | if __name__ == '__main__': 25 | print(where()) 26 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/compat.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | pythoncompat 5 | """ 6 | 7 | from .packages import chardet 8 | 9 | import sys 10 | 11 | # ------- 12 | # Pythons 13 | # ------- 14 | 15 | # Syntax sugar. 16 | _ver = sys.version_info 17 | 18 | #: Python 2.x? 19 | is_py2 = (_ver[0] == 2) 20 | 21 | #: Python 3.x? 22 | is_py3 = (_ver[0] == 3) 23 | 24 | try: 25 | import simplejson as json 26 | except (ImportError, SyntaxError): 27 | # simplejson does not support Python 3.2, it throws a SyntaxError 28 | # because of u'...' Unicode literals. 29 | import json 30 | 31 | # --------- 32 | # Specifics 33 | # --------- 34 | 35 | if is_py2: 36 | from urllib import quote, unquote, quote_plus, unquote_plus, urlencode, getproxies, proxy_bypass 37 | from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag 38 | from urllib2 import parse_http_list 39 | import cookielib 40 | from Cookie import Morsel 41 | from StringIO import StringIO 42 | from .packages.urllib3.packages.ordered_dict import OrderedDict 43 | 44 | builtin_str = str 45 | bytes = str 46 | str = unicode 47 | basestring = basestring 48 | numeric_types = (int, long, float) 49 | 50 | elif is_py3: 51 | from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag 52 | from urllib.request import parse_http_list, getproxies, proxy_bypass 53 | from http import cookiejar as cookielib 54 | from http.cookies import Morsel 55 | from io import StringIO 56 | from collections import OrderedDict 57 | 58 | builtin_str = str 59 | str = str 60 | bytes = bytes 61 | basestring = (str, bytes) 62 | numeric_types = (int, float) 63 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/exceptions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.exceptions 5 | ~~~~~~~~~~~~~~~~~~~ 6 | 7 | This module contains the set of Requests' exceptions. 8 | 9 | """ 10 | from .packages.urllib3.exceptions import HTTPError as BaseHTTPError 11 | 12 | 13 | class RequestException(IOError): 14 | """There was an ambiguous exception that occurred while handling your 15 | request.""" 16 | 17 | def __init__(self, *args, **kwargs): 18 | """ 19 | Initialize RequestException with `request` and `response` objects. 20 | """ 21 | response = kwargs.pop('response', None) 22 | self.response = response 23 | self.request = kwargs.pop('request', None) 24 | if (response is not None and not self.request and 25 | hasattr(response, 'request')): 26 | self.request = self.response.request 27 | super(RequestException, self).__init__(*args, **kwargs) 28 | 29 | 30 | class HTTPError(RequestException): 31 | """An HTTP error occurred.""" 32 | 33 | 34 | class ConnectionError(RequestException): 35 | """A Connection error occurred.""" 36 | 37 | 38 | class ProxyError(ConnectionError): 39 | """A proxy error occurred.""" 40 | 41 | 42 | class SSLError(ConnectionError): 43 | """An SSL error occurred.""" 44 | 45 | 46 | class Timeout(RequestException): 47 | """The request timed out. 48 | 49 | Catching this error will catch both 50 | :exc:`~requests.exceptions.ConnectTimeout` and 51 | :exc:`~requests.exceptions.ReadTimeout` errors. 52 | """ 53 | 54 | 55 | class ConnectTimeout(ConnectionError, Timeout): 56 | """The request timed out while trying to connect to the remote server. 57 | 58 | Requests that produced this error are safe to retry. 59 | """ 60 | 61 | 62 | class ReadTimeout(Timeout): 63 | """The server did not send any data in the allotted amount of time.""" 64 | 65 | 66 | class URLRequired(RequestException): 67 | """A valid URL is required to make a request.""" 68 | 69 | 70 | class TooManyRedirects(RequestException): 71 | """Too many redirects.""" 72 | 73 | 74 | class MissingSchema(RequestException, ValueError): 75 | """The URL schema (e.g. http or https) is missing.""" 76 | 77 | 78 | class InvalidSchema(RequestException, ValueError): 79 | """See defaults.py for valid schemas.""" 80 | 81 | 82 | class InvalidURL(RequestException, ValueError): 83 | """ The URL provided was somehow invalid. """ 84 | 85 | 86 | class ChunkedEncodingError(RequestException): 87 | """The server declared chunked encoding but sent an invalid chunk.""" 88 | 89 | 90 | class ContentDecodingError(RequestException, BaseHTTPError): 91 | """Failed to decode response content""" 92 | 93 | 94 | class StreamConsumedError(RequestException, TypeError): 95 | """The content for this response was already consumed""" 96 | 97 | 98 | class RetryError(RequestException): 99 | """Custom retries logic failed""" 100 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/hooks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.hooks 5 | ~~~~~~~~~~~~~~ 6 | 7 | This module provides the capabilities for the Requests hooks system. 8 | 9 | Available hooks: 10 | 11 | ``response``: 12 | The response generated from a Request. 13 | 14 | """ 15 | 16 | 17 | HOOKS = ['response'] 18 | 19 | 20 | def default_hooks(): 21 | hooks = {} 22 | for event in HOOKS: 23 | hooks[event] = [] 24 | return hooks 25 | 26 | # TODO: response is the only one 27 | 28 | 29 | def dispatch_hook(key, hooks, hook_data, **kwargs): 30 | """Dispatches a hook dictionary on a given piece of data.""" 31 | 32 | hooks = hooks or dict() 33 | 34 | if key in hooks: 35 | hooks = hooks.get(key) 36 | 37 | if hasattr(hooks, '__call__'): 38 | hooks = [hooks] 39 | 40 | for hook in hooks: 41 | _hook_data = hook(hook_data, **kwargs) 42 | if _hook_data is not None: 43 | hook_data = _hook_data 44 | 45 | return hook_data 46 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import urllib3 4 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/__init__.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # This library is free software; you can redistribute it and/or 3 | # modify it under the terms of the GNU Lesser General Public 4 | # License as published by the Free Software Foundation; either 5 | # version 2.1 of the License, or (at your option) any later version. 6 | # 7 | # This library is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | # Lesser General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Lesser General Public 13 | # License along with this library; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 15 | # 02110-1301 USA 16 | ######################### END LICENSE BLOCK ######################### 17 | 18 | __version__ = "2.3.0" 19 | from sys import version_info 20 | 21 | 22 | def detect(aBuf): 23 | if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or 24 | (version_info >= (3, 0) and not isinstance(aBuf, bytes))): 25 | raise ValueError('Expected a bytes object, not a unicode object') 26 | 27 | from . import universaldetector 28 | u = universaldetector.UniversalDetector() 29 | u.reset() 30 | u.feed(aBuf) 31 | u.close() 32 | return u.result 33 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/big5prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import Big5DistributionAnalysis 31 | from .mbcssm import Big5SMModel 32 | 33 | 34 | class Big5Prober(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(Big5SMModel) 38 | self._mDistributionAnalyzer = Big5DistributionAnalysis() 39 | self.reset() 40 | 41 | def get_charset_name(self): 42 | return "Big5" 43 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/chardetect.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Script which takes one or more file paths and reports on their detected 4 | encodings 5 | 6 | Example:: 7 | 8 | % chardetect somefile someotherfile 9 | somefile: windows-1252 with confidence 0.5 10 | someotherfile: ascii with confidence 1.0 11 | 12 | If no paths are provided, it takes its input from stdin. 13 | 14 | """ 15 | 16 | from __future__ import absolute_import, print_function, unicode_literals 17 | 18 | import argparse 19 | import sys 20 | from io import open 21 | 22 | from chardet import __version__ 23 | from chardet.universaldetector import UniversalDetector 24 | 25 | 26 | def description_of(lines, name='stdin'): 27 | """ 28 | Return a string describing the probable encoding of a file or 29 | list of strings. 30 | 31 | :param lines: The lines to get the encoding of. 32 | :type lines: Iterable of bytes 33 | :param name: Name of file or collection of lines 34 | :type name: str 35 | """ 36 | u = UniversalDetector() 37 | for line in lines: 38 | u.feed(line) 39 | u.close() 40 | result = u.result 41 | if result['encoding']: 42 | return '{0}: {1} with confidence {2}'.format(name, result['encoding'], 43 | result['confidence']) 44 | else: 45 | return '{0}: no result'.format(name) 46 | 47 | 48 | def main(argv=None): 49 | ''' 50 | Handles command line arguments and gets things started. 51 | 52 | :param argv: List of arguments, as if specified on the command-line. 53 | If None, ``sys.argv[1:]`` is used instead. 54 | :type argv: list of str 55 | ''' 56 | # Get command line arguments 57 | parser = argparse.ArgumentParser( 58 | description="Takes one or more file paths and reports their detected \ 59 | encodings", 60 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, 61 | conflict_handler='resolve') 62 | parser.add_argument('input', 63 | help='File whose encoding we would like to determine.', 64 | type=argparse.FileType('rb'), nargs='*', 65 | default=[sys.stdin]) 66 | parser.add_argument('--version', action='version', 67 | version='%(prog)s {0}'.format(__version__)) 68 | args = parser.parse_args(argv) 69 | 70 | for f in args.input: 71 | if f.isatty(): 72 | print("You are running chardetect interactively. Press " + 73 | "CTRL-D twice at the start of a blank line to signal the " + 74 | "end of your input. If you want help, run chardetect " + 75 | "--help\n", file=sys.stderr) 76 | print(description_of(f, f.name)) 77 | 78 | 79 | if __name__ == '__main__': 80 | main() 81 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/charsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from . import constants 30 | import re 31 | 32 | 33 | class CharSetProber: 34 | def __init__(self): 35 | pass 36 | 37 | def reset(self): 38 | self._mState = constants.eDetecting 39 | 40 | def get_charset_name(self): 41 | return None 42 | 43 | def feed(self, aBuf): 44 | pass 45 | 46 | def get_state(self): 47 | return self._mState 48 | 49 | def get_confidence(self): 50 | return 0.0 51 | 52 | def filter_high_bit_only(self, aBuf): 53 | aBuf = re.sub(b'([\x00-\x7F])+', b' ', aBuf) 54 | return aBuf 55 | 56 | def filter_without_english_letters(self, aBuf): 57 | aBuf = re.sub(b'([A-Za-z])+', b' ', aBuf) 58 | return aBuf 59 | 60 | def filter_with_english_letters(self, aBuf): 61 | # TODO 62 | return aBuf 63 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/codingstatemachine.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .constants import eStart 29 | from .compat import wrap_ord 30 | 31 | 32 | class CodingStateMachine: 33 | def __init__(self, sm): 34 | self._mModel = sm 35 | self._mCurrentBytePos = 0 36 | self._mCurrentCharLen = 0 37 | self.reset() 38 | 39 | def reset(self): 40 | self._mCurrentState = eStart 41 | 42 | def next_state(self, c): 43 | # for each byte we get its class 44 | # if it is first byte, we also get byte length 45 | # PY3K: aBuf is a byte stream, so c is an int, not a byte 46 | byteCls = self._mModel['classTable'][wrap_ord(c)] 47 | if self._mCurrentState == eStart: 48 | self._mCurrentBytePos = 0 49 | self._mCurrentCharLen = self._mModel['charLenTable'][byteCls] 50 | # from byte's class and stateTable, we get its next state 51 | curr_state = (self._mCurrentState * self._mModel['classFactor'] 52 | + byteCls) 53 | self._mCurrentState = self._mModel['stateTable'][curr_state] 54 | self._mCurrentBytePos += 1 55 | return self._mCurrentState 56 | 57 | def get_current_charlen(self): 58 | return self._mCurrentCharLen 59 | 60 | def get_coding_state_machine(self): 61 | return self._mModel['name'] 62 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/compat.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # Contributor(s): 3 | # Ian Cordasco - port to Python 4 | # 5 | # This library is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU Lesser General Public 7 | # License as published by the Free Software Foundation; either 8 | # version 2.1 of the License, or (at your option) any later version. 9 | # 10 | # This library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with this library; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | # 02110-1301 USA 19 | ######################### END LICENSE BLOCK ######################### 20 | 21 | import sys 22 | 23 | 24 | if sys.version_info < (3, 0): 25 | base_str = (str, unicode) 26 | else: 27 | base_str = (bytes, str) 28 | 29 | 30 | def wrap_ord(a): 31 | if sys.version_info < (3, 0) and isinstance(a, base_str): 32 | return ord(a) 33 | else: 34 | return a 35 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/constants.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | _debug = 0 30 | 31 | eDetecting = 0 32 | eFoundIt = 1 33 | eNotMe = 2 34 | 35 | eStart = 0 36 | eError = 1 37 | eItsMe = 2 38 | 39 | SHORTCUT_THRESHOLD = 0.95 40 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/cp949prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCKRDistributionAnalysis 31 | from .mbcssm import CP949SMModel 32 | 33 | 34 | class CP949Prober(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(CP949SMModel) 38 | # NOTE: CP949 is a superset of EUC-KR, so the distribution should be 39 | # not different. 40 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis() 41 | self.reset() 42 | 43 | def get_charset_name(self): 44 | return "CP949" 45 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/euckrprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCKRDistributionAnalysis 31 | from .mbcssm import EUCKRSMModel 32 | 33 | 34 | class EUCKRProber(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(EUCKRSMModel) 38 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis() 39 | self.reset() 40 | 41 | def get_charset_name(self): 42 | return "EUC-KR" 43 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/euctwprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCTWDistributionAnalysis 31 | from .mbcssm import EUCTWSMModel 32 | 33 | class EUCTWProber(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(EUCTWSMModel) 37 | self._mDistributionAnalyzer = EUCTWDistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "EUC-TW" 42 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/gb2312prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import GB2312DistributionAnalysis 31 | from .mbcssm import GB2312SMModel 32 | 33 | class GB2312Prober(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(GB2312SMModel) 37 | self._mDistributionAnalyzer = GB2312DistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "GB2312" 42 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/mbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | from .charsetgroupprober import CharSetGroupProber 31 | from .utf8prober import UTF8Prober 32 | from .sjisprober import SJISProber 33 | from .eucjpprober import EUCJPProber 34 | from .gb2312prober import GB2312Prober 35 | from .euckrprober import EUCKRProber 36 | from .cp949prober import CP949Prober 37 | from .big5prober import Big5Prober 38 | from .euctwprober import EUCTWProber 39 | 40 | 41 | class MBCSGroupProber(CharSetGroupProber): 42 | def __init__(self): 43 | CharSetGroupProber.__init__(self) 44 | self._mProbers = [ 45 | UTF8Prober(), 46 | SJISProber(), 47 | EUCJPProber(), 48 | GB2312Prober(), 49 | EUCKRProber(), 50 | CP949Prober(), 51 | Big5Prober(), 52 | EUCTWProber() 53 | ] 54 | self.reset() 55 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/chardet/utf8prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | from .charsetprober import CharSetProber 30 | from .codingstatemachine import CodingStateMachine 31 | from .mbcssm import UTF8SMModel 32 | 33 | ONE_CHAR_PROB = 0.5 34 | 35 | 36 | class UTF8Prober(CharSetProber): 37 | def __init__(self): 38 | CharSetProber.__init__(self) 39 | self._mCodingSM = CodingStateMachine(UTF8SMModel) 40 | self.reset() 41 | 42 | def reset(self): 43 | CharSetProber.reset(self) 44 | self._mCodingSM.reset() 45 | self._mNumOfMBChar = 0 46 | 47 | def get_charset_name(self): 48 | return "utf-8" 49 | 50 | def feed(self, aBuf): 51 | for c in aBuf: 52 | codingState = self._mCodingSM.next_state(c) 53 | if codingState == constants.eError: 54 | self._mState = constants.eNotMe 55 | break 56 | elif codingState == constants.eItsMe: 57 | self._mState = constants.eFoundIt 58 | break 59 | elif codingState == constants.eStart: 60 | if self._mCodingSM.get_current_charlen() >= 2: 61 | self._mNumOfMBChar += 1 62 | 63 | if self.get_state() == constants.eDetecting: 64 | if self.get_confidence() > constants.SHORTCUT_THRESHOLD: 65 | self._mState = constants.eFoundIt 66 | 67 | return self.get_state() 68 | 69 | def get_confidence(self): 70 | unlike = 0.99 71 | if self._mNumOfMBChar < 6: 72 | for i in range(0, self._mNumOfMBChar): 73 | unlike = unlike * ONE_CHAR_PROB 74 | return 1.0 - unlike 75 | else: 76 | return unlike 77 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/urllib3/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | urllib3 - Thread-safe connection pooling and re-using. 3 | """ 4 | 5 | __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)' 6 | __license__ = 'MIT' 7 | __version__ = '1.10.4' 8 | 9 | 10 | from .connectionpool import ( 11 | HTTPConnectionPool, 12 | HTTPSConnectionPool, 13 | connection_from_url 14 | ) 15 | 16 | from . import exceptions 17 | from .filepost import encode_multipart_formdata 18 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url 19 | from .response import HTTPResponse 20 | from .util.request import make_headers 21 | from .util.url import get_host 22 | from .util.timeout import Timeout 23 | from .util.retry import Retry 24 | 25 | 26 | # Set default logging handler to avoid "No handler found" warnings. 27 | import logging 28 | try: # Python 2.7+ 29 | from logging import NullHandler 30 | except ImportError: 31 | class NullHandler(logging.Handler): 32 | def emit(self, record): 33 | pass 34 | 35 | logging.getLogger(__name__).addHandler(NullHandler()) 36 | 37 | def add_stderr_logger(level=logging.DEBUG): 38 | """ 39 | Helper for quickly adding a StreamHandler to the logger. Useful for 40 | debugging. 41 | 42 | Returns the handler after adding it. 43 | """ 44 | # This method needs to be in this __init__.py to get the __name__ correct 45 | # even if urllib3 is vendored within another package. 46 | logger = logging.getLogger(__name__) 47 | handler = logging.StreamHandler() 48 | handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s')) 49 | logger.addHandler(handler) 50 | logger.setLevel(level) 51 | logger.debug('Added a stderr logging handler to logger: %s' % __name__) 52 | return handler 53 | 54 | # ... Clean up. 55 | del NullHandler 56 | 57 | 58 | import warnings 59 | # SecurityWarning's always go off by default. 60 | warnings.simplefilter('always', exceptions.SecurityWarning, append=True) 61 | # InsecurePlatformWarning's don't vary between requests, so we keep it default. 62 | warnings.simplefilter('default', exceptions.InsecurePlatformWarning, 63 | append=True) 64 | 65 | def disable_warnings(category=exceptions.HTTPWarning): 66 | """ 67 | Helper for quickly disabling all urllib3 warnings. 68 | """ 69 | warnings.simplefilter('ignore', category) 70 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/urllib3/contrib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Qiniu.dzbundle/requests/packages/urllib3/contrib/__init__.py -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/urllib3/filepost.py: -------------------------------------------------------------------------------- 1 | import codecs 2 | 3 | from uuid import uuid4 4 | from io import BytesIO 5 | 6 | from .packages import six 7 | from .packages.six import b 8 | from .fields import RequestField 9 | 10 | writer = codecs.lookup('utf-8')[3] 11 | 12 | 13 | def choose_boundary(): 14 | """ 15 | Our embarassingly-simple replacement for mimetools.choose_boundary. 16 | """ 17 | return uuid4().hex 18 | 19 | 20 | def iter_field_objects(fields): 21 | """ 22 | Iterate over fields. 23 | 24 | Supports list of (k, v) tuples and dicts, and lists of 25 | :class:`~urllib3.fields.RequestField`. 26 | 27 | """ 28 | if isinstance(fields, dict): 29 | i = six.iteritems(fields) 30 | else: 31 | i = iter(fields) 32 | 33 | for field in i: 34 | if isinstance(field, RequestField): 35 | yield field 36 | else: 37 | yield RequestField.from_tuples(*field) 38 | 39 | 40 | def iter_fields(fields): 41 | """ 42 | .. deprecated:: 1.6 43 | 44 | Iterate over fields. 45 | 46 | The addition of :class:`~urllib3.fields.RequestField` makes this function 47 | obsolete. Instead, use :func:`iter_field_objects`, which returns 48 | :class:`~urllib3.fields.RequestField` objects. 49 | 50 | Supports list of (k, v) tuples and dicts. 51 | """ 52 | if isinstance(fields, dict): 53 | return ((k, v) for k, v in six.iteritems(fields)) 54 | 55 | return ((k, v) for k, v in fields) 56 | 57 | 58 | def encode_multipart_formdata(fields, boundary=None): 59 | """ 60 | Encode a dictionary of ``fields`` using the multipart/form-data MIME format. 61 | 62 | :param fields: 63 | Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). 64 | 65 | :param boundary: 66 | If not specified, then a random boundary will be generated using 67 | :func:`mimetools.choose_boundary`. 68 | """ 69 | body = BytesIO() 70 | if boundary is None: 71 | boundary = choose_boundary() 72 | 73 | for field in iter_field_objects(fields): 74 | body.write(b('--%s\r\n' % (boundary))) 75 | 76 | writer(body).write(field.render_headers()) 77 | data = field.data 78 | 79 | if isinstance(data, int): 80 | data = str(data) # Backwards compatibility 81 | 82 | if isinstance(data, six.text_type): 83 | writer(body).write(data) 84 | else: 85 | body.write(data) 86 | 87 | body.write(b'\r\n') 88 | 89 | body.write(b('--%s--\r\n' % (boundary))) 90 | 91 | content_type = str('multipart/form-data; boundary=%s' % boundary) 92 | 93 | return body.getvalue(), content_type 94 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/urllib3/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import ssl_match_hostname 4 | 5 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | # Python 3.2+ 3 | from ssl import CertificateError, match_hostname 4 | except ImportError: 5 | try: 6 | # Backport of the function from a pypi module 7 | from backports.ssl_match_hostname import CertificateError, match_hostname 8 | except ImportError: 9 | # Our vendored copy 10 | from ._implementation import CertificateError, match_hostname 11 | 12 | # Not needed, but documenting what we provide. 13 | __all__ = ('CertificateError', 'match_hostname') 14 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/urllib3/util/__init__.py: -------------------------------------------------------------------------------- 1 | # For backwards compatibility, provide imports that used to be here. 2 | from .connection import is_connection_dropped 3 | from .request import make_headers 4 | from .response import is_fp_closed 5 | from .ssl_ import ( 6 | SSLContext, 7 | HAS_SNI, 8 | assert_fingerprint, 9 | resolve_cert_reqs, 10 | resolve_ssl_version, 11 | ssl_wrap_socket, 12 | ) 13 | from .timeout import ( 14 | current_time, 15 | Timeout, 16 | ) 17 | 18 | from .retry import Retry 19 | from .url import ( 20 | get_host, 21 | parse_url, 22 | split_first, 23 | Url, 24 | ) 25 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/urllib3/util/request.py: -------------------------------------------------------------------------------- 1 | from base64 import b64encode 2 | 3 | from ..packages.six import b 4 | 5 | ACCEPT_ENCODING = 'gzip,deflate' 6 | 7 | 8 | def make_headers(keep_alive=None, accept_encoding=None, user_agent=None, 9 | basic_auth=None, proxy_basic_auth=None, disable_cache=None): 10 | """ 11 | Shortcuts for generating request headers. 12 | 13 | :param keep_alive: 14 | If ``True``, adds 'connection: keep-alive' header. 15 | 16 | :param accept_encoding: 17 | Can be a boolean, list, or string. 18 | ``True`` translates to 'gzip,deflate'. 19 | List will get joined by comma. 20 | String will be used as provided. 21 | 22 | :param user_agent: 23 | String representing the user-agent you want, such as 24 | "python-urllib3/0.6" 25 | 26 | :param basic_auth: 27 | Colon-separated username:password string for 'authorization: basic ...' 28 | auth header. 29 | 30 | :param proxy_basic_auth: 31 | Colon-separated username:password string for 'proxy-authorization: basic ...' 32 | auth header. 33 | 34 | :param disable_cache: 35 | If ``True``, adds 'cache-control: no-cache' header. 36 | 37 | Example:: 38 | 39 | >>> make_headers(keep_alive=True, user_agent="Batman/1.0") 40 | {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'} 41 | >>> make_headers(accept_encoding=True) 42 | {'accept-encoding': 'gzip,deflate'} 43 | """ 44 | headers = {} 45 | if accept_encoding: 46 | if isinstance(accept_encoding, str): 47 | pass 48 | elif isinstance(accept_encoding, list): 49 | accept_encoding = ','.join(accept_encoding) 50 | else: 51 | accept_encoding = ACCEPT_ENCODING 52 | headers['accept-encoding'] = accept_encoding 53 | 54 | if user_agent: 55 | headers['user-agent'] = user_agent 56 | 57 | if keep_alive: 58 | headers['connection'] = 'keep-alive' 59 | 60 | if basic_auth: 61 | headers['authorization'] = 'Basic ' + \ 62 | b64encode(b(basic_auth)).decode('utf-8') 63 | 64 | if proxy_basic_auth: 65 | headers['proxy-authorization'] = 'Basic ' + \ 66 | b64encode(b(proxy_basic_auth)).decode('utf-8') 67 | 68 | if disable_cache: 69 | headers['cache-control'] = 'no-cache' 70 | 71 | return headers 72 | -------------------------------------------------------------------------------- /Qiniu.dzbundle/requests/packages/urllib3/util/response.py: -------------------------------------------------------------------------------- 1 | def is_fp_closed(obj): 2 | """ 3 | Checks whether a given file-like object is closed. 4 | 5 | :param obj: 6 | The file-like object to check. 7 | """ 8 | 9 | try: 10 | # Check via the official file-like-object way. 11 | return obj.closed 12 | except AttributeError: 13 | pass 14 | 15 | try: 16 | # Check if the object is a container for another file-like object that 17 | # gets released on exhaustion (e.g. HTTPResponse). 18 | return obj.fp is None 19 | except AttributeError: 20 | pass 21 | 22 | raise ValueError("Unable to determine whether fp is closed.") 23 | -------------------------------------------------------------------------------- /Quick Image Compressor.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Quick image converter and compressor 3 | # Description: Converts one or more image files into JPG, resizes it to maximum 1000px and compresses it to 75%. A great solution for images intended to be used on websites or blogs. 4 | # Handles: Files 5 | # Creator: Kolja Nolte 6 | # URL: https://www.koljanolte.com 7 | # Events: Dragged 8 | # KeyModifiers: Command, Option, Control, Shift 9 | # SkipConfig: No 10 | # RunsSandboxed: Yes 11 | # Version: 1.1.0 12 | # MinDropzoneVersion: 3.0 13 | 14 | def dragged 15 | $dz.determinate(true) 16 | 17 | # Maximum width of compressed images 18 | max_width = 1000 19 | 20 | # Quality of the output image (0 = worst, 100 = best) 21 | image_quality = 75 22 | 23 | # Images dragged and dropped into the app 24 | image_paths = Array $items 25 | 26 | # Now, the actual process starts 27 | $dz.begin('Begin compressing and resizing images...') 28 | 29 | # Getting the path of the parent directory of the first image 30 | image_parent_directory_path = File.dirname(image_paths[0]) 31 | 32 | # We add this to get a unique MD5 hash 33 | random_number = rand(99) 34 | 35 | # Initial process percentage 36 | percent = 0 37 | 38 | # Set initial process percentage 39 | $dz.percent(percent) 40 | 41 | # Loop to check whether the images exists 42 | image_paths.each do |image_path| 43 | next unless File.exist?(image_path) 44 | 45 | # Now, get the MD5 hash of the current image file 46 | md5_hash = `md5 -q "#{image_path}"` + random_number.to_s 47 | 48 | # Cut it; nobody likes long file names 49 | md5_hash = md5_hash[1..8] 50 | 51 | # Add the file ending. We know it's jpg because we're going to convert it in the next step 52 | new_image_file_name = md5_hash + '.jpg' 53 | 54 | # Build the path 55 | new_image_file_path = image_parent_directory_path + '/' + new_image_file_name 56 | 57 | percent += 100 / image_paths.count 58 | 59 | # Run a couple of shell commands 60 | `bin/convert '#{image_path}' -quiet -quality #{image_quality} -flatten -resize '#{max_width}x#{max_width}>' '#{new_image_file_path}'` 61 | `bin/jpegoptim -q --strip-all -o '#{new_image_file_path}'` 62 | `bin/image_optim --no-pngout --no-svgo '#{new_image_file_path}'` 63 | 64 | # Update process percentage 65 | $dz.percent(percent) 66 | end 67 | 68 | # Define notification message 69 | message = 'Successfully compressed 1 image.' 70 | message_plural = "Successfully compressed #{image_paths.count} images." 71 | message = message_plural if image_paths.count > 1 72 | 73 | # Display notification message 74 | $dz.finish(message) 75 | 76 | # Nope, we don't need anything in our clipboard 77 | $dz.text(false) 78 | end 79 | 80 | # THE END -------------------------------------------------------------------------------- /Quick Image Compressor.dzbundle/bin/convert: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Quick Image Compressor.dzbundle/bin/convert -------------------------------------------------------------------------------- /Quick Image Compressor.dzbundle/bin/image_optim: -------------------------------------------------------------------------------- 1 | #!/usr/local/opt/ruby/bin/ruby 2 | # 3 | # This file was generated by RubyGems. 4 | # 5 | # The application 'image_optim' is installed as part of a gem, and 6 | # this file is here to facilitate running it. 7 | # 8 | 9 | require 'rubygems' 10 | 11 | version = ">= 0.a" 12 | 13 | if ARGV.first 14 | str = ARGV.first 15 | str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding 16 | if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then 17 | version = $1 18 | ARGV.shift 19 | end 20 | end 21 | 22 | if Gem.respond_to?(:activate_bin_path) 23 | load Gem.activate_bin_path('image_optim', 'image_optim', version) 24 | else 25 | gem "image_optim", version 26 | load Gem.bin_path("image_optim", "image_optim", version) 27 | end 28 | -------------------------------------------------------------------------------- /Quick Image Compressor.dzbundle/bin/jpegoptim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Quick Image Compressor.dzbundle/bin/jpegoptim -------------------------------------------------------------------------------- /Quick Image Compressor.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Quick Image Compressor.dzbundle/icon.png -------------------------------------------------------------------------------- /Rackspace Cloud Files.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Rackspace Cloud Files 3 | # Description: Uploads files to a Rackspace Cloud Files account container.\n\nYou will be prompted for the region and container on your first upload. Click the action to change the configured container. 4 | # Handles: Files 5 | # Creator: Alexandru Chirițescu 6 | # URL: http://alexchiri.com 7 | # OptionsNIB: UsernameAPIKey 8 | # Events: Dragged, Clicked 9 | # SkipConfig: No 10 | # RunsSandboxed: Yes 11 | # Version: 2.1 12 | # MinDropzoneVersion: 3.0 13 | # UniqueID: 1017 14 | 15 | require 'rackspace' 16 | 17 | def dragged 18 | rackspace = Rackspace.new 19 | 20 | $dz.determinate(false) 21 | 22 | $dz.begin('Connecting to Rackspace Cloud Files...') 23 | rackspace.configure_client 24 | 25 | $dz.begin('Getting container...') 26 | 27 | remote_container = rackspace.get_remote_container 28 | 29 | # If it doesn't exist, then error 30 | if remote_container.nil? 31 | $dz.error('Error', 'Could not access or create the remote container') 32 | end 33 | 34 | urls ||= Array.new 35 | 36 | # Upload each file to the cloud files endpoint 37 | $items.each do |file| 38 | urls << rackspace.upload_file(file, remote_container) 39 | end 40 | 41 | if urls.length == 1 42 | if urls[0].nil? or urls[0].to_s.strip.length == 0 43 | $dz.finish('No URL(s) were copied to clipboard, because CDN is disabled or no URL was returned!') 44 | $dz.url(false) 45 | else 46 | $dz.finish('URL is now in clipboard') 47 | $dz.text("#{urls[0]}") 48 | end 49 | elsif urls.length > 1 50 | merged_urls = urls.join("\n") 51 | if merged_urls.to_s.strip.length == 0 52 | $dz.finish('No URL(s) were copied to clipboard, because CDN is disabled or no URL was returned!') 53 | $dz.url(false) 54 | else 55 | $dz.finish('URLs are now in clipboard') 56 | $dz.text(merged_urls) 57 | end 58 | end 59 | 60 | end 61 | 62 | def clicked 63 | rackspace = Rackspace.new 64 | 65 | $dz.determinate(false) 66 | 67 | rackspace.read_region 68 | rackspace.read_container_name 69 | rackspace.read_cdn 70 | rackspace.read_custom_domain 71 | 72 | $dz.finish('Selected region and container name were saved!') 73 | 74 | $dz.url(false) 75 | end -------------------------------------------------------------------------------- /Rackspace Cloud Files.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Rackspace Cloud Files.dzbundle/icon.png -------------------------------------------------------------------------------- /Rename and Move Files.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Rename and Move Files 3 | # Description: Allows you to rename and move dropped files to a specified folder. Hold down option while dragging to rename and copy. 4 | # Handles: Files 5 | # Creator: Stephen Millard 6 | # URL: http://thouhtasylum.com 7 | # OptionsNIB: ChooseFolder 8 | # UseSelectedItemNameAndIcon: Yes 9 | # Events: Clicked, Dragged 10 | # SkipConfig: No 11 | # RunsSandboxed: Yes 12 | # Version: 1.0 13 | # MinDropzoneVersion: 3.0 14 | # UniqueID: 81512718 15 | 16 | # ACTION: FILE(S) DRAGGED ONTO ICON 17 | def dragged 18 | # Rsync will provide progress updates, so set action to show progress 19 | $dz.determinate(true) 20 | 21 | # Log if we are copying or moving 22 | bMove = true 23 | if ENV['OPERATION'] == "NSDragOperationCopy" 24 | strOperation = "Copying" 25 | bMove = false 26 | else 27 | strOperation = "Moving" 28 | end 29 | 30 | # Rename all passed in files 31 | astrFileRenamed = Array.new 32 | for intIndex in 0 ... $items.size 33 | 34 | # Display dialog to rename file 35 | strPashuaConfig = " 36 | *.title = Rename File 37 | p.type = textfield 38 | p.label = File Name 39 | p.default = #{File.basename($items[intIndex])} 40 | " 41 | objResult = $dz.pashua(strPashuaConfig) 42 | 43 | # Useful for debugging 44 | puts objResult['p'] 45 | puts $items[intIndex] 46 | puts File.dirname($items[intIndex]) 47 | 48 | # Rename the file 49 | strRenamedFilePath = File.dirname($items[intIndex]) + "/" + objResult['p'] 50 | File.rename($items[intIndex], strRenamedFilePath) 51 | 52 | # Add the new file path to an array 53 | astrFileRenamed.push(strRenamedFilePath) 54 | end 55 | 56 | # Move/copy files 57 | # Uses the new set of file paths in the array 58 | $dz.begin("#{strOperation} files...") 59 | Rsync.do_copy(astrFileRenamed, ENV['EXTRA_PATH'], bMove) 60 | finish_op = (bMove ? "Move" : "Copy") 61 | 62 | # Notification with option to open the file path 63 | last_component = ENV['EXTRA_PATH'].split('/').last.gsub(/^(.{30,}?).*$/m,'\1...') 64 | $dz.finish("Click here to open the '#{last_component}' folder") 65 | $dz.url(false) 66 | end 67 | 68 | 69 | # ACTION: ICON CLICKED 70 | def clicked 71 | # Open the folder path this action is set to move/copy to 72 | escaped_path = ENV['EXTRA_PATH'].gsub(/["`$\\]/){ |s| '\\' + s } 73 | system("open \"#{escaped_path}\"") 74 | end 75 | -------------------------------------------------------------------------------- /Rename and Move Files.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Rename and Move Files.dzbundle/icon.png -------------------------------------------------------------------------------- /SCP Upload.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: SCP Upload 3 | # Description: Allows files to be uploaded to a remote SSH server. If the option key is held down then files are zipped up before uploading. 4 | # Handles: Files 5 | # Events: Dragged, TestConnection 6 | # KeyModifiers: Option 7 | # Creator: Aptonic Software 8 | # URL: http://aptonic.com 9 | # OptionsNIB: ExtendedLogin 10 | # DefaultPort: 22 11 | # Version: 1.6 12 | # RunsSandboxed: No 13 | # MinDropzoneVersion: 3.0 14 | # UniqueID: 1009 15 | 16 | require 'scp_uploader' 17 | 18 | $host_info = {:server => ENV['server'], 19 | :port => ENV['port'], 20 | :username => ENV['username'], 21 | :password => ENV['password']} 22 | 23 | def dragged 24 | delete_zip = false 25 | 26 | if ENV['KEY_MODIFIERS'] == "Option" 27 | # Zip up files before uploading 28 | if $items.length == 1 29 | # Use directory or file name as zip file name 30 | dir_name = $items[0].split(File::SEPARATOR)[-1] 31 | file = ZipFiles.zip($items, "#{dir_name}.zip") 32 | else 33 | file = ZipFiles.zip($items, "files.zip") 34 | end 35 | 36 | # Remove quotes 37 | items = [file[1..-2]] 38 | delete_zip = true 39 | else 40 | # Recursive upload 41 | items = $items 42 | end 43 | 44 | $dz.begin("Starting transfer...") 45 | $dz.determinate(false) 46 | 47 | remote_paths = SCPUploader.do_upload(items, ENV['remote_path'], $host_info) 48 | ZipFiles.delete_zip(items[0]) if delete_zip 49 | 50 | # Put URL of uploaded file on pasteboard 51 | finish_text = "Upload Complete" 52 | 53 | if remote_paths.length == 1 54 | filename = remote_paths[0].split(File::SEPARATOR)[-1].strip 55 | 56 | if ENV['root_url'] != nil 57 | slash = (ENV['root_url'][-1,1] == "/" ? "" : "/") 58 | url = ENV['root_url'] + slash + filename 59 | finish_text = "URL is now on clipboard" 60 | else 61 | url = filename 62 | end 63 | else 64 | url = false 65 | end 66 | 67 | $dz.finish(finish_text) 68 | $dz.url(url) 69 | end 70 | 71 | def test_connection 72 | SCPUploader.test_connection($host_info) 73 | end 74 | -------------------------------------------------------------------------------- /SCP Upload.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/SCP Upload.dzbundle/icon.png -------------------------------------------------------------------------------- /Screenshot.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Screenshot 3 | # Description: Take a screenshot, add it to ~/Screenshots and add to Drop Bar 4 | # Creator: Gareth Evans 5 | # URL: http://yoursite.com 6 | # OptionsNIB: ChooseFolder 7 | # Events: Clicked 8 | # KeyModifiers: Command, Option, Control, Shift 9 | # SkipConfig: No 10 | # RunsSandboxed: No 11 | # Version: 1.0 12 | # MinDropzoneVersion: 3.0 13 | # UniqueID: 1037 14 | 15 | def clicked 16 | # Create the Screenshots directory if not already present 17 | # system("mkdir ~/Screenshots") # No longer required with Options:NIB 18 | 19 | # Make a filename with the current time 20 | formatted_time = Time.now.strftime("%F at %I.%M.%S %p") 21 | filename = "Screen Shot " + formatted_time + ".png" 22 | # file_path = File.expand_path('~') + "/Screenshots/" + filename # commented out to allow user folder 23 | file_path = ENV['EXTRA_PATH'] + "/" + filename 24 | 25 | # Capture screenshot 26 | system("screencapture -i \"" + file_path + "\"") 27 | 28 | # Add to Drop Bar 29 | $dz.add_dropbar([file_path]) 30 | 31 | # Notification 32 | $dz.finish("Screenshot added") 33 | $dz.url(false) 34 | end 35 | -------------------------------------------------------------------------------- /Screenshot.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Screenshot.dzbundle/icon.png -------------------------------------------------------------------------------- /Search Mac App Store.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Search Mac App Store 3 | # Description: Searches the Mac App Store for apps with names containing the dragged text or the text on the clipboard when clicked. 4 | # Handles: Text 5 | # Creator: Aptonic Software 6 | # URL: https://aptonic.com 7 | # Events: Clicked, Dragged 8 | # SkipConfig: Yes 9 | # RunsSandboxed: Yes 10 | # Version: 1.0 11 | # MinDropzoneVersion: 3.0 12 | 13 | def dragged 14 | search($items[0]) 15 | end 16 | 17 | def clicked 18 | search($dz.read_clipboard) 19 | end 20 | 21 | def search(term) 22 | $dz.begin("Searching Mac App Store...") 23 | $dz.determinate(false) 24 | 25 | url = "itms-apps://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&term=#{term}" 26 | system("open \"#{url}\"") 27 | 28 | $dz.finish("Search Complete") 29 | $dz.url(false) 30 | end 31 | -------------------------------------------------------------------------------- /Search Mac App Store.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Search Mac App Store.dzbundle/icon.png -------------------------------------------------------------------------------- /Show Image Size.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Show Image Size 3 | # Description: Displays the width and height of a local or remote image file. 4 | # Handles: Files 5 | # Creator: Kolja Nolte 6 | # URL: https://www.koljanolte.com 7 | # Events: Dragged 8 | # KeyModifiers: 9 | # SkipConfig: No 10 | # RunsSandboxed: Yes 11 | # Version: 1.0.0 12 | # MinDropzoneVersion: 3.0 13 | 14 | require 'fastimage' 15 | require 'net/http' 16 | require 'net/https' 17 | require 'open-uri' 18 | 19 | def dragged 20 | puts $items.inspect 21 | 22 | $dz.begin('Analyzing file ' + File.basename($items[0]) + '...') 23 | $dz.determinate(true) 24 | 25 | $dz.percent(10) 26 | sleep(0.5) 27 | $dz.percent(50) 28 | sleep(0.5) 29 | $dz.percent(100) 30 | 31 | image_path = $items[0] 32 | image_size = FastImage.size(image_path) 33 | image_width = image_size[0].to_s 34 | image_height = image_size[1].to_s 35 | dimensions = image_width + 'x' + image_height 36 | output = dimensions 37 | 38 | $dz.finish(output) 39 | 40 | $dz.text(dimensions) 41 | end -------------------------------------------------------------------------------- /Show Image Size.dzbundle/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Show Image Size.dzbundle/icon.icns -------------------------------------------------------------------------------- /Show Image Size.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Show Image Size.dzbundle/icon.png -------------------------------------------------------------------------------- /Slack.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Slack 3 | # Description: Uploads files to a Slack channel \n\nIn order to get the token needed for the API Key field below, login at https://slack.com with your account and afterwards go to https://api.slack.com. Scroll down and copy the token value from the Authentication section in the API Key below. 4 | # Handles: Files 5 | # Creator: Alexandru Chirițescu 6 | # URL: http://alexchiri.com 7 | # OptionsNIB: APIKey 8 | # Events: Clicked, Dragged 9 | # SkipConfig: No 10 | # RunsSandboxed: No 11 | # Version: 1.1 12 | # MinDropzoneVersion: 3.0 13 | # UniqueID: 1019 14 | 15 | require 'lib/faraday' 16 | require 'slack' 17 | 18 | def dragged 19 | slack = Slack.new 20 | 21 | $dz.determinate(false) 22 | 23 | $dz.begin('Getting list of channels from Slack...') 24 | 25 | channel_id = slack.select_channel 26 | # commented this out until I figure out how to post a message to Slack as a user and not as a bot 27 | # if ENV['dragged_type'] == "files" 28 | $items.each do |file| 29 | slack.upload_file(file, channel_id) 30 | end 31 | 32 | $dz.finish('File(s) were uploaded into Slack!') 33 | # else 34 | # $items.each do |message| 35 | # slack.post_message(message, channel_id) 36 | # end 37 | # 38 | # $dz.finish("Message(s) were posted into Slack!") 39 | # end 40 | 41 | $dz.url(false) 42 | end 43 | 44 | def clicked 45 | system('open https://www.slack.com/') 46 | end -------------------------------------------------------------------------------- /Slack.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Slack.dzbundle/icon.png -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/adapter.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | # Public: This is a base class for all Faraday adapters. Adapters are 3 | # responsible for fulfilling a Faraday request. 4 | class Adapter < Middleware 5 | CONTENT_LENGTH = 'Content-Length'.freeze 6 | 7 | register_middleware File.expand_path('../adapter', __FILE__), 8 | :test => [:Test, 'test'], 9 | :net_http => [:NetHttp, 'net_http'], 10 | :net_http_persistent => [:NetHttpPersistent, 'net_http_persistent'], 11 | :typhoeus => [:Typhoeus, 'typhoeus'], 12 | :patron => [:Patron, 'patron'], 13 | :em_synchrony => [:EMSynchrony, 'em_synchrony'], 14 | :em_http => [:EMHttp, 'em_http'], 15 | :excon => [:Excon, 'excon'], 16 | :rack => [:Rack, 'rack'], 17 | :httpclient => [:HTTPClient, 'httpclient'] 18 | 19 | # Public: This module marks an Adapter as supporting parallel requests. 20 | module Parallelism 21 | attr_writer :supports_parallel 22 | def supports_parallel?() @supports_parallel end 23 | 24 | def inherited(subclass) 25 | super 26 | subclass.supports_parallel = self.supports_parallel? 27 | end 28 | end 29 | 30 | extend Parallelism 31 | self.supports_parallel = false 32 | 33 | def call(env) 34 | env.clear_body if env.needs_body? 35 | end 36 | 37 | def save_response(env, status, body, headers = nil) 38 | env.status = status 39 | env.body = body 40 | env.response_headers = Utils::Headers.new.tap do |response_headers| 41 | response_headers.update headers unless headers.nil? 42 | yield(response_headers) if block_given? 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/adapter/em_http_ssl_patch.rb: -------------------------------------------------------------------------------- 1 | require 'openssl' 2 | require 'em-http' 3 | 4 | module EmHttpSslPatch 5 | def ssl_verify_peer(cert_string) 6 | cert = nil 7 | begin 8 | cert = OpenSSL::X509::Certificate.new(cert_string) 9 | rescue OpenSSL::X509::CertificateError 10 | return false 11 | end 12 | 13 | @last_seen_cert = cert 14 | 15 | if certificate_store.verify(@last_seen_cert) 16 | begin 17 | certificate_store.add_cert(@last_seen_cert) 18 | rescue OpenSSL::X509::StoreError => e 19 | raise e unless e.message == 'cert already in hash table' 20 | end 21 | true 22 | else 23 | raise OpenSSL::SSL::SSLError.new(%(unable to verify the server certificate for "#{host}")) 24 | end 25 | end 26 | 27 | def ssl_handshake_completed 28 | return true unless verify_peer? 29 | 30 | unless OpenSSL::SSL.verify_certificate_identity(@last_seen_cert, host) 31 | raise OpenSSL::SSL::SSLError.new(%(host "#{host}" does not match the server certificate)) 32 | else 33 | true 34 | end 35 | end 36 | 37 | def verify_peer? 38 | parent.connopts.tls[:verify_peer] 39 | end 40 | 41 | def host 42 | parent.connopts.host 43 | end 44 | 45 | def certificate_store 46 | @certificate_store ||= begin 47 | store = OpenSSL::X509::Store.new 48 | store.set_default_paths 49 | ca_file = parent.connopts.tls[:cert_chain_file] 50 | store.add_file(ca_file) if ca_file 51 | store 52 | end 53 | end 54 | end 55 | 56 | EventMachine::HttpStubConnection.send(:include, EmHttpSslPatch) 57 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/adapter/em_synchrony.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | 3 | module Faraday 4 | class Adapter 5 | class EMSynchrony < Faraday::Adapter 6 | include EMHttp::Options 7 | 8 | dependency do 9 | require 'em-synchrony/em-http' 10 | require 'em-synchrony/em-multi' 11 | require 'fiber' 12 | end 13 | 14 | self.supports_parallel = true 15 | 16 | def self.setup_parallel_manager(options = {}) 17 | ParallelManager.new 18 | end 19 | 20 | def call(env) 21 | super 22 | request = EventMachine::HttpRequest.new(Utils::URI(env[:url].to_s), connection_config(env)) 23 | 24 | http_method = env[:method].to_s.downcase.to_sym 25 | 26 | # Queue requests for parallel execution. 27 | if env[:parallel_manager] 28 | env[:parallel_manager].add(request, http_method, request_config(env)) do |resp| 29 | save_response(env, resp.response_header.status, resp.response) do |resp_headers| 30 | resp.response_header.each do |name, value| 31 | resp_headers[name.to_sym] = value 32 | end 33 | end 34 | 35 | # Finalize the response object with values from `env`. 36 | env[:response].finish(env) 37 | end 38 | 39 | # Execute single request. 40 | else 41 | client = nil 42 | block = lambda { request.send(http_method, request_config(env)) } 43 | 44 | if !EM.reactor_running? 45 | EM.run do 46 | Fiber.new { 47 | client = block.call 48 | EM.stop 49 | }.resume 50 | end 51 | else 52 | client = block.call 53 | end 54 | 55 | raise client.error if client.error 56 | 57 | save_response(env, client.response_header.status, client.response) do |resp_headers| 58 | client.response_header.each do |name, value| 59 | resp_headers[name.to_sym] = value 60 | end 61 | end 62 | end 63 | 64 | @app.call env 65 | rescue Errno::ECONNREFUSED 66 | raise Error::ConnectionFailed, $! 67 | rescue EventMachine::Connectify::CONNECTError => err 68 | if err.message.include?("Proxy Authentication Required") 69 | raise Error::ConnectionFailed, %{407 "Proxy Authentication Required "} 70 | else 71 | raise Error::ConnectionFailed, err 72 | end 73 | rescue => err 74 | if defined?(OpenSSL) && OpenSSL::SSL::SSLError === err 75 | raise Faraday::SSLError, err 76 | else 77 | raise 78 | end 79 | end 80 | end 81 | end 82 | end 83 | 84 | require 'faraday/adapter/em_synchrony/parallel_manager' 85 | 86 | begin 87 | require 'openssl' 88 | rescue LoadError 89 | warn "Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support" 90 | else 91 | require 'faraday/adapter/em_http_ssl_patch' 92 | end if Faraday::Adapter::EMSynchrony.loaded? 93 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/adapter/em_synchrony/parallel_manager.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Adapter 3 | class EMSynchrony < Faraday::Adapter 4 | class ParallelManager 5 | 6 | # Add requests to queue. The `request` argument should be a 7 | # `EM::HttpRequest` object. 8 | def add(request, method, *args, &block) 9 | queue << { 10 | :request => request, 11 | :method => method, 12 | :args => args, 13 | :block => block 14 | } 15 | end 16 | 17 | # Run all requests on queue with `EM::Synchrony::Multi`, wrapping 18 | # it in a reactor and fiber if needed. 19 | def run 20 | result = nil 21 | if !EM.reactor_running? 22 | EM.run { 23 | Fiber.new do 24 | result = perform 25 | EM.stop 26 | end.resume 27 | } 28 | else 29 | result = perform 30 | end 31 | result 32 | end 33 | 34 | 35 | private 36 | 37 | # The request queue. 38 | def queue 39 | @queue ||= [] 40 | end 41 | 42 | # Main `EM::Synchrony::Multi` performer. 43 | def perform 44 | multi = ::EM::Synchrony::Multi.new 45 | 46 | queue.each do |item| 47 | method = "a#{item[:method]}".to_sym 48 | 49 | req = item[:request].send(method, *item[:args]) 50 | req.callback(&item[:block]) 51 | 52 | req_name = "req_#{multi.requests.size}".to_sym 53 | multi.add(req_name, req) 54 | end 55 | 56 | # Clear the queue, so parallel manager objects can be reused. 57 | @queue = [] 58 | 59 | # Block fiber until all requests have returned. 60 | multi.perform 61 | end 62 | 63 | end # ParallelManager 64 | end # EMSynchrony 65 | end # Adapter 66 | end # Faraday 67 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/adapter/excon.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Adapter 3 | class Excon < Faraday::Adapter 4 | dependency 'excon' 5 | 6 | def initialize(app, connection_options = {}) 7 | @connection_options = connection_options 8 | super(app) 9 | end 10 | 11 | def call(env) 12 | super 13 | 14 | opts = {} 15 | if env[:url].scheme == 'https' && ssl = env[:ssl] 16 | opts[:ssl_verify_peer] = !!ssl.fetch(:verify, true) 17 | opts[:ssl_ca_path] = ssl[:ca_path] if ssl[:ca_path] 18 | opts[:ssl_ca_file] = ssl[:ca_file] if ssl[:ca_file] 19 | opts[:client_cert] = ssl[:client_cert] if ssl[:client_cert] 20 | opts[:client_key] = ssl[:client_key] if ssl[:client_key] 21 | opts[:certificate] = ssl[:certificate] if ssl[:certificate] 22 | opts[:private_key] = ssl[:private_key] if ssl[:private_key] 23 | 24 | # https://github.com/geemus/excon/issues/106 25 | # https://github.com/jruby/jruby-ossl/issues/19 26 | opts[:nonblock] = false 27 | end 28 | 29 | if ( req = env[:request] ) 30 | if req[:timeout] 31 | opts[:read_timeout] = req[:timeout] 32 | opts[:connect_timeout] = req[:timeout] 33 | opts[:write_timeout] = req[:timeout] 34 | end 35 | 36 | if req[:open_timeout] 37 | opts[:connect_timeout] = req[:open_timeout] 38 | opts[:write_timeout] = req[:open_timeout] 39 | end 40 | 41 | if req[:proxy] 42 | opts[:proxy] = { 43 | :host => req[:proxy][:uri].host, 44 | :port => req[:proxy][:uri].port, 45 | :scheme => req[:proxy][:uri].scheme, 46 | :user => req[:proxy][:user], 47 | :password => req[:proxy][:password] 48 | } 49 | end 50 | end 51 | 52 | conn = ::Excon.new(env[:url].to_s, opts.merge(@connection_options)) 53 | 54 | resp = conn.request \ 55 | :method => env[:method].to_s.upcase, 56 | :headers => env[:request_headers], 57 | :body => read_body(env) 58 | 59 | save_response(env, resp.status.to_i, resp.body, resp.headers) 60 | 61 | @app.call env 62 | rescue ::Excon::Errors::SocketError => err 63 | if err.message =~ /\btimeout\b/ 64 | raise Error::TimeoutError, err 65 | elsif err.message =~ /\bcertificate\b/ 66 | raise Faraday::SSLError, err 67 | else 68 | raise Error::ConnectionFailed, err 69 | end 70 | rescue ::Excon::Errors::Timeout => err 71 | raise Error::TimeoutError, err 72 | end 73 | 74 | # TODO: support streaming requests 75 | def read_body(env) 76 | env[:body].respond_to?(:read) ? env[:body].read : env[:body] 77 | end 78 | end 79 | end 80 | end 81 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/adapter/net_http_persistent.rb: -------------------------------------------------------------------------------- 1 | # Rely on autoloading instead of explicit require; helps avoid the "already 2 | # initialized constant" warning on Ruby 1.8.7 when NetHttp is refereced below. 3 | # require 'faraday/adapter/net_http' 4 | 5 | module Faraday 6 | class Adapter 7 | # Experimental adapter for net-http-persistent 8 | class NetHttpPersistent < NetHttp 9 | dependency 'net/http/persistent' 10 | 11 | def net_http_connection(env) 12 | if proxy = env[:request][:proxy] 13 | proxy_uri = ::URI::HTTP === proxy[:uri] ? proxy[:uri].dup : ::URI.parse(proxy[:uri].to_s) 14 | proxy_uri.user = proxy_uri.password = nil 15 | # awful patch for net-http-persistent 2.8 not unescaping user/password 16 | (class << proxy_uri; self; end).class_eval do 17 | define_method(:user) { proxy[:user] } 18 | define_method(:password) { proxy[:password] } 19 | end if proxy[:user] 20 | end 21 | Net::HTTP::Persistent.new 'Faraday', proxy_uri 22 | end 23 | 24 | def perform_request(http, env) 25 | http.request env[:url], create_request(env) 26 | rescue Net::HTTP::Persistent::Error => error 27 | if error.message.include? 'Timeout' 28 | raise Faraday::Error::TimeoutError, error 29 | elsif error.message.include? 'connection refused' 30 | raise Faraday::Error::ConnectionFailed, error 31 | else 32 | raise 33 | end 34 | end 35 | 36 | def configure_ssl(http, ssl) 37 | http.verify_mode = ssl_verify_mode(ssl) 38 | http.cert_store = ssl_cert_store(ssl) 39 | 40 | http.certificate = ssl[:client_cert] if ssl[:client_cert] 41 | http.private_key = ssl[:client_key] if ssl[:client_key] 42 | http.ca_file = ssl[:ca_file] if ssl[:ca_file] 43 | http.ssl_version = ssl[:version] if ssl[:version] 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/adapter/patron.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Adapter 3 | class Patron < Faraday::Adapter 4 | dependency 'patron' 5 | 6 | def initialize(app, &block) 7 | super(app) 8 | @block = block 9 | end 10 | 11 | def call(env) 12 | super 13 | 14 | # TODO: support streaming requests 15 | env[:body] = env[:body].read if env[:body].respond_to? :read 16 | 17 | session = @session ||= create_session 18 | 19 | if req = env[:request] 20 | session.timeout = session.connect_timeout = req[:timeout] if req[:timeout] 21 | session.connect_timeout = req[:open_timeout] if req[:open_timeout] 22 | 23 | if proxy = req[:proxy] 24 | proxy_uri = proxy[:uri].dup 25 | proxy_uri.user = proxy[:user] && Utils.escape(proxy[:user]).gsub('+', '%20') 26 | proxy_uri.password = proxy[:password] && Utils.escape(proxy[:password]).gsub('+', '%20') 27 | session.proxy = proxy_uri.to_s 28 | end 29 | end 30 | 31 | response = begin 32 | data = env[:body] ? env[:body].to_s : nil 33 | session.request(env[:method], env[:url].to_s, env[:request_headers], :data => data) 34 | rescue Errno::ECONNREFUSED, ::Patron::ConnectionFailed 35 | raise Error::ConnectionFailed, $! 36 | end 37 | 38 | save_response(env, response.status, response.body, response.headers) 39 | 40 | @app.call env 41 | rescue ::Patron::TimeoutError => err 42 | raise Faraday::Error::TimeoutError, err 43 | rescue ::Patron::Error => err 44 | if err.message.include?("code 407") 45 | raise Error::ConnectionFailed, %{407 "Proxy Authentication Required "} 46 | else 47 | raise Error::ConnectionFailed, err 48 | end 49 | end 50 | 51 | if loaded? && defined?(::Patron::Request::VALID_ACTIONS) 52 | # HAX: helps but doesn't work completely 53 | # https://github.com/toland/patron/issues/34 54 | ::Patron::Request::VALID_ACTIONS.tap do |actions| 55 | actions << :patch unless actions.include? :patch 56 | actions << :options unless actions.include? :options 57 | end 58 | end 59 | 60 | def create_session 61 | session = ::Patron::Session.new 62 | session.insecure = true 63 | @block.call(session) if @block 64 | session 65 | end 66 | end 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/adapter/rack.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Adapter 3 | # Sends requests to a Rack app. 4 | # 5 | # Examples 6 | # 7 | # class MyRackApp 8 | # def call(env) 9 | # [200, {'Content-Type' => 'text/html'}, ["hello world"]] 10 | # end 11 | # end 12 | # 13 | # Faraday.new do |conn| 14 | # conn.adapter :rack, MyRackApp.new 15 | # end 16 | class Rack < Faraday::Adapter 17 | dependency 'rack/test' 18 | 19 | # not prefixed with "HTTP_" 20 | SPECIAL_HEADERS = %w[ CONTENT_LENGTH CONTENT_TYPE ] 21 | 22 | def initialize(faraday_app, rack_app) 23 | super(faraday_app) 24 | mock_session = ::Rack::MockSession.new(rack_app) 25 | @session = ::Rack::Test::Session.new(mock_session) 26 | end 27 | 28 | def call(env) 29 | super 30 | rack_env = { 31 | :method => env[:method], 32 | :input => env[:body].respond_to?(:read) ? env[:body].read : env[:body], 33 | 'rack.url_scheme' => env[:url].scheme 34 | } 35 | 36 | env[:request_headers].each do |name, value| 37 | name = name.upcase.tr('-', '_') 38 | name = "HTTP_#{name}" unless SPECIAL_HEADERS.include? name 39 | rack_env[name] = value 40 | end if env[:request_headers] 41 | 42 | timeout = env[:request][:timeout] || env[:request][:open_timeout] 43 | response = if timeout 44 | Timer.timeout(timeout, Faraday::Error::TimeoutError) { execute_request(env, rack_env) } 45 | else 46 | execute_request(env, rack_env) 47 | end 48 | 49 | save_response(env, response.status, response.body, response.headers) 50 | @app.call env 51 | end 52 | 53 | def execute_request(env, rack_env) 54 | @session.request(env[:url].to_s, rack_env) 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/autoload.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | # Internal: Adds the ability for other modules to manage autoloadable 3 | # constants. 4 | module AutoloadHelper 5 | # Internal: Registers the constants to be auto loaded. 6 | # 7 | # prefix - The String require prefix. If the path is inside Faraday, then 8 | # it will be prefixed with the root path of this loaded Faraday 9 | # version. 10 | # options - Hash of Symbol => String library names. 11 | # 12 | # Examples. 13 | # 14 | # Faraday.autoload_all 'faraday/foo', 15 | # :Bar => 'bar' 16 | # 17 | # # requires faraday/foo/bar to load Faraday::Bar. 18 | # Faraday::Bar 19 | # 20 | # 21 | # Returns nothing. 22 | def autoload_all(prefix, options) 23 | if prefix =~ /^faraday(\/|$)/i 24 | prefix = File.join(Faraday.root_path, prefix) 25 | end 26 | options.each do |const_name, path| 27 | autoload const_name, File.join(prefix, path) 28 | end 29 | end 30 | 31 | # Internal: Loads each autoloaded constant. If thread safety is a concern, 32 | # wrap this in a Mutex. 33 | # 34 | # Returns nothing. 35 | def load_autoloaded_constants 36 | constants.each do |const| 37 | const_get(const) if autoload?(const) 38 | end 39 | end 40 | 41 | # Internal: Filters the module's contents with those that have been already 42 | # autoloaded. 43 | # 44 | # Returns an Array of Class/Module objects. 45 | def all_loaded_constants 46 | constants.map { |c| const_get(c) }. 47 | select { |a| a.respond_to?(:loaded?) && a.loaded? } 48 | end 49 | end 50 | 51 | class Adapter 52 | extend AutoloadHelper 53 | autoload_all 'faraday/adapter', 54 | :NetHttp => 'net_http', 55 | :NetHttpPersistent => 'net_http_persistent', 56 | :Typhoeus => 'typhoeus', 57 | :EMSynchrony => 'em_synchrony', 58 | :EMHttp => 'em_http', 59 | :Patron => 'patron', 60 | :Excon => 'excon', 61 | :Test => 'test', 62 | :Rack => 'rack', 63 | :HTTPClient => 'httpclient' 64 | end 65 | 66 | class Request 67 | extend AutoloadHelper 68 | autoload_all 'faraday/request', 69 | :UrlEncoded => 'url_encoded', 70 | :Multipart => 'multipart', 71 | :Retry => 'retry', 72 | :Timeout => 'timeout', 73 | :Authorization => 'authorization', 74 | :BasicAuthentication => 'basic_authentication', 75 | :TokenAuthentication => 'token_authentication', 76 | :Instrumentation => 'instrumentation' 77 | end 78 | 79 | class Response 80 | extend AutoloadHelper 81 | autoload_all 'faraday/response', 82 | :RaiseError => 'raise_error', 83 | :Logger => 'logger' 84 | end 85 | end 86 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/error.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Error < StandardError; end 3 | class MissingDependency < Error; end 4 | 5 | class ClientError < Error 6 | attr_reader :response 7 | 8 | def initialize(ex, response = nil) 9 | @wrapped_exception = nil 10 | @response = response 11 | 12 | if ex.respond_to?(:backtrace) 13 | super(ex.message) 14 | @wrapped_exception = ex 15 | elsif ex.respond_to?(:each_key) 16 | super("the server responded with status #{ex[:status]}") 17 | @response = ex 18 | else 19 | super(ex.to_s) 20 | end 21 | end 22 | 23 | def backtrace 24 | if @wrapped_exception 25 | @wrapped_exception.backtrace 26 | else 27 | super 28 | end 29 | end 30 | 31 | def inspect 32 | %(#<#{self.class}>) 33 | end 34 | end 35 | 36 | class ConnectionFailed < ClientError; end 37 | class ResourceNotFound < ClientError; end 38 | class ParsingError < ClientError; end 39 | 40 | class TimeoutError < ClientError 41 | def initialize(ex = nil) 42 | super(ex || "timeout") 43 | end 44 | end 45 | 46 | class SSLError < ClientError 47 | end 48 | 49 | [:MissingDependency, :ClientError, :ConnectionFailed, :ResourceNotFound, 50 | :ParsingError, :TimeoutError, :SSLError].each do |const| 51 | Error.const_set(const, Faraday.const_get(const)) 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/middleware.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Middleware 3 | extend MiddlewareRegistry 4 | 5 | class << self 6 | attr_accessor :load_error 7 | private :load_error= 8 | end 9 | 10 | self.load_error = nil 11 | 12 | # Executes a block which should try to require and reference dependent libraries 13 | def self.dependency(lib = nil) 14 | lib ? require(lib) : yield 15 | rescue LoadError, NameError => error 16 | self.load_error = error 17 | end 18 | 19 | def self.new(*) 20 | raise "missing dependency for #{self}: #{load_error.message}" unless loaded? 21 | super 22 | end 23 | 24 | def self.loaded? 25 | load_error.nil? 26 | end 27 | 28 | def self.inherited(subclass) 29 | super 30 | subclass.send(:load_error=, self.load_error) 31 | end 32 | 33 | def initialize(app = nil) 34 | @app = app 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/request.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | # Used to setup urls, params, headers, and the request body in a sane manner. 3 | # 4 | # @connection.post do |req| 5 | # req.url 'http://localhost', 'a' => '1' # 'http://localhost?a=1' 6 | # req.headers['b'] = '2' # Header 7 | # req.params['c'] = '3' # GET Param 8 | # req['b'] = '2' # also Header 9 | # req.body = 'abc' 10 | # end 11 | # 12 | class Request < Struct.new(:method, :path, :params, :headers, :body, :options) 13 | extend MiddlewareRegistry 14 | 15 | register_middleware File.expand_path('../request', __FILE__), 16 | :url_encoded => [:UrlEncoded, 'url_encoded'], 17 | :multipart => [:Multipart, 'multipart'], 18 | :retry => [:Retry, 'retry'], 19 | :authorization => [:Authorization, 'authorization'], 20 | :basic_auth => [:BasicAuthentication, 'basic_authentication'], 21 | :token_auth => [:TokenAuthentication, 'token_authentication'], 22 | :instrumentation => [:Instrumentation, 'instrumentation'] 23 | 24 | def self.create(request_method) 25 | new(request_method).tap do |request| 26 | yield(request) if block_given? 27 | end 28 | end 29 | 30 | # Public: Replace params, preserving the existing hash type 31 | def params=(hash) 32 | if params 33 | params.replace hash 34 | else 35 | super 36 | end 37 | end 38 | 39 | # Public: Replace request headers, preserving the existing hash type 40 | def headers=(hash) 41 | if headers 42 | headers.replace hash 43 | else 44 | super 45 | end 46 | end 47 | 48 | def url(path, params = nil) 49 | if path.respond_to? :query 50 | if query = path.query 51 | path = path.dup 52 | path.query = nil 53 | end 54 | else 55 | path, query = path.split('?', 2) 56 | end 57 | self.path = path 58 | self.params.merge_query query, options.params_encoder 59 | self.params.update(params) if params 60 | end 61 | 62 | def [](key) 63 | headers[key] 64 | end 65 | 66 | def []=(key, value) 67 | headers[key] = value 68 | end 69 | 70 | # ENV Keys 71 | # :method - a symbolized request method (:get, :post) 72 | # :body - the request body that will eventually be converted to a string. 73 | # :url - URI instance for the current request. 74 | # :status - HTTP response status code 75 | # :request_headers - hash of HTTP Headers to be sent to the server 76 | # :response_headers - Hash of HTTP headers from the server 77 | # :parallel_manager - sent if the connection is in parallel mode 78 | # :request - Hash of options for configuring the request. 79 | # :timeout - open/read timeout Integer in seconds 80 | # :open_timeout - read timeout Integer in seconds 81 | # :proxy - Hash of proxy options 82 | # :uri - Proxy Server URI 83 | # :user - Proxy server username 84 | # :password - Proxy server password 85 | # :ssl - Hash of options for configuring SSL requests. 86 | def to_env(connection) 87 | Env.new(method, body, connection.build_exclusive_url(path, params), 88 | options, headers, connection.ssl, connection.parallel_manager) 89 | end 90 | end 91 | end 92 | 93 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/request/authorization.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Request::Authorization < Faraday::Middleware 3 | KEY = "Authorization".freeze unless defined? KEY 4 | 5 | # Public 6 | def self.header(type, token) 7 | case token 8 | when String, Symbol 9 | "#{type} #{token}" 10 | when Hash 11 | build_hash(type.to_s, token) 12 | else 13 | raise ArgumentError, "Can't build an Authorization #{type} header from #{token.inspect}" 14 | end 15 | end 16 | 17 | # Internal 18 | def self.build_hash(type, hash) 19 | offset = KEY.size + type.size + 3 20 | comma = ",\n#{' ' * offset}" 21 | values = [] 22 | hash.each do |key, value| 23 | values << "#{key}=#{value.to_s.inspect}" 24 | end 25 | "#{type} #{values * comma}" 26 | end 27 | 28 | def initialize(app, type, token) 29 | @header_value = self.class.header(type, token) 30 | super(app) 31 | end 32 | 33 | # Public 34 | def call(env) 35 | unless env.request_headers[KEY] 36 | env.request_headers[KEY] = @header_value 37 | end 38 | @app.call(env) 39 | end 40 | end 41 | end 42 | 43 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/request/basic_authentication.rb: -------------------------------------------------------------------------------- 1 | require 'base64' 2 | 3 | module Faraday 4 | class Request::BasicAuthentication < Request.load_middleware(:authorization) 5 | # Public 6 | def self.header(login, pass) 7 | value = Base64.encode64([login, pass].join(':')) 8 | value.gsub!("\n", '') 9 | super(:Basic, value) 10 | end 11 | end 12 | end 13 | 14 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/request/instrumentation.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Request::Instrumentation < Faraday::Middleware 3 | class Options < Faraday::Options.new(:name, :instrumenter) 4 | def name 5 | self[:name] ||= 'request.faraday' 6 | end 7 | 8 | def instrumenter 9 | self[:instrumenter] ||= ActiveSupport::Notifications 10 | end 11 | end 12 | 13 | # Public: Instruments requests using Active Support. 14 | # 15 | # Measures time spent only for synchronous requests. 16 | # 17 | # Examples 18 | # 19 | # ActiveSupport::Notifications.subscribe('request.faraday') do |name, starts, ends, _, env| 20 | # url = env[:url] 21 | # http_method = env[:method].to_s.upcase 22 | # duration = ends - starts 23 | # $stderr.puts '[%s] %s %s (%.3f s)' % [url.host, http_method, url.request_uri, duration] 24 | # end 25 | def initialize(app, options = nil) 26 | super(app) 27 | @name, @instrumenter = Options.from(options).values_at(:name, :instrumenter) 28 | end 29 | 30 | def call(env) 31 | @instrumenter.instrument(@name, env) do 32 | @app.call(env) 33 | end 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/request/multipart.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path("../url_encoded", __FILE__) 2 | 3 | module Faraday 4 | class Request::Multipart < Request::UrlEncoded 5 | self.mime_type = 'multipart/form-data'.freeze 6 | DEFAULT_BOUNDARY = "-----------RubyMultipartPost".freeze unless defined? DEFAULT_BOUNDARY 7 | 8 | def call(env) 9 | match_content_type(env) do |params| 10 | env.request.boundary ||= DEFAULT_BOUNDARY 11 | env.request_headers[CONTENT_TYPE] += "; boundary=#{env.request.boundary}" 12 | env.body = create_multipart(env, params) 13 | end 14 | @app.call env 15 | end 16 | 17 | def process_request?(env) 18 | type = request_type(env) 19 | env.body.respond_to?(:each_key) and !env.body.empty? and ( 20 | (type.empty? and has_multipart?(env.body)) or 21 | type == self.class.mime_type 22 | ) 23 | end 24 | 25 | def has_multipart?(obj) 26 | # string is an enum in 1.8, returning list of itself 27 | if obj.respond_to?(:each) && !obj.is_a?(String) 28 | (obj.respond_to?(:values) ? obj.values : obj).each do |val| 29 | return true if (val.respond_to?(:content_type) || has_multipart?(val)) 30 | end 31 | end 32 | false 33 | end 34 | 35 | def create_multipart(env, params) 36 | boundary = env.request.boundary 37 | parts = process_params(params) do |key, value| 38 | Faraday::Parts::Part.new(boundary, key, value) 39 | end 40 | parts << Faraday::Parts::EpiloguePart.new(boundary) 41 | 42 | body = Faraday::CompositeReadIO.new(parts) 43 | env.request_headers[Faraday::Env::ContentLength] = body.length.to_s 44 | return body 45 | end 46 | 47 | def process_params(params, prefix = nil, pieces = nil, &block) 48 | params.inject(pieces || []) do |all, (key, value)| 49 | key = "#{prefix}[#{key}]" if prefix 50 | 51 | case value 52 | when Array 53 | values = value.inject([]) { |a,v| a << [nil, v] } 54 | process_params(values, key, all, &block) 55 | when Hash 56 | process_params(value, key, all, &block) 57 | else 58 | all << block.call(key, value) 59 | end 60 | end 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/request/token_authentication.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Request::TokenAuthentication < Request.load_middleware(:authorization) 3 | # Public 4 | def self.header(token, options = nil) 5 | options ||= {} 6 | options[:token] = token 7 | super(:Token, options) 8 | end 9 | 10 | def initialize(app, token, options = nil) 11 | super(app, token, options) 12 | end 13 | end 14 | end 15 | 16 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/request/url_encoded.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Request::UrlEncoded < Faraday::Middleware 3 | CONTENT_TYPE = 'Content-Type'.freeze unless defined? CONTENT_TYPE 4 | 5 | class << self 6 | attr_accessor :mime_type 7 | end 8 | self.mime_type = 'application/x-www-form-urlencoded'.freeze 9 | 10 | def call(env) 11 | match_content_type(env) do |data| 12 | params = Faraday::Utils::ParamsHash[data] 13 | env.body = params.to_query(env.params_encoder) 14 | end 15 | @app.call env 16 | end 17 | 18 | def match_content_type(env) 19 | if process_request?(env) 20 | env.request_headers[CONTENT_TYPE] ||= self.class.mime_type 21 | yield(env.body) unless env.body.respond_to?(:to_str) 22 | end 23 | end 24 | 25 | def process_request?(env) 26 | type = request_type(env) 27 | env.body and (type.empty? or type == self.class.mime_type) 28 | end 29 | 30 | def request_type(env) 31 | type = env.request_headers[CONTENT_TYPE].to_s 32 | type = type.split(';', 2).first if type.index(';') 33 | type 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/response.rb: -------------------------------------------------------------------------------- 1 | require 'forwardable' 2 | 3 | module Faraday 4 | class Response 5 | # Used for simple response middleware. 6 | class Middleware < Faraday::Middleware 7 | def call(env) 8 | @app.call(env).on_complete do |environment| 9 | on_complete(environment) 10 | end 11 | end 12 | 13 | # Override this to modify the environment after the response has finished. 14 | # Calls the `parse` method if defined 15 | def on_complete(env) 16 | env.body = parse(env.body) if respond_to?(:parse) && env.parse_body? 17 | end 18 | end 19 | 20 | extend Forwardable 21 | extend MiddlewareRegistry 22 | 23 | register_middleware File.expand_path('../response', __FILE__), 24 | :raise_error => [:RaiseError, 'raise_error'], 25 | :logger => [:Logger, 'logger'] 26 | 27 | def initialize(env = nil) 28 | @env = Env.from(env) if env 29 | @on_complete_callbacks = [] 30 | end 31 | 32 | attr_reader :env 33 | 34 | def_delegators :env, :to_hash 35 | 36 | def status 37 | finished? ? env.status : nil 38 | end 39 | 40 | def headers 41 | finished? ? env.response_headers : {} 42 | end 43 | def_delegator :headers, :[] 44 | 45 | def body 46 | finished? ? env.body : nil 47 | end 48 | 49 | def finished? 50 | !!env 51 | end 52 | 53 | def on_complete 54 | if not finished? 55 | @on_complete_callbacks << Proc.new 56 | else 57 | yield(env) 58 | end 59 | return self 60 | end 61 | 62 | def finish(env) 63 | raise "response already finished" if finished? 64 | @env = Env.from(env) 65 | @on_complete_callbacks.each { |callback| callback.call(env) } 66 | return self 67 | end 68 | 69 | def success? 70 | finished? && env.success? 71 | end 72 | 73 | # because @on_complete_callbacks cannot be marshalled 74 | def marshal_dump 75 | !finished? ? nil : { 76 | :status => @env.status, :body => @env.body, 77 | :response_headers => @env.response_headers 78 | } 79 | end 80 | 81 | def marshal_load(env) 82 | @env = Env.from(env) 83 | end 84 | 85 | # Expand the env with more properties, without overriding existing ones. 86 | # Useful for applying request params after restoring a marshalled Response. 87 | def apply_request(request_env) 88 | raise "response didn't finish yet" unless finished? 89 | @env = Env.from(request_env).update(@env) 90 | return self 91 | end 92 | end 93 | end 94 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/response/logger.rb: -------------------------------------------------------------------------------- 1 | require 'forwardable' 2 | 3 | module Faraday 4 | class Response::Logger < Response::Middleware 5 | extend Forwardable 6 | 7 | def initialize(app, logger = nil) 8 | super(app) 9 | @logger = logger || begin 10 | require 'logger' 11 | ::Logger.new(STDOUT) 12 | end 13 | end 14 | 15 | def_delegators :@logger, :debug, :info, :warn, :error, :fatal 16 | 17 | def call(env) 18 | info "#{env.method} #{env.url.to_s}" 19 | debug('request') { dump_headers env.request_headers } 20 | super 21 | end 22 | 23 | def on_complete(env) 24 | info('Status') { env.status.to_s } 25 | debug('response') { dump_headers env.response_headers } 26 | end 27 | 28 | private 29 | 30 | def dump_headers(headers) 31 | headers.map { |k, v| "#{k}: #{v.inspect}" }.join("\n") 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/response/raise_error.rb: -------------------------------------------------------------------------------- 1 | module Faraday 2 | class Response::RaiseError < Response::Middleware 3 | ClientErrorStatuses = 400...600 4 | 5 | def on_complete(env) 6 | case env[:status] 7 | when 404 8 | raise Faraday::Error::ResourceNotFound, response_values(env) 9 | when 407 10 | # mimic the behavior that we get with proxy requests with HTTPS 11 | raise Faraday::Error::ConnectionFailed, %{407 "Proxy Authentication Required "} 12 | when ClientErrorStatuses 13 | raise Faraday::Error::ClientError, response_values(env) 14 | end 15 | end 16 | 17 | def response_values(env) 18 | {:status => env.status, :headers => env.response_headers, :body => env.body} 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/faraday/upload_io.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'lib/composite_io' 3 | require 'lib/parts' 4 | require 'stringio' 5 | rescue LoadError 6 | $stderr.puts "Install the multipart-post gem." 7 | raise 8 | end 9 | 10 | module Faraday 11 | # Similar but not compatible with ::CompositeReadIO provided by multipart-post. 12 | class CompositeReadIO 13 | def initialize(*parts) 14 | @parts = parts.flatten 15 | @ios = @parts.map { |part| part.to_io } 16 | @index = 0 17 | end 18 | 19 | def length 20 | @parts.inject(0) { |sum, part| sum + part.length } 21 | end 22 | 23 | def rewind 24 | @ios.each { |io| io.rewind } 25 | @index = 0 26 | end 27 | 28 | # Read from IOs in order until `length` bytes have been received. 29 | def read(length = nil, outbuf = nil) 30 | got_result = false 31 | outbuf = outbuf ? outbuf.replace("") : "" 32 | 33 | while io = current_io 34 | if result = io.read(length) 35 | got_result ||= !result.nil? 36 | result.force_encoding("BINARY") if result.respond_to?(:force_encoding) 37 | outbuf << result 38 | length -= result.length if length 39 | break if length == 0 40 | end 41 | advance_io 42 | end 43 | (!got_result && length) ? nil : outbuf 44 | end 45 | 46 | def close 47 | @ios.each { |io| io.close } 48 | end 49 | 50 | def ensure_open_and_readable 51 | # Rubinius compatibility 52 | end 53 | 54 | private 55 | 56 | def current_io 57 | @ios[@index] 58 | end 59 | 60 | def advance_io 61 | @index += 1 62 | end 63 | end 64 | 65 | UploadIO = ::UploadIO 66 | Parts = ::Parts 67 | end 68 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json.rb: -------------------------------------------------------------------------------- 1 | require 'json/common' 2 | 3 | ## 4 | # = JavaScript Object Notation (JSON) 5 | # 6 | # JSON is a lightweight data-interchange format. It is easy for us 7 | # humans to read and write. Plus, equally simple for machines to generate or parse. 8 | # JSON is completely language agnostic, making it the ideal interchange format. 9 | # 10 | # Built on two universally available structures: 11 | # 1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array. 12 | # 2. An ordered list of values. More commonly called an _array_, vector, sequence or list. 13 | # 14 | # To read more about JSON visit: http://json.org 15 | # 16 | # == Parsing JSON 17 | # 18 | # To parse a JSON string received by another application or generated within 19 | # your existing application: 20 | # 21 | # require 'json' 22 | # 23 | # my_hash = JSON.parse('{"hello": "goodbye"}') 24 | # puts my_hash["hello"] => "goodbye" 25 | # 26 | # Notice the extra quotes '' around the hash notation. Ruby expects 27 | # the argument to be a string and can't convert objects like a hash or array. 28 | # 29 | # Ruby converts your string into a hash 30 | # 31 | # == Generating JSON 32 | # 33 | # Creating a JSON string for communication or serialization is 34 | # just as simple. 35 | # 36 | # require 'json' 37 | # 38 | # my_hash = {:hello => "goodbye"} 39 | # puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}" 40 | # 41 | # Or an alternative way: 42 | # 43 | # require 'json' 44 | # puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}" 45 | # 46 | # JSON.generate only allows objects or arrays to be converted 47 | # to JSON syntax. to_json, however, accepts many Ruby classes 48 | # even though it acts only as a method for serialization: 49 | # 50 | # require 'json' 51 | # 52 | # 1.to_json => "1" 53 | # 54 | module JSON 55 | require 'json/version' 56 | 57 | begin 58 | require 'json/ext' 59 | rescue LoadError 60 | require 'json/pure' 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/bigdecimal.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | defined?(::BigDecimal) or require 'bigdecimal' 5 | 6 | class BigDecimal 7 | # Import a JSON Marshalled object. 8 | # 9 | # method used for JSON marshalling support. 10 | def self.json_create(object) 11 | BigDecimal._load object['b'] 12 | end 13 | 14 | # Marshal the object to JSON. 15 | # 16 | # method used for JSON marshalling support. 17 | def as_json(*) 18 | { 19 | JSON.create_id => self.class.name, 20 | 'b' => _dump, 21 | } 22 | end 23 | 24 | # return the JSON value 25 | def to_json(*) 26 | as_json.to_json 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/complex.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | defined?(::Complex) or require 'complex' 5 | 6 | class Complex 7 | def self.json_create(object) 8 | Complex(object['r'], object['i']) 9 | end 10 | 11 | def as_json(*) 12 | { 13 | JSON.create_id => self.class.name, 14 | 'r' => real, 15 | 'i' => imag, 16 | } 17 | end 18 | 19 | def to_json(*) 20 | as_json.to_json 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/core.rb: -------------------------------------------------------------------------------- 1 | # This file requires the implementations of ruby core's custom objects for 2 | # serialisation/deserialisation. 3 | 4 | require 'json/add/date' 5 | require 'json/add/date_time' 6 | require 'json/add/exception' 7 | require 'json/add/range' 8 | require 'json/add/regexp' 9 | require 'json/add/struct' 10 | require 'json/add/symbol' 11 | require 'json/add/time' 12 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/date.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | require 'date' 5 | 6 | # Date serialization/deserialization 7 | class Date 8 | 9 | # Deserializes JSON string by converting Julian year y, month 10 | # m, day d and Day of Calendar Reform sg to Date. 11 | def self.json_create(object) 12 | civil(*object.values_at('y', 'm', 'd', 'sg')) 13 | end 14 | 15 | alias start sg unless method_defined?(:start) 16 | 17 | # Returns a hash, that will be turned into a JSON object and represent this 18 | # object. 19 | def as_json(*) 20 | { 21 | JSON.create_id => self.class.name, 22 | 'y' => year, 23 | 'm' => month, 24 | 'd' => day, 25 | 'sg' => start, 26 | } 27 | end 28 | 29 | # Stores class name (Date) with Julian year y, month m, day 30 | # d and Day of Calendar Reform sg as JSON string 31 | def to_json(*args) 32 | as_json.to_json(*args) 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/date_time.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | require 'date' 5 | 6 | # DateTime serialization/deserialization 7 | class DateTime 8 | 9 | # Deserializes JSON string by converting year y, month m, 10 | # day d, hour H, minute M, second S, 11 | # offset of and Day of Calendar Reform sg to DateTime. 12 | def self.json_create(object) 13 | args = object.values_at('y', 'm', 'd', 'H', 'M', 'S') 14 | of_a, of_b = object['of'].split('/') 15 | if of_b and of_b != '0' 16 | args << Rational(of_a.to_i, of_b.to_i) 17 | else 18 | args << of_a 19 | end 20 | args << object['sg'] 21 | civil(*args) 22 | end 23 | 24 | alias start sg unless method_defined?(:start) 25 | 26 | # Returns a hash, that will be turned into a JSON object and represent this 27 | # object. 28 | def as_json(*) 29 | { 30 | JSON.create_id => self.class.name, 31 | 'y' => year, 32 | 'm' => month, 33 | 'd' => day, 34 | 'H' => hour, 35 | 'M' => min, 36 | 'S' => sec, 37 | 'of' => offset.to_s, 38 | 'sg' => start, 39 | } 40 | end 41 | 42 | # Stores class name (DateTime) with Julian year y, month m, 43 | # day d, hour H, minute M, second S, 44 | # offset of and Day of Calendar Reform sg as JSON string 45 | def to_json(*args) 46 | as_json.to_json(*args) 47 | end 48 | end 49 | 50 | 51 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/exception.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Exception serialization/deserialization 6 | class Exception 7 | 8 | # Deserializes JSON string by constructing new Exception object with message 9 | # m and backtrace b serialized with to_json 10 | def self.json_create(object) 11 | result = new(object['m']) 12 | result.set_backtrace object['b'] 13 | result 14 | end 15 | 16 | # Returns a hash, that will be turned into a JSON object and represent this 17 | # object. 18 | def as_json(*) 19 | { 20 | JSON.create_id => self.class.name, 21 | 'm' => message, 22 | 'b' => backtrace, 23 | } 24 | end 25 | 26 | # Stores class name (Exception) with message m and backtrace array 27 | # b as JSON string 28 | def to_json(*args) 29 | as_json.to_json(*args) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/ostruct.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | require 'ostruct' 5 | 6 | # OpenStruct serialization/deserialization 7 | class OpenStruct 8 | 9 | # Deserializes JSON string by constructing new Struct object with values 10 | # v serialized by to_json. 11 | def self.json_create(object) 12 | new(object['t'] || object[:t]) 13 | end 14 | 15 | # Returns a hash, that will be turned into a JSON object and represent this 16 | # object. 17 | def as_json(*) 18 | klass = self.class.name 19 | klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!" 20 | { 21 | JSON.create_id => klass, 22 | 't' => table, 23 | } 24 | end 25 | 26 | # Stores class name (OpenStruct) with this struct's values v as a 27 | # JSON string. 28 | def to_json(*args) 29 | as_json.to_json(*args) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/range.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Range serialization/deserialization 6 | class Range 7 | 8 | # Deserializes JSON string by constructing new Range object with arguments 9 | # a serialized by to_json. 10 | def self.json_create(object) 11 | new(*object['a']) 12 | end 13 | 14 | # Returns a hash, that will be turned into a JSON object and represent this 15 | # object. 16 | def as_json(*) 17 | { 18 | JSON.create_id => self.class.name, 19 | 'a' => [ first, last, exclude_end? ] 20 | } 21 | end 22 | 23 | # Stores class name (Range) with JSON array of arguments a which 24 | # include first (integer), last (integer), and 25 | # exclude_end? (boolean) as JSON string. 26 | def to_json(*args) 27 | as_json.to_json(*args) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/rational.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | defined?(::Rational) or require 'rational' 5 | 6 | class Rational 7 | def self.json_create(object) 8 | Rational(object['n'], object['d']) 9 | end 10 | 11 | def as_json(*) 12 | { 13 | JSON.create_id => self.class.name, 14 | 'n' => numerator, 15 | 'd' => denominator, 16 | } 17 | end 18 | 19 | def to_json(*) 20 | as_json.to_json 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/regexp.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Regexp serialization/deserialization 6 | class Regexp 7 | 8 | # Deserializes JSON string by constructing new Regexp object with source 9 | # s (Regexp or String) and options o serialized by 10 | # to_json 11 | def self.json_create(object) 12 | new(object['s'], object['o']) 13 | end 14 | 15 | # Returns a hash, that will be turned into a JSON object and represent this 16 | # object. 17 | def as_json(*) 18 | { 19 | JSON.create_id => self.class.name, 20 | 'o' => options, 21 | 's' => source, 22 | } 23 | end 24 | 25 | # Stores class name (Regexp) with options o and source s 26 | # (Regexp or String) as JSON string 27 | def to_json(*) 28 | as_json.to_json 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/struct.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Struct serialization/deserialization 6 | class Struct 7 | 8 | # Deserializes JSON string by constructing new Struct object with values 9 | # v serialized by to_json. 10 | def self.json_create(object) 11 | new(*object['v']) 12 | end 13 | 14 | # Returns a hash, that will be turned into a JSON object and represent this 15 | # object. 16 | def as_json(*) 17 | klass = self.class.name 18 | klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!" 19 | { 20 | JSON.create_id => klass, 21 | 'v' => values, 22 | } 23 | end 24 | 25 | # Stores class name (Struct) with Struct values v as a JSON string. 26 | # Only named structs are supported. 27 | def to_json(*args) 28 | as_json.to_json(*args) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/symbol.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Symbol serialization/deserialization 6 | class Symbol 7 | # Returns a hash, that will be turned into a JSON object and represent this 8 | # object. 9 | def as_json(*) 10 | { 11 | JSON.create_id => self.class.name, 12 | 's' => to_s, 13 | } 14 | end 15 | 16 | # Stores class name (Symbol) with String representation of Symbol as a JSON string. 17 | def to_json(*a) 18 | as_json.to_json(*a) 19 | end 20 | 21 | # Deserializes JSON string by converting the string value stored in the object to a Symbol 22 | def self.json_create(o) 23 | o['s'].to_sym 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/add/time.rb: -------------------------------------------------------------------------------- 1 | unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 | require 'json' 3 | end 4 | 5 | # Time serialization/deserialization 6 | class Time 7 | 8 | # Deserializes JSON string by converting time since epoch to Time 9 | def self.json_create(object) 10 | if usec = object.delete('u') # used to be tv_usec -> tv_nsec 11 | object['n'] = usec * 1000 12 | end 13 | if instance_methods.include?(:tv_nsec) 14 | at(object['s'], Rational(object['n'], 1000)) 15 | else 16 | at(object['s'], object['n'] / 1000) 17 | end 18 | end 19 | 20 | # Returns a hash, that will be turned into a JSON object and represent this 21 | # object. 22 | def as_json(*) 23 | nanoseconds = [ tv_usec * 1000 ] 24 | respond_to?(:tv_nsec) and nanoseconds << tv_nsec 25 | nanoseconds = nanoseconds.max 26 | { 27 | JSON.create_id => self.class.name, 28 | 's' => tv_sec, 29 | 'n' => nanoseconds, 30 | } 31 | end 32 | 33 | # Stores class name (Time) with number of seconds since epoch and number of 34 | # microseconds for Time as JSON string 35 | def to_json(*args) 36 | as_json.to_json(*args) 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/ext.rb: -------------------------------------------------------------------------------- 1 | if ENV['SIMPLECOV_COVERAGE'].to_i == 1 2 | require 'simplecov' 3 | SimpleCov.start do 4 | add_filter "/tests/" 5 | end 6 | end 7 | require 'json/common' 8 | 9 | module JSON 10 | # This module holds all the modules/classes that implement JSON's 11 | # functionality as C extensions. 12 | module Ext 13 | require 'json/ext/parser' 14 | require 'json/ext/generator' 15 | $DEBUG and warn "Using Ext extension for JSON." 16 | JSON.parser = Parser 17 | JSON.generator = Generator 18 | end 19 | 20 | JSON_LOADED = true unless defined?(::JSON::JSON_LOADED) 21 | end 22 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/ext/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Slack.dzbundle/lib/json/ext/.keep -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/ext/generator.bundle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Slack.dzbundle/lib/json/ext/generator.bundle -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/ext/parser.bundle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Slack.dzbundle/lib/json/ext/parser.bundle -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/generic_object.rb: -------------------------------------------------------------------------------- 1 | require 'ostruct' 2 | 3 | module JSON 4 | class GenericObject < OpenStruct 5 | class << self 6 | alias [] new 7 | 8 | def json_creatable? 9 | @json_creatable 10 | end 11 | 12 | attr_writer :json_creatable 13 | 14 | def json_create(data) 15 | data = data.dup 16 | data.delete JSON.create_id 17 | self[data] 18 | end 19 | 20 | def from_hash(object) 21 | case 22 | when object.respond_to?(:to_hash) 23 | result = new 24 | object.to_hash.each do |key, value| 25 | result[key] = from_hash(value) 26 | end 27 | result 28 | when object.respond_to?(:to_ary) 29 | object.to_ary.map { |a| from_hash(a) } 30 | else 31 | object 32 | end 33 | end 34 | 35 | def load(source, proc = nil, opts = {}) 36 | result = ::JSON.load(source, proc, opts.merge(:object_class => self)) 37 | result.nil? ? new : result 38 | end 39 | 40 | def dump(obj, *args) 41 | ::JSON.dump(obj, *args) 42 | end 43 | end 44 | self.json_creatable = false 45 | 46 | def to_hash 47 | table 48 | end 49 | 50 | def [](name) 51 | table[name.to_sym] 52 | end 53 | 54 | def []=(name, value) 55 | __send__ "#{name}=", value 56 | end 57 | 58 | def |(other) 59 | self.class[other.to_hash.merge(to_hash)] 60 | end 61 | 62 | def as_json(*) 63 | { JSON.create_id => self.class.name }.merge to_hash 64 | end 65 | 66 | def to_json(*a) 67 | as_json.to_json(*a) 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/pure.rb: -------------------------------------------------------------------------------- 1 | if ENV['SIMPLECOV_COVERAGE'].to_i == 1 2 | require 'simplecov' 3 | SimpleCov.start do 4 | add_filter "/tests/" 5 | end 6 | end 7 | require 'json/common' 8 | require 'json/pure/parser' 9 | require 'json/pure/generator' 10 | 11 | module JSON 12 | # This module holds all the modules/classes that implement JSON's 13 | # functionality in pure ruby. 14 | module Pure 15 | $DEBUG and warn "Using Pure library for JSON." 16 | JSON.parser = Parser 17 | JSON.generator = Generator 18 | end 19 | 20 | JSON_LOADED = true unless defined?(::JSON::JSON_LOADED) 21 | end 22 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/json/version.rb: -------------------------------------------------------------------------------- 1 | module JSON 2 | # JSON version 3 | VERSION = '1.8.1' 4 | VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: 5 | VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: 6 | VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: 7 | VERSION_BUILD = VERSION_ARRAY[2] # :nodoc: 8 | end 9 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/multipart_post.rb: -------------------------------------------------------------------------------- 1 | #-- 2 | # Copyright (c) 2007-2013 Nick Sieger. 3 | # See the file README.txt included with the distribution for 4 | # software license details. 5 | #++ 6 | 7 | module MultipartPost 8 | VERSION = "2.0.0" 9 | end 10 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/multipartable.rb: -------------------------------------------------------------------------------- 1 | #-- 2 | # Copyright (c) 2007-2013 Nick Sieger. 3 | # See the file README.txt included with the distribution for 4 | # software license details. 5 | #++ 6 | 7 | require 'parts' 8 | module Multipartable 9 | DEFAULT_BOUNDARY = "-----------RubyMultipartPost" 10 | def initialize(path, params, headers={}, boundary = DEFAULT_BOUNDARY) 11 | headers = headers.clone # don't want to modify the original variable 12 | parts_headers = headers.delete(:parts) || {} 13 | super(path, headers) 14 | parts = params.map do |k,v| 15 | case v 16 | when Array 17 | v.map {|item| Parts::Part.new(boundary, k, item, parts_headers[k]) } 18 | else 19 | Parts::Part.new(boundary, k, v, parts_headers[k]) 20 | end 21 | end.flatten 22 | parts << Parts::EpiloguePart.new(boundary) 23 | ios = parts.map {|p| p.to_io } 24 | self.set_content_type(headers["Content-Type"] || "multipart/form-data", 25 | { "boundary" => boundary }) 26 | self.content_length = parts.inject(0) {|sum,i| sum + i.length } 27 | self.body_stream = CompositeReadIO.new(*ios) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/net/http/post/multipart.rb: -------------------------------------------------------------------------------- 1 | #-- 2 | # Copyright (c) 2007-2012 Nick Sieger. 3 | # See the file README.txt included with the distribution for 4 | # software license details. 5 | #++ 6 | 7 | require 'net/http' 8 | require 'stringio' 9 | require 'cgi' 10 | require 'composite_io' 11 | require 'multipartable' 12 | require 'parts' 13 | 14 | module Net #:nodoc: 15 | class HTTP #:nodoc: 16 | class Put 17 | class Multipart < Put 18 | include Multipartable 19 | end 20 | end 21 | class Post #:nodoc: 22 | class Multipart < Post 23 | include Multipartable 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /Slack.dzbundle/lib/parts.rb: -------------------------------------------------------------------------------- 1 | #-- 2 | # Copyright (c) 2007-2013 Nick Sieger. 3 | # See the file README.txt included with the distribution for 4 | # software license details. 5 | #++ 6 | 7 | module Parts 8 | module Part #:nodoc: 9 | def self.new(boundary, name, value, headers = {}) 10 | headers ||= {} # avoid nil values 11 | if file?(value) 12 | FilePart.new(boundary, name, value, headers) 13 | else 14 | ParamPart.new(boundary, name, value, headers) 15 | end 16 | end 17 | 18 | def self.file?(value) 19 | value.respond_to?(:content_type) && value.respond_to?(:original_filename) 20 | end 21 | 22 | def length 23 | @part.length 24 | end 25 | 26 | def to_io 27 | @io 28 | end 29 | end 30 | 31 | class ParamPart 32 | include Part 33 | def initialize(boundary, name, value, headers = {}) 34 | @part = build_part(boundary, name, value, headers) 35 | @io = StringIO.new(@part) 36 | end 37 | 38 | def length 39 | @part.bytesize 40 | end 41 | 42 | def build_part(boundary, name, value, headers = {}) 43 | part = '' 44 | part << "--#{boundary}\r\n" 45 | part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n" 46 | part << "Content-Type: #{headers["Content-Type"]}\r\n" if headers["Content-Type"] 47 | part << "\r\n" 48 | part << "#{value}\r\n" 49 | end 50 | end 51 | 52 | # Represents a part to be filled from file IO. 53 | class FilePart 54 | include Part 55 | attr_reader :length 56 | def initialize(boundary, name, io, headers = {}) 57 | file_length = io.respond_to?(:length) ? io.length : File.size(io.local_path) 58 | @head = build_head(boundary, name, io.original_filename, io.content_type, file_length, 59 | io.respond_to?(:opts) ? io.opts.merge(headers) : headers) 60 | @foot = "\r\n" 61 | @length = @head.bytesize + file_length + @foot.length 62 | @io = CompositeReadIO.new(StringIO.new(@head), io, StringIO.new(@foot)) 63 | end 64 | 65 | def build_head(boundary, name, filename, type, content_len, opts = {}, headers = {}) 66 | trans_encoding = opts["Content-Transfer-Encoding"] || "binary" 67 | content_disposition = opts["Content-Disposition"] || "form-data" 68 | 69 | part = '' 70 | part << "--#{boundary}\r\n" 71 | part << "Content-Disposition: #{content_disposition}; name=\"#{name.to_s}\"; filename=\"#{filename}\"\r\n" 72 | part << "Content-Length: #{content_len}\r\n" 73 | if content_id = opts["Content-ID"] 74 | part << "Content-ID: #{content_id}\r\n" 75 | end 76 | 77 | if headers["Content-Type"] != nil 78 | part << "Content-Type: " + headers["Content-Type"] + "\r\n" 79 | else 80 | part << "Content-Type: #{type}\r\n" 81 | end 82 | 83 | part << "Content-Transfer-Encoding: #{trans_encoding}\r\n" 84 | part << "\r\n" 85 | end 86 | end 87 | 88 | # Represents the epilogue or closing boundary. 89 | class EpiloguePart 90 | include Part 91 | def initialize(boundary) 92 | @part = "--#{boundary}--\r\n\r\n" 93 | @io = StringIO.new(@part) 94 | end 95 | end 96 | end 97 | -------------------------------------------------------------------------------- /Sleep.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Sleep 3 | # Description: Puts your Mac to sleep. 4 | # Events: Clicked 5 | # Creator: Aptonic Software 6 | # URL: http://aptonic.com 7 | # Version: 1.0 8 | # RunsSandboxed: No 9 | # UniqueID: 1027 10 | # MinDropzoneVersion: 3.0 11 | 12 | def clicked 13 | $dz.finish("Sleeping...") 14 | $dz.url(false) 15 | `osascript -e 'tell application "System Events" to sleep' >& /dev/null` 16 | end 17 | -------------------------------------------------------------------------------- /Sleep.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Sleep.dzbundle/icon.png -------------------------------------------------------------------------------- /SparseImage.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/SparseImage.dzbundle/icon.png -------------------------------------------------------------------------------- /Strip PDF Front.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Strip PDF Front.dzbundle/icon.png -------------------------------------------------------------------------------- /Strip PDF Front.dzbundle/pdfpict.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Strip PDF Front.dzbundle/pdfpict.pxm -------------------------------------------------------------------------------- /Strip PDF from Zip.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Strip PDF from Zip 3 | # Description: This actions takes zip files, and removes the PDF. It will give the PDF the same name as the zip file and delete the zip file. 4 | # Handles: Files 5 | # Creator: Richard Guay 6 | # URL: http://customct.com 7 | # Events: Dragged 8 | # SkipConfig: No 9 | # RunsSandboxed: No 10 | # Version: 1.0 11 | # MinDropzoneVersion: 3.0 12 | 13 | def dragged 14 | # 15 | # Get the total number of zip files. 16 | # 17 | total = $items.count 18 | 19 | $dz.begin("Working on #{total} Zips...") 20 | 21 | # Below line switches the progress display to determinate mode so we can show progress 22 | $dz.determinate(true) 23 | 24 | # 25 | # Index over all of the given images. 26 | # 27 | for index in 0 ... total 28 | # 29 | # Get the name of the zip file. 30 | # 31 | filename = File.basename($items[index],".zip") 32 | 33 | # 34 | # Get the full path to the zip file 35 | # 36 | zipath = File.dirname($items[index]) 37 | 38 | # 39 | # Unzip the pdf file inside the zip file without the internal zip path to the 40 | # location of the zip file. Keep the output split by ':' to get the name of the 41 | # pdf file with it's path. This only works if there is one pdf in the zip! 42 | # 43 | output = `/usr/bin/unzip -j -d "#{zipath}" "#{$items[index]}" "*.pdf"`.split(':') 44 | 45 | # 46 | # Rename the pdf file to the same as the basename of the zip. 47 | # 48 | File.rename(output[2].strip,"#{zipath}/#{filename}.pdf") 49 | 50 | # 51 | # Remove the zip file. 52 | # 53 | FileUtils.rm("#{$items[index]}", :force => true) 54 | 55 | # 56 | # Tell Dropzone what percentage is done. 57 | # 58 | $dz.percent((((index + 1)*100)/total).to_i) 59 | 60 | # 61 | # Set the results string to finished. 62 | # 63 | result = "Finished those Zip files!" 64 | end 65 | 66 | # 67 | # The below line tells Dropzone to end with a notification center 68 | # notification with the text "Task Complete" 69 | # 70 | $dz.finish(result) 71 | $dz.text(false) 72 | end 73 | -------------------------------------------------------------------------------- /Strip PDF from Zip.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Strip PDF from Zip.dzbundle/icon.png -------------------------------------------------------------------------------- /Strip PDF from Zip.dzbundle/pdfpict.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Strip PDF from Zip.dzbundle/pdfpict.pxm -------------------------------------------------------------------------------- /Trash.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Trash 3 | # Description: An action to throw items into the trash if Finder is running. Otherwise, it simply deletes them using the command line. 4 | # Handles: Files 5 | # Creator: Richard Guay 6 | # URL: http://customct.com 7 | # Events: Dragged 8 | # SkipConfig: No 9 | # RunsSandboxed: Yes 10 | # Version: 1.1 11 | # MinDropzoneVersion: 3.0 12 | 13 | def dragged 14 | # 15 | # Begin the action. 16 | # 17 | $dz.begin("Trashing...") 18 | 19 | # 20 | # Below line switches the progress display to determinate mode so we can show progress 21 | # 22 | $dz.determinate(true) 23 | 24 | # 25 | # Below lines tell Dropzone to update the progress bar display and cycle through 26 | # each item dropped onto the action. 27 | # 28 | $dz.percent(1) 29 | count = $items.count 30 | index = 0 31 | $items.each {|file| 32 | # 33 | # Delete the file using the trash utility from Homebrew if Finder is running. Otherwise, 34 | # just delete it with the rm command. 35 | # 36 | finderR = `./finderRunning` 37 | if finderR =~ /not running/ then 38 | `rm -Rf "#{file}"` 39 | else 40 | `./trash -va "#{file}"` 41 | end 42 | 43 | # 44 | # Tell Dropzone what percentage is done. 45 | # 46 | index = index + 1 47 | $dz.percent((((index + 1)*100)/count).to_i) 48 | } 49 | 50 | # 51 | # Show the user that the task is done. 52 | # 53 | $dz.finish("Task Complete") 54 | $dz.url(false) 55 | end 56 | -------------------------------------------------------------------------------- /Trash.dzbundle/finderRunning: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Trash.dzbundle/finderRunning -------------------------------------------------------------------------------- /Trash.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Trash.dzbundle/icon.png -------------------------------------------------------------------------------- /Trash.dzbundle/trash: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Trash.dzbundle/trash -------------------------------------------------------------------------------- /UnbundleZipByName.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Unbundle Zip by Name 3 | # Description: This action will unzip a zip file into the curret directory and rename the files to the name of the zip file. 4 | # Handles: Files 5 | # Events: Dragged 6 | # Creator: Richard Guay 7 | # RunsSandboxed: Yes 8 | # Version: 1.0 9 | # URL: http://customct.com 10 | # MinDropzoneVersion: 3.0 11 | # UniqueID: 1008 12 | 13 | require 'fileutils' 14 | 15 | def dragged 16 | # 17 | # Turn on determinate mode. 18 | # 19 | $dz.determinate(true) 20 | 21 | # 22 | # Process each zip file. 23 | # 24 | total = $items.count 25 | 26 | # 27 | # Set default result message. 28 | # 29 | result = "Not a Zip file!" 30 | 31 | # 32 | # Tell dropzone we are starting... 33 | # 34 | $dz.begin("Start compressing #{total} images...") 35 | 36 | # 37 | # Index over all of the given images. 38 | # 39 | for index in 0 ... total 40 | # 41 | # Determine if it is a zip file. 42 | # 43 | ext = File.extname($items[index]) 44 | if ext == ".zip" 45 | # 46 | # Get the file name 47 | # 48 | zipname = File.basename($items[index],".zip") 49 | zippath = File.dirname($items[index]) 50 | 51 | # 52 | # Extract the files. 53 | # 54 | `/usr/bin/unzip "#{zippath}/#{zipname}.zip" -d "#{zippath}/#{zipname}/"` 55 | 56 | # 57 | # change each file to the new basename based on zip file's name. 58 | # 59 | Dir.foreach("#{zippath}/#{zipname}") {|filename| 60 | if (filename != ".") && (filename != "..") 61 | ext = File.extname(filename) 62 | File.rename("#{zippath}/#{zipname}/#{filename}", "#{zippath}/#{zipname}/#{zipname}#{ext}") 63 | end 64 | } 65 | 66 | # 67 | # Tell Dropzone what percentage is done. 68 | # 69 | $dz.percent((((index + 1)*100)/total).to_i) 70 | 71 | # 72 | # Set the results string to finished. 73 | # 74 | result = "Finished Extraction." 75 | end 76 | end 77 | 78 | # 79 | # Tell the user that it is done. 80 | # 81 | $dz.finish(result) 82 | 83 | # 84 | # Finish out the dropzone protocal. If you want a url in the clipboard, pass it 85 | # here. If you just want to copy text to the clipboard, use $dz.text() instead. 86 | # Either $dz.url() or $dz.text() has to be the last thing in the dragged method. 87 | # 88 | $dz.url(false) 89 | end 90 | -------------------------------------------------------------------------------- /UnbundleZipByName.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/UnbundleZipByName.dzbundle/icon.png -------------------------------------------------------------------------------- /Up1.dzbundle/bundler/setup.rb: -------------------------------------------------------------------------------- 1 | require 'rbconfig' 2 | # ruby 1.8.7 doesn't define RUBY_ENGINE 3 | ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' 4 | ruby_version = RbConfig::CONFIG["ruby_version"] 5 | path = File.expand_path('..', __FILE__) 6 | $:.unshift "#{path}/" 7 | $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sjcl-1.0.1/lib" 8 | -------------------------------------------------------------------------------- /Up1.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Up1.dzbundle/icon.png -------------------------------------------------------------------------------- /Up1.dzbundle/ruby/2.0.0/gems/sjcl-1.0.1/lib/sjcl.rb: -------------------------------------------------------------------------------- 1 | require 'sjcl/bit_array' 2 | require 'sjcl/codec_string' 3 | require 'sjcl/codec_base64' 4 | require 'sjcl/codec_hex' 5 | require 'sjcl/aes' 6 | require 'sjcl/ccm' 7 | require 'sjcl/pbkdf2' 8 | require 'sjcl/random' 9 | require 'json' 10 | require 'base64' 11 | 12 | module SJCL 13 | 14 | DEFAULT = { 15 | v:1, iter:100_000, ks:256, ts:64, 16 | mode:"ccm", adata:"", cipher:"aes" 17 | } 18 | 19 | def self.decrypt(password, jsonstr) 20 | cipher_obj = JSON.parse(jsonstr, :symbolize_names => true) 21 | key = SJCL::Misc.pbkdf2(password, 22 | cipher_obj[:salt], 23 | cipher_obj[:iter], 24 | cipher_obj[:ks]) 25 | cipher = SJCL::Cipher::AES.new(key) 26 | 27 | ct = SJCL::Codec::Base64.toBits(cipher_obj[:ct]) 28 | iv = SJCL::Codec::Base64.toBits(cipher_obj[:iv]) 29 | adata = SJCL::Codec::Base64.toBits(cipher_obj[:adata]) 30 | out = SJCL::Mode::CCM.decrypt(cipher, ct, iv, adata) 31 | SJCL::Codec::UTF8String.fromBits(out) 32 | end 33 | 34 | def self.encrypt(password, str, opts={}) 35 | opts = DEFAULT.merge(opts) 36 | iv = SJCL::Random.randomWords(4) 37 | salt = SJCL::Codec::Base64.fromBits(SJCL::Random.randomWords(2)) 38 | key = SJCL::Misc.pbkdf2(password, 39 | salt, 40 | opts[:iter], 41 | opts[:ks]) 42 | cipher = SJCL::Cipher::AES.new(key) 43 | pt = SJCL::Codec::UTF8String.toBits(str) 44 | adata = SJCL::Codec::UTF8String.toBits(opts[:adata]) 45 | ct = SJCL::Mode::CCM.encrypt(cipher, pt, iv, adata) 46 | ct = SJCL::Codec::Base64.fromBits(ct) 47 | out = opts.merge({ 48 | :ct => ct, 49 | :iv => SJCL::Codec::Base64.fromBits(iv), 50 | :salt => salt 51 | }) 52 | out.to_json 53 | end 54 | 55 | end 56 | -------------------------------------------------------------------------------- /Up1.dzbundle/ruby/2.0.0/gems/sjcl-1.0.1/lib/sjcl/aes.rb: -------------------------------------------------------------------------------- 1 | require 'sjcl/aes_tables' 2 | 3 | module SJCL::Cipher 4 | class AES 5 | TABLES = SJCL::Cipher::AES_Tables::TABLES 6 | attr_reader :key 7 | 8 | def initialize(key) 9 | @raw_key = key 10 | @keyLen = key.length 11 | schedule_keys 12 | end 13 | 14 | def schedule_keys 15 | sbox = TABLES[0][4] 16 | decTable = TABLES[1] 17 | encKey = @raw_key.dup 18 | decKey = [] 19 | rcon = 1 20 | i = @keyLen 21 | j = 0 22 | while i < 4*@keyLen + 28 23 | tmp = encKey[i-1] ? encKey[i-1] & 0xFFFFFFFF : 0 24 | if (i % @keyLen === 0 || (@keyLen === 8 && i % @keyLen === 4)) 25 | tmp = sbox[tmp >> 24] << 24 ^ sbox[tmp >> 16 & 255] << 16 ^ sbox[tmp >> 8 & 255] << 8 ^ sbox[tmp & 255] 26 | if (i % @keyLen === 0) 27 | tmp = tmp<<8 ^ tmp >> 24 ^ rcon << 24 28 | rcon = rcon << 1 ^ (rcon >> 7) * 283 29 | end 30 | end 31 | encKey[i] = (encKey[i-@keyLen] ^ tmp) & 0xFFFFFFFF; 32 | i += 1 33 | end 34 | while i > 0 35 | tmp = encKey[j & 3 != 0 ? i : i - 4]; 36 | tmp = tmp & 0xFFFFFFFF 37 | if (i<=4 || j<4) 38 | decKey[j] = tmp; 39 | else 40 | decKey[j] = decTable[0][sbox[tmp >> 24]] ^ 41 | decTable[1][sbox[tmp >> 16 & 255]] ^ 42 | decTable[2][sbox[tmp >> 8 & 255]] ^ 43 | decTable[3][sbox[tmp & 255]] 44 | end 45 | decKey[j] = decKey[j] & 0xFFFFFFFF 46 | i -= 1 47 | j += 1 48 | end 49 | @key = [encKey, decKey] 50 | end 51 | 52 | def encrypt(data) 53 | crypt(data,0) 54 | end 55 | 56 | def decrypt(data) 57 | crypt(data,1) 58 | end 59 | 60 | private 61 | 62 | def crypt(input, dir) 63 | key = @key[dir] 64 | a = input[0] ^ key[0] 65 | b = input[dir == 1 ? 3 : 1] ^ key[1] 66 | c = input[2] ^ key[2] 67 | d = input[dir == 1 ? 1 : 3] ^ key[3] 68 | a2 = 0 69 | b2 = 0 70 | c2 = 0 71 | nInnerRounds = key.length/4 - 2 72 | kIndex = 4 73 | out = [0,0,0,0] 74 | table = TABLES[dir] 75 | # Load up the tables 76 | t0 = table[0] 77 | t1 = table[1] 78 | t2 = table[2] 79 | t3 = table[3] 80 | sbox = table[4] 81 | 82 | nInnerRounds.times do 83 | a2 = t0[a >> 24 & 255] ^ t1[b>>16 & 255] ^ t2[c>>8 & 255] ^ t3[d & 255] ^ key[kIndex] 84 | b2 = t0[b >> 24 & 255] ^ t1[c>>16 & 255] ^ t2[d>>8 & 255] ^ t3[a & 255] ^ key[kIndex + 1] 85 | c2 = t0[c >> 24 & 255] ^ t1[d>>16 & 255] ^ t2[a>>8 & 255] ^ t3[b & 255] ^ key[kIndex + 2] 86 | d = t0[d >> 24 & 255] ^ t1[a>>16 & 255] ^ t2[b>>8 & 255] ^ t3[c & 255] ^ key[kIndex + 3] 87 | kIndex += 4 88 | a=a2; b=b2; c=c2; 89 | end 90 | 91 | 4.times do |i| 92 | out[dir != 0 ? 3&-i : i] = 93 | sbox[a>>24 & 255]<<24 ^ 94 | sbox[b>>16 & 255]<<16 ^ 95 | sbox[c>>8 & 255]<<8 ^ 96 | sbox[d & 255] ^ 97 | key[kIndex]; 98 | kIndex += 1 99 | a2=a; a=b; b=c; c=d; d=a2; 100 | end 101 | return out 102 | end 103 | 104 | end 105 | end 106 | -------------------------------------------------------------------------------- /Up1.dzbundle/ruby/2.0.0/gems/sjcl-1.0.1/lib/sjcl/codec_base64.rb: -------------------------------------------------------------------------------- 1 | module SJCL::Codec 2 | module Base64 3 | CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 4 | def self.fromBits(arr, noEquals=false, url=false) 5 | out = "" 6 | bits=0 7 | c = CHARS.dup 8 | ta=0 9 | i = 0 10 | bl = SJCL::BitArray.bitLength(arr) 11 | if (url) 12 | c = c[0,62] + '-_'; 13 | end 14 | while (out.length * 6) < bl 15 | a = (arr[i] & 0xFFFFFFFF) || 0 16 | out += c[(ta ^ a >> bits) >> 26,1] 17 | if (bits < 6) 18 | ta = (a << (6-bits)) & 0xFFFFFFFF 19 | bits += 26 20 | i += 1 21 | else 22 | ta = (ta << 6) & 0xFFFFFFFF 23 | bits -= 6 24 | end 25 | end 26 | while ((out.length & 3 > 0) && !noEquals) 27 | out += "=" 28 | end 29 | return out 30 | end 31 | 32 | def self.toBits(str, url=false) 33 | i=0 34 | bits = 0 35 | ta = 0 36 | c = CHARS.dup 37 | out = [] 38 | if (url) 39 | c = c[0,62] + '-_' 40 | end 41 | while (i < str.length) 42 | str = str.gsub(/\s|=/, '') 43 | x = c.index(str[i]); 44 | unless x 45 | raise "this isn't base64!" 46 | end 47 | if (bits > 26) 48 | bits -= 26; 49 | out << ((ta ^ x >> bits) & 0xFFFFFFFF) 50 | ta = x << (32-bits) 51 | ta &= 0xFFFFFFFF 52 | else 53 | bits += 6 54 | ta ^= x << (32-bits) 55 | ta &= 0xFFFFFFFF 56 | end 57 | i += 1 58 | end 59 | if (bits&56 > 0) 60 | out.push(SJCL::BitArray.partial(bits & 56, ta, 1)); 61 | end 62 | return out 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /Up1.dzbundle/ruby/2.0.0/gems/sjcl-1.0.1/lib/sjcl/codec_hex.rb: -------------------------------------------------------------------------------- 1 | module SJCL::Codec 2 | module Hex 3 | def self.fromBits(arr) 4 | out = "" 5 | arr.length.times do |i| 6 | out += ((arr[i] & 0xFFFFFFFF)|0).to_s(16).rjust(8,'0')[0,8] 7 | end 8 | return out[0, SJCL::BitArray.bitLength(arr)/4] 9 | end 10 | 11 | def self.toBits(str) 12 | out = [] 13 | len = str.length 14 | str = str + "00000000" 15 | i = 0 16 | while i < str.length 17 | out.push(str[i,8].to_i(16) ^ 0) 18 | i += 8 19 | end 20 | return SJCL::BitArray.clamp(out, len*4) 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /Up1.dzbundle/ruby/2.0.0/gems/sjcl-1.0.1/lib/sjcl/codec_string.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'cgi' 3 | 4 | module SJCL::Codec 5 | module UTF8String 6 | def self.fromBits(arr) 7 | out = [] 8 | bl = SJCL::BitArray.bitLength(arr) 9 | i = 0 10 | tmp = 0 11 | (bl/8).times do 12 | if ((i&3) === 0) 13 | tmp = arr[i/4] 14 | end 15 | out << (tmp >> 24) 16 | tmp <<= 8 17 | i += 1 18 | end 19 | out.pack('C*').force_encoding('utf-8') 20 | end 21 | 22 | def self.toBits(str) 23 | str_arr = str.unpack("C*") 24 | out = [] 25 | tmp=0 26 | i=0 27 | str_arr.length.times do 28 | tmp = tmp << 8 | str_arr[i] 29 | if ((i&3) === 3) 30 | out.push(tmp); 31 | tmp = 0; 32 | end 33 | i += 1 34 | end 35 | if (i&3 != 0) 36 | out.push(SJCL::BitArray.partial(8*(i&3), tmp)); 37 | end 38 | return out 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /Up1.dzbundle/ruby/2.0.0/gems/sjcl-1.0.1/lib/sjcl/pbkdf2.rb: -------------------------------------------------------------------------------- 1 | require 'base64' 2 | require 'openssl' 3 | 4 | module SJCL 5 | module Misc 6 | 7 | def self.pbkdf2(password, salt, iter, length) 8 | key = OpenSSL::PKCS5.pbkdf2_hmac(password, Base64.decode64(salt), iter, length/8, 'SHA256') 9 | SJCL::Codec::Hex.toBits(key.unpack('H*')[0]) 10 | end 11 | 12 | end 13 | end 14 | 15 | -------------------------------------------------------------------------------- /Up1.dzbundle/ruby/2.0.0/gems/sjcl-1.0.1/lib/sjcl/random.rb: -------------------------------------------------------------------------------- 1 | require 'securerandom' 2 | 3 | module SJCL::Random 4 | 5 | # Number of 4 byte words to retun 6 | def self.randomWords(len) 7 | SJCL::Codec::Hex.toBits(SecureRandom.hex(len*4)) 8 | end 9 | 10 | end 11 | -------------------------------------------------------------------------------- /Up1.dzbundle/ruby/2.0.0/gems/sjcl-1.0.1/lib/sjcl/version.rb: -------------------------------------------------------------------------------- 1 | module SJCL 2 | VERSION = "1.0.1" 3 | end 4 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/.idea/YouTube.dzbundle.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: YouTube Uploader 3 | # Description: Uploads dragged videos to YouTube. \n\nYou can select the privacy level and after upload it opens the edit page of the video in the default browser.\n\nBy using this action you agree YouTube Terms of Service at\n https://www.youtube.com/t/terms and the Google privacy policy at https://policies.google.com/privacy\n\nYou can manage or revoke Dropzone's access to your Google Account at https://security.google.com/settings/security/permissions 4 | # Handles: Files 5 | # Creator: Aptonic Software 6 | # URL: http://aptonic.com 7 | # OptionsNIB: GoogleAuth 8 | # AuthScope: https://www.googleapis.com/auth/youtube.upload 9 | # Events: Dragged, Clicked 10 | # RunsSandboxed: Yes 11 | # Version: 2.7 12 | # UniqueID: 1026 13 | # MinDropzoneVersion: 3.2.1 14 | 15 | require 'youtube' 16 | 17 | def dragged 18 | youtube = Youtube.new 19 | 20 | $dz.determinate(false) 21 | 22 | youtube.configure_client 23 | privacy_status = youtube.read_privacy_status 24 | 25 | $items.each do |file| 26 | youtube.upload_video(file, privacy_status) 27 | end 28 | 29 | $dz.finish('Video(s) were uploaded to YouTube!') 30 | $dz.url(false) 31 | 32 | end 33 | 34 | def clicked 35 | system('open https://youtube.com') 36 | end 37 | -------------------------------------------------------------------------------- /YouTube Uploader.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/YouTube Uploader.dzbundle/icon.png -------------------------------------------------------------------------------- /Zip by Parent Name.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: Zip by Parent Name 3 | # Description: Zip up multiple files and naming by the parent directory's name. 4 | # Handles: Files 5 | # Creator: Aptonic Software 6 | # URL: http://aptonic.com 7 | # OptionsNIB: ChooseFolder 8 | # Events: Dragged 9 | # SkipConfig: No 10 | # RunsSandboxed: Yes 11 | # Version: 1.2 12 | # MinDropzoneVersion: 3.2.1 13 | 14 | def dragged 15 | $dz.determinate(false) 16 | filename = File.basename(File.dirname($items[0])) 17 | parentdir = File.dirname($items[0]) 18 | zipfile = ZipFiles.zip($items, filename + ".zip") 19 | zipfile = zipfile[1, zipfile.length - 2] 20 | system("zip -d \"#{zipfile}\" '__MACOSX*' '*.DS_Store' >& /dev/null") 21 | Rsync.do_copy([zipfile], parentdir, true) 22 | $dz.finish("ZIP created") 23 | $dz.url(false) 24 | end 25 | -------------------------------------------------------------------------------- /Zip by Parent Name.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/Zip by Parent Name.dzbundle/icon.png -------------------------------------------------------------------------------- /docs/alert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/alert.png -------------------------------------------------------------------------------- /docs/copy-and-edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/copy-and-edit.png -------------------------------------------------------------------------------- /docs/debug-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/debug-console.png -------------------------------------------------------------------------------- /docs/determinate-false.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/determinate-false.png -------------------------------------------------------------------------------- /docs/determinate-true.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/determinate-true.png -------------------------------------------------------------------------------- /docs/develop-action.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/develop-action.png -------------------------------------------------------------------------------- /docs/develop-dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/develop-dialog.png -------------------------------------------------------------------------------- /docs/develop-python.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/develop-python.png -------------------------------------------------------------------------------- /docs/dzbundle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/dzbundle.png -------------------------------------------------------------------------------- /docs/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/error.png -------------------------------------------------------------------------------- /docs/fail-notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/fail-notification.png -------------------------------------------------------------------------------- /docs/finish-notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/finish-notification.png -------------------------------------------------------------------------------- /docs/inputbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/inputbox.png -------------------------------------------------------------------------------- /docs/keymodifiers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/keymodifiers.png -------------------------------------------------------------------------------- /docs/login-optionsnib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/login-optionsnib.png -------------------------------------------------------------------------------- /docs/open-debug-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/open-debug-console.png -------------------------------------------------------------------------------- /docs/pashua-enter-text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/pashua-enter-text.png -------------------------------------------------------------------------------- /docs/pashua-selection-dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/pashua-selection-dialog.png -------------------------------------------------------------------------------- /docs/replace-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/replace-icon.png -------------------------------------------------------------------------------- /docs/reveal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/reveal.png -------------------------------------------------------------------------------- /docs/show-package-contents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/docs/show-package-contents.png -------------------------------------------------------------------------------- /md5 Filename.dzbundle/action.rb: -------------------------------------------------------------------------------- 1 | # Dropzone Action Info 2 | # Name: md5 Filename 3 | # Description: Renames any dragged file(s) to a random, eight-characters-long md5 string. 4 | # Handles: Files 5 | # Creator: Kolja Nolte 6 | # URL: https://www.koljanolte.com 7 | # Events: Dragged 8 | # KeyModifiers: Command, Option, Control, Shift 9 | # SkipConfig: No 10 | # RunsSandboxed: Yes 11 | # Version: 1.0.0 12 | # MinDropzoneVersion: 3.0 13 | 14 | def dragged 15 | require 'digest' 16 | 17 | puts $items.inspect 18 | 19 | file_path = $items[0].to_s 20 | basename = File.basename(file_path) 21 | new_file_name = nil 22 | counter = 0 23 | 24 | unless File.exist?(file_path) 25 | $dz.finish("Error: The file \"#{basename}\" could not be found. The file was not renamed.") 26 | 27 | exit 28 | end 29 | 30 | $dz.begin("Start renaming #{basename}...") 31 | $dz.determinate(true) 32 | 33 | $items.each do |file_path_single| 34 | current_directory = File.dirname(file_path_single) 35 | md5 = Digest::MD5.file file_path_single 36 | md5 = md5.hexdigest[1..8] 37 | file_extension = File.extname(file_path_single) 38 | new_file_name = md5 + file_extension 39 | new_file_path = current_directory + '/' + new_file_name 40 | 41 | $dz.percent(10) 42 | sleep(0.3) 43 | $dz.percent(50) 44 | sleep(0.1) 45 | $dz.percent(100) 46 | 47 | if File.rename(File.path(file_path_single), new_file_path) 48 | counter += 1 49 | end 50 | end 51 | 52 | text = "File \"#{basename}\" has been successfully renamed to \"#{new_file_name}\"." 53 | 54 | if counter > 1 55 | text = "#{counter} files have been successfully renamed." 56 | end 57 | 58 | $dz.finish(text) 59 | $dz.text(false) 60 | end -------------------------------------------------------------------------------- /md5 Filename.dzbundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aptonic/dropzone4-actions/7ab31d95ff7875f45f79fc23b77db89b810795dd/md5 Filename.dzbundle/icon.png --------------------------------------------------------------------------------