This commit is contained in:
tdreyno 2009-10-22 16:22:00 -07:00
commit 65b4620f77
3 changed files with 14 additions and 9 deletions

View file

@ -6,7 +6,7 @@ require 'optparse'
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman') require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
env = ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development' env = ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development'
options = { :Port => 4567, :Host => 'localhost', :AccessLog => [] } options = { :Port => 4567, :AccessLog => [] }
OptionParser.new { |opts| OptionParser.new { |opts|
opts.banner = "Usage: mm-server [rack options]" opts.banner = "Usage: mm-server [rack options]"

View file

@ -21,11 +21,14 @@ END
compressor = ::YUI::JavaScriptCompressor.new(:munge => true) compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
Dir[File.join(Middleman::Base.build_dir, Middleman::Base.js_dir, "**", "*.js")].each do |path| Dir[File.join(Middleman::Base.build_dir, Middleman::Base.js_dir, "**", "*.js")].each do |path|
compressed_js = compressor.compress(File.read(path)) lines = IO.readlines(path)
if lines.length > 1
compressed_js = compressor.compress(lines.join($/))
File.open(path, 'w') { |f| f.write(compressed_js) } File.open(path, 'w') { |f| f.write(compressed_js) }
say "<%= color('#{"[COMPRESSED]".rjust(12)}', :yellow) %> " + path.gsub(Middleman::Base.build_dir+"/", '') say "<%= color('#{"[COMPRESSED]".rjust(12)}', :yellow) %> " + path.gsub(Middleman::Base.build_dir+"/", '')
end end
end end
end
end if Middleman::Base.environment == "build" end if Middleman::Base.environment == "build"
end end

View file

@ -14,10 +14,12 @@ end
class Templater::Actions::Template class Templater::Actions::Template
def render def render
@render_cache ||= begin
# The default render just requests the page over Rack and writes the response # The default render just requests the page over Rack and writes the response
request_path = destination.gsub(File.join(Dir.pwd, Middleman::Base.build_dir), "") request_path = destination.gsub(File.join(Dir.pwd, Middleman::Base.build_dir), "")
browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base)) browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base))
browser.get(request_path) browser.get(request_path)
browser.last_response.body browser.last_response.body
end end
end
end end