Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b6985ac
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## INSTALLATION | ||
|
||
cd ~/.redcar/plugins | ||
git clone git://github.com/antono/redcar-pastie.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'net/http' | ||
require 'uri' | ||
|
||
module Redcar | ||
|
||
class Pastie | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Plugin.define do | ||
name "pastie" | ||
version "0.1" | ||
file "lib", "pastie" | ||
object "Redcar::Pastie" | ||
dependencies "redcar", ">0" | ||
end |
Test :)