Revision: 9518
Updated Code
at November 11, 2008 00:11 by nighthawk
Updated Code
#!/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
Revision: 9517
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 11, 2008 00:10 by nighthawk
Initial Code
#!/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
Initial URL
Initial Description
Initial Title
TextMate Ruby Snippet Posting
Initial Tags
command, textmate, ruby
Initial Language
Ruby