diff --git a/CHANGELOG.md b/CHANGELOG.md
index 989b3eac..51b454c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
+* 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
====
+
* Turn html5 boilerplate into a layout
* Fix errors when templates have empty YAML
* Show the hostname when initializing MM
diff --git a/middleman-core/features/missing-tilt-lib.feature b/middleman-core/features/missing-tilt-lib.feature
new file mode 100644
index 00000000..95b7ba5a
--- /dev/null
+++ b/middleman-core/features/missing-tilt-lib.feature
@@ -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"
\ No newline at end of file
diff --git a/middleman-core/fixtures/missing-tilt-library-app/config.rb b/middleman-core/fixtures/missing-tilt-library-app/config.rb
new file mode 100644
index 00000000..4fcf66d7
--- /dev/null
+++ b/middleman-core/fixtures/missing-tilt-library-app/config.rb
@@ -0,0 +1,2 @@
+ignore "danger-zone/*"
+ignore "*.textile"
\ No newline at end of file
diff --git a/middleman-core/fixtures/missing-tilt-library-app/source/danger-zone/more-wiki.html.wiki b/middleman-core/fixtures/missing-tilt-library-app/source/danger-zone/more-wiki.html.wiki
new file mode 100644
index 00000000..32a18237
--- /dev/null
+++ b/middleman-core/fixtures/missing-tilt-library-app/source/danger-zone/more-wiki.html.wiki
@@ -0,0 +1 @@
+More
\ No newline at end of file
diff --git a/middleman-core/fixtures/missing-tilt-library-app/source/safe-zone/my-wiki.html.wiki b/middleman-core/fixtures/missing-tilt-library-app/source/safe-zone/my-wiki.html.wiki
new file mode 100644
index 00000000..dc30e052
--- /dev/null
+++ b/middleman-core/fixtures/missing-tilt-library-app/source/safe-zone/my-wiki.html.wiki
@@ -0,0 +1 @@
+Safe
\ No newline at end of file
diff --git a/middleman-core/fixtures/missing-tilt-library-app/source/textile-source.html.textile b/middleman-core/fixtures/missing-tilt-library-app/source/textile-source.html.textile
new file mode 100644
index 00000000..04e4284f
--- /dev/null
+++ b/middleman-core/fixtures/missing-tilt-library-app/source/textile-source.html.textile
@@ -0,0 +1 @@
+Textx
\ No newline at end of file
diff --git a/middleman-core/fixtures/missing-tilt-library-app/source/wiki-source.html.wiki b/middleman-core/fixtures/missing-tilt-library-app/source/wiki-source.html.wiki
new file mode 100644
index 00000000..af5a0623
--- /dev/null
+++ b/middleman-core/fixtures/missing-tilt-library-app/source/wiki-source.html.wiki
@@ -0,0 +1 @@
+Hola
\ No newline at end of file
diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb
index 6cea9d70..608f450e 100644
--- a/middleman-core/lib/middleman-core/cli/build.rb
+++ b/middleman-core/lib/middleman-core/cli/build.rb
@@ -1,4 +1,5 @@
require "middleman-core"
+require "fileutils"
# CLI Module
module Middleman::Cli
@@ -64,7 +65,9 @@ module Middleman::Cli
action GlobAction.new(self, opts)
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
exit(1) if @had_errors
@@ -118,7 +121,17 @@ module Middleman::Cli
output_file = File.join(build_dir, resource.destination_path)
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
begin
response = self.class.shared_rack.get(URI.escape(resource.destination_path))
diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb
index e05d95ed..4dea060a 100644
--- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb
@@ -75,6 +75,19 @@ module Middleman
app.register Middleman::Renderers::Stylus
rescue LoadError
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
alias :included :registered
diff --git a/middleman-core/lib/middleman-core/renderers/sass.rb b/middleman-core/lib/middleman-core/renderers/sass.rb
index 45698ebf..d6d78852 100644
--- a/middleman-core/lib/middleman-core/renderers/sass.rb
+++ b/middleman-core/lib/middleman-core/renderers/sass.rb
@@ -16,12 +16,11 @@ module Middleman
# Location of SASS .sass-cache directory.
# @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
template_extensions :scss => :css,
:sass => :css
- config[:sass_cache_path] = File.join(app.root_path, '.sass-cache')
end
# Tell Tilt to use it as well (for inline sass blocks)
diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb
index b4b543fe..fba225ec 100644
--- a/middleman-core/lib/middleman-core/util.rb
+++ b/middleman-core/lib/middleman-core/util.rb
@@ -10,7 +10,7 @@ require "thor"
# Core Pathname library used for traversal
require "pathname"
-require 'win32/file' if File::ALT_SEPARATOR
+require "rack"
module Middleman
@@ -21,8 +21,17 @@ module Middleman
# @param [String] filename The file to check.
# @return [Boolean]
def self.binary?(filename)
- s = (File.read(filename, File.stat(filename).blksize) || "").split(//)
- ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
+ ext = File.extname(filename)
+ 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
# The logger
diff --git a/middleman-more/features/helpers_link_to.feature b/middleman-more/features/helpers_link_to.feature
index 1607cc24..e445f7f0 100644
--- a/middleman-more/features/helpers_link_to.feature
+++ b/middleman-more/features/helpers_link_to.feature
@@ -21,6 +21,40 @@ Feature: link_to helper
Then I should see 'absolute: Needs Index'
Then I should see 'relative: Relative'
+ 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
Given a fixture app "indexable-app"
And a file named "config.rb" with:
diff --git a/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb
index fe44eda5..95ddae8a 100644
--- a/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb
+++ b/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb
@@ -129,15 +129,20 @@ module Middleman
# Handle Resources, which define their own url method
if url.respond_to? :url
- args[url_arg_index] = url.url
- elsif url.include? '://'
+ url = args[url_arg_index] = url.url
+ end
+
+ if url.include? '://'
raise "Can't use the relative option with an external URL" if relative
elsif current_resource
# Handle relative urls
current_source_dir = Pathname('/' + current_resource.path).dirname
- uri = URI(url)
- url_path = uri.path
+ begin
+ uri = URI(url)
+ url_path = uri.path
+ rescue
+ end
if url_path
path = Pathname(url_path)
diff --git a/middleman-more/lib/middleman-more/extensions/automatic_image_sizes.rb b/middleman-more/lib/middleman-more/extensions/automatic_image_sizes.rb
index 927e8f07..00f48e03 100644
--- a/middleman-more/lib/middleman-more/extensions/automatic_image_sizes.rb
+++ b/middleman-more/lib/middleman-more/extensions/automatic_image_sizes.rb
@@ -30,7 +30,11 @@ module Middleman
# @param [Hash] params
# @return [String]
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] ||= ""
real_path = path
@@ -49,6 +53,8 @@ module Middleman
end
end
end
+
+ params = params.delete_if {|key| key == :supported_extensions }
super(path, params)
end
diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec
index 76d926b5..e2ff56a2 100644
--- a/middleman/middleman.gemspec
+++ b/middleman/middleman.gemspec
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
s.add_dependency("middleman-core", 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