forked from a4agarwal/dropzone-user-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPapers.dropzone
72 lines (67 loc) · 1.72 KB
/
Papers.dropzone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/ruby
# Dropzone Destination Info
# Name: Papers
# Description: Open URL or import PDF files in Papers.
# Handles: NSStringPboardType, NSFilenamesPboardType
# Creator: Jan Mol
# URL: None
# IconURL: http://gigapple.files.wordpress.com/2007/12/papers-icon.png
# Events: Dragged, Clicked
def importurl(url)
# Open Papers using Applescript
begin
`osascript -e 'tell application "Papers"'\
-e 'activate'\
-e 'open location "#{url}"'\
-e 'end tell'`
rescue Exeption => e
$dz.finish("Error uploading in Papers! %s" % e)
$dz.url(false)
exit
end
end
def importpdf(path)
# Open Papers using Applescript
begin
`osascript -e 'tell application "Papers"'\
-e 'activate'\
-e 'open POSIX file "#{path}"'\
-e 'end tell'`
rescue Exeption => e
$dz.finish("Error importing in Papers! %s" % e)
$dz.url(false)
exit
end
end
def dragged
$dz.determinate(false)
begin
case ENV['DRAGGED_TYPE']
when 'NSStringPboardType'
$dz.begin("Opening URL in Papers...")
importurl($items[0])
$dz.finish("Opened URL in Papers")
when 'NSFilenamesPboardType'
$dz.begin("Importing PDF in Papers...")
importpdf($items[0])
$dz.finish("Imported PDF in Papers")
end
$dz.url(false)
rescue Exeption => e
$dz.finish("Error importing in Papers! %s" % e)
$dz.url(false)
exit
end
end
def clicked
# Open Papers using Applescript
begin
`osascript -e 'tell application "Papers"'\
-e 'activate'\
-e 'end tell'`
rescue Exeption => e
$dz.finish("Error importing Papers! %s" % e)
$dz.url(false)
exit
end
end