imagebin 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/bin/take-screenshot +11 -3
- data/lib/imagebin.rb +12 -3
- metadata +1 -1
data/VERSION.yml
CHANGED
data/bin/take-screenshot
CHANGED
@@ -5,6 +5,9 @@
|
|
5
5
|
# Requires: imagemagick, xmessage, and the imagebin script
|
6
6
|
#
|
7
7
|
|
8
|
+
require 'rubygems'
|
9
|
+
require 'imagebin'
|
10
|
+
|
8
11
|
# Location to save files
|
9
12
|
working_dir = "/tmp"
|
10
13
|
# Default delay before taking screenshots
|
@@ -13,7 +16,6 @@ delay = 3
|
|
13
16
|
prefix = "screenshot"
|
14
17
|
import = `which import`.chomp
|
15
18
|
xmess = `which xmessage`.chomp
|
16
|
-
imagebin = `which imagebin`.chomp
|
17
19
|
|
18
20
|
# Check if the dir to store the screenshots exists, else create it:
|
19
21
|
Dir.mkdir(working_dir) if not File.exists?(working_dir)
|
@@ -21,8 +23,14 @@ Dir.mkdir(working_dir) if not File.exists?(working_dir)
|
|
21
23
|
i = Dir.glob("#{working_dir}/#{prefix}.png").size + 1
|
22
24
|
|
23
25
|
sleep delay
|
26
|
+
|
27
|
+
# Take the screenshot with the 'import' command.
|
24
28
|
system("#{import}", "-window", "root", "#{working_dir}/#{prefix}-#{i}.png")
|
25
|
-
|
26
|
-
|
29
|
+
|
30
|
+
ibin = Imagebin.new({ "f" => "#{working_dir}/#{prefix}-#{i}.png",
|
31
|
+
"adult" => "t",
|
32
|
+
})
|
33
|
+
|
34
|
+
system("#{xmess}", "-nearmouse", "#{ibin.pic_link}")
|
27
35
|
|
28
36
|
File.delete("#{working_dir}/#{prefix}-#{i}.png")
|
data/lib/imagebin.rb
CHANGED
@@ -20,10 +20,19 @@ class Imagebin
|
|
20
20
|
# })
|
21
21
|
#
|
22
22
|
def initialize(options)
|
23
|
-
|
24
|
-
|
23
|
+
@options = { "t" => "file",
|
24
|
+
"name" => "",
|
25
|
+
"tags" => "",
|
26
|
+
"description" => "",
|
27
|
+
"adult" => "f",
|
28
|
+
"direct_link" => "0",
|
29
|
+
"f" => "",
|
30
|
+
}
|
31
|
+
@options.merge!(options)
|
32
|
+
File.open(@options["f"]) do |file|
|
33
|
+
@options["f"] = file
|
25
34
|
clnt = HTTPClient.new
|
26
|
-
res = clnt.post('http://imagebin.ca/upload.php', options).content
|
35
|
+
res = clnt.post('http://imagebin.ca/upload.php', @options).content
|
27
36
|
@doc = Hpricot(res)
|
28
37
|
end
|
29
38
|
end
|