Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improved ImageShack script

  • Loading branch information...
commit 9fce15f0c6112ce6082e09c1c13b6b7f1734573f 1 parent f77457f
@aptonic authored
View
1  Copy to Terminal path.dropzone
@@ -4,6 +4,7 @@
# Name: Copy to Terminal path
# Description: Dropped files will be copied to the current Terminal.app path.
# Handles: NSFilenamesPboardType
+# Events: Dragged
# Creator: Aptonic Software
# URL: http://aptonic.com
# IconURL: http://aptonic.com/destinations/icons/terminal.png
View
28 ImageShack.dropzone
@@ -1,12 +1,13 @@
#!/usr/bin/ruby
# Dropzone Destination Info
-# Name: ImageShack Upload
-# Description: Provides the ability to upload an image to ImageShack.
+# Name: ImageShack
+# Description: Uploads an image to ImageShack. Holding down option causes the resulting URL to be minified using the Is.Gd service.
# Handles: NSFilenamesPboardType
+# Events: Clicked, Dragged
# Creator: Paul William
# URL: http://entropytheblog.com
-# IconURL: http://img521.imageshack.us/img521/8/imageshackx.png
+# IconURL: http://aptonic.com/destinations/icons/imageshack.png
require "rexml/document"
@@ -21,19 +22,22 @@ def dragged
output = IO.popen("/usr/bin/curl -A '#{FF_USERAGENT}' -F 'xml=yes' -F 'fileupload=@#{file_path}' http://www.imageshack.us/index.php 2>&1").read
begin
- doc = REXML::Document.new(output)
url = ""
- doc.elements.each("links/image_link"){|e| url = e.text}
- $dz.finish("URL is now on clipboard.")
+ doc = REXML::Document.new(output)
+ doc.elements.each("links/image_link") {|e| url = e.text}
+
+ # TODO: Minify if option key is held down
+ #url = IsGd.minify(url)
+
+ $dz.finish("URL is now on clipboard")
$dz.url(url)
- rescue Exception => e
- $dz.finish("Error uploading")
- $dz.url("0")
- end
+ rescue
+ $dz.finish("Upload Failed")
+ $dz.url(false)
+ end
end
def clicked
- $dz.finish("You clicked me!")
- $dz.url("0")
+ system("open http://imageshack.us/")
end
View
50 ImageShackIsGd.dropzone
@@ -1,50 +0,0 @@
-#!/usr/bin/ruby
-
-# Dropzone Destination Info
-# Name: ImageShack / is.gd Upload
-# Description: Provides the ability to upload an image to ImageShack. The URL is then shortened with the is.gd service.
-# Handles: NSFilenamesPboardType
-# Creator: Paul William
-# URL: http://entropytheblog.com
-# IconURL: http://img241.imageshack.us/img241/6271/imageshackisgd.png
-
-require "rexml/document"
-require 'net/http'
-require 'uri'
-
-FF_USERAGENT = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"
-
-def dragged
- $dz.determinate(false)
-
- file_path = $items[0]
- $dz.begin("Uploading ...")
-
- output = IO.popen("/usr/bin/curl -A '#{FF_USERAGENT}' -F 'xml=yes' -F 'fileupload=@#{file_path}' http://www.imageshack.us/index.php 2>&1").read
-
- begin
- doc = REXML::Document.new(output)
- url = ""
- doc.elements.each("links/image_link"){|e| url = e.text}
-
- resp = Net::HTTP.get_response(URI.parse("http://is.gd/api.php?longurl=#{url}"))
- if resp.response.class == Net::HTTPOK
- url = resp.body
- finish_text = "URL is now on clipboard."
- else
- finish_text = "URL is now on clipboard. (is.gd failed)"
- end
-
- $dz.finish(finish_text)
- $dz.url(url)
- rescue Exception => e
- $dz.finish("Error uploading.")
- $dz.url("0")
- end
-
-end
-
-def clicked
- $dz.finish("You clicked me!")
- $dz.url("0")
-end
View
2  TwitDoc.dropzone
@@ -42,7 +42,7 @@ def dragged
$dz.finish("URL is now on clipboard")
$dz.url(url)
rescue Exception => e
- $dz.finish("Upload Error")
+ $dz.finish("Upload Failed")
$dz.url(false)
end
View
2  TwitPic.dropzone
@@ -42,7 +42,7 @@ def dragged
$dz.finish("URL is now on clipboard")
$dz.url(url)
rescue
- $dz.finish("Upload Error")
+ $dz.finish("Upload Failed")
$dz.url(false)
end
Please sign in to comment.
Something went wrong with that request. Please try again.