I'm bad at Ruby
This commit is contained in:
parent
a6e577b83a
commit
593cdb27aa
3 changed files with 5 additions and 5 deletions
|
@ -69,7 +69,7 @@ module Middleman::Extensions
|
||||||
dirpath = Pathname.new(File.dirname(path))
|
dirpath = Pathname.new(File.dirname(path))
|
||||||
|
|
||||||
if path =~ /(^\/$)|(\.(htm|html|php|css|js)$)/
|
if path =~ /(^\/$)|(\.(htm|html|php|css|js)$)/
|
||||||
body = ::Middleman.Util.extract_response_text(response)
|
body = ::Middleman::Util.extract_response_text(response)
|
||||||
|
|
||||||
if body
|
if body
|
||||||
# TODO: This regex will change some paths in plan HTML (not in a tag) - is that OK?
|
# TODO: This regex will change some paths in plan HTML (not in a tag) - is that OK?
|
||||||
|
|
|
@ -52,7 +52,7 @@ module Middleman
|
||||||
path = env["PATH_INFO"]
|
path = env["PATH_INFO"]
|
||||||
|
|
||||||
if (path.end_with?('.html') || path.end_with?('.php')) && @inline
|
if (path.end_with?('.html') || path.end_with?('.php')) && @inline
|
||||||
uncompressed_source = ::Middleman.Util.extract_response_text(response)
|
uncompressed_source = ::Middleman::Util.extract_response_text(response)
|
||||||
|
|
||||||
minified = uncompressed_source.gsub(/(<style[^>]*>\s*(?:\/\*<!\[CDATA\[\*\/\n)?)(.*?)((?:(?:\n\s*)?\/\*\]\]>\*\/)?\s*<\/style>)/m) do |match|
|
minified = uncompressed_source.gsub(/(<style[^>]*>\s*(?:\/\*<!\[CDATA\[\*\/\n)?)(.*?)((?:(?:\n\s*)?\/\*\]\]>\*\/)?\s*<\/style>)/m) do |match|
|
||||||
first = $1
|
first = $1
|
||||||
|
@ -67,7 +67,7 @@ module Middleman
|
||||||
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
||||||
response = [minified]
|
response = [minified]
|
||||||
elsif path.end_with?('.css') && @ignore.none? {|ignore| path =~ ignore }
|
elsif path.end_with?('.css') && @ignore.none? {|ignore| path =~ ignore }
|
||||||
uncompressed_source = extract_response_text(response)
|
uncompressed_source = ::Middleman::Util.extract_response_text(response)
|
||||||
minified_css = @compressor.compress(uncompressed_source)
|
minified_css = @compressor.compress(uncompressed_source)
|
||||||
|
|
||||||
headers["Content-Length"] = ::Rack::Utils.bytesize(minified_css).to_s
|
headers["Content-Length"] = ::Rack::Utils.bytesize(minified_css).to_s
|
||||||
|
|
|
@ -54,7 +54,7 @@ module Middleman
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if (path.end_with?('.html') || path.end_with?('.php')) && @inline
|
if (path.end_with?('.html') || path.end_with?('.php')) && @inline
|
||||||
uncompressed_source = ::Middleman.Util.extract_response_text(response)
|
uncompressed_source = ::Middleman::Util.extract_response_text(response)
|
||||||
|
|
||||||
minified = uncompressed_source.gsub(/(<script[^>]*>\s*(?:\/\/(?:(?:<!--)|(?:<!\[CDATA\[))\n)?)(.*?)((?:(?:\n\s*)?\/\/(?:(?:-->)|(?:\]\]>)))?\s*<\/script>)/m) do |match|
|
minified = uncompressed_source.gsub(/(<script[^>]*>\s*(?:\/\/(?:(?:<!--)|(?:<!\[CDATA\[))\n)?)(.*?)((?:(?:\n\s*)?\/\/(?:(?:-->)|(?:\]\]>)))?\s*<\/script>)/m) do |match|
|
||||||
first = $1
|
first = $1
|
||||||
|
@ -76,7 +76,7 @@ module Middleman
|
||||||
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
||||||
response = [minified]
|
response = [minified]
|
||||||
elsif path.end_with?('.js') && @ignore.none? {|ignore| path =~ ignore }
|
elsif path.end_with?('.js') && @ignore.none? {|ignore| path =~ ignore }
|
||||||
uncompressed_source = extract_response_text(response)
|
uncompressed_source = ::Middleman::Util.extract_response_text(response)
|
||||||
minified_js = @compressor.compress(uncompressed_source)
|
minified_js = @compressor.compress(uncompressed_source)
|
||||||
|
|
||||||
headers["Content-Length"] = ::Rack::Utils.bytesize(minified_js).to_s
|
headers["Content-Length"] = ::Rack::Utils.bytesize(minified_js).to_s
|
||||||
|
|
Loading…
Add table
Reference in a new issue