Skip to content

Commit 632ae51

Browse files
author
Roman Revyakin
committed
Gist extension for PopClip
0 parents  commit 632ae51

File tree

7 files changed

+170
-0
lines changed

7 files changed

+170
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Extensions for PopClip
2+
====================
3+
4+
This is repository for extensions for [PopClip](http://pilotmoon.com/popclip)
5+
Currently available:
6+
- gist

gist/.DS_Store

6 KB
Binary file not shown.

gist/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Gist for PopClip
2+
====================
3+
*version 1.3 21 Sep 2014*
4+
5+
This is extension for sending selected text to [Gist](http://gist.github.com).
6+
In result you got short link in your clipboard. After installation the following options are available:
7+
- Default file extension of pasted text
8+
- Default description of pasted text
9+
- Token to submit gists on behalf of your own Git account
10+
- Whether a gist should be secret or public
11+
- Whether you want a gist to be open in a default browser
12+
13+
## Notes ##
14+
15+
For this extension to work you need [gist](https://github.com/defunkt/gist) to be installed on your computer
16+
(`sudo gem install gist` in a terminal).
17+
In order to be able to paste gists into your own account, you need to provide API token in the options.
18+
19+
## Credits ##
20+
21+
Icon by [Github](https://github.com/logos)

gist/gist.popclipext/Config.plist

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Version</key>
6+
<string>1.3</string>
7+
<key>Extension Identifier</key>
8+
<string>com.devopsyturvy.sendtogist</string>
9+
<key>Actions</key>
10+
<array>
11+
<dict>
12+
<key>After</key>
13+
<string>copy-result</string>
14+
<key>After</key>
15+
<string>preview-result</string>
16+
<key>Title</key>
17+
<string>Gist</string>
18+
<key>Image File</key>
19+
<string>octicon.png</string>
20+
<key>Script Interpreter</key>
21+
<string>/usr/bin/ruby</string>
22+
<key>Shell Script File</key>
23+
<string>sendtogist.rb</string>
24+
</dict>
25+
</array>
26+
<key>Options</key>
27+
<array>
28+
<dict>
29+
<key>Option Identifier</key>
30+
<string>extension</string>
31+
<key>Option Label</key>
32+
<string>Gist file extension</string>
33+
<key>Option Type</key>
34+
<string>multiple</string>
35+
<key>Option Values</key>
36+
<array>
37+
<string>txt</string>
38+
<string>php</string>
39+
<string>java</string>
40+
<string>html</string>
41+
<string>haskell</string>
42+
<string>vim</string>
43+
<string>c</string>
44+
<string>sh</string>
45+
<string>py</string>
46+
<string>pl</string>
47+
<string>rb</string>
48+
<string>tcl</string>
49+
<string>xml</string>
50+
<string>sql</string>
51+
<string>yaml</string>
52+
</array>
53+
<key>Option Default Value</key>
54+
<string>text</string>
55+
</dict>
56+
<dict>
57+
<key>Option Identifier</key>
58+
<string>token</string>
59+
<key>Option Label</key>
60+
<string>Git access token</string>
61+
<key>Option Type</key>
62+
<string>string</string>
63+
</dict>
64+
<dict>
65+
<key>Option Identifier</key>
66+
<string>proxy</string>
67+
<key>Option Label</key>
68+
<string>Proxy url</string>
69+
<key>Option Type</key>
70+
<string>string</string>
71+
</dict>
72+
<dict>
73+
<key>Option Identifier</key>
74+
<string>description</string>
75+
<key>Option Label</key>
76+
<string>Gist description</string>
77+
<key>Option Type</key>
78+
<string>string</string>
79+
<key>Option Default Value</key>
80+
<string>created with popclip send2gist extension</string>
81+
</dict>
82+
<dict>
83+
<key>Option Identifier</key>
84+
<string>secret</string>
85+
<key>Option Label</key>
86+
<string>Secret gist</string>
87+
<key>Option Type</key>
88+
<string>boolean</string>
89+
<key>Option Default Value</key>
90+
<string>0</string>
91+
</dict>
92+
<dict>
93+
<key>Option Identifier</key>
94+
<string>open</string>
95+
<key>Option Label</key>
96+
<string>Open gist in browser</string>
97+
<key>Option Type</key>
98+
<string>boolean</string>
99+
<key>Option Default Value</key>
100+
<string>1</string>
101+
</dict>
102+
</array>
103+
<key>Extension Name</key>
104+
<string>SendToGist</string>
105+
<key>Required OS Version</key>
106+
<string>10.6.8</string>
107+
<key>Required Software Version</key>
108+
<string>701</string>
109+
</dict>
110+
</plist>

gist/gist.popclipext/octicon.png

7.15 KB
Loading

gist/gist.popclipext/sendtogist.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env ruby
2+
3+
require "gist"
4+
5+
options = {}
6+
options[:access_token] = ENV['POPCLIP_OPTION_TOKEN']
7+
8+
if ENV['POPCLIP_OPTION_SECRET'] and ENV['POPCLIP_OPTION_SECRET'] == "1"
9+
options[:private] = true
10+
end
11+
12+
if ENV['POPCLIP_OPTION_OPEN'] and ENV['POPCLIP_OPTION_OPEN'] == "1"
13+
options[:open] = true
14+
end
15+
16+
if ENV['POPCLIP_OPTION_PROXY']
17+
ENV['HTTP_PROXY'] = ENV['POPCLIP_OPTION_PROXY']
18+
ENV['https_proxy'] = ENV['POPCLIP_OPTION_PROXY']
19+
ENV['HTTP_PROXY'] = ENV['POPCLIP_OPTION_PROXY']
20+
ENV['HTTPS_PROXY'] = ENV['POPCLIP_OPTION_PROXY']
21+
end
22+
23+
options[:description] = ENV['POPCLIP_OPTION_DESCRIPTION']
24+
options[:filename] = "send2gist.#{ENV['POPCLIP_OPTION_EXTENSION']}"
25+
26+
begin
27+
puts Gist.gist(ENV['POPCLIP_TEXT'], options)['url']
28+
rescue Gist::Error => e
29+
puts "Error: #{e.message}"
30+
exit 1
31+
rescue Interrupt
32+
# bye!
33+
end

gist/gist.popclipextz

8.67 KB
Binary file not shown.

0 commit comments

Comments
 (0)