/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/ruby $: << ENV['TM_SUPPORT_PATH'] + '/lib' require "ui" require "xmlrpc/client" unless ENV['SNIPPLR_KEY'] puts "Please first set your 'SNIPPLR_KEY' in Preferences > Advanced > Shell Variables." exit end unless ENV['TM_SELECTED_TEXT'] and ENV['TM_SELECTED_TEXT'].length > 0 puts "No text selected." exit end TextMate::UI.request_string(:title => "Post Snippet to Snipplr", :prompt => "Name this snippet:", :button1 => "Christen") do |title| TextMate::UI.request_string(:title => "Post Snippet to Snipplr", :prompt => "Enter tags (space-delimited):", :button1 => "Post") do |tags| begin server = XMLRPC::Client.new2("http://snipplr.com/xml-rpc.php") snippet_list = server.call( 'snippet.post', ENV['SNIPPLR_KEY'], title, ENV['TM_SELECTED_TEXT'], tags) puts "Snippet successfully posted." rescue TextMate::UI.alert(:critical, "Snipplr error", "Could not post snippet.") end end end
Comments
