Merge remote-tracking branch 'origin/3.0-stable'

Conflicts:
	CHANGELOG.md
	middleman-core/lib/middleman-core/cli/build.rb
	middleman-core/lib/middleman-core/core_extensions/rendering.rb
	middleman-core/lib/middleman-core/preview_server.rb
	middleman-core/lib/middleman-core/renderers/sass.rb
	middleman-core/lib/middleman-core/sitemap/store.rb
	middleman-core/lib/middleman-core/util.rb
	middleman-core/lib/middleman-core/version.rb
	middleman-more/lib/middleman-more/core_extensions/compass.rb
	middleman-more/lib/middleman-more/core_extensions/default_helpers.rb
	middleman-more/lib/middleman-more/extensions/asset_hash.rb
This commit is contained in:
Ben Hollis 2013-01-25 21:43:30 -08:00
commit c0c14f4eab
15 changed files with 122 additions and 13 deletions

View file

@ -19,9 +19,13 @@ Master
==== ====
* Directly send binary files in preview and copy them in build, avoiding reading large binary files into memory for rendering. #643 #699 * Directly send binary files in preview and copy them in build, avoiding reading large binary files into memory for rendering. #643 #699
* Make link_to helper ignore QueryString values when looking up Sitemap resources
* Directly copy binary files during build, and stream them during preview, to avoid reading them into memory
* Make sure all paths in Sitemap are using Pathname
3.0.7 3.0.7
==== ====
* Turn html5 boilerplate into a layout * Turn html5 boilerplate into a layout
* Fix errors when templates have empty YAML * Fix errors when templates have empty YAML
* Show the hostname when initializing MM * Show the hostname when initializing MM

View file

@ -0,0 +1,20 @@
Feature: Tilt missing support libraries
Scenario: Rendering Textile and Wiki files
Given the Server is running at "missing-tilt-library-app"
When I go to "/danger-zone/more-wiki.html.wiki"
Then I should see "File Not Found"
When I go to "/danger-zone/more-wiki.html"
Then I should see "File Not Found"
When I go to "/safe-zone/my-wiki.html.wiki"
Then I should see "Safe"
When I go to "/safe-zone/my-wiki.html"
Then I should see "File Not Found"
When I go to "/textile-source.html.textile"
Then I should see "File Not Found"
When I go to "/textile-source.html"
Then I should see "File Not Found"
When I go to "/wiki-source.html.wiki"
Then I should see "Hola"
When I go to "/wiki-source.html"
Then I should see "File Not Found"

View file

@ -0,0 +1,2 @@
ignore "danger-zone/*"
ignore "*.textile"

View file

@ -1,4 +1,5 @@
require "middleman-core" require "middleman-core"
require "fileutils"
# CLI Module # CLI Module
module Middleman::Cli module Middleman::Cli
@ -64,7 +65,9 @@ module Middleman::Cli
action GlobAction.new(self, opts) action GlobAction.new(self, opts)
if @had_errors && !@debugging if @had_errors && !@debugging
self.shell.say "There were errors during this build, re-run with --verbose to see the full exception." cmd = "middleman build --verbose"
cmd = "bundle exec '#{cmd}'" if defined?(Bundler)
self.shell.say "There were errors during this build, re-run with `#{cmd}` to see the full exception."
end end
exit(1) if @had_errors exit(1) if @had_errors
@ -118,7 +121,17 @@ module Middleman::Cli
output_file = File.join(build_dir, resource.destination_path) output_file = File.join(build_dir, resource.destination_path)
if resource.binary? if resource.binary?
copy_file(resource.source_file, output_file) if !File.exists?(output_file)
say_status :create, output_file, :green
elsif FileUtils.compare_file(resource.source_file, output_file)
say_status :identical, output_file, :blue
return output_file
else
say_status :update, output_file, :yellow
end
FileUtils.mkdir_p(File.dirname(output_file))
FileUtils.cp(resource.source_file, output_file)
else else
begin begin
response = self.class.shared_rack.get(URI.escape(resource.destination_path)) response = self.class.shared_rack.get(URI.escape(resource.destination_path))

View file

@ -75,6 +75,19 @@ module Middleman
app.register Middleman::Renderers::Stylus app.register Middleman::Renderers::Stylus
rescue LoadError rescue LoadError
end end
# Clean up missing Tilt exts
app.after_configuration do
Tilt.mappings.each do |key, klasses|
begin
Tilt[".#{key}"]
rescue LoadError
Tilt.mappings.delete(key)
rescue NameError
Tilt.mappings.delete(key)
end
end
end
end end
alias :included :registered alias :included :registered

View file

@ -16,12 +16,11 @@ module Middleman
# Location of SASS .sass-cache directory. # Location of SASS .sass-cache directory.
# @return [String] # @return [String]
app.config.define_setting :sass_cache_path, nil, 'Location of sass cache' # runtime compile of path app.config.define_setting :sass_cache_path, File.join(app.root_path, '.sass-cache'), 'Location of sass cache' # runtime compile of path
app.before_configuration do app.before_configuration do
template_extensions :scss => :css, template_extensions :scss => :css,
:sass => :css :sass => :css
config[:sass_cache_path] = File.join(app.root_path, '.sass-cache')
end end
# Tell Tilt to use it as well (for inline sass blocks) # Tell Tilt to use it as well (for inline sass blocks)

View file

@ -10,7 +10,7 @@ require "thor"
# Core Pathname library used for traversal # Core Pathname library used for traversal
require "pathname" require "pathname"
require 'win32/file' if File::ALT_SEPARATOR require "rack"
module Middleman module Middleman
@ -21,8 +21,17 @@ module Middleman
# @param [String] filename The file to check. # @param [String] filename The file to check.
# @return [Boolean] # @return [Boolean]
def self.binary?(filename) def self.binary?(filename)
s = (File.read(filename, File.stat(filename).blksize) || "").split(//) ext = File.extname(filename)
((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30 return false if Tilt.registered?(ext.sub('.',''))
ext = ".#{ext}" unless ext.to_s[0] == ?.
mime = ::Rack::Mime.mime_type(ext, nil)
return false unless mime
return false if mime.start_with?('text/')
return false if mime.include?('xml')
return false if mime.include?('json')
return false if mime.include?('javascript')
true
end end
# The logger # The logger

View file

@ -21,6 +21,40 @@ Feature: link_to helper
Then I should see 'absolute: <a href="../needs_index.html">Needs Index</a>' Then I should see 'absolute: <a href="../needs_index.html">Needs Index</a>'
Then I should see 'relative: <a href="../needs_index.html">Relative</a>' Then I should see 'relative: <a href="../needs_index.html">Relative</a>'
Scenario: link_to relative works with strip_index_file
Given a fixture app "indexable-app"
And a file named "config.rb" with:
"""
set :relative_links, true
set :strip_index_file, true
helpers do
def menu_items(path='link_to.html')
sitemap.find_resource_by_destination_path(path).children
end
end
"""
And a file named "source/link_to.html.erb" with:
"""
<% menu_items.each do |item| %>
<%= link_to(item.metadata[:page]['title'], item.url) %>
<%= link_to(item.metadata[:page]['title'], item) %>
<% end %>
"""
And a file named "source/link_to/sub.html.erb" with:
"""
<% menu_items.each do |item| %>
<%= link_to(item.metadata[:page]['title'], item.url) %>
<%= link_to(item.metadata[:page]['title'], item) %>
<% end %>
"""
And the Server is running at "indexable-app"
When I go to "/link_to.html"
Then I should see '"link_to/sub.html"'
Then I should not see "/link_to/sub.html"
When I go to "/link_to/sub.html"
Then I should see '"sub.html"'
Then I should not see "/link_to/sub.html"
Scenario: link_to produces relative links when :relative_links is set to true Scenario: link_to produces relative links when :relative_links is set to true
Given a fixture app "indexable-app" Given a fixture app "indexable-app"
And a file named "config.rb" with: And a file named "config.rb" with:

View file

@ -129,15 +129,20 @@ module Middleman
# Handle Resources, which define their own url method # Handle Resources, which define their own url method
if url.respond_to? :url if url.respond_to? :url
args[url_arg_index] = url.url url = args[url_arg_index] = url.url
elsif url.include? '://' end
if url.include? '://'
raise "Can't use the relative option with an external URL" if relative raise "Can't use the relative option with an external URL" if relative
elsif current_resource elsif current_resource
# Handle relative urls # Handle relative urls
current_source_dir = Pathname('/' + current_resource.path).dirname current_source_dir = Pathname('/' + current_resource.path).dirname
begin
uri = URI(url) uri = URI(url)
url_path = uri.path url_path = uri.path
rescue
end
if url_path if url_path
path = Pathname(url_path) path = Pathname(url_path)

View file

@ -30,7 +30,11 @@ module Middleman
# @param [Hash] params # @param [Hash] params
# @return [String] # @return [String]
def image_tag(path, params={}) def image_tag(path, params={})
if !params.has_key?(:width) && !params.has_key?(:height) && !path.include?("://") params[:supported_extensions] ||= %w(.png .jpg .jpeg .bmp .gif)
if !params.has_key?(:width) && !params.has_key?(:height) && !path.include?("://") &&
params[:supported_extensions].include?(File.extname(path).downcase)
params[:alt] ||= "" params[:alt] ||= ""
real_path = path real_path = path
@ -50,6 +54,8 @@ module Middleman
end end
end end
params = params.delete_if {|key| key == :supported_extensions }
super(path, params) super(path, params)
end end
end end

View file

@ -19,6 +19,6 @@ Gem::Specification.new do |s|
s.add_dependency("middleman-core", Middleman::VERSION) s.add_dependency("middleman-core", Middleman::VERSION)
s.add_dependency("middleman-more", Middleman::VERSION) s.add_dependency("middleman-more", Middleman::VERSION)
s.add_dependency("middleman-sprockets", "~> 3.0.2") s.add_dependency("middleman-sprockets", "~> 3.0.6")
end end