Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit b6985aca6fa3efebe8f33e483e9e2b5ac021f864 0 parents
Antono Vasiljev authored
Showing with 69 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +4 −0 README.md
  3. +57 −0 lib/pastie.rb
  4. +7 −0 plugin.rb
1  .gitignore
@@ -0,0 +1 @@
+tags
4 README.md
@@ -0,0 +1,4 @@
+## INSTALLATION
+
+ cd ~/.redcar/plugins
+ git clone git://github.com/antono/redcar-pastie.git
57 lib/pastie.rb
@@ -0,0 +1,57 @@
+require 'net/http'
+require 'uri'
+
+module Redcar
+
+ class Pastie
Antono Vasiljev Owner
antono added a note

Test :)

i c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ 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 plugin.rb
@@ -0,0 +1,7 @@
+Plugin.define do
+ name "pastie"
+ version "0.1"
+ file "lib", "pastie"
+ object "Redcar::Pastie"
+ dependencies "redcar", ">0"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.