Don't look for frontmatter on binary files. Fixes #728
This commit is contained in:
parent
0bedb36f3f
commit
2e2516b95a
|
@ -128,8 +128,11 @@ module Middleman::CoreExtensions
|
|||
# @return [Array<Thor::CoreExt::HashWithIndifferentAccess, String>]
|
||||
def frontmatter_and_content(path)
|
||||
full_path = File.expand_path(File.join(@app.source_dir, path))
|
||||
content = File.read(full_path)
|
||||
data = {}
|
||||
content = nil
|
||||
|
||||
if !::Middleman::Util.binary?(full_path)
|
||||
content = File.read(full_path)
|
||||
|
||||
begin
|
||||
if content =~ /\A.*coding:/
|
||||
|
@ -146,6 +149,7 @@ module Middleman::CoreExtensions
|
|||
rescue => e
|
||||
# Probably a binary file, move on
|
||||
end
|
||||
end
|
||||
|
||||
[::Middleman::Util.recursively_enhance(data).freeze, content]
|
||||
end
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
require "middleman-core/sitemap/extensions/traversal"
|
||||
|
||||
require 'win32/file' if File::ALT_SEPARATOR
|
||||
|
||||
module Middleman
|
||||
|
||||
# Sitemap namespace
|
||||
|
@ -153,8 +151,7 @@ module Middleman
|
|||
#
|
||||
# @retrun [Boolean]
|
||||
def binary?
|
||||
s = (File.read(source_file, File.stat(source_file).blksize) || "").split(//)
|
||||
((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
|
||||
::Middleman::Util.binary?(source_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,10 +10,21 @@ require "thor"
|
|||
# Core Pathname library used for traversal
|
||||
require "pathname"
|
||||
|
||||
require 'win32/file' if File::ALT_SEPARATOR
|
||||
|
||||
module Middleman
|
||||
|
||||
module Util
|
||||
|
||||
# Whether the source file is binary.
|
||||
#
|
||||
# @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
|
||||
end
|
||||
|
||||
# The logger
|
||||
#
|
||||
# @return [Middleman::Logger] The logger
|
||||
|
|
Loading…
Reference in a new issue