Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service to post private gists #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Create New Private Gist.workflow/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Create New Private Gist</string>
</dict>
<key>NSMessage</key>
<string>runWorkflowAsService</string>
<key>NSSendTypes</key>
<array>
<string>public.utf8-plain-text</string>
</array>
</dict>
</array>
</dict>
</plist>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
299 changes: 299 additions & 0 deletions Create New Private Gist.workflow/Contents/document.wflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AMApplicationBuild</key>
<string>247</string>
<key>AMApplicationVersion</key>
<string>2.1</string>
<key>AMDocumentVersion</key>
<string>2</string>
<key>actions</key>
<array>
<dict>
<key>action</key>
<dict>
<key>AMAccepts</key>
<dict>
<key>Container</key>
<string>List</string>
<key>Optional</key>
<true/>
<key>Types</key>
<array>
<string>com.apple.cocoa.string</string>
</array>
</dict>
<key>AMActionVersion</key>
<string>2.0.1</string>
<key>AMParameterProperties</key>
<dict>
<key>COMMAND_STRING</key>
<dict/>
<key>CheckedForUserDefaultShell</key>
<dict/>
<key>inputMethod</key>
<dict/>
<key>shell</key>
<dict/>
<key>source</key>
<dict/>
</dict>
<key>AMProvides</key>
<dict>
<key>Container</key>
<string>List</string>
<key>Types</key>
<array>
<string>com.apple.cocoa.string</string>
</array>
</dict>
<key>ActionBundlePath</key>
<string>/System/Library/Automator/Run Shell Script.action</string>
<key>ActionName</key>
<string>Run Shell Script</string>
<key>ActionParameters</key>
<dict>
<key>COMMAND_STRING</key>
<string>require 'uri'
require 'net/http'

GIST_URL = 'http://gist.github.com/%s.txt'
@proxy = ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil
def write(content, private_gist=false)
url = URI.parse('http://gist.github.com/gists')
if @proxy
req = Net::HTTP::Proxy(@proxy.host, @proxy.port).post_form(url, data(nil, nil, content, private_gist))
else
req = Net::HTTP.post_form(url, data(nil, nil, content, private_gist))
end
req['Location']
end

def data(name, ext, content, private_gist)
return {
'file_ext[gistfile1]' =&gt; ext,
'file_name[gistfile1]' =&gt; name,
'file_contents[gistfile1]' =&gt; content
}.merge(private_gist ? { 'action_button' =&gt; 'private' } : {}).merge(auth)
end

def auth
user = `git config --global github.user`.strip
token = `git config --global github.token`.strip
user.to_s.empty? ? {} : { :login =&gt; user, :token =&gt; token }
end

location = write $stdin.read, true
`open #{location}`</string>
<key>CheckedForUserDefaultShell</key>
<true/>
<key>inputMethod</key>
<integer>0</integer>
<key>shell</key>
<string>/usr/bin/ruby</string>
<key>source</key>
<string></string>
</dict>
<key>Application</key>
<array>
<string>Automator</string>
</array>
<key>BundleIdentifier</key>
<string>com.apple.RunShellScript</string>
<key>CFBundleVersion</key>
<string>2.0.1</string>
<key>CanShowSelectedItemsWhenRun</key>
<false/>
<key>CanShowWhenRun</key>
<true/>
<key>Category</key>
<array>
<string>AMCategoryUtilities</string>
</array>
<key>Class Name</key>
<string>RunShellScriptAction</string>
<key>InputUUID</key>
<string>154B7B30-7894-4EEA-BA89-98EA866834C6</string>
<key>Keywords</key>
<array>
<string>Shell</string>
<string>Script</string>
<string>Command</string>
<string>Run</string>
<string>Unix</string>
</array>
<key>OutputUUID</key>
<string>935D2379-FE0B-4EF1-8A4E-EFC47462AA74</string>
<key>ShowWhenRun</key>
<false/>
<key>UUID</key>
<string>A487AA83-27A4-4633-B21F-0CD5D9149714</string>
<key>UnlocalizedApplications</key>
<array>
<string>Automator</string>
</array>
<key>arguments</key>
<dict>
<key>0</key>
<dict>
<key>default value</key>
<integer>0</integer>
<key>name</key>
<string>inputMethod</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>0</string>
</dict>
<key>1</key>
<dict>
<key>default value</key>
<string></string>
<key>name</key>
<string>source</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>1</string>
</dict>
<key>2</key>
<dict>
<key>default value</key>
<false/>
<key>name</key>
<string>CheckedForUserDefaultShell</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>2</string>
</dict>
<key>3</key>
<dict>
<key>default value</key>
<string></string>
<key>name</key>
<string>COMMAND_STRING</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>3</string>
</dict>
<key>4</key>
<dict>
<key>default value</key>
<string>/bin/sh</string>
<key>name</key>
<string>shell</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>4</string>
</dict>
</dict>
<key>isViewVisible</key>
<true/>
<key>location</key>
<string>351.500000:542.000000</string>
<key>nibPath</key>
<string>/System/Library/Automator/Run Shell Script.action/Contents/Resources/English.lproj/main.nib</string>
</dict>
<key>isViewVisible</key>
<true/>
</dict>
</array>
<key>connectors</key>
<dict/>
<key>state</key>
<dict>
<key>AMLogTabViewSelectedIndex</key>
<integer>0</integer>
<key>libraryState</key>
<dict>
<key>actionsMajorSplitViewState</key>
<dict>
<key>expandedPosition</key>
<real>0.0</real>
<key>subviewState</key>
<array>
<string>0.000000, 0.000000, 349.000000, 692.000000, NO</string>
<string>0.000000, 693.000000, 349.000000, -1.000000, NO</string>
</array>
</dict>
<key>actionsMinorSplitViewState</key>
<dict>
<key>expandedPosition</key>
<real>0.0</real>
<key>subviewState</key>
<array>
<string>0.000000, 0.000000, 150.000000, 692.000000, NO</string>
<string>151.000000, 0.000000, 198.000000, 692.000000, NO</string>
</array>
</dict>
<key>variablesMajorSplitViewState</key>
<dict>
<key>expandedPosition</key>
<real>0.0</real>
<key>subviewState</key>
<array>
<string>0.000000, 0.000000, 350.000000, 555.000000, NO</string>
<string>0.000000, 556.000000, 350.000000, 148.000000, NO</string>
</array>
</dict>
<key>variablesMinorSplitViewState</key>
<dict>
<key>expandedPosition</key>
<real>0.0</real>
<key>subviewState</key>
<array>
<string>0.000000, 0.000000, 163.000000, 555.000000, NO</string>
<string>164.000000, 0.000000, 186.000000, 555.000000, NO</string>
</array>
</dict>
</dict>
<key>majorSplitViewState</key>
<dict>
<key>expandedPosition</key>
<real>349</real>
<key>subviewState</key>
<array>
<string>0.000000, 0.000000, 349.000000, 737.000000, NO</string>
<string>350.000000, 0.000000, 718.000000, 737.000000, NO</string>
</array>
</dict>
<key>minorSplitViewState</key>
<dict>
<key>expandedPosition</key>
<real>162</real>
<key>subviewState</key>
<array>
<string>0.000000, 0.000000, 718.000000, 546.000000, NO</string>
<string>0.000000, 556.000000, 718.000000, 162.000000, NO</string>
</array>
</dict>
<key>windowFrame</key>
<string>{{187, 64}, {1067, 814}}</string>
<key>workflowViewScrollPosition</key>
<string>{{0, 51}, {703, 546}}</string>
</dict>
<key>workflowMetaData</key>
<dict>
<key>serviceInputTypeIdentifier</key>
<string>com.apple.Automator.text</string>
<key>serviceOutputTypeIdentifier</key>
<string>com.apple.Automator.nothing</string>
<key>workflowTypeIdentifier</key>
<string>com.apple.Automator.servicesMenu</string>
</dict>
</dict>
</plist>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading