handful of fixes
This commit is contained in:
parent
ac11d6dbd2
commit
bed5705841
|
@ -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]"
|
||||||
|
|
|
@ -5,7 +5,7 @@ class << Middleman::Base
|
||||||
if http_path.include?("://") || !%w(.css .png .jpg .js .gif).include?(File.extname(http_path))
|
if http_path.include?("://") || !%w(.css .png .jpg .js .gif).include?(File.extname(http_path))
|
||||||
http_path
|
http_path
|
||||||
else
|
else
|
||||||
real_path = File.join(self.environment == "build" ? self.build_dir : self.public, prefix, path)
|
real_path = File.join(self.public, prefix, path)
|
||||||
http_path << "?" + File.mtime(real_path).strftime("%s") if File.readable?(real_path)
|
http_path << "?" + File.mtime(real_path).strftime("%s") if File.readable?(real_path)
|
||||||
http_path
|
http_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,9 +21,12 @@ 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)
|
||||||
File.open(path, 'w') { |f| f.write(compressed_js) }
|
if lines.length > 1
|
||||||
say "<%= color('#{"[COMPRESSED]".rjust(12)}', :yellow) %> " + path.gsub(Middleman::Base.build_dir+"/", '')
|
compressed_js = compressor.compress(lines.join($/))
|
||||||
|
File.open(path, 'w') { |f| f.write(compressed_js) }
|
||||||
|
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"
|
||||||
|
|
|
@ -14,10 +14,12 @@ end
|
||||||
|
|
||||||
class Templater::Actions::Template
|
class Templater::Actions::Template
|
||||||
def render
|
def render
|
||||||
# The default render just requests the page over Rack and writes the response
|
@render_cache ||= begin
|
||||||
request_path = destination.gsub(File.join(Dir.pwd, Middleman::Base.build_dir), "")
|
# The default render just requests the page over Rack and writes the response
|
||||||
browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base))
|
request_path = destination.gsub(File.join(Dir.pwd, Middleman::Base.build_dir), "")
|
||||||
browser.get(request_path)
|
browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base))
|
||||||
browser.last_response.body
|
browser.get(request_path)
|
||||||
|
browser.last_response.body
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue