Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
antono committed May 27, 2010
0 parents commit b6985ac
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
tags
4 changes: 4 additions & 0 deletions README.md
@@ -0,0 +1,4 @@
## INSTALLATION

cd ~/.redcar/plugins
git clone git://github.com/antono/redcar-pastie.git
57 changes: 57 additions & 0 deletions lib/pastie.rb
@@ -0,0 +1,57 @@
require 'net/http'
require 'uri'

module Redcar

class Pastie

This comment has been minimized.

Copy link
@antono

antono Jul 1, 2010

Author Owner

Test :)

This comment has been minimized.

Copy link
@mikesmullin

mikesmullin Jul 1, 2010

i c


def self.keymaps
linwin = Keymap.build("main", [:linux, :windows]) do
link "Ctrl+Shift+P", Pastie::PasteSelection
end

osx = Keymap.build("main", :osx) do
link "Cmd+Shift+P", Pastie::PasteSelection
end

[linwin, osx]
end

def self.menus
Menu::Builder.build do
sub_menu "Plugins" do
sub_menu "Pastie" do
item "Paste selection", PasteSelection
item "Select service", SelectService
end
end
end
end

class PasteSelection < EditTabCommand
def execute
text = doc.selection? ? doc.selected_text : doc.to_s
resp = paste_text(text)
message = resp || "Can't paste :("
Application::Dialog.message_box(message)
end

private

def paste_text(text)
uri = URI.parse('http://gist.github.com/api/v1/xml/new')
res = Net::HTTP.post_form(uri, { "files[#{tab.title}]" => text })
if res.code == '200'
'http://gist.github.com/' + res.body.match(/repo>(\d+)</)[1]
else
false
end
end
end

class SelectService < Redcar::Command
def execute
end
end
end
end
7 changes: 7 additions & 0 deletions plugin.rb
@@ -0,0 +1,7 @@
Plugin.define do
name "pastie"
version "0.1"
file "lib", "pastie"
object "Redcar::Pastie"
dependencies "redcar", ">0"
end

0 comments on commit b6985ac

Please sign in to comment.