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