This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Magdin

By: a guest on Mar 26th, 2008  |  syntax: Ruby  |  size: 0.64 KB  |  views: 97  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env ruby
  2. require 'net/http'
  3. require 'cgi'
  4. require "#{ENV['TM_SUPPORT_PATH']}/lib/progress.rb"
  5.  
  6. pretty_props = `"#{ENV['TM_SUPPORT_PATH']}"/bin/CocoaDialog html --html-from-file "#{ENV['TM_SUPPORT_PATH']}"/script/pretty.html --title "PrettyPrinter.de"  --width 500 --height 500`
  7.  
  8.  
  9. TextMate.call_with_progress("Making code pretty") do
  10. source = CGI.escape(STDIN.read)
  11.  
  12. url = URI.parse('http://www.prettyprinter.de')
  13. res = Net::HTTP.start(url.host, url.port) {|http|
  14.  http.post('/module.php?name=PrettyPrinter', "skiphtml=on&source=#{source}&#{pretty_props}")
  15. }
  16. result_code = CGI.unescapeHTML(res.body)
  17. print %{#{result_code}}
  18. end
clone this paste RAW Paste Data