#!/usr/bin/env ruby require 'net/http' require 'cgi' require "#{ENV['TM_SUPPORT_PATH']}/lib/progress.rb" 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` TextMate.call_with_progress("Making code pretty") do source = CGI.escape(STDIN.read) url = URI.parse('http://www.prettyprinter.de') res = Net::HTTP.start(url.host, url.port) {|http| http.post('/module.php?name=PrettyPrinter', "skiphtml=on&source=#{source}&#{pretty_props}") } result_code = CGI.unescapeHTML(res.body) print %{#{result_code}} end